spree_analytics_trackers 1.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.bundle/config +2 -0
- data/.gitignore +21 -0
- data/.rspec +3 -0
- data/.rubocop.yml +2 -0
- data/.travis.yml +44 -0
- data/Appraisals +11 -0
- data/Gemfile +7 -0
- data/LICENSE +26 -0
- data/README.md +77 -0
- data/Rakefile +21 -0
- data/app/assets/javascripts/spree/frontend/add_to_cart_analytics.js +50 -0
- data/app/assets/javascripts/spree/frontend/remove_from_cart_analytics.js +34 -0
- data/app/controllers/spree/admin/trackers_controller.rb +14 -0
- data/app/controllers/spree_analytics_trackers/store_controller_decorator.rb +14 -0
- data/app/helpers/spree/trackers_helper.rb +86 -0
- data/app/models/spree/tracker.rb +31 -0
- data/app/models/spree_analytics_trackers/user_decorator.rb +9 -0
- data/app/overrides/add_analytics_to_admin_sidebar.rb +8 -0
- data/app/overrides/add_cart_viewed_to_orders_edit.rb +10 -0
- data/app/overrides/add_checkout_step_viewed_to_checkout_edit.rb +18 -0
- data/app/overrides/add_google_analytics_page_view_to_spree_application.rb +10 -0
- data/app/overrides/add_google_analytics_to_spree_application.rb +9 -0
- data/app/overrides/add_google_purchase_to_orders_show.rb +9 -0
- data/app/overrides/add_order_complete_to_orders_show.rb +10 -0
- data/app/overrides/add_product_list_filtered_to_taxons_show.rb +10 -0
- data/app/overrides/add_product_list_viewed_to_products_list.rb +10 -0
- data/app/overrides/add_product_viewed_to_products_show.rb +10 -0
- data/app/overrides/add_products_searched_to_products_list.rb +10 -0
- data/app/overrides/add_segment_initializer_to_layout.rb +10 -0
- data/app/overrides/add_segment_page_viewed_to_layout.rb +10 -0
- data/app/presenters/spree_analytics_trackers/base_presenter.rb +14 -0
- data/app/presenters/spree_analytics_trackers/segment/order_presenter.rb +32 -0
- data/app/presenters/spree_analytics_trackers/segment/product_presenter.rb +40 -0
- data/app/views/spree/admin/shared/_analytics_sidebar_menu.html.erb +3 -0
- data/app/views/spree/admin/trackers/_form.html.erb +42 -0
- data/app/views/spree/admin/trackers/edit.html.erb +13 -0
- data/app/views/spree/admin/trackers/index.html.erb +42 -0
- data/app/views/spree/admin/trackers/new.html.erb +13 -0
- data/app/views/spree/shared/trackers/google_analytics/_checkout_step_viewed.js.erb +19 -0
- data/app/views/spree/shared/trackers/google_analytics/_initializer.js.erb +25 -0
- data/app/views/spree/shared/trackers/google_analytics/_page_viewed.js.erb +13 -0
- data/app/views/spree/shared/trackers/google_analytics/_purchase.js.erb +22 -0
- data/app/views/spree/shared/trackers/segment/_cart_viewed.js.erb +27 -0
- data/app/views/spree/shared/trackers/segment/_checkout_step_viewed.js.erb +21 -0
- data/app/views/spree/shared/trackers/segment/_initializer.js.erb +7 -0
- data/app/views/spree/shared/trackers/segment/_order_complete.js.erb +11 -0
- data/app/views/spree/shared/trackers/segment/_page_viewed.js.erb +7 -0
- data/app/views/spree/shared/trackers/segment/_product_list_filtered.js.erb +23 -0
- data/app/views/spree/shared/trackers/segment/_product_list_viewed.js.erb +19 -0
- data/app/views/spree/shared/trackers/segment/_product_viewed.js.erb +12 -0
- data/app/views/spree/shared/trackers/segment/_products_searched.js.erb +10 -0
- data/bin/rails +7 -0
- data/config/locales/en.yml +18 -0
- data/config/locales/zh-TW.yml +19 -0
- data/config/routes.rb +5 -0
- data/db/migrate/20171013160337_create_spree_trackers.rb +20 -0
- data/db/migrate/20200721163729_add_store_id_to_spree_trackers.rb +14 -0
- data/gemfiles/.bundle/config +2 -0
- data/gemfiles/spree_4_1.gemfile +9 -0
- data/gemfiles/spree_master.gemfile +9 -0
- data/lib/generators/spree_analytics_trackers/install/install_generator.rb +28 -0
- data/lib/spree_analytics_trackers.rb +5 -0
- data/lib/spree_analytics_trackers/engine.rb +20 -0
- data/lib/spree_analytics_trackers/factories.rb +10 -0
- data/lib/spree_analytics_trackers/version.rb +17 -0
- data/spec/features/admin/configuration/analytics_tracker_spec.rb +61 -0
- data/spec/features/products_spec.rb +315 -0
- data/spec/fixtures/thinking-cat.jpg +0 -0
- data/spec/models/spree/tracker_spec.rb +32 -0
- data/spec/presenters/spree_analytics_trackers/segment/order_presenter_spec.rb +34 -0
- data/spec/spec_helper.rb +18 -0
- data/spec/support/custom_products.rb +26 -0
- data/spree_analytics_trackers.gemspec +31 -0
- metadata +98 -200
@@ -0,0 +1,315 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe 'Visiting Products', type: :feature, js: true do
|
5
|
+
include_context 'custom products'
|
6
|
+
|
7
|
+
let(:store) { Spree::Store.default }
|
8
|
+
|
9
|
+
let(:store_name) do
|
10
|
+
((first_store = Spree::Store.first) && first_store.name).to_s
|
11
|
+
end
|
12
|
+
|
13
|
+
let!(:ga_tracker) { create(:tracker) }
|
14
|
+
let!(:segment_tracker) { create(:tracker, engine: :segment) }
|
15
|
+
|
16
|
+
before do
|
17
|
+
visit spree.products_path
|
18
|
+
allow(ENV).to receive(:[]).and_call_original
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'is able to show the shopping cart after adding a product to it' do
|
22
|
+
click_link 'Ruby on Rails Ringer T-Shirt'
|
23
|
+
expect(page).to have_content('$159.99')
|
24
|
+
|
25
|
+
expect(page).to have_selector('form#add-to-cart-form')
|
26
|
+
expect(page).to have_selector(:button, id: 'add-to-cart-button', disabled: false)
|
27
|
+
click_button 'add-to-cart-button'
|
28
|
+
expect(page).to have_content(Spree.t(:added_to_cart))
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'using Russian Rubles as a currency' do
|
32
|
+
before do
|
33
|
+
store.update(default_currency: 'RUB')
|
34
|
+
end
|
35
|
+
|
36
|
+
let!(:product) do
|
37
|
+
product = Spree::Product.find_by(name: 'Ruby on Rails Ringer T-Shirt')
|
38
|
+
product.master.prices.create(amount: 19.99, currency: 'RUB')
|
39
|
+
product.tap(&:save)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Regression tests for #2737
|
43
|
+
context 'uses руб as the currency symbol' do
|
44
|
+
it 'on products page' do
|
45
|
+
visit spree.products_path
|
46
|
+
within("#product_#{product.id}") do
|
47
|
+
within('.product-component-price') do
|
48
|
+
expect(page).to have_content('19.99 ₽')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'on product page' do
|
54
|
+
visit spree.product_path(product)
|
55
|
+
within('.price') do
|
56
|
+
expect(page).to have_content('19.99 ₽')
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'when adding a product to the cart' do
|
61
|
+
add_to_cart(product)
|
62
|
+
|
63
|
+
within('.shopping-cart-total-amount') do
|
64
|
+
expect(page).to have_content('19.99 ₽')
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'is able to search for a product' do
|
71
|
+
find('.search-icons').click
|
72
|
+
fill_in 'keywords', with: 'shirt'
|
73
|
+
|
74
|
+
if Spree.version.to_f > 4.1
|
75
|
+
first('button[type=submit]').click
|
76
|
+
else
|
77
|
+
find('#search-dropdown label').click
|
78
|
+
end
|
79
|
+
|
80
|
+
expect(page).to have_css('.product-component-name').once
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'a product with variants' do
|
84
|
+
let(:product) { Spree::Product.find_by(name: 'Ruby on Rails Baseball Jersey') }
|
85
|
+
let(:option_value) { create(:option_value) }
|
86
|
+
let!(:variant) { build(:variant, price: 5.59, product: product, option_values: []) }
|
87
|
+
|
88
|
+
before do
|
89
|
+
image = File.open(File.expand_path('../fixtures/thinking-cat.jpg', __dir__))
|
90
|
+
create_image(product, image)
|
91
|
+
|
92
|
+
product.option_types << option_value.option_type
|
93
|
+
variant.option_values << option_value
|
94
|
+
variant.save!
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'is displayed' do
|
98
|
+
expect { click_link product.name }.not_to raise_error
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'displays price of first variant listed' do
|
102
|
+
click_link product.name
|
103
|
+
within('#product-price') do
|
104
|
+
expect(page).to have_content variant.price
|
105
|
+
expect(page).not_to have_content Spree.t(:out_of_stock)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
it "doesn't display out of stock for master product" do
|
110
|
+
product.master.stock_items.update_all count_on_hand: 0, backorderable: false
|
111
|
+
|
112
|
+
click_link product.name
|
113
|
+
within('#product-price') do
|
114
|
+
expect(page).not_to have_content Spree.t(:out_of_stock)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
it "doesn't display cart form if all variants (including master) are out of stock" do
|
119
|
+
product.variants_including_master.each { |v| v.stock_items.update_all count_on_hand: 0, backorderable: false }
|
120
|
+
|
121
|
+
click_link product.name
|
122
|
+
within('[data-hook=product_price]') do
|
123
|
+
expect(page).not_to have_content Spree.t(:add_to_cart)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
context 'a product with variants, images only for the variants' do
|
129
|
+
let(:product) { Spree::Product.find_by(name: 'Ruby on Rails Baseball Jersey') }
|
130
|
+
let(:variant1) { create(:variant, product: product, price: 9.99) }
|
131
|
+
let(:variant2) { create(:variant, product: product, price: 10.99) }
|
132
|
+
|
133
|
+
before do
|
134
|
+
image = File.open(File.expand_path('../fixtures/thinking-cat.jpg', __dir__))
|
135
|
+
create_image(variant1, image)
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'does not display no image available' do
|
139
|
+
visit spree.products_path
|
140
|
+
expect(page).to have_selector("img[data-src$='thinking-cat.jpg']")
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
context 'an out of stock product without variants' do
|
145
|
+
let(:product) { Spree::Product.find_by(name: 'Ruby on Rails Tote') }
|
146
|
+
|
147
|
+
before do
|
148
|
+
product.master.stock_items.update_all count_on_hand: 0, backorderable: false
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'does display out of stock for master product' do
|
152
|
+
click_link product.name
|
153
|
+
within('#inside-product-cart-form') do
|
154
|
+
expect(page).to have_content Spree.t(:out_of_stock).upcase
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
it "doesn't display cart form if master is out of stock" do
|
159
|
+
click_link product.name
|
160
|
+
within('[data-hook=product_price]') do
|
161
|
+
expect(page).not_to have_content Spree.t(:add_to_cart)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
context 'pagination' do
|
167
|
+
before { Spree::Config.products_per_page = 3 }
|
168
|
+
|
169
|
+
it 'is able to display products priced between 151 and 200 dollars across multiple pages' do
|
170
|
+
find(:css, '#filtersPrice').click
|
171
|
+
within(:css, '#collapseFilterPrice') { click_on '$151 - $200' }
|
172
|
+
expect(page).to have_css('.product-component-name').exactly(3).times
|
173
|
+
next_page = find_all(:css, '.next_page')
|
174
|
+
within(next_page[0]) { find(:css, '.page-link').click }
|
175
|
+
expect(page).to have_css('.product-component-name').once
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
it 'returns the correct title when displaying a single product' do
|
180
|
+
product = Spree::Product.find_by(name: 'Ruby on Rails Baseball Jersey')
|
181
|
+
click_link product.name
|
182
|
+
|
183
|
+
within('div#product-description') do
|
184
|
+
within('h1.product-details-title') do
|
185
|
+
expect(page).to have_content('Ruby on Rails Baseball Jersey')
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
context 'product is on sale' do
|
191
|
+
let(:product) do
|
192
|
+
FactoryBot.create(:base_product, description: 'Testing sample', name: 'Sample', price: '19.99')
|
193
|
+
end
|
194
|
+
let(:option_type) { create(:option_type) }
|
195
|
+
let(:option_value1) { create(:option_value, name: 'small', presentation: 'S', option_type: option_type) }
|
196
|
+
let(:option_value2) { create(:option_value, name: 'medium', presentation: 'M', option_type: option_type) }
|
197
|
+
let(:option_value3) { create(:option_value, name: 'large', presentation: 'L', option_type: option_type) }
|
198
|
+
let(:variant1) { create(:variant, product: product, option_values: [option_value1], price: '49.99') }
|
199
|
+
let(:variant2) { create(:variant, product: product, option_values: [option_value2], price: '69.99') }
|
200
|
+
let(:variant3) { create(:variant, product: product, option_values: [option_value3], price: '89.99') }
|
201
|
+
|
202
|
+
before do
|
203
|
+
if Spree.version.to_f > 4.1
|
204
|
+
price1 = Spree::Price.find_by(variant: variant1)
|
205
|
+
price2 = Spree::Price.find_by(variant: variant2)
|
206
|
+
price3 = Spree::Price.find_by(variant: variant3)
|
207
|
+
price1.update(compare_at_amount: '149.99')
|
208
|
+
price2.update(compare_at_amount: '169.99')
|
209
|
+
price3.update(compare_at_amount: '79.99')
|
210
|
+
price1.save
|
211
|
+
price2.save
|
212
|
+
price3.save
|
213
|
+
|
214
|
+
product.master.prices.first.update(compare_at_amount: 29.99)
|
215
|
+
end
|
216
|
+
|
217
|
+
product.master.stock_items.update_all count_on_hand: 10, backorderable: true
|
218
|
+
product.option_types << option_type
|
219
|
+
product.variants << [variant1, variant2, variant3]
|
220
|
+
product.tap(&:save)
|
221
|
+
|
222
|
+
visit spree.product_path(product)
|
223
|
+
end
|
224
|
+
|
225
|
+
it 'shows pre sales price on PDP' do
|
226
|
+
expect(page).to have_content('$49.99')
|
227
|
+
end
|
228
|
+
|
229
|
+
it 'shows both pre sales and current prices on PDP' do
|
230
|
+
if Spree.version.to_f > 4.1
|
231
|
+
expect(page).to have_content('$49.99')
|
232
|
+
expect(page).to have_content('$149.99')
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
it 'shows prices for other variants' do
|
237
|
+
within('.product-variants-variant-values') do
|
238
|
+
find('li', text: 'M').click
|
239
|
+
end
|
240
|
+
|
241
|
+
expect(page).to have_content('$69.99')
|
242
|
+
|
243
|
+
if Spree.version.to_f > 4.1
|
244
|
+
expect(page).to have_content('$169.99')
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
it 'does not show pre sales price when it is bigger than price' do
|
249
|
+
if Spree.version.to_f > 4.1
|
250
|
+
within('.product-variants-variant-values') do
|
251
|
+
find('li', text: 'L').click
|
252
|
+
end
|
253
|
+
|
254
|
+
expect(page).to have_content('$89.99')
|
255
|
+
expect(page).not_to have_content('$79.99')
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
xdescribe 'When Requesting A Product By Variant Using URL Query String' do
|
261
|
+
let(:product) do
|
262
|
+
FactoryBot.create(:base_product, description: 'Testing sample', name: 'Sample', price: '19.99')
|
263
|
+
end
|
264
|
+
|
265
|
+
let(:option_type) { create(:option_type) }
|
266
|
+
let(:option_value1) { create(:option_value, name: 'small', presentation: 'S', option_type: option_type) }
|
267
|
+
let(:option_value2) { create(:option_value, name: 'medium', presentation: 'M', option_type: option_type) }
|
268
|
+
let(:option_value3) { create(:option_value, name: 'large', presentation: 'L', option_type: option_type) }
|
269
|
+
let(:variant1) { create(:variant, product: product, option_values: [option_value1], price: '49.99', sku: 'VAR-1') }
|
270
|
+
let(:variant2) { create(:variant, product: product, option_values: [option_value2], price: '69.99', sku: 'VAR-2') }
|
271
|
+
let(:variant3) { create(:variant, product: product, option_values: [option_value3], price: '89.99', sku: 'VAR-3') }
|
272
|
+
|
273
|
+
before do
|
274
|
+
product.option_types << option_type
|
275
|
+
product.variants << [variant1, variant2, variant3]
|
276
|
+
product.tap(&:save)
|
277
|
+
product.stock_items.last.update count_on_hand: 0, backorderable: false
|
278
|
+
end
|
279
|
+
|
280
|
+
context 'Make sure the requested variant' do
|
281
|
+
it 'shows the correct price in the HTML' do
|
282
|
+
visit spree.product_path(product) + '?variant=' + variant3.id.to_s
|
283
|
+
expect(page).to have_content(variant3.price.to_s)
|
284
|
+
end
|
285
|
+
|
286
|
+
it 'shows back-ordered in the HTML when product is on backorder' do
|
287
|
+
visit spree.product_path(product) + '?variant=' + variant2.id.to_s
|
288
|
+
expect(page).to have_content('BACKORDERED')
|
289
|
+
end
|
290
|
+
|
291
|
+
it 'shows out of stock in the HTML when the product is unavailable' do
|
292
|
+
visit spree.product_path(product) + '?variant=' + variant3.id.to_s
|
293
|
+
expect(page).to have_content('OUT OF STOCK')
|
294
|
+
end
|
295
|
+
|
296
|
+
it 'does not update the variant HTML details if no variant is matched' do
|
297
|
+
visit spree.product_path(product) + '?variant=9283923297832973283'
|
298
|
+
expect(page).to have_content(variant1.price.to_s)
|
299
|
+
expect(page).to have_content('BACKORDERED')
|
300
|
+
end
|
301
|
+
|
302
|
+
it 'sets JSON in the Schema.org SKU, URL, price and availability' do
|
303
|
+
visit spree.product_path(product) + '?variant=' + variant3.id.to_s
|
304
|
+
|
305
|
+
jsonld = page.find('script[type="application/ld+json"]', visible: false).text(:all)
|
306
|
+
jsonstring = Capybara.string(jsonld)
|
307
|
+
|
308
|
+
expect(jsonstring).to have_text('?variant=' + variant3.id.to_s)
|
309
|
+
expect(jsonstring).to have_text('"availability":"OutOfStock"')
|
310
|
+
expect(jsonstring).to have_text('"sku":"VAR-3"')
|
311
|
+
expect(jsonstring).to have_text('"price":"89.99"')
|
312
|
+
end
|
313
|
+
end
|
314
|
+
end
|
315
|
+
end
|
Binary file
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spree::Tracker, type: :model do
|
4
|
+
describe 'current' do
|
5
|
+
it 'returns the first active tracker' do
|
6
|
+
tracker = create(:tracker)
|
7
|
+
tracker.clear_cache
|
8
|
+
expect(Spree::Tracker.current).to eq(tracker)
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'does not return an inactive tracker' do
|
12
|
+
tracker = create(:tracker, active: false)
|
13
|
+
tracker.clear_cache
|
14
|
+
expect(Spree::Tracker.current).to be_nil
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'multi-store' do
|
18
|
+
let(:default_store) { Spree::Store.default }
|
19
|
+
let(:euro_store) { create(:store, code: :eu, name: 'eurozone') }
|
20
|
+
let!(:default_tracker) { create(:tracker, store: default_store, engine: :google_analytics) }
|
21
|
+
let!(:euro_tracker) { create(:tracker, store: euro_store, engine: :google_analytics) }
|
22
|
+
|
23
|
+
it 'returns default tracker from default store' do
|
24
|
+
expect(Spree::Tracker.current).to eq(default_tracker)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'returns tracker from a specified store' do
|
28
|
+
expect(Spree::Tracker.current(:google_analytics, euro_store)).to eq(euro_tracker)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SpreeAnalyticsTrackers::Segment::OrderPresenter, type: :presenter do
|
4
|
+
let(:order) { create(:order_with_line_items) }
|
5
|
+
|
6
|
+
subject { described_class.new(order) }
|
7
|
+
|
8
|
+
describe '#to_json' do
|
9
|
+
let(:result) do
|
10
|
+
{
|
11
|
+
order_id: order.number.to_s,
|
12
|
+
total: order.total&.to_f,
|
13
|
+
shipping: order.shipment_total&.to_f,
|
14
|
+
tax: order.additional_tax_total&.to_f,
|
15
|
+
discount: order.promo_total&.to_f,
|
16
|
+
coupon: order.promo_code,
|
17
|
+
currency: order.currency,
|
18
|
+
products: order.line_items.map{ |line_item|
|
19
|
+
{
|
20
|
+
product_id: line_item.product_id&.to_s,
|
21
|
+
sku: line_item.sku&.to_s,
|
22
|
+
name: line_item.name,
|
23
|
+
price: line_item.price&.to_f,
|
24
|
+
quantity: line_item.quantity
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}.to_json
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'returns serialized object' do
|
31
|
+
expect(subject.to_json).to eq(result)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV['RAILS_ENV'] = 'test'
|
3
|
+
|
4
|
+
require File.expand_path('../dummy/config/environment.rb', __FILE__)
|
5
|
+
|
6
|
+
require 'spree_dev_tools/rspec/spec_helper'
|
7
|
+
|
8
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
9
|
+
# in spec/support/ and its subdirectories.
|
10
|
+
Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].sort.each { |f| require f }
|
11
|
+
|
12
|
+
require 'spree_analytics_trackers/factories'
|
13
|
+
|
14
|
+
require 'spree/testing_support/image_helpers'
|
15
|
+
|
16
|
+
RSpec.configure do |config|
|
17
|
+
config.include Spree::TestingSupport::ImageHelpers
|
18
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
shared_context 'custom products' do
|
2
|
+
before do
|
3
|
+
taxonomy = FactoryBot.create(:taxonomy, name: 'Categories')
|
4
|
+
root = taxonomy.root
|
5
|
+
clothing_taxon = FactoryBot.create(:taxon, name: 'Clothing', parent_id: root.id)
|
6
|
+
trending_taxon = FactoryBot.create(:taxon, name: 'Trending')
|
7
|
+
bags_taxon = FactoryBot.create(:taxon, name: 'Bags', parent_id: root.id)
|
8
|
+
mugs_taxon = FactoryBot.create(:taxon, name: 'Mugs', parent_id: root.id)
|
9
|
+
|
10
|
+
taxonomy = FactoryBot.create(:taxonomy, name: 'Brands')
|
11
|
+
root = taxonomy.root
|
12
|
+
apache_taxon = FactoryBot.create(:taxon, name: 'Apache', parent_id: root.id)
|
13
|
+
rails_taxon = FactoryBot.create(:taxon, name: 'Ruby on Rails', parent_id: root.id)
|
14
|
+
ruby_taxon = FactoryBot.create(:taxon, name: 'Ruby', parent_id: root.id)
|
15
|
+
|
16
|
+
FactoryBot.create(:custom_product, name: 'Ruby on Rails Ringer T-Shirt', price: '159.99', taxons: [rails_taxon, clothing_taxon])
|
17
|
+
FactoryBot.create(:custom_product, name: 'Ruby on Rails Mug', price: '55.99', taxons: [rails_taxon, mugs_taxon, trending_taxon])
|
18
|
+
FactoryBot.create(:custom_product, name: 'Ruby on Rails Tote', price: '55.99', taxons: [rails_taxon, bags_taxon, trending_taxon])
|
19
|
+
FactoryBot.create(:custom_product, name: 'Ruby on Rails Bag', price: '102.99', taxons: [rails_taxon, bags_taxon])
|
20
|
+
FactoryBot.create(:custom_product, name: 'Ruby on Rails Baseball Jersey', price: '190.99', taxons: [rails_taxon, clothing_taxon])
|
21
|
+
FactoryBot.create(:custom_product, name: 'Ruby on Rails Stein', price: '156.99', taxons: [rails_taxon, mugs_taxon])
|
22
|
+
FactoryBot.create(:custom_product, name: 'Ruby on Rails Jr. Spaghetti', price: '190.99', taxons: [rails_taxon, clothing_taxon])
|
23
|
+
FactoryBot.create(:custom_product, name: 'Ruby Baseball Jersey', price: '250.99', taxons: [ruby_taxon, clothing_taxon])
|
24
|
+
FactoryBot.create(:custom_product, name: 'Apache Baseball Jersey', price: '250.99', taxons: [apache_taxon, clothing_taxon])
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
lib = File.expand_path('../lib/', __FILE__)
|
2
|
+
$LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
require 'spree_analytics_trackers/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.name = 'spree_analytics_trackers'
|
9
|
+
s.version = SpreeAnalyticsTrackers.version
|
10
|
+
s.summary = 'Adds analytics trackers functionality to Spree'
|
11
|
+
s.description = 'Supports Google Analytics '
|
12
|
+
s.required_ruby_version = '>= 2.5.0'
|
13
|
+
|
14
|
+
s.author = 'Spark Solutions'
|
15
|
+
s.email = 'we@sparksolutions.co'
|
16
|
+
s.homepage = 'https://github.com/spree-contrib/spree_analytics_trackers'
|
17
|
+
s.license = 'BSD-3-Clause'
|
18
|
+
|
19
|
+
s.files = `git ls-files`.split("\n")
|
20
|
+
s.test_files = `git ls-files -- spec/*`.split("\n")
|
21
|
+
s.require_path = 'lib'
|
22
|
+
s.requirements << 'none'
|
23
|
+
|
24
|
+
spree_version = '>= 4.1.0', '< 5.0'
|
25
|
+
s.add_dependency 'spree_core', spree_version
|
26
|
+
s.add_dependency 'spree_backend', spree_version
|
27
|
+
s.add_dependency 'spree_extension'
|
28
|
+
s.add_dependency 'deface', '~> 1.0'
|
29
|
+
|
30
|
+
s.add_development_dependency 'spree_dev_tools'
|
31
|
+
end
|