solidus_virtual_gift_card 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.circleci/config.yml +35 -0
- data/Gemfile +20 -6
- data/README.md +4 -3
- data/Rakefile +2 -2
- data/app/controllers/spree/admin/gift_cards_controller.rb +14 -14
- data/app/controllers/spree/api/gift_cards_controller.rb +2 -2
- data/app/decorators/models/solidus_virtual_gift_card/spree/inventory_unit_decorator.rb +13 -0
- data/app/decorators/models/solidus_virtual_gift_card/spree/line_item_decorator.rb +24 -0
- data/app/{models/concerns/spree/gift_cards/order_contents_concerns.rb → decorators/models/solidus_virtual_gift_card/spree/order_contents_decorator.rb} +14 -20
- data/app/{models/concerns/spree/gift_cards/order_concerns.rb → decorators/models/solidus_virtual_gift_card/spree/order_decorator.rb} +14 -14
- data/app/{models → decorators/models/solidus_virtual_gift_card}/spree/store_credit_category_decorator.rb +1 -1
- data/app/mailers/spree/gift_card_mailer.rb +5 -2
- data/app/models/spree/gift_cards/gift_card_date_format_error.rb +6 -0
- data/app/models/{concerns/spree → spree}/redemption_code_generator.rb +0 -0
- data/app/models/spree/virtual_gift_card.rb +19 -16
- data/app/overrides/admin_gift_card_order_confirmation.rb +4 -4
- data/app/overrides/admin_item_view_gift_card_codes.rb +12 -12
- data/app/overrides/admin_user_sidebar_store_credits.rb +3 -3
- data/app/overrides/admin_user_sub_menu.rb +2 -2
- data/app/views/spree/admin/gift_cards/_lookup_form.html.erb +2 -2
- data/app/views/spree/admin/gift_cards/_redemption_form.html.erb +1 -1
- data/app/views/spree/admin/gift_cards/edit.html.erb +5 -5
- data/app/views/spree/admin/gift_cards/index.html.erb +1 -1
- data/app/views/spree/admin/gift_cards/lookup.html.erb +1 -1
- data/app/views/spree/admin/orders/_confirmation_gift_card_details.html.erb +9 -9
- data/app/views/spree/admin/orders/_gift_card_details.html.erb +2 -2
- data/app/views/spree/admin/users/_gift_card_sidebar.html.erb +2 -2
- data/app/views/spree/gift_card_mailer/gift_card_email.text.erb +3 -3
- data/config/initializers/line_item_controller_gift_card_details.rb +1 -1
- data/db/migrate/20140623152903_create_virtual_gift_card.rb +1 -1
- data/db/migrate/20140624175113_seed_gift_card_category.rb +1 -1
- data/db/migrate/20140627185148_add_timestamps_to_gift_cards.rb +1 -1
- data/db/migrate/20140702153907_add_gift_card_flag_to_products.rb +1 -1
- data/db/migrate/20140707200431_add_line_item_to_gift_card.rb +1 -1
- data/db/migrate/20151013172931_add_recipient_fields_to_virtual_gift_card.rb +1 -1
- data/db/migrate/20151013210615_add_active_flag_to_virtual_gift_card.rb +1 -1
- data/db/migrate/20151013214647_set_redeemable_true_on_virtual_gift_cards.rb +2 -2
- data/db/migrate/20151019190731_add_email_send_time_to_virtual_gift_card.rb +1 -1
- data/db/migrate/20151109202300_add_deactivated_at_to_gift_card.rb +1 -1
- data/db/migrate/20151110202752_add_inventory_unit_to_gift_card.rb +1 -1
- data/db/migrate/20151111211220_backfill_inventory_units_on_gift_card.rb +2 -2
- data/lib/generators/solidus_virtual_gift_card/install/install_generator.rb +1 -1
- data/lib/solidus_virtual_gift_card.rb +1 -0
- data/lib/spree_virtual_gift_card/engine.rb +3 -3
- data/lib/spree_virtual_gift_card/factories.rb +7 -7
- data/lib/tasks/send_gift_card_emails.rake +1 -1
- data/solidus_virtual_gift_card.gemspec +23 -21
- data/spec/controllers/spree/admin/gift_cards_controller_spec.rb +33 -34
- data/spec/controllers/spree/api/gift_cards_controller_spec.rb +12 -13
- data/spec/features/admin/gift_cards_spec.rb +19 -17
- data/spec/features/admin/products_card_spec.rb +3 -3
- data/spec/lib/tasks/send_gift_card_emails_spec.rb +12 -12
- data/spec/mailers/spree/gift_card_mailer_spec.rb +4 -4
- data/spec/models/concerns/spree/redemption_code_generator_spec.rb +5 -5
- data/spec/models/spree/line_item_spec.rb +2 -2
- data/spec/models/spree/order_contents_spec.rb +82 -82
- data/spec/models/spree/order_spec.rb +13 -13
- data/spec/models/spree/permission_sets/virtual_gift_card_display_spec.rb +2 -2
- data/spec/models/spree/permission_sets/virtual_gift_card_management_spec.rb +2 -2
- data/spec/models/spree/store_credit_category_spec.rb +6 -6
- data/spec/models/spree/virtual_gift_card_spec.rb +23 -23
- data/spec/spec_helper.rb +13 -74
- data/spec/support/cancan.rb +3 -0
- metadata +56 -25
- data/.travis.yml +0 -8
- data/app/models/concerns/spree/gift_cards/inventory_unit_concerns.rb +0 -10
- data/app/models/concerns/spree/gift_cards/line_item_concerns.rb +0 -22
- data/app/models/spree/inventory_unit_decorator.rb +0 -1
- data/app/models/spree/line_item_decorator.rb +0 -1
- data/app/models/spree/order_contents_decorator.rb +0 -1
- data/app/models/spree/order_decorator.rb +0 -1
- data/circle.yml +0 -6
@@ -5,40 +5,40 @@ describe Spree::OrderContents do
|
|
5
5
|
let(:variant) { create(:variant) }
|
6
6
|
let(:order_contents) { Spree::OrderContents.new(order) }
|
7
7
|
|
8
|
-
let(:recipient_name) {
|
9
|
-
let(:recipient_email) {
|
10
|
-
let(:purchaser_name) {
|
11
|
-
let(:gift_message) {
|
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
12
|
let(:send_email_at) { 2.days.from_now }
|
13
13
|
let(:options) do
|
14
14
|
{
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
21
|
}
|
22
22
|
}
|
23
23
|
end
|
24
24
|
let(:quantity) { 1 }
|
25
25
|
|
26
|
-
describe
|
26
|
+
describe '#add' do
|
27
27
|
subject { order_contents.add(variant, quantity, options) }
|
28
28
|
|
29
|
-
it
|
29
|
+
it 'creates a line item' do
|
30
30
|
expect { subject }.to change { Spree::LineItem.count }.by(1)
|
31
31
|
end
|
32
32
|
|
33
|
-
context
|
34
|
-
before { variant.product.
|
33
|
+
context 'with a gift card product' do
|
34
|
+
before { variant.product.update(gift_card: true) }
|
35
35
|
|
36
|
-
it
|
36
|
+
it 'creates a line item' do
|
37
37
|
expect { subject }.to change { Spree::LineItem.count }.by(1)
|
38
38
|
end
|
39
39
|
|
40
|
-
context
|
41
|
-
it
|
40
|
+
context 'with a single gift card' do
|
41
|
+
it 'creates a gift card' do
|
42
42
|
expect { subject }.to change { Spree::VirtualGiftCard.count }.by(1)
|
43
43
|
gift_card = Spree::VirtualGiftCard.last
|
44
44
|
expect(gift_card.recipient_name).to eq(recipient_name)
|
@@ -48,38 +48,38 @@ describe Spree::OrderContents do
|
|
48
48
|
expect(gift_card.send_email_at).to eq(send_email_at.to_date)
|
49
49
|
end
|
50
50
|
|
51
|
-
context
|
52
|
-
context
|
51
|
+
context '#format_date' do
|
52
|
+
context 'without send_email_at' do
|
53
53
|
let(:send_email_at) { nil }
|
54
|
-
it
|
54
|
+
it 'sets to current date' do
|
55
55
|
subject
|
56
56
|
gift_card = Spree::VirtualGiftCard.last
|
57
57
|
expect(gift_card.send_email_at).to eq(Date.today)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
context
|
62
|
-
let(:send_email_at) {
|
63
|
-
it
|
64
|
-
expect{ subject }.to raise_error Spree::GiftCards::
|
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::GiftCardDateFormatError
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
context
|
70
|
+
context 'with multiple gift cards' do
|
71
71
|
let(:quantity) { 2 }
|
72
72
|
|
73
|
-
it
|
73
|
+
it 'creates two gift cards' do
|
74
74
|
expect { subject }.to change { Spree::VirtualGiftCard.count }.by(2)
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
-
context
|
79
|
-
context
|
78
|
+
context 'adding a gift card with an existing line item' do
|
79
|
+
context 'when the gift card properties match' do
|
80
80
|
before { @line_item = order_contents.add(variant, quantity, options) }
|
81
81
|
|
82
|
-
it
|
82
|
+
it 'adds to the existing gift card' do
|
83
83
|
expect(order.line_items.count).to be(1)
|
84
84
|
new_line_item = subject
|
85
85
|
expect(order.reload.line_items.count).to be(1)
|
@@ -87,25 +87,25 @@ describe Spree::OrderContents do
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
-
context
|
91
|
-
let(:recipient_name2) {
|
92
|
-
let(:recipient_email2) {
|
93
|
-
let(:purchaser_name2) {
|
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
94
|
let(:options2) do
|
95
95
|
{
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
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
102
|
}
|
103
103
|
}
|
104
104
|
end
|
105
105
|
|
106
106
|
before { @line_item = order_contents.add(variant, quantity, options2) }
|
107
107
|
|
108
|
-
it
|
108
|
+
it 'creates a new line item with a gift card' do
|
109
109
|
expect(order.line_items.count).to be(1)
|
110
110
|
new_line_item = subject
|
111
111
|
expect(@line_item.id).to_not eq new_line_item.id
|
@@ -116,67 +116,67 @@ describe Spree::OrderContents do
|
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
119
|
-
context
|
120
|
-
it
|
119
|
+
context 'with a non gift card product' do
|
120
|
+
it 'does not create a gift card' do
|
121
121
|
expect { subject }.to_not change { Spree::VirtualGiftCard.count }
|
122
122
|
end
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
126
|
-
describe
|
126
|
+
describe '#remove' do
|
127
127
|
subject { order_contents.remove(variant, quantity, options) }
|
128
128
|
|
129
|
-
context
|
129
|
+
context 'for a non-gift-card product' do
|
130
130
|
before { order_contents.add(variant, quantity, options) }
|
131
131
|
|
132
|
-
it
|
132
|
+
it 'deletes a line item' do
|
133
133
|
expect { subject }.to change { Spree::LineItem.count }.by(-1)
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
137
|
-
context
|
137
|
+
context 'with a gift card product' do
|
138
138
|
before do
|
139
|
-
variant.product.
|
139
|
+
variant.product.update(gift_card: true)
|
140
140
|
end
|
141
141
|
|
142
|
-
context
|
142
|
+
context 'with a single gift card' do
|
143
143
|
before do
|
144
144
|
order_contents.add(variant, quantity, options)
|
145
145
|
end
|
146
146
|
|
147
|
-
it
|
147
|
+
it 'deletes a line item' do
|
148
148
|
expect { subject }.to change { Spree::LineItem.count }.by(-1)
|
149
149
|
end
|
150
150
|
|
151
|
-
it
|
151
|
+
it 'deletes a gift card' do
|
152
152
|
expect { subject }.to change { Spree::VirtualGiftCard.count }.by(-1)
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
156
|
-
context
|
156
|
+
context 'with multiple gift cards' do
|
157
157
|
let(:quantity) { 2 }
|
158
158
|
|
159
159
|
before do
|
160
160
|
order_contents.add(variant, quantity, options)
|
161
161
|
end
|
162
162
|
|
163
|
-
it
|
163
|
+
it 'deletes two gift cards' do
|
164
164
|
expect { subject }.to change { Spree::VirtualGiftCard.count }.by(-2)
|
165
165
|
end
|
166
166
|
end
|
167
167
|
|
168
|
-
context
|
169
|
-
let(:recipient_name2) {
|
170
|
-
let(:recipient_email2) {
|
171
|
-
let(:purchaser_name2) {
|
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
172
|
let(:options2) do
|
173
173
|
{
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
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
180
|
}
|
181
181
|
}
|
182
182
|
end
|
@@ -186,8 +186,8 @@ describe Spree::OrderContents do
|
|
186
186
|
@line_item2 = order_contents.add(variant, quantity, options2)
|
187
187
|
end
|
188
188
|
|
189
|
-
context
|
190
|
-
it
|
189
|
+
context 'removing the first line item' do
|
190
|
+
it 'removes the correct line item' do
|
191
191
|
expect(order.line_items.count).to be(2)
|
192
192
|
subject
|
193
193
|
expect(order.reload.line_items.count).to be(1)
|
@@ -195,10 +195,10 @@ describe Spree::OrderContents do
|
|
195
195
|
end
|
196
196
|
end
|
197
197
|
|
198
|
-
context
|
198
|
+
context 'removing the second line item' do
|
199
199
|
subject { order_contents.remove(variant, quantity, options2) }
|
200
200
|
|
201
|
-
it
|
201
|
+
it 'removes the correct line item' do
|
202
202
|
expect(order.line_items.count).to be(2)
|
203
203
|
subject
|
204
204
|
expect(order.reload.line_items.count).to be(1)
|
@@ -207,24 +207,24 @@ describe Spree::OrderContents do
|
|
207
207
|
end
|
208
208
|
end
|
209
209
|
|
210
|
-
context
|
210
|
+
context 'when no gift card details are supplied' do
|
211
211
|
subject { order_contents.remove(variant, quantity) }
|
212
212
|
|
213
213
|
before do
|
214
214
|
order_contents.add(variant, quantity, options)
|
215
215
|
end
|
216
216
|
|
217
|
-
it
|
217
|
+
it 'removes the line item with the correct variant' do
|
218
218
|
expect { subject }.to change { Spree::LineItem.count }.by(-1)
|
219
219
|
end
|
220
220
|
|
221
|
-
it
|
221
|
+
it 'removes the gift card' do
|
222
222
|
expect { subject }.to change { Spree::VirtualGiftCard.count }.by(-1)
|
223
223
|
end
|
224
224
|
end
|
225
225
|
end
|
226
226
|
|
227
|
-
describe
|
227
|
+
describe '#update_cart' do
|
228
228
|
subject { order_contents.update_cart(update_params) }
|
229
229
|
|
230
230
|
let(:update_params) do
|
@@ -233,33 +233,33 @@ describe Spree::OrderContents do
|
|
233
233
|
}
|
234
234
|
end
|
235
235
|
|
236
|
-
context
|
236
|
+
context 'for a gift card line item' do
|
237
237
|
before do
|
238
|
-
variant.product.
|
238
|
+
variant.product.update(gift_card: true)
|
239
239
|
@line_item = order_contents.add(variant, 2, options)
|
240
240
|
end
|
241
241
|
|
242
|
-
context
|
243
|
-
let(:quantity) {
|
242
|
+
context 'line item is being updated to a higher quantity' do
|
243
|
+
let(:quantity) { '4' }
|
244
244
|
|
245
|
-
it
|
245
|
+
it 'creates new gift cards' do
|
246
246
|
expect { subject }.to change { Spree::VirtualGiftCard.count }.by(2)
|
247
247
|
end
|
248
248
|
end
|
249
249
|
|
250
|
-
context
|
251
|
-
context
|
252
|
-
let(:quantity) {
|
250
|
+
context 'line item is being updated to a lower quantity' do
|
251
|
+
context 'one lower' do
|
252
|
+
let(:quantity) { '1' }
|
253
253
|
|
254
|
-
it
|
254
|
+
it 'destroys gift cards' do
|
255
255
|
expect { subject }.to change { Spree::VirtualGiftCard.count }.by(-1)
|
256
256
|
end
|
257
257
|
end
|
258
258
|
|
259
|
-
context
|
260
|
-
let(:quantity) {
|
259
|
+
context 'multiple lower' do
|
260
|
+
let(:quantity) { '0' }
|
261
261
|
|
262
|
-
it
|
262
|
+
it 'destroys gift cards' do
|
263
263
|
expect { subject }.to change { Spree::VirtualGiftCard.count }.by(-2)
|
264
264
|
end
|
265
265
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Spree::Order do
|
4
|
-
describe
|
5
|
-
context
|
4
|
+
describe '#finalize!' do
|
5
|
+
context 'the order contains gift cards and transitions to complete' do
|
6
6
|
let(:gift_card) { create(:virtual_gift_card) }
|
7
7
|
let(:order) { create(:order_with_line_items, state: 'complete', line_items: [gift_card.line_item]) }
|
8
8
|
|
9
9
|
subject { order.finalize! }
|
10
10
|
|
11
|
-
it
|
11
|
+
it 'makes the gift card redeemable' do
|
12
12
|
subject
|
13
13
|
expect(gift_card.reload.redeemable).to be true
|
14
14
|
expect(gift_card.reload.redemption_code).to be_present
|
@@ -16,18 +16,18 @@ describe Spree::Order do
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
describe
|
19
|
+
describe '#send_gift_card_emails' do
|
20
20
|
subject { order.send_gift_card_emails }
|
21
21
|
|
22
|
-
context
|
22
|
+
context 'the order has gift cards' do
|
23
23
|
let(:gift_card) { create(:virtual_gift_card, send_email_at: send_email_at) }
|
24
24
|
let(:line_item) { gift_card.line_item }
|
25
25
|
let(:gift_card_2) { create(:virtual_gift_card, line_item: line_item, send_email_at: send_email_at) }
|
26
26
|
let(:order) { gift_card.line_item.order }
|
27
27
|
|
28
|
-
context
|
28
|
+
context 'send_email_at is not set' do
|
29
29
|
let(:send_email_at) { nil }
|
30
|
-
it
|
30
|
+
it 'should call GiftCardMailer#send' do
|
31
31
|
expect(Spree::GiftCardMailer).to receive(:gift_card_email).with(gift_card).and_return(double(deliver_later: true))
|
32
32
|
expect(Spree::GiftCardMailer).to receive(:gift_card_email).with(gift_card_2).and_return(double(deliver_later: true))
|
33
33
|
subject
|
@@ -35,9 +35,9 @@ describe Spree::Order do
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
context
|
38
|
+
context 'send_email_at is in the past' do
|
39
39
|
let(:send_email_at) { 2.days.ago }
|
40
|
-
it
|
40
|
+
it 'should call GiftCardMailer#send' do
|
41
41
|
expect(Spree::GiftCardMailer).to receive(:gift_card_email).with(gift_card).and_return(double(deliver_later: true))
|
42
42
|
expect(Spree::GiftCardMailer).to receive(:gift_card_email).with(gift_card_2).and_return(double(deliver_later: true))
|
43
43
|
subject
|
@@ -45,9 +45,9 @@ describe Spree::Order do
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
context
|
48
|
+
context 'send_email_at is in the future' do
|
49
49
|
let(:send_email_at) { 2.days.from_now }
|
50
|
-
it
|
50
|
+
it 'does not call GiftCardMailer#send' do
|
51
51
|
expect(Spree::GiftCardMailer).to_not receive(:gift_card_email)
|
52
52
|
subject
|
53
53
|
expect(gift_card.reload.sent_at).to_not be_present
|
@@ -55,10 +55,10 @@ describe Spree::Order do
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
context
|
58
|
+
context 'no gift cards' do
|
59
59
|
let(:order) { create(:order_with_line_items) }
|
60
60
|
|
61
|
-
it
|
61
|
+
it 'should not call GiftCardMailer#send' do
|
62
62
|
expect(Spree::GiftCardMailer).to_not receive(:gift_card_email)
|
63
63
|
subject
|
64
64
|
end
|
@@ -5,7 +5,7 @@ describe Spree::PermissionSets::VirtualGiftCardDisplay do
|
|
5
5
|
|
6
6
|
subject { ability }
|
7
7
|
|
8
|
-
context
|
8
|
+
context 'when activated' do
|
9
9
|
before do
|
10
10
|
described_class.new(ability).activate!
|
11
11
|
end
|
@@ -14,7 +14,7 @@ describe Spree::PermissionSets::VirtualGiftCardDisplay do
|
|
14
14
|
it { should be_able_to(:display, Spree::VirtualGiftCard) }
|
15
15
|
end
|
16
16
|
|
17
|
-
context
|
17
|
+
context 'when not activated' do
|
18
18
|
it { should_not be_able_to(:admin, Spree::VirtualGiftCard) }
|
19
19
|
it { should_not be_able_to(:display, Spree::VirtualGiftCard) }
|
20
20
|
end
|
@@ -6,7 +6,7 @@ describe Spree::PermissionSets::VirtualGiftCardManagement do
|
|
6
6
|
|
7
7
|
subject { ability }
|
8
8
|
|
9
|
-
context
|
9
|
+
context 'when activated' do
|
10
10
|
before do
|
11
11
|
described_class.new(ability).activate!
|
12
12
|
end
|
@@ -14,7 +14,7 @@ describe Spree::PermissionSets::VirtualGiftCardManagement do
|
|
14
14
|
it { should be_able_to(:manage, Spree::VirtualGiftCard) }
|
15
15
|
end
|
16
16
|
|
17
|
-
context
|
17
|
+
context 'when not activated' do
|
18
18
|
it { should_not be_able_to(:manage, Spree::VirtualGiftCard) }
|
19
19
|
end
|
20
20
|
end
|
@@ -1,21 +1,21 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Spree::StoreCreditCategory, type: :model do
|
4
|
-
describe
|
4
|
+
describe '#non_expiring?' do
|
5
5
|
subject { build(:store_credit_category, name: category_name).non_expiring? }
|
6
6
|
|
7
|
-
context
|
7
|
+
context 'non-expiring type store credit' do
|
8
8
|
let(:category_name) { Spree::StoreCreditCategory.non_expiring_credit_types.first }
|
9
9
|
|
10
|
-
it
|
10
|
+
it 'returns true' do
|
11
11
|
expect(subject).to be true
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
context
|
16
|
-
let(:category_name) {
|
15
|
+
context 'expiring type store credit' do
|
16
|
+
let(:category_name) { 'Expiring' }
|
17
17
|
|
18
|
-
it
|
18
|
+
it 'returns false' do
|
19
19
|
expect(subject).to be false
|
20
20
|
end
|
21
21
|
end
|