shopify-routes 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/shopify-routes.rb +1 -1
- data/script/console +3 -0
- data/shopify-routes.gemspec +6 -4
- data/spec/lib/shopify-routes_spec.rb +84 -86
- data/spec/routes_helper_spec.rb +54 -0
- data/spec/support/rails_app.rb +1 -1
- data/spec/support/routes_helper.rb +16 -0
- metadata +30 -16
data/lib/shopify-routes.rb
CHANGED
data/script/console
ADDED
data/shopify-routes.gemspec
CHANGED
@@ -12,9 +12,11 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
13
13
|
gem.name = "shopify-routes"
|
14
14
|
gem.require_paths = ["lib"]
|
15
|
-
gem.version = "0.0.
|
15
|
+
gem.version = "0.0.5"
|
16
16
|
|
17
|
-
gem.
|
18
|
-
gem.
|
19
|
-
|
17
|
+
gem.add_development_dependency "rspec-rails", "~> 2.9.0"
|
18
|
+
gem.add_development_dependency "pry", "~>0.9.9.4"
|
19
|
+
|
20
|
+
gem.add_runtime_dependency "rails", ">= 3.0.0"
|
21
|
+
gem.add_runtime_dependency "shopify_api", ">= 3.0.0"
|
20
22
|
end
|
@@ -6,203 +6,201 @@ describe "ShopifyAPI.routes" do
|
|
6
6
|
@domain = "domain.myshopify.com"
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
|
-
@router.routes.find {|r| r.name == name }
|
11
|
-
end
|
9
|
+
describe "redirect routes" do
|
12
10
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
route.app.path(params, nil)
|
18
|
-
end
|
11
|
+
describe "brochure" do
|
12
|
+
subject { redirect_for :brochure }
|
13
|
+
it { should eq "http://www.shopify.com?ref=referrer" }
|
14
|
+
end
|
19
15
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
16
|
+
describe "signup" do
|
17
|
+
subject { redirect_for :signup }
|
18
|
+
it { should eq "https://app.shopify.com/services/signup?ref=referrer" }
|
19
|
+
end
|
25
20
|
|
26
|
-
|
21
|
+
describe "admin" do
|
22
|
+
subject { redirect_for :admin }
|
23
|
+
it { should eq "https://#{@domain}/admin" }
|
24
|
+
end
|
27
25
|
|
28
26
|
describe "applications" do
|
29
|
-
subject { redirect_for
|
30
|
-
it { should eq path_for
|
27
|
+
subject { redirect_for :applications }
|
28
|
+
it { should eq path_for :applications }
|
31
29
|
end
|
32
30
|
|
33
31
|
describe "orders" do
|
34
|
-
subject { redirect_for
|
35
|
-
it { should eq path_for
|
32
|
+
subject { redirect_for :orders }
|
33
|
+
it { should eq path_for :orders }
|
36
34
|
end
|
37
35
|
|
38
36
|
describe "order" do
|
39
|
-
subject { redirect_for
|
40
|
-
it { should eq path_for
|
37
|
+
subject { redirect_for :order, 1 }
|
38
|
+
it { should eq path_for :orders, "1" }
|
41
39
|
end
|
42
40
|
|
43
41
|
describe "customers" do
|
44
|
-
subject { redirect_for
|
45
|
-
it { should eq path_for
|
42
|
+
subject { redirect_for :customers }
|
43
|
+
it { should eq path_for :customers }
|
46
44
|
end
|
47
45
|
|
48
46
|
describe "customer" do
|
49
|
-
subject { redirect_for
|
50
|
-
it { should eq path_for
|
47
|
+
subject { redirect_for :customer, "1" }
|
48
|
+
it { should eq path_for :customers, "1" }
|
51
49
|
end
|
52
50
|
|
53
51
|
describe "new_customer" do
|
54
|
-
subject { redirect_for
|
55
|
-
it { should eq path_for
|
52
|
+
subject { redirect_for :new_customer }
|
53
|
+
it { should eq path_for :customers, "new" }
|
56
54
|
end
|
57
55
|
|
58
56
|
describe "products" do
|
59
|
-
subject { redirect_for
|
60
|
-
it { should eq path_for
|
57
|
+
subject { redirect_for :products }
|
58
|
+
it { should eq path_for :products }
|
61
59
|
end
|
62
60
|
|
63
61
|
describe "product" do
|
64
|
-
subject { redirect_for
|
65
|
-
it { should eq path_for
|
62
|
+
subject { redirect_for :product, 1 }
|
63
|
+
it { should eq path_for :products, 1 }
|
66
64
|
end
|
67
65
|
|
68
66
|
describe "new_product" do
|
69
|
-
subject { redirect_for
|
70
|
-
it { should eq path_for
|
67
|
+
subject { redirect_for :new_product }
|
68
|
+
it { should eq path_for :products, "new" }
|
71
69
|
end
|
72
70
|
|
73
71
|
describe "custom_collections" do
|
74
|
-
subject { redirect_for
|
75
|
-
it { should eq path_for
|
72
|
+
subject { redirect_for :custom_collections }
|
73
|
+
it { should eq path_for :custom_collections }
|
76
74
|
end
|
77
75
|
|
78
76
|
describe "custom_collection" do
|
79
|
-
subject { redirect_for
|
80
|
-
it { should eq path_for
|
77
|
+
subject { redirect_for :custom_collection, 1 }
|
78
|
+
it { should eq path_for :custom_collections, "1" }
|
81
79
|
end
|
82
80
|
|
83
81
|
describe "new_custom_collection" do
|
84
|
-
subject { redirect_for
|
85
|
-
it { should eq path_for
|
82
|
+
subject { redirect_for :new_custom_collection }
|
83
|
+
it { should eq path_for :custom_collections, "new" }
|
86
84
|
end
|
87
85
|
|
88
86
|
describe "smart_collections" do
|
89
|
-
subject { redirect_for
|
90
|
-
it { should eq path_for
|
87
|
+
subject { redirect_for :smart_collections }
|
88
|
+
it { should eq path_for :smart_collections }
|
91
89
|
end
|
92
90
|
|
93
91
|
describe "smart_collection" do
|
94
|
-
subject { redirect_for
|
95
|
-
it { should eq path_for
|
92
|
+
subject { redirect_for :smart_collection, 1 }
|
93
|
+
it { should eq path_for :smart_collections, "1" }
|
96
94
|
end
|
97
95
|
|
98
96
|
describe "new_smart_collection" do
|
99
|
-
subject { redirect_for
|
100
|
-
it { should eq path_for
|
97
|
+
subject { redirect_for :new_smart_collection }
|
98
|
+
it { should eq path_for :smart_collections, "new" }
|
101
99
|
end
|
102
100
|
|
103
101
|
describe "pages" do
|
104
|
-
subject { redirect_for
|
105
|
-
it { should eq path_for
|
102
|
+
subject { redirect_for :pages }
|
103
|
+
it { should eq path_for :pages }
|
106
104
|
end
|
107
105
|
|
108
106
|
describe "page" do
|
109
|
-
subject { redirect_for
|
110
|
-
it { should eq path_for
|
107
|
+
subject { redirect_for :page, 1 }
|
108
|
+
it { should eq path_for :pages, "1" }
|
111
109
|
end
|
112
110
|
|
113
111
|
describe "new_page" do
|
114
|
-
subject { redirect_for
|
115
|
-
it { should eq path_for
|
112
|
+
subject { redirect_for :new_page }
|
113
|
+
it { should eq path_for :pages, "new" }
|
116
114
|
end
|
117
115
|
|
118
116
|
describe "blogs" do
|
119
|
-
subject { redirect_for
|
120
|
-
it { should eq path_for
|
117
|
+
subject { redirect_for :blogs }
|
118
|
+
it { should eq path_for :blogs }
|
121
119
|
end
|
122
120
|
|
123
121
|
describe "blog" do
|
124
|
-
subject { redirect_for
|
125
|
-
it { should eq path_for
|
122
|
+
subject { redirect_for :blog, 1 }
|
123
|
+
it { should eq path_for :blogs, "1" }
|
126
124
|
end
|
127
125
|
|
128
126
|
describe "new_blog" do
|
129
|
-
subject { redirect_for
|
130
|
-
it { should eq path_for
|
127
|
+
subject { redirect_for :new_blog }
|
128
|
+
it { should eq path_for :blogs, "new" }
|
131
129
|
end
|
132
130
|
|
133
131
|
describe "navigation" do
|
134
|
-
subject { redirect_for
|
135
|
-
it { should eq path_for
|
132
|
+
subject { redirect_for :navigation }
|
133
|
+
it { should eq path_for :links }
|
136
134
|
end
|
137
135
|
|
138
136
|
describe "promotions" do
|
139
|
-
subject { redirect_for
|
140
|
-
it { should eq path_for
|
137
|
+
subject { redirect_for :promotions }
|
138
|
+
it { should eq path_for :marketing }
|
141
139
|
end
|
142
140
|
|
143
141
|
describe "themes" do
|
144
|
-
subject { redirect_for
|
145
|
-
it { should eq path_for
|
142
|
+
subject { redirect_for :themes }
|
143
|
+
it { should eq path_for :themes }
|
146
144
|
end
|
147
145
|
|
148
146
|
describe "theme" do
|
149
|
-
subject { redirect_for
|
150
|
-
it { should eq path_for
|
147
|
+
subject { redirect_for :theme, 1 }
|
148
|
+
it { should eq path_for :themes, "1" }
|
151
149
|
end
|
152
150
|
|
153
151
|
describe "theme_settings" do
|
154
|
-
subject { redirect_for
|
152
|
+
subject { redirect_for :theme_settings, "1" }
|
155
153
|
it { should eq path_for "themes/1/settings" }
|
156
154
|
end
|
157
155
|
|
158
156
|
describe "general_settings" do
|
159
|
-
subject { redirect_for
|
160
|
-
it { should eq path_for
|
157
|
+
subject { redirect_for :general_settings }
|
158
|
+
it { should eq path_for :general_preferences }
|
161
159
|
end
|
162
160
|
|
163
161
|
describe "regions" do
|
164
|
-
subject { redirect_for
|
165
|
-
it { should eq path_for
|
162
|
+
subject { redirect_for :regions }
|
163
|
+
it { should eq path_for :countries }
|
166
164
|
end
|
167
165
|
|
168
166
|
describe "checkout_and_payment" do
|
169
|
-
subject { redirect_for
|
170
|
-
it { should eq path_for
|
167
|
+
subject { redirect_for :checkout_and_payment }
|
168
|
+
it { should eq path_for :payments }
|
171
169
|
end
|
172
170
|
|
173
171
|
describe "shipping_rates" do
|
174
|
-
subject { redirect_for
|
175
|
-
it { should eq path_for
|
172
|
+
subject { redirect_for :shipping_rates }
|
173
|
+
it { should eq path_for :shipping }
|
176
174
|
end
|
177
175
|
|
178
176
|
describe "weight_based_shipping_rate" do
|
179
|
-
subject { redirect_for
|
180
|
-
it { should eq path_for
|
177
|
+
subject { redirect_for :weight_based_shipping_rate, 1 }
|
178
|
+
it { should eq path_for :weight_based_shipping_rates, "1" }
|
181
179
|
end
|
182
180
|
|
183
181
|
describe "price_based_shipping_rate" do
|
184
|
-
subject { redirect_for
|
185
|
-
it { should eq path_for
|
182
|
+
subject { redirect_for :price_based_shipping_rate, 1 }
|
183
|
+
it { should eq path_for :price_based_shipping_rates, "1" }
|
186
184
|
end
|
187
185
|
|
188
186
|
describe "fulfillment_services" do
|
189
|
-
subject { redirect_for
|
190
|
-
it { should eq path_for
|
187
|
+
subject { redirect_for :fulfillment_services }
|
188
|
+
it { should eq path_for :fulfillment_services }
|
191
189
|
end
|
192
190
|
|
193
191
|
describe "notifications" do
|
194
|
-
subject { redirect_for
|
195
|
-
it { should eq path_for
|
192
|
+
subject { redirect_for :notifications }
|
193
|
+
it { should eq path_for :notifications }
|
196
194
|
end
|
197
195
|
|
198
196
|
describe "notification" do
|
199
|
-
subject { redirect_for
|
200
|
-
it { should eq path_for
|
197
|
+
subject { redirect_for :notification, 1 }
|
198
|
+
it { should eq path_for :notifications, "1" }
|
201
199
|
end
|
202
200
|
|
203
201
|
describe "domains" do
|
204
|
-
subject { redirect_for
|
205
|
-
it { should eq path_for
|
202
|
+
subject { redirect_for :domains }
|
203
|
+
it { should eq path_for :domains }
|
206
204
|
end
|
207
205
|
end
|
208
206
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "route helper methods" do
|
4
|
+
before do
|
5
|
+
@router = RailsApp::Application.routes
|
6
|
+
@domain = "domain.myshopify.com"
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#find_route" do
|
10
|
+
context "with a valid name" do
|
11
|
+
it "should return a Journey::Route" do
|
12
|
+
@router.routes.should_receive(:find).and_return(@router.routes.first)
|
13
|
+
# NOTE: the name is not important here, since it's mocked
|
14
|
+
find_route("brochure").should be_a Journey::Route
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "with an invalid name" do
|
19
|
+
it "should return nil" do
|
20
|
+
find_route("haveyouevernoticedthatweirdalandkennyghavethesamehaircut").should be_nil
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#redirect_for" do
|
26
|
+
context "without an id" do
|
27
|
+
subject { redirect_for :brochure }
|
28
|
+
it { should eq "http://www.shopify.com?ref=referrer" }
|
29
|
+
end
|
30
|
+
|
31
|
+
context "with an id" do
|
32
|
+
subject { redirect_for :products, 1 }
|
33
|
+
it { should eq "https://#{@domain}/admin/products/1" }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "#path_for" do
|
38
|
+
context "without an id" do
|
39
|
+
subject { path_for :a_resource }
|
40
|
+
it { should be_a String }
|
41
|
+
it { should =~ /https:\/\/#{@domain}\/admin\// }
|
42
|
+
it { should =~ /a_resource/ }
|
43
|
+
it { should_not =~ /a_resource\// }
|
44
|
+
end
|
45
|
+
context "with an id" do
|
46
|
+
subject { path_for :a_resource, "with_an_id" }
|
47
|
+
it { should be_a String }
|
48
|
+
it { should =~ /https:\/\/#{@domain}\/admin\// }
|
49
|
+
it { should =~ /a_resource\// }
|
50
|
+
it { should =~ /with_an_id/ }
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
data/spec/support/rails_app.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
def find_route(name)
|
2
|
+
@router.routes.find {|r| r.name == name.to_s }
|
3
|
+
end
|
4
|
+
|
5
|
+
def redirect_for(resource, id = nil)
|
6
|
+
route = find_route(resource)
|
7
|
+
params = { :shop => @domain }
|
8
|
+
params[:id] = id unless id.nil?
|
9
|
+
route.app.path(params, nil)
|
10
|
+
end
|
11
|
+
|
12
|
+
def path_for(resource, id = nil)
|
13
|
+
path = "https://#{@domain}/admin/#{resource.to_s}"
|
14
|
+
path += "/#{id}" unless id.nil?
|
15
|
+
path
|
16
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shopify-routes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,19 +12,30 @@ cert_chain: []
|
|
12
12
|
date: 2012-05-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name: rails
|
16
|
-
requirement: &
|
15
|
+
name: rspec-rails
|
16
|
+
requirement: &14499120 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
22
|
-
type: :
|
21
|
+
version: 2.9.0
|
22
|
+
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *14499120
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
|
-
name:
|
27
|
-
requirement: &
|
26
|
+
name: pry
|
27
|
+
requirement: &14498440 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.9.9.4
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *14498440
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rails
|
38
|
+
requirement: &14497780 !ruby/object:Gem::Requirement
|
28
39
|
none: false
|
29
40
|
requirements:
|
30
41
|
- - ! '>='
|
@@ -32,18 +43,18 @@ dependencies:
|
|
32
43
|
version: 3.0.0
|
33
44
|
type: :runtime
|
34
45
|
prerelease: false
|
35
|
-
version_requirements: *
|
46
|
+
version_requirements: *14497780
|
36
47
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
38
|
-
requirement: &
|
48
|
+
name: shopify_api
|
49
|
+
requirement: &14497320 !ruby/object:Gem::Requirement
|
39
50
|
none: false
|
40
51
|
requirements:
|
41
|
-
- -
|
52
|
+
- - ! '>='
|
42
53
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
44
|
-
type: :
|
54
|
+
version: 3.0.0
|
55
|
+
type: :runtime
|
45
56
|
prerelease: false
|
46
|
-
version_requirements: *
|
57
|
+
version_requirements: *14497320
|
47
58
|
description: Provides routes that redirect back to Shopify pages.
|
48
59
|
email:
|
49
60
|
- travis.j.haynes@gmail.com
|
@@ -59,10 +70,13 @@ files:
|
|
59
70
|
- README.md
|
60
71
|
- Rakefile
|
61
72
|
- lib/shopify-routes.rb
|
73
|
+
- script/console
|
62
74
|
- shopify-routes.gemspec
|
63
75
|
- spec/lib/shopify-routes_spec.rb
|
76
|
+
- spec/routes_helper_spec.rb
|
64
77
|
- spec/spec_helper.rb
|
65
78
|
- spec/support/rails_app.rb
|
79
|
+
- spec/support/routes_helper.rb
|
66
80
|
homepage: ''
|
67
81
|
licenses: []
|
68
82
|
post_install_message:
|