dugway 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.rspec +1 -0
- data/.travis.yml +3 -0
- data/Gemfile +1 -1
- data/LICENSE.txt +22 -0
- data/dugway.gemspec +3 -0
- data/lib/dugway/cart.rb +8 -12
- data/lib/dugway/cli/templates/Gemfile.tt +1 -1
- data/lib/dugway/cli/templates/gitignore.tt +1 -0
- data/lib/dugway/cli/templates/source/product.html +5 -3
- data/lib/dugway/cli/templates/source/stylesheets/cart.css.sass +8 -0
- data/lib/dugway/cli/templates/source/stylesheets/product.css.sass +32 -0
- data/lib/dugway/liquid/drops/cart_item_drop.rb +4 -0
- data/lib/dugway/liquid/drops/product_drop.rb +10 -6
- data/lib/dugway/liquid/drops/product_option_drop.rb +1 -1
- data/lib/dugway/liquid/drops/shipping_option_drop.rb +2 -0
- data/lib/dugway/liquid/tags/checkout_form.rb +1 -1
- data/lib/dugway/version.rb +1 -1
- data/spec/features/contact_form_spec.rb +43 -0
- data/spec/features/page_rendering_spec.rb +69 -0
- data/spec/features/shopping_spec.rb +38 -0
- data/spec/fixtures/store/products.js +1 -1
- data/spec/fixtures/store/store.js +1 -1
- data/spec/fixtures/theme/cart.html +22 -7
- data/spec/fixtures/theme/contact.html +37 -37
- data/spec/fixtures/theme/layout.html +8 -0
- data/spec/fixtures/theme/settings.json +1 -0
- data/spec/fixtures/theme/styles.css +2 -2
- data/spec/spec_helper.rb +8 -0
- data/spec/units/dugway/cart_spec.rb +204 -0
- data/spec/units/dugway/liquid/drops/account_drop_spec.rb +54 -0
- data/spec/units/dugway/liquid/drops/artist_drop_spec.rb +40 -0
- data/spec/units/dugway/liquid/drops/artists_drop_spec.rb +41 -0
- data/spec/units/dugway/liquid/drops/cart_drop_spec.rb +81 -0
- data/spec/units/dugway/liquid/drops/cart_item_drop_spec.rb +72 -0
- data/spec/units/dugway/liquid/drops/categories_drop_spec.rb +41 -0
- data/spec/units/dugway/liquid/drops/category_drop_spec.rb +40 -0
- data/spec/units/dugway/liquid/drops/contact_drop_spec.rb +124 -0
- data/spec/units/dugway/liquid/drops/country_drop_spec.rb +17 -0
- data/spec/units/dugway/liquid/drops/image_drop_spec.rb +23 -0
- data/spec/units/dugway/liquid/drops/page_drop_spec.rb +70 -0
- data/spec/units/dugway/liquid/drops/pages_drop_spec.rb +29 -0
- data/spec/units/dugway/liquid/drops/product_drop_spec.rb +269 -0
- data/spec/units/dugway/liquid/drops/product_option_drop_spec.rb +86 -0
- data/spec/units/dugway/liquid/drops/products_drop_spec.rb +127 -0
- data/spec/units/dugway/liquid/drops/shipping_option_drop_spec.rb +26 -0
- data/spec/units/dugway/liquid/drops/theme_drop_spec.rb +68 -0
- data/spec/units/dugway/store_spec.rb +27 -27
- data/spec/units/dugway/template_spec.rb +12 -0
- data/spec/units/dugway/theme_spec.rb +198 -0
- metadata +95 -57
- data/spec/units/dugway_spec.rb +0 -9
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Dugway::Drops::PageDrop do
|
4
|
+
let(:page) {
|
5
|
+
page = Dugway.store.page('about-us')
|
6
|
+
page['full_url'] = 'http://test.bigcartel.com/about-us'
|
7
|
+
page['full_path'] = '/about-us'
|
8
|
+
Dugway::Drops::PageDrop.new(page)
|
9
|
+
}
|
10
|
+
|
11
|
+
describe "#id" do
|
12
|
+
it "should return the page's id" do
|
13
|
+
page.id.should == 95821979
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#name" do
|
18
|
+
it "should return the page's name" do
|
19
|
+
page.name.should == 'About Us'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#content" do
|
24
|
+
it "should return the page's content" do
|
25
|
+
page.content.should == "<p>We're really cool!</p>"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "#category" do
|
30
|
+
it "should return the page's category" do
|
31
|
+
page.category.should == 'custom'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "#permalink" do
|
36
|
+
it "should return the page's permalink" do
|
37
|
+
page.permalink.should == 'about-us'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "#url" do
|
42
|
+
it "should return the page's url" do
|
43
|
+
page.url.should == '/about-us'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "#full_url" do
|
48
|
+
it "should return the page's full_url" do
|
49
|
+
page.full_url.should == 'http://test.bigcartel.com/about-us'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "#full_path" do
|
54
|
+
it "should return the page's full_path" do
|
55
|
+
page.full_path.should == '/about-us'
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "#meta_description" do
|
60
|
+
it "should return the page's meta_description" do
|
61
|
+
page.meta_description.should == 'Example meta description'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "#meta_keywords" do
|
66
|
+
it "should return the page's meta_keywords" do
|
67
|
+
page.meta_keywords.should == 'example, key, words'
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Dugway::Drops::PagesDrop do
|
4
|
+
let(:pages) { Dugway::Drops::PagesDrop.new(Dugway.store.pages.map { |p| Dugway::Drops::PageDrop.new(p) }) }
|
5
|
+
|
6
|
+
describe "#all" do
|
7
|
+
it "should return an array of all pages" do
|
8
|
+
all = pages.all
|
9
|
+
all.should be_an_instance_of(Array)
|
10
|
+
all.size.should == 1
|
11
|
+
|
12
|
+
page = all.first
|
13
|
+
page.should be_an_instance_of(Dugway::Drops::PageDrop)
|
14
|
+
page.name.should == 'About Us'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#permalink" do
|
19
|
+
it "should return the page by permalink" do
|
20
|
+
page = pages.contact
|
21
|
+
page.should be_an_instance_of(Dugway::Drops::PageDrop)
|
22
|
+
page.name.should == 'Contact'
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should return the nil for an invalid permalink" do
|
26
|
+
pages.blah.should be_nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,269 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Dugway::Drops::ProductDrop do
|
4
|
+
let(:product) { Dugway::Drops::ProductDrop.new(Dugway.store.products.first) }
|
5
|
+
|
6
|
+
describe "#id" do
|
7
|
+
it "should return the product's id" do
|
8
|
+
product.id.should == 9422939
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#name" do
|
13
|
+
it "should return the product's name" do
|
14
|
+
product.name.should == 'My Product'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#permalink" do
|
19
|
+
it "should return the product's permalink" do
|
20
|
+
product.permalink.should == 'my-product'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#url" do
|
25
|
+
it "should return the product's url" do
|
26
|
+
product.url.should == '/product/my-product'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#edit_url" do
|
31
|
+
it "should return the product's edit url" do
|
32
|
+
product.edit_url.should == "http://bigcartel.com"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#position" do
|
37
|
+
it "should return the product's position" do
|
38
|
+
product.position.should == 1
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "#description" do
|
43
|
+
it "should return the product's description" do
|
44
|
+
product.description.should == 'This is a description of my product.'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "#status" do
|
49
|
+
it "should return the product's status" do
|
50
|
+
product.status.should == 'active'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "#created_at" do
|
55
|
+
it "should return the product's created_at date" do
|
56
|
+
product.created_at.should == Time.parse('2013-02-10T19:28:11-07:00')
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "#categories" do
|
61
|
+
it "should return the product's categories" do
|
62
|
+
categories = product.categories
|
63
|
+
categories.should be_an_instance_of(Array)
|
64
|
+
categories.size.should == 1
|
65
|
+
|
66
|
+
product = categories.first
|
67
|
+
product.should be_an_instance_of(Dugway::Drops::CategoryDrop)
|
68
|
+
product.name.should == 'Tees'
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "#artists" do
|
73
|
+
it "should return the product's artists" do
|
74
|
+
artists = product.artists
|
75
|
+
artists.should be_an_instance_of(Array)
|
76
|
+
artists.size.should == 1
|
77
|
+
|
78
|
+
artist = artists.first
|
79
|
+
artist.should be_an_instance_of(Dugway::Drops::ArtistDrop)
|
80
|
+
artist.name.should == 'Artist One'
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "#css_class" do
|
85
|
+
it "should return the right css_class when active" do
|
86
|
+
product.css_class.should == 'product'
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should return the right css_class when sold out" do
|
90
|
+
product.stub(:status) { 'sold-out' }
|
91
|
+
product.css_class.should == 'product sold'
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should return the right css_class when coming soon" do
|
95
|
+
product.stub(:status) { 'coming-soon' }
|
96
|
+
product.css_class.should == 'product soon'
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should return the right css_class when on sale" do
|
100
|
+
product.stub(:on_sale) { true }
|
101
|
+
product.css_class.should == 'product sale'
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should return the right css_class when non-active and on sale" do
|
105
|
+
product.stub(:status) { 'sold-out' }
|
106
|
+
product.stub(:on_sale) { true }
|
107
|
+
product.css_class.should == 'product sold sale'
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "#price" do
|
112
|
+
it "should return nil, because price is deprecated" do
|
113
|
+
product.price.should be_nil
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe "#default_price" do
|
118
|
+
it "should return the product's default_price" do
|
119
|
+
product.default_price.should == 10.0
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe "#variable_pricing" do
|
124
|
+
it "should return true when options have a different price" do
|
125
|
+
product.variable_pricing.should be(true)
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should return false when options have same price" do
|
129
|
+
Dugway::Drops::ProductOptionDrop.any_instance.stub(:price) { 10.0 }
|
130
|
+
product.variable_pricing.should be(false)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
describe "#min_price" do
|
135
|
+
it "should return the product's lowest price" do
|
136
|
+
product.min_price.should == 10.0
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
describe "#max_price" do
|
141
|
+
it "should return the product's highest price" do
|
142
|
+
product.max_price.should == 15.0
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
describe "#on_sale" do
|
147
|
+
it "should return if the product is on sale" do
|
148
|
+
product.on_sale.should be(false)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
describe "#has_default_option" do
|
153
|
+
it "should return false if the product has multiple options" do
|
154
|
+
product.has_default_option.should be(false)
|
155
|
+
end
|
156
|
+
|
157
|
+
it "should return false if the product has one option not named 'Default'" do
|
158
|
+
product.stub(:options) { [Dugway::Drops::ProductOptionDrop.new({ 'name' => 'Blah'})] }
|
159
|
+
product.has_default_option.should be(false)
|
160
|
+
end
|
161
|
+
|
162
|
+
it "should return true if the product has one option named 'Default'" do
|
163
|
+
product.stub(:options) { [Dugway::Drops::ProductOptionDrop.new({ 'name' => 'Default'})] }
|
164
|
+
product.has_default_option.should be(true)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
describe "#option" do
|
169
|
+
it "should return the product's first option" do
|
170
|
+
option = product.option
|
171
|
+
option.should be_an_instance_of(Dugway::Drops::ProductOptionDrop)
|
172
|
+
option.name.should == 'Small'
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
describe "#options" do
|
177
|
+
it "should return the product's options" do
|
178
|
+
options = product.options
|
179
|
+
options.should be_an_instance_of(Array)
|
180
|
+
options.size.should == 4
|
181
|
+
|
182
|
+
option = options.first
|
183
|
+
option.should be_an_instance_of(Dugway::Drops::ProductOptionDrop)
|
184
|
+
option.name.should == 'Small'
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
describe "#options_in_stock" do
|
189
|
+
it "should return the product's options that aren't sold out" do
|
190
|
+
options = product.options_in_stock
|
191
|
+
options.should be_an_instance_of(Array)
|
192
|
+
options.size.should == 3
|
193
|
+
|
194
|
+
option = options.first
|
195
|
+
option.should be_an_instance_of(Dugway::Drops::ProductOptionDrop)
|
196
|
+
option.name.should == 'Small'
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
describe "#shipping" do
|
201
|
+
it "should return the product's shipping" do
|
202
|
+
shipping = product.shipping
|
203
|
+
shipping.should be_an_instance_of(Array)
|
204
|
+
shipping.size.should == 2
|
205
|
+
|
206
|
+
option = shipping.first
|
207
|
+
option.should be_an_instance_of(Dugway::Drops::ShippingOptionDrop)
|
208
|
+
option.country.name.should == 'United States'
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
describe "#image" do
|
213
|
+
it "should return the product's first image" do
|
214
|
+
image = product.image
|
215
|
+
image.should be_an_instance_of(Dugway::Drops::ImageDrop)
|
216
|
+
image.url.should == 'http://cache1.bigcartel.com/product_images/92599166/mens_tee_1.jpg'
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
describe "#images" do
|
221
|
+
it "should return the product's images" do
|
222
|
+
images = product.images
|
223
|
+
images.should be_an_instance_of(Array)
|
224
|
+
images.size.should == 5
|
225
|
+
|
226
|
+
image = images.first
|
227
|
+
image.should be_an_instance_of(Dugway::Drops::ImageDrop)
|
228
|
+
image.url.should == 'http://cache1.bigcartel.com/product_images/92599166/mens_tee_1.jpg'
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
describe "#image_count" do
|
233
|
+
it "should return the product's image_count" do
|
234
|
+
product.image_count.should == 5
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
describe "#previous_product" do
|
239
|
+
it "should return nil when there isn't one" do
|
240
|
+
product.previous_product.should be_nil
|
241
|
+
end
|
242
|
+
|
243
|
+
describe "when there is one" do
|
244
|
+
let(:product) { Dugway::Drops::ProductDrop.new(Dugway.store.products.last) }
|
245
|
+
|
246
|
+
it "should return the previous product" do
|
247
|
+
previous_product = product.previous_product
|
248
|
+
previous_product.should be_an_instance_of(Dugway::Drops::ProductDrop)
|
249
|
+
previous_product.name.should == 'My Tee'
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
describe "#next_product" do
|
255
|
+
it "should return the next product when there is one" do
|
256
|
+
next_product = product.next_product
|
257
|
+
next_product.should be_an_instance_of(Dugway::Drops::ProductDrop)
|
258
|
+
next_product.name.should == 'My Tee'
|
259
|
+
end
|
260
|
+
|
261
|
+
describe "when there isn't one" do
|
262
|
+
let(:product) { Dugway::Drops::ProductDrop.new(Dugway.store.products.last) }
|
263
|
+
|
264
|
+
it "should return nil" do
|
265
|
+
product.next_product.should be_nil
|
266
|
+
end
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Dugway::Drops::ProductOptionDrop do
|
4
|
+
let(:product) { Dugway::Drops::ProductDrop.new(Dugway.store.products.first) }
|
5
|
+
let(:option) { product.option }
|
6
|
+
|
7
|
+
describe "#id" do
|
8
|
+
it "should return the option's id" do
|
9
|
+
option.id.should == 29474321
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#name" do
|
14
|
+
it "should return the option's name" do
|
15
|
+
option.name.should == 'Small'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#price" do
|
20
|
+
it "should return the option's price" do
|
21
|
+
option.price.should == 10.0
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#has_custom_price" do
|
26
|
+
it "should return false when it has the same price" do
|
27
|
+
option.has_custom_price.should be(false)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should return true when it has a different price" do
|
31
|
+
option.stub(:price) { 25.0 }
|
32
|
+
option.has_custom_price.should be(true)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#position" do
|
37
|
+
it "should return the option's position" do
|
38
|
+
option.position.should == 1
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "#sold" do
|
43
|
+
it "should return a random number" do
|
44
|
+
option.sold.should be >= 0
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "#sold_out" do
|
49
|
+
it "should return whether the option's sold_out" do
|
50
|
+
option.sold_out.should be(false)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "#quantity" do
|
55
|
+
it "should return a positivie random number if not sold_out" do
|
56
|
+
option.quantity.should be >= 0
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should return 0 when it is sold_out" do
|
60
|
+
option.stub(:sold_out) { true }
|
61
|
+
option.quantity.should be(0)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "#inventory" do
|
66
|
+
it "should return the option's calculated inventory" do
|
67
|
+
option.stub(:quantity) { 25 }
|
68
|
+
option.stub(:sold) { 75 }
|
69
|
+
option.inventory.should be(25)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "#default" do
|
74
|
+
it "should true if it's the default option" do
|
75
|
+
option.default.should be(true)
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "when it's not the default option" do
|
79
|
+
let(:option) { product.options.last }
|
80
|
+
|
81
|
+
it "should return false" do
|
82
|
+
option.default.should be(false)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|