solidus_virtual_gift_card 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/app/assets/javascripts/spree/backend/solidus_virtual_gift_card.coffee +6 -6
- data/app/assets/stylesheets/spree/backend/solidus_virtual_gift_card.css +4 -0
- data/app/controllers/spree/admin/gift_cards_controller.rb +32 -12
- data/app/mailers/spree/gift_card_mailer.rb +2 -1
- data/app/models/concerns/spree/gift_cards/line_item_concerns.rb +6 -1
- data/app/models/concerns/spree/gift_cards/order_concerns.rb +15 -9
- data/app/models/concerns/spree/gift_cards/order_contents_concerns.rb +84 -0
- data/app/models/spree/order_contents_decorator.rb +1 -0
- data/app/models/spree/virtual_gift_card.rb +47 -10
- data/app/overrides/admin_gift_card_order_confirmation.rb +6 -0
- data/app/overrides/admin_item_view_gift_card_codes.rb +9 -2
- data/app/views/spree/admin/gift_cards/_lookup_form.html.erb +31 -6
- data/app/views/spree/admin/gift_cards/edit.html.erb +81 -0
- data/app/views/spree/admin/gift_cards/index.html.erb +39 -0
- data/app/views/spree/admin/gift_cards/show.html.erb +0 -32
- data/app/views/spree/admin/orders/_cart_gift_card_details.html.erb +3 -0
- data/app/views/spree/admin/orders/_confirmation_gift_card_details.html.erb +50 -0
- data/app/views/spree/admin/orders/_gift_card_details.html.erb +2 -0
- data/app/views/spree/admin/orders/_shipments_gift_card_details.html.erb +3 -0
- data/bin/rails +1 -1
- data/config/initializers/line_item_controller_gift_card_details.rb +4 -0
- data/config/initializers/ransack.rb +7 -0
- data/config/locales/en.yml +3 -0
- data/config/routes.rb +9 -1
- data/db/migrate/20151013172931_add_recipient_fields_to_virtual_gift_card.rb +8 -0
- data/db/migrate/20151013210615_add_active_flag_to_virtual_gift_card.rb +5 -0
- data/db/migrate/20151013214647_set_redeemable_true_on_virtual_gift_cards.rb +11 -0
- data/db/migrate/20151019190731_add_email_send_time_to_virtual_gift_card.rb +7 -0
- data/lib/spree_virtual_gift_card/factories.rb +11 -2
- data/lib/tasks/send_gift_card_emails.rake +8 -0
- data/solidus_virtual_gift_card.gemspec +1 -1
- data/spec/controllers/spree/admin/gift_cards_controller_spec.rb +1 -33
- data/spec/controllers/spree/api/gift_cards_controller_spec.rb +1 -1
- data/spec/features/admin/gift_cards_spec.rb +74 -0
- data/spec/lib/tasks/send_gift_card_emails_spec.rb +60 -0
- data/spec/models/spree/line_item_spec.rb +21 -0
- data/spec/models/spree/order_contents_spec.rb +270 -0
- data/spec/models/spree/order_spec.rb +34 -57
- data/spec/models/spree/virtual_gift_card_spec.rb +54 -23
- data/spec/spec_helper.rb +1 -0
- metadata +23 -3
- data/app/views/spree/admin/orders/_gift_card_redemption_codes.html.erb +0 -3
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "solidus_virtual_gift_card:send_current_emails" do
|
4
|
+
|
5
|
+
let(:task) { Rake::Task['solidus_virtual_gift_card:send_current_emails'] }
|
6
|
+
let(:purchaser) {create(:user)}
|
7
|
+
|
8
|
+
before do
|
9
|
+
Rails.application.load_tasks
|
10
|
+
task.reenable
|
11
|
+
end
|
12
|
+
|
13
|
+
subject { task.invoke }
|
14
|
+
|
15
|
+
context "with gift card sent today" do
|
16
|
+
it "sends emails to be sent today" do
|
17
|
+
gift_card = Spree::VirtualGiftCard.create!(amount: 50, send_email_at: Date.today, redeemable: true, purchaser: purchaser)
|
18
|
+
expect(Spree::GiftCardMailer).to receive(:gift_card_email).with(gift_card).and_return(double(deliver_later: true))
|
19
|
+
subject
|
20
|
+
end
|
21
|
+
|
22
|
+
it "does not send unredeemable giftcards" do
|
23
|
+
gift_card = Spree::VirtualGiftCard.create!(amount: 50, send_email_at: Date.today)
|
24
|
+
expect(Spree::GiftCardMailer).to_not receive(:gift_card_email).with(gift_card)
|
25
|
+
subject
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "with gift card already sent today" do
|
30
|
+
it "sends emails to be sent today" do
|
31
|
+
Spree::VirtualGiftCard.create!(amount: 50, send_email_at: Date.today, sent_at: DateTime.now, redeemable: true, purchaser: purchaser)
|
32
|
+
expect(Spree::GiftCardMailer).to_not receive(:gift_card_email)
|
33
|
+
subject
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "with gift cards sent in the future" do
|
38
|
+
it "does not sends emails" do
|
39
|
+
Spree::VirtualGiftCard.create!(amount: 50, send_email_at: 10.days.from_now.to_date, redeemable: true, purchaser: purchaser)
|
40
|
+
expect(Spree::GiftCardMailer).to_not receive(:gift_card_email)
|
41
|
+
subject
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context "with gift cards sent in the past" do
|
46
|
+
it "does not sends emails" do
|
47
|
+
Spree::VirtualGiftCard.create!(amount: 50, send_email_at: 1.days.ago, sent_at: 1.days.ago.to_date, redeemable: true, purchaser: purchaser)
|
48
|
+
expect(Spree::GiftCardMailer).to_not receive(:gift_card_email)
|
49
|
+
subject
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context "with gift cards not specified" do
|
54
|
+
it "does not sends emails" do
|
55
|
+
Spree::VirtualGiftCard.create!(amount: 50, send_email_at: nil)
|
56
|
+
expect(Spree::GiftCardMailer).to_not receive(:gift_card_email)
|
57
|
+
subject
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -27,4 +27,25 @@ describe Spree::LineItem do
|
|
27
27
|
expect(subject.first).to have_value gift_card.formatted_amount
|
28
28
|
end
|
29
29
|
end
|
30
|
+
|
31
|
+
describe "#gift_card_details" do
|
32
|
+
let(:line_item) { create(:line_item, quantity: 2) }
|
33
|
+
let!(:gift_card) { create(:redeemable_virtual_gift_card, line_item: line_item) }
|
34
|
+
let!(:gift_card_2) { create(:redeemable_virtual_gift_card, line_item: line_item) }
|
35
|
+
let(:subject) { line_item.gift_card_details }
|
36
|
+
|
37
|
+
it 'contains all gift cards on the line item' do
|
38
|
+
expect(subject.size).to eq line_item.quantity
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'contains the correct keys and values' do
|
42
|
+
gift_card_details = subject.first
|
43
|
+
expect(gift_card_details[:amount]).to eq gift_card.formatted_amount
|
44
|
+
expect(gift_card_details[:redemption_code]).to eq gift_card.formatted_redemption_code
|
45
|
+
expect(gift_card_details[:recipient_email]).to eq gift_card.recipient_email
|
46
|
+
expect(gift_card_details[:recipient_name]).to eq gift_card.recipient_name
|
47
|
+
expect(gift_card_details[:purchaser_name]).to eq gift_card.purchaser_name
|
48
|
+
expect(gift_card_details[:gift_message]).to eq gift_card.gift_message
|
49
|
+
end
|
50
|
+
end
|
30
51
|
end
|
@@ -0,0 +1,270 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spree::OrderContents do
|
4
|
+
let(:order) { create(:order) }
|
5
|
+
let(:variant) { create(:variant) }
|
6
|
+
let(:order_contents) { Spree::OrderContents.new(order) }
|
7
|
+
|
8
|
+
let(:recipient_name) { "Ron Weasly" }
|
9
|
+
let(:recipient_email) { "ron@weasly.com" }
|
10
|
+
let(:purchaser_name) { "Harry Potter" }
|
11
|
+
let(:gift_message) { "Thought you could use some trousers, mate" }
|
12
|
+
let(:send_email_at) { 2.days.from_now }
|
13
|
+
let(:options) do
|
14
|
+
{
|
15
|
+
"gift_card_details" => {
|
16
|
+
"recipient_name" => recipient_name,
|
17
|
+
"recipient_email" => recipient_email,
|
18
|
+
"purchaser_name" => purchaser_name,
|
19
|
+
"gift_message" => gift_message,
|
20
|
+
"send_email_at" => send_email_at,
|
21
|
+
}
|
22
|
+
}
|
23
|
+
end
|
24
|
+
let(:quantity) { 1 }
|
25
|
+
|
26
|
+
describe "#add" do
|
27
|
+
subject { order_contents.add(variant, quantity, options) }
|
28
|
+
|
29
|
+
it "creates a line item" do
|
30
|
+
expect { subject }.to change { Spree::LineItem.count }.by(1)
|
31
|
+
end
|
32
|
+
|
33
|
+
context "with a gift card product" do
|
34
|
+
before { variant.product.update_attributes(gift_card: true) }
|
35
|
+
|
36
|
+
it "creates a line item" do
|
37
|
+
expect { subject }.to change { Spree::LineItem.count }.by(1)
|
38
|
+
end
|
39
|
+
|
40
|
+
context "with a single gift card" do
|
41
|
+
it "creates a gift card" do
|
42
|
+
expect { subject }.to change { Spree::VirtualGiftCard.count }.by(1)
|
43
|
+
gift_card = Spree::VirtualGiftCard.last
|
44
|
+
expect(gift_card.recipient_name).to eq(recipient_name)
|
45
|
+
expect(gift_card.recipient_email).to eq(recipient_email)
|
46
|
+
expect(gift_card.purchaser_name).to eq(purchaser_name)
|
47
|
+
expect(gift_card.gift_message).to eq(gift_message)
|
48
|
+
expect(gift_card.send_email_at).to eq(send_email_at.to_date)
|
49
|
+
end
|
50
|
+
|
51
|
+
context "#format_date" do
|
52
|
+
context "without send_email_at" do
|
53
|
+
let(:send_email_at) { nil }
|
54
|
+
it "sets to current date" do
|
55
|
+
subject
|
56
|
+
gift_card = Spree::VirtualGiftCard.last
|
57
|
+
expect(gift_card.send_email_at).to eq(Date.today)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context "with invalid date" do
|
62
|
+
let(:send_email_at) { "12/14/2020" }
|
63
|
+
it "errors" do
|
64
|
+
expect{ subject }.to raise_error Spree::GiftCards::OrderContentsConcerns::GiftCardDateFormatError
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context "with multiple gift cards" do
|
71
|
+
let(:quantity) { 2 }
|
72
|
+
|
73
|
+
it "creates two gift cards" do
|
74
|
+
expect { subject }.to change { Spree::VirtualGiftCard.count }.by(2)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context "adding a gift card with an existing line item" do
|
79
|
+
context "when the gift card properties match" do
|
80
|
+
before { @line_item = order_contents.add(variant, quantity, options) }
|
81
|
+
|
82
|
+
it "adds to the existing gift card" do
|
83
|
+
expect(order.line_items.count).to be(1)
|
84
|
+
new_line_item = subject
|
85
|
+
expect(order.reload.line_items.count).to be(1)
|
86
|
+
expect(@line_item.reload.gift_cards.count).to be(2)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context "when the gift card properties are different" do
|
91
|
+
let(:recipient_name2) { "Severus Snape" }
|
92
|
+
let(:recipient_email2) { "wingardium@leviosa.com" }
|
93
|
+
let(:purchaser_name2) { "Dumbledore" }
|
94
|
+
let(:options2) do
|
95
|
+
{
|
96
|
+
"gift_card_details" => {
|
97
|
+
"recipient_name" => recipient_name2,
|
98
|
+
"recipient_email" => recipient_email2,
|
99
|
+
"purchaser_name" => purchaser_name2,
|
100
|
+
"gift_message" => gift_message,
|
101
|
+
"send_email_at" => send_email_at,
|
102
|
+
}
|
103
|
+
}
|
104
|
+
end
|
105
|
+
|
106
|
+
before { @line_item = order_contents.add(variant, quantity, options2) }
|
107
|
+
|
108
|
+
it "creates a new line item with a gift card" do
|
109
|
+
expect(order.line_items.count).to be(1)
|
110
|
+
new_line_item = subject
|
111
|
+
expect(@line_item.id).to_not eq new_line_item.id
|
112
|
+
expect(order.reload.line_items.count).to be(2)
|
113
|
+
expect(new_line_item.gift_cards.count).to be(1)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
context "with a non gift card product" do
|
120
|
+
it "does not create a gift card" do
|
121
|
+
expect { subject }.to_not change { Spree::VirtualGiftCard.count }
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
describe "#remove" do
|
127
|
+
subject { order_contents.remove(variant, quantity, options) }
|
128
|
+
|
129
|
+
context "for a non-gift-card product" do
|
130
|
+
before { order_contents.add(variant, quantity, options) }
|
131
|
+
|
132
|
+
it "deletes a line item" do
|
133
|
+
expect { subject }.to change { Spree::LineItem.count }.by(-1)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
context "with a gift card product" do
|
138
|
+
before do
|
139
|
+
variant.product.update_attributes(gift_card: true)
|
140
|
+
end
|
141
|
+
|
142
|
+
context "with a single gift card" do
|
143
|
+
before do
|
144
|
+
order_contents.add(variant, quantity, options)
|
145
|
+
end
|
146
|
+
|
147
|
+
it "deletes a line item" do
|
148
|
+
expect { subject }.to change { Spree::LineItem.count }.by(-1)
|
149
|
+
end
|
150
|
+
|
151
|
+
it "deletes a gift card" do
|
152
|
+
expect { subject }.to change { Spree::VirtualGiftCard.count }.by(-1)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
context "with multiple gift cards" do
|
157
|
+
let(:quantity) { 2 }
|
158
|
+
|
159
|
+
before do
|
160
|
+
order_contents.add(variant, quantity, options)
|
161
|
+
end
|
162
|
+
|
163
|
+
it "deletes two gift cards" do
|
164
|
+
expect { subject }.to change { Spree::VirtualGiftCard.count }.by(-2)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
context "with two gift card line items with identical variants" do
|
169
|
+
let(:recipient_name2) { "Severus Snape" }
|
170
|
+
let(:recipient_email2) { "wingardium@leviosa.com" }
|
171
|
+
let(:purchaser_name2) { "Dumbledore" }
|
172
|
+
let(:options2) do
|
173
|
+
{
|
174
|
+
"gift_card_details" => {
|
175
|
+
"recipient_name" => recipient_name2,
|
176
|
+
"recipient_email" => recipient_email2,
|
177
|
+
"purchaser_name" => purchaser_name2,
|
178
|
+
"gift_message" => gift_message,
|
179
|
+
"send_email_at" => send_email_at,
|
180
|
+
}
|
181
|
+
}
|
182
|
+
end
|
183
|
+
|
184
|
+
before do
|
185
|
+
@line_item = order_contents.add(variant, quantity, options)
|
186
|
+
@line_item2 = order_contents.add(variant, quantity, options2)
|
187
|
+
end
|
188
|
+
|
189
|
+
context "removing the first line item" do
|
190
|
+
it "removes the correct line item" do
|
191
|
+
expect(order.line_items.count).to be(2)
|
192
|
+
subject
|
193
|
+
expect(order.reload.line_items.count).to be(1)
|
194
|
+
expect(order.line_items).to_not include(@line_item)
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
context "removing the second line item" do
|
199
|
+
subject { order_contents.remove(variant, quantity, options2) }
|
200
|
+
|
201
|
+
it "removes the correct line item" do
|
202
|
+
expect(order.line_items.count).to be(2)
|
203
|
+
subject
|
204
|
+
expect(order.reload.line_items.count).to be(1)
|
205
|
+
expect(order.line_items).to_not include(@line_item2)
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
context "when no gift card details are supplied" do
|
211
|
+
subject { order_contents.remove(variant, quantity) }
|
212
|
+
|
213
|
+
before do
|
214
|
+
order_contents.add(variant, quantity, options)
|
215
|
+
end
|
216
|
+
|
217
|
+
it "removes the line item with the correct variant" do
|
218
|
+
expect { subject }.to change { Spree::LineItem.count }.by(-1)
|
219
|
+
end
|
220
|
+
|
221
|
+
it "removes the gift card" do
|
222
|
+
expect { subject }.to change { Spree::VirtualGiftCard.count }.by(-1)
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
describe "#update_cart" do
|
228
|
+
subject { order_contents.update_cart(update_params) }
|
229
|
+
|
230
|
+
let(:update_params) do
|
231
|
+
{
|
232
|
+
line_items_attributes: { id: @line_item.id, quantity: quantity, options: {}}
|
233
|
+
}
|
234
|
+
end
|
235
|
+
|
236
|
+
context "for a gift card line item" do
|
237
|
+
before do
|
238
|
+
variant.product.update_attributes(gift_card: true)
|
239
|
+
@line_item = order_contents.add(variant, 2, options)
|
240
|
+
end
|
241
|
+
|
242
|
+
context "line item is being updated to a higher quantity" do
|
243
|
+
let(:quantity) { "4" }
|
244
|
+
|
245
|
+
it "creates new gift cards" do
|
246
|
+
expect { subject }.to change { Spree::VirtualGiftCard.count }.by(2)
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
context "line item is being updated to a lower quantity" do
|
251
|
+
context "one lower" do
|
252
|
+
let(:quantity) { "1" }
|
253
|
+
|
254
|
+
it "destroys gift cards" do
|
255
|
+
expect { subject }.to change { Spree::VirtualGiftCard.count }.by(-1)
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
context "multiple lower" do
|
260
|
+
let(:quantity) { "0" }
|
261
|
+
|
262
|
+
it "destroys gift cards" do
|
263
|
+
expect { subject }.to change { Spree::VirtualGiftCard.count }.by(-2)
|
264
|
+
end
|
265
|
+
end
|
266
|
+
end
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|
270
|
+
end
|
@@ -1,64 +1,57 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Spree::Order do
|
4
|
-
describe "#create_gift_cards" do
|
5
|
-
let(:order) { create(:order_with_line_items) }
|
6
|
-
let(:line_item) { order.line_items.first }
|
7
|
-
subject { order.create_gift_cards }
|
8
|
-
|
9
|
-
context "the line item is a gift card" do
|
10
|
-
before do
|
11
|
-
allow(line_item).to receive(:gift_card?).and_return(true)
|
12
|
-
allow(line_item).to receive(:quantity).and_return(3)
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'creates a gift card for each gift card in the line item' do
|
16
|
-
expect { subject }.to change { Spree::VirtualGiftCard.count }.by(line_item.quantity)
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'sets the purchaser, amount, and currency' do
|
20
|
-
expect(Spree::VirtualGiftCard).to receive(:create!).exactly(3).times.with(amount: line_item.price, currency: line_item.currency, purchaser: order.user, line_item: line_item)
|
21
|
-
subject
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
context "the line item is not a gift card" do
|
26
|
-
before { allow(line_item).to receive(:gift_card?).and_return(false) }
|
27
|
-
|
28
|
-
it 'does not create a gift card' do
|
29
|
-
expect(Spree::VirtualGiftCard).not_to receive(:create!)
|
30
|
-
subject
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
4
|
describe "#finalize!" do
|
36
5
|
context "the order contains gift cards and transitions to complete" do
|
37
|
-
let(:
|
6
|
+
let(:gift_card) { create(:virtual_gift_card) }
|
7
|
+
let(:order) { create(:order_with_line_items, state: 'complete', line_items: [gift_card.line_item]) }
|
38
8
|
|
39
9
|
subject { order.finalize! }
|
40
10
|
|
41
|
-
it "
|
42
|
-
expect(order).to receive(:create_gift_cards)
|
11
|
+
it "makes the gift card redeemable" do
|
43
12
|
subject
|
13
|
+
expect(gift_card.reload.redeemable).to be true
|
14
|
+
expect(gift_card.reload.redemption_code).to be_present
|
44
15
|
end
|
45
16
|
end
|
46
17
|
end
|
47
18
|
|
48
19
|
describe "#send_gift_card_emails" do
|
49
|
-
|
50
20
|
subject { order.send_gift_card_emails }
|
51
21
|
|
52
22
|
context "the order has gift cards" do
|
53
|
-
let(:gift_card) { create(:virtual_gift_card) }
|
23
|
+
let(:gift_card) { create(:virtual_gift_card, send_email_at: send_email_at) }
|
54
24
|
let(:line_item) { gift_card.line_item }
|
55
|
-
let(:gift_card_2) { create(:virtual_gift_card, line_item: line_item) }
|
25
|
+
let(:gift_card_2) { create(:virtual_gift_card, line_item: line_item, send_email_at: send_email_at) }
|
56
26
|
let(:order) { gift_card.line_item.order }
|
57
27
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
28
|
+
context "send_email_at is not set" do
|
29
|
+
let(:send_email_at) { nil }
|
30
|
+
it "should call GiftCardMailer#send" do
|
31
|
+
expect(Spree::GiftCardMailer).to receive(:gift_card_email).with(gift_card).and_return(double(deliver_later: true))
|
32
|
+
expect(Spree::GiftCardMailer).to receive(:gift_card_email).with(gift_card_2).and_return(double(deliver_later: true))
|
33
|
+
subject
|
34
|
+
expect(gift_card.reload.sent_at).to be_present
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "send_email_at is in the past" do
|
39
|
+
let(:send_email_at) { 2.days.ago }
|
40
|
+
it "should call GiftCardMailer#send" do
|
41
|
+
expect(Spree::GiftCardMailer).to receive(:gift_card_email).with(gift_card).and_return(double(deliver_later: true))
|
42
|
+
expect(Spree::GiftCardMailer).to receive(:gift_card_email).with(gift_card_2).and_return(double(deliver_later: true))
|
43
|
+
subject
|
44
|
+
expect(gift_card.reload.sent_at).to be_present
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "send_email_at is in the future" do
|
49
|
+
let(:send_email_at) { 2.days.from_now }
|
50
|
+
it "does not call GiftCardMailer#send" do
|
51
|
+
expect(Spree::GiftCardMailer).to_not receive(:gift_card_email)
|
52
|
+
subject
|
53
|
+
expect(gift_card.reload.sent_at).to_not be_present
|
54
|
+
end
|
62
55
|
end
|
63
56
|
end
|
64
57
|
|
@@ -71,20 +64,4 @@ describe Spree::Order do
|
|
71
64
|
end
|
72
65
|
end
|
73
66
|
end
|
74
|
-
|
75
|
-
describe "#display_total_applicable_store_credit" do
|
76
|
-
let(:total_applicable_store_credit) { 10.00 }
|
77
|
-
|
78
|
-
subject { create(:order) }
|
79
|
-
|
80
|
-
before { allow(subject).to receive_messages(total_applicable_store_credit: total_applicable_store_credit) }
|
81
|
-
|
82
|
-
it "returns a money instance" do
|
83
|
-
expect(subject.display_total_applicable_store_credit).to be_a(Spree::Money)
|
84
|
-
end
|
85
|
-
|
86
|
-
it "returns a negative amount" do
|
87
|
-
expect(subject.display_total_applicable_store_credit.money.cents).to eq (total_applicable_store_credit * -100.0)
|
88
|
-
end
|
89
|
-
end
|
90
67
|
end
|