Skip to content

Commit

Permalink
Fix test coverage, code styling
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Altmann committed Aug 2, 2016
1 parent f34a6a9 commit eda4674
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
8 changes: 4 additions & 4 deletions app/controllers/business_transactions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ def export

def set_transport_ready
authorize @business_transaction
notice = ''
@notice = ''

if @business_transaction.prepare
CartMailer.courier_notification(@business_transaction).deliver
notice = I18n.t('transaction.notice.ready_success', id: @business_transaction.id)
@notice = I18n.t('transaction.notice.ready_success', id: @business_transaction.id)
else
notice = I18n.t('transaction.notice.ready_failure', id: @business_transaction.id)
@notice = I18n.t('transaction.notice.ready_failure', id: @business_transaction.id)
end

redirect_to line_item_group_path(@business_transaction.line_item_group), notice: notice
redirect_to line_item_group_path(@business_transaction.line_item_group), notice: @notice
end

private
Expand Down
12 changes: 11 additions & 1 deletion test/controllers/business_transactions_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,21 @@ def login
end

describe 'GET set_transport_ready' do
it 'should redirect to line item group ' do
it 'should redirect to line item group with success notice' do
bt = create :business_transaction
sign_in bt.seller
get :set_transport_ready, id: bt.id
assert_redirected_to line_item_group_path(bt.line_item_group)
assert_equal I18n.t('transaction.notice.ready_success'), assigns[:notice]
end

it 'should redirect with failure notice if bt is already shipped' do
bt = create :business_transaction
bt.ship
sign_in bt.seller
get :set_transport_ready, id: bt.id
assert_redirected_to line_item_group_path(bt.line_item_group)
assert_equal I18n.t('transaction.notice.ready_failure'), assigns[:notice]
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/objects/business_transaction_exporter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

travel_to Time.new(2016, 04, 01, 12) do
lig = create :line_item_group, :with_business_transactions, :with_unified_transport,
:with_unified_payment_paypal, :sold
:with_unified_payment_paypal, :sold
user = lig.seller

exporter = BusinessTransactionExporter.new(user)
Expand Down

0 comments on commit eda4674

Please sign in to comment.