shopify-routes 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.rspec +1 -0
- data/.travis.yml +1 -0
- data/Rakefile +6 -0
- data/lib/shopify-routes.rb +14 -7
- data/shopify-routes.gemspec +4 -2
- data/spec/lib/shopify-routes_spec.rb +208 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/support/rails_app.rb +21 -0
- metadata +31 -4
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/.travis.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm: 1.9.3
|
data/Rakefile
CHANGED
data/lib/shopify-routes.rb
CHANGED
@@ -58,8 +58,9 @@ module ShopifyAPI
|
|
58
58
|
# @param [String] path The path for the route
|
59
59
|
# @param [Array] actions List of actions to draw for this route
|
60
60
|
# @param [String] nom Alias for the route if the path name does not suffice
|
61
|
+
# @param [String] suffix An optional suffix to include at the end of the redirect URI
|
61
62
|
# @api private
|
62
|
-
def match(path, actions, nom = path)
|
63
|
+
def match(path, actions, nom = path, suffix = "")
|
63
64
|
|
64
65
|
# only draw this route if it's included
|
65
66
|
return unless include?(path)
|
@@ -67,8 +68,8 @@ module ShopifyAPI
|
|
67
68
|
actions.each do |action|
|
68
69
|
|
69
70
|
# create the route, and it's name
|
70
|
-
route
|
71
|
-
name
|
71
|
+
route = "*shop/admin/#{path.to_s}"
|
72
|
+
name = nom.to_s
|
72
73
|
|
73
74
|
case action
|
74
75
|
|
@@ -81,6 +82,7 @@ module ShopifyAPI
|
|
81
82
|
when :new
|
82
83
|
route << "/new"
|
83
84
|
name = "new_#{name.singularize}"
|
85
|
+
suffix = "/new"
|
84
86
|
|
85
87
|
# custom routes
|
86
88
|
else
|
@@ -91,7 +93,12 @@ module ShopifyAPI
|
|
91
93
|
end
|
92
94
|
|
93
95
|
# draw the route
|
94
|
-
|
96
|
+
options = {
|
97
|
+
route => path,
|
98
|
+
:as => name
|
99
|
+
}
|
100
|
+
|
101
|
+
match_admin_path options, suffix
|
95
102
|
end
|
96
103
|
|
97
104
|
end
|
@@ -102,7 +109,7 @@ module ShopifyAPI
|
|
102
109
|
# @param [String] resource The name of the resource - plural or singular
|
103
110
|
# @param [ActionDispatch::Routing::RouteSet] The router to add the matches
|
104
111
|
# @api private
|
105
|
-
def match_admin_path(options = {})
|
112
|
+
def match_admin_path(options = {}, suffix = "")
|
106
113
|
|
107
114
|
# use the router from the options, or the cached one
|
108
115
|
router = options[:router] || @router
|
@@ -126,7 +133,7 @@ module ShopifyAPI
|
|
126
133
|
uri << "/#{params[:id]}" if params.include?(:id)
|
127
134
|
|
128
135
|
# return the redirect URI
|
129
|
-
uri
|
136
|
+
uri + suffix
|
130
137
|
},
|
131
138
|
|
132
139
|
:as => options[:as]
|
@@ -182,7 +189,7 @@ module ShopifyAPI
|
|
182
189
|
match :links, [:index], "navigation"
|
183
190
|
match :marketing, [:index], "promotions"
|
184
191
|
match :themes, [:index, :show]
|
185
|
-
match :themes, [":id/settings"], "theme_settings"
|
192
|
+
match :themes, [":id/settings"], "theme_settings", "/settings"
|
186
193
|
match :general_preferences, [:index], "general_settings"
|
187
194
|
match :countries, [:index, :show, :new], "regions"
|
188
195
|
match :payments, [:index], "checkout_and_payment"
|
data/shopify-routes.gemspec
CHANGED
@@ -12,7 +12,9 @@ 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.4"
|
16
16
|
|
17
|
-
gem.add_runtime_dependency
|
17
|
+
gem.add_runtime_dependency "rails", ">= 3.0.0"
|
18
|
+
gem.add_runtime_dependency "shopify_api", ">= 3.0.0"
|
19
|
+
gem.add_development_dependency "rspec-rails", "~> 2.9.0"
|
18
20
|
end
|
@@ -0,0 +1,208 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "ShopifyAPI.routes" do
|
4
|
+
before do
|
5
|
+
@router = RailsApp::Application.routes
|
6
|
+
@domain = "domain.myshopify.com"
|
7
|
+
end
|
8
|
+
|
9
|
+
def find_route(name)
|
10
|
+
@router.routes.find {|r| r.name == name }
|
11
|
+
end
|
12
|
+
|
13
|
+
def redirect_for(resource, id = nil)
|
14
|
+
route = find_route(resource)
|
15
|
+
params = { :shop => @domain }
|
16
|
+
params[:id] = id unless id.nil?
|
17
|
+
route.app.path(params, nil)
|
18
|
+
end
|
19
|
+
|
20
|
+
def path_for(resource, id = nil)
|
21
|
+
path = "https://#{@domain}/admin/#{resource}"
|
22
|
+
path += "/#{id}" unless id.nil?
|
23
|
+
path
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "redirect routes" do
|
27
|
+
|
28
|
+
describe "applications" do
|
29
|
+
subject { redirect_for "applications" }
|
30
|
+
it { should eq path_for "applications" }
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "orders" do
|
34
|
+
subject { redirect_for "orders" }
|
35
|
+
it { should eq path_for "orders" }
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "order" do
|
39
|
+
subject { redirect_for "order", "1" }
|
40
|
+
it { should eq path_for "orders", "1" }
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "customers" do
|
44
|
+
subject { redirect_for "customers" }
|
45
|
+
it { should eq path_for "customers" }
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "customer" do
|
49
|
+
subject { redirect_for "customer", "1" }
|
50
|
+
it { should eq path_for "customers", "1" }
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "new_customer" do
|
54
|
+
subject { redirect_for "new_customer" }
|
55
|
+
it { should eq path_for "customers", "new" }
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "products" do
|
59
|
+
subject { redirect_for "products" }
|
60
|
+
it { should eq path_for "products" }
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "product" do
|
64
|
+
subject { redirect_for "product", "1" }
|
65
|
+
it { should eq path_for "products", "1" }
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "new_product" do
|
69
|
+
subject { redirect_for "new_product" }
|
70
|
+
it { should eq path_for "products", "new" }
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "custom_collections" do
|
74
|
+
subject { redirect_for "custom_collections" }
|
75
|
+
it { should eq path_for "custom_collections" }
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "custom_collection" do
|
79
|
+
subject { redirect_for "custom_collection", "1" }
|
80
|
+
it { should eq path_for "custom_collections", "1" }
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "new_custom_collection" do
|
84
|
+
subject { redirect_for "new_custom_collection" }
|
85
|
+
it { should eq path_for "custom_collections", "new" }
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "smart_collections" do
|
89
|
+
subject { redirect_for "smart_collections" }
|
90
|
+
it { should eq path_for "smart_collections" }
|
91
|
+
end
|
92
|
+
|
93
|
+
describe "smart_collection" do
|
94
|
+
subject { redirect_for "smart_collection", "1" }
|
95
|
+
it { should eq path_for "smart_collections", "1" }
|
96
|
+
end
|
97
|
+
|
98
|
+
describe "new_smart_collection" do
|
99
|
+
subject { redirect_for "new_smart_collection" }
|
100
|
+
it { should eq path_for "smart_collections", "new" }
|
101
|
+
end
|
102
|
+
|
103
|
+
describe "pages" do
|
104
|
+
subject { redirect_for "pages" }
|
105
|
+
it { should eq path_for "pages" }
|
106
|
+
end
|
107
|
+
|
108
|
+
describe "page" do
|
109
|
+
subject { redirect_for "page", "1" }
|
110
|
+
it { should eq path_for "pages", "1" }
|
111
|
+
end
|
112
|
+
|
113
|
+
describe "new_page" do
|
114
|
+
subject { redirect_for "new_page" }
|
115
|
+
it { should eq path_for "pages", "new" }
|
116
|
+
end
|
117
|
+
|
118
|
+
describe "blogs" do
|
119
|
+
subject { redirect_for "blogs" }
|
120
|
+
it { should eq path_for "blogs" }
|
121
|
+
end
|
122
|
+
|
123
|
+
describe "blog" do
|
124
|
+
subject { redirect_for "blog", "1" }
|
125
|
+
it { should eq path_for "blogs", "1" }
|
126
|
+
end
|
127
|
+
|
128
|
+
describe "new_blog" do
|
129
|
+
subject { redirect_for "new_blog" }
|
130
|
+
it { should eq path_for "blogs", "new" }
|
131
|
+
end
|
132
|
+
|
133
|
+
describe "navigation" do
|
134
|
+
subject { redirect_for "navigation" }
|
135
|
+
it { should eq path_for "links" }
|
136
|
+
end
|
137
|
+
|
138
|
+
describe "promotions" do
|
139
|
+
subject { redirect_for "promotions" }
|
140
|
+
it { should eq path_for "marketing" }
|
141
|
+
end
|
142
|
+
|
143
|
+
describe "themes" do
|
144
|
+
subject { redirect_for "themes" }
|
145
|
+
it { should eq path_for "themes" }
|
146
|
+
end
|
147
|
+
|
148
|
+
describe "theme" do
|
149
|
+
subject { redirect_for "theme", "1" }
|
150
|
+
it { should eq path_for "themes", "1" }
|
151
|
+
end
|
152
|
+
|
153
|
+
describe "theme_settings" do
|
154
|
+
subject { redirect_for "theme_settings", "1" }
|
155
|
+
it { should eq path_for "themes/1/settings" }
|
156
|
+
end
|
157
|
+
|
158
|
+
describe "general_settings" do
|
159
|
+
subject { redirect_for "general_settings" }
|
160
|
+
it { should eq path_for "general_preferences" }
|
161
|
+
end
|
162
|
+
|
163
|
+
describe "regions" do
|
164
|
+
subject { redirect_for "regions" }
|
165
|
+
it { should eq path_for "countries" }
|
166
|
+
end
|
167
|
+
|
168
|
+
describe "checkout_and_payment" do
|
169
|
+
subject { redirect_for "checkout_and_payment" }
|
170
|
+
it { should eq path_for "payments" }
|
171
|
+
end
|
172
|
+
|
173
|
+
describe "shipping_rates" do
|
174
|
+
subject { redirect_for "shipping_rates" }
|
175
|
+
it { should eq path_for "shipping" }
|
176
|
+
end
|
177
|
+
|
178
|
+
describe "weight_based_shipping_rate" do
|
179
|
+
subject { redirect_for "weight_based_shipping_rate", "1" }
|
180
|
+
it { should eq path_for "weight_based_shipping_rates", "1" }
|
181
|
+
end
|
182
|
+
|
183
|
+
describe "price_based_shipping_rate" do
|
184
|
+
subject { redirect_for "price_based_shipping_rate", "1" }
|
185
|
+
it { should eq path_for "price_based_shipping_rates", "1" }
|
186
|
+
end
|
187
|
+
|
188
|
+
describe "fulfillment_services" do
|
189
|
+
subject { redirect_for "fulfillment_services" }
|
190
|
+
it { should eq path_for "fulfillment_services" }
|
191
|
+
end
|
192
|
+
|
193
|
+
describe "notifications" do
|
194
|
+
subject { redirect_for "notifications" }
|
195
|
+
it { should eq path_for "notifications" }
|
196
|
+
end
|
197
|
+
|
198
|
+
describe "notification" do
|
199
|
+
subject { redirect_for "notification", "1" }
|
200
|
+
it { should eq path_for "notifications", "1" }
|
201
|
+
end
|
202
|
+
|
203
|
+
describe "domains" do
|
204
|
+
subject { redirect_for "domains" }
|
205
|
+
it { should eq path_for "domains" }
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'shopify-routes'
|
4
|
+
|
5
|
+
# load all the support files
|
6
|
+
Dir["spec/support/**/*.rb"].each { |f| require File.expand_path(f) }
|
7
|
+
require 'rspec/rails' # this has to be loaded after the support files
|
8
|
+
|
9
|
+
RSpec.configure do |config|
|
10
|
+
config.mock_with :rspec
|
11
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rails'
|
2
|
+
require "action_controller/railtie"
|
3
|
+
|
4
|
+
module RailsApp
|
5
|
+
# Provides a Rails application environment to use when running the specs
|
6
|
+
class Application < Rails::Application
|
7
|
+
config.encoding = 'utf-8'
|
8
|
+
end
|
9
|
+
|
10
|
+
Application.configure do
|
11
|
+
config.active_support.deprecation = :stderr
|
12
|
+
config.logger = Logger.new(STDOUT)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
Rails.env = 'test'
|
17
|
+
RailsApp::Application.initialize!
|
18
|
+
|
19
|
+
RailsApp::Application.routes.draw do
|
20
|
+
ShopifyAPI.routes(self)
|
21
|
+
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.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: &25042380 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.0.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *25042380
|
14
25
|
- !ruby/object:Gem::Dependency
|
15
26
|
name: shopify_api
|
16
|
-
requirement: &
|
27
|
+
requirement: &25058280 !ruby/object:Gem::Requirement
|
17
28
|
none: false
|
18
29
|
requirements:
|
19
30
|
- - ! '>='
|
@@ -21,7 +32,18 @@ dependencies:
|
|
21
32
|
version: 3.0.0
|
22
33
|
type: :runtime
|
23
34
|
prerelease: false
|
24
|
-
version_requirements: *
|
35
|
+
version_requirements: *25058280
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec-rails
|
38
|
+
requirement: &25057820 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 2.9.0
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *25057820
|
25
47
|
description: Provides routes that redirect back to Shopify pages.
|
26
48
|
email:
|
27
49
|
- travis.j.haynes@gmail.com
|
@@ -30,12 +52,17 @@ extensions: []
|
|
30
52
|
extra_rdoc_files: []
|
31
53
|
files:
|
32
54
|
- .gitignore
|
55
|
+
- .rspec
|
56
|
+
- .travis.yml
|
33
57
|
- Gemfile
|
34
58
|
- LICENSE
|
35
59
|
- README.md
|
36
60
|
- Rakefile
|
37
61
|
- lib/shopify-routes.rb
|
38
62
|
- shopify-routes.gemspec
|
63
|
+
- spec/lib/shopify-routes_spec.rb
|
64
|
+
- spec/spec_helper.rb
|
65
|
+
- spec/support/rails_app.rb
|
39
66
|
homepage: ''
|
40
67
|
licenses: []
|
41
68
|
post_install_message:
|