-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1451 from jordan-brough/add-promotion-remove-from
Also: Add a CHANGELOG entry
- Loading branch information
Showing
11 changed files
with
217 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require 'spec_helper' | ||
|
||
describe Spree::PromotionAction, type: :model do | ||
describe '#remove_from' do | ||
class MyPromotionAction < Spree::PromotionAction | ||
def perform(options = {}) | ||
order = options[:order] | ||
order.adjustments.create!(amount: 1, order: order, source: self, label: 'foo') | ||
true | ||
end | ||
end | ||
|
||
let(:action) { promotion.actions.first! } | ||
let!(:promotion) { create(:promotion, promotion_actions: [MyPromotionAction.new]) } | ||
let(:order) { create(:order) } | ||
|
||
# this adjustment should not get removed | ||
let!(:other_adjustment) { create(:adjustment, order: order, source: nil) } | ||
|
||
before do | ||
action.perform(order: order) | ||
@action_adjustment = order.adjustments.where(source: action).first! | ||
end | ||
|
||
it 'removes the action adjustment' do | ||
expect(order.adjustments).to match_array([other_adjustment, @action_adjustment]) | ||
|
||
expect(Spree::Deprecation).to( | ||
receive(:warn). | ||
with(/"MyPromotionAction" does not define #remove_from/, anything) | ||
) | ||
|
||
action.remove_from(order) | ||
|
||
expect(order.adjustments).to eq([other_adjustment]) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters