Skip to content

Commit

Permalink
fix(sale): generate_sales_subscription_offers now returns true
Browse files Browse the repository at this point in the history
  • Loading branch information
DioFun committed Aug 3, 2024
1 parent 8894741 commit 720c7d2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions app/controllers/sales_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ def new

def create
@sale = @owner.sales_as_client.new(sales_params)
return redirect_to :new_user_sale, user: @user, status: :unprocessable_entity unless
@sale.generate(duration: params[:sale][:duration], seller: current_user)
unless @sale.generate(duration: params[:sale][:duration], seller: current_user)
return redirect_to :new_user_sale, user: @user, status: :unprocessable_entity
end
return redirect_to :new_user_sale, user: @user, status: :unprocessable_entity if @sale.empty?

authorize! :create, @sale
Expand Down
2 changes: 1 addition & 1 deletion app/models/sale.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def generate_sales_subscription_offers(duration)
duration -= quantity * offer.duration
end
end
return if duration.zero?
return true if duration.zero?

errors.add(:base, 'Subscription offers are not exhaustive!')
false

Check warning on line 78 in app/models/sale.rb

View check run for this annotation

Codecov / codecov/patch

app/models/sale.rb#L77-L78

Added lines #L77 - L78 were not covered by tests
Expand Down

0 comments on commit 720c7d2

Please sign in to comment.