shopify_app 6.0.6 → 6.1.0
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.
- checksums.yaml +4 -4
- data/config/routes.rb +6 -8
- data/lib/generators/shopify_app/install/install_generator.rb +11 -0
- data/lib/generators/shopify_app/install/templates/home_controller.rb +1 -0
- data/lib/generators/shopify_app/install/templates/shopify_app.rb +4 -4
- data/lib/generators/shopify_app/routes/routes_generator.rb +4 -4
- data/lib/shopify_app/configuration.rb +0 -8
- data/lib/shopify_app/engine.rb +1 -1
- data/lib/shopify_app/login_protection.rb +6 -0
- data/lib/shopify_app/sessions_controller.rb +3 -3
- data/lib/shopify_app/version.rb +1 -1
- data/test/app_templates/config/routes.rb +1 -0
- data/test/controllers/sessions_routes_test.rb +27 -0
- data/test/dummy/Rakefile +6 -0
- data/test/generators/install_generator_test.rb +11 -1
- data/test/generators/routes_generator_test.rb +1 -8
- data/test/shopify_app/configuration_test.rb +0 -12
- metadata +5 -25
- checksums.yaml.gz.sig +0 -2
- data.tar.gz.sig +0 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75b41ef7f4d4ae9853a762bfb050494599f5c26a
|
4
|
+
data.tar.gz: ff8d4b05b617c4ea2118121859541afa1af867f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f879ca0a0bcadbc8966ee68d70e7b2bf6f66c642259d5623d9a0913b9c016acc936b0244a3e5fda574e57fe1b848516c00e3ece21cfec108d67f53dc63a5fc3e
|
7
|
+
data.tar.gz: e7d0b4717e650a1c6adc802c502d474252c1e71e25c0a46471def03f3b79d2b8da7765468cfe441fbd580f6f3d6a26e54a7de8ca81af2d9645dac15d86db9d73
|
data/config/routes.rb
CHANGED
@@ -1,10 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
get 'logout' => :destroy, :as => :logout
|
8
|
-
end
|
1
|
+
ShopifyApp::Engine.routes.draw do
|
2
|
+
controller :sessions do
|
3
|
+
get 'login' => :new, :as => :login
|
4
|
+
post 'login' => :create, :as => :authenticate
|
5
|
+
get 'auth/shopify/callback' => :callback
|
6
|
+
get 'logout' => :destroy, :as => :logout
|
9
7
|
end
|
10
8
|
end
|
@@ -11,9 +11,19 @@ module ShopifyApp
|
|
11
11
|
def initialize(args, *options)
|
12
12
|
@opts = Hash[options.first.join(' ').scan(/--?([^=\s]+)(?:=(\S+))?/)]
|
13
13
|
@opts = @opts.with_indifferent_access
|
14
|
+
@opts.reverse_merge!(defaults)
|
14
15
|
super(args, *options)
|
15
16
|
end
|
16
17
|
|
18
|
+
def defaults
|
19
|
+
{
|
20
|
+
api_key: '<api_key>',
|
21
|
+
secret: '<secret>',
|
22
|
+
scope: 'read_orders, read_products',
|
23
|
+
embedded: 'true'
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
17
27
|
def create_shopify_app_initializer
|
18
28
|
template 'shopify_app.rb', 'config/initializers/shopify_app.rb'
|
19
29
|
end
|
@@ -70,6 +80,7 @@ module ShopifyApp
|
|
70
80
|
end
|
71
81
|
|
72
82
|
def add_home_index_route
|
83
|
+
route "mount ShopifyApp::Engine, at: '/'"
|
73
84
|
route "root :to => 'home#index'"
|
74
85
|
end
|
75
86
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
ShopifyApp.configure do |config|
|
2
|
-
config.api_key = "<%= opts[:api_key]
|
3
|
-
config.secret = "<%= opts[:secret]
|
4
|
-
config.scope = "<%= opts[:scope]
|
5
|
-
config.embedded_app = <%=
|
2
|
+
config.api_key = "<%= opts[:api_key] %>"
|
3
|
+
config.secret = "<%= opts[:secret] %>"
|
4
|
+
config.scope = "<%= opts[:scope] %>"
|
5
|
+
config.embedded_app = <%= embedded_app? %>
|
6
6
|
end
|
@@ -10,10 +10,10 @@ module ShopifyApp
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def disable_engine_routes
|
13
|
-
|
14
|
-
'config/
|
15
|
-
"
|
16
|
-
|
13
|
+
gsub_file(
|
14
|
+
'config/routes.rb',
|
15
|
+
"mount ShopifyApp::Engine, at: '/'",
|
16
|
+
''
|
17
17
|
)
|
18
18
|
end
|
19
19
|
|
@@ -10,18 +10,10 @@ module ShopifyApp
|
|
10
10
|
attr_accessor :embedded_app
|
11
11
|
alias_method :embedded_app?, :embedded_app
|
12
12
|
|
13
|
-
# use the built in session routes?
|
14
|
-
attr_accessor :routes
|
15
|
-
|
16
13
|
# configure myshopify domain for local shopify development
|
17
14
|
attr_accessor :myshopify_domain
|
18
15
|
|
19
|
-
def routes_enabled?
|
20
|
-
@routes
|
21
|
-
end
|
22
|
-
|
23
16
|
def initialize
|
24
|
-
@routes = true
|
25
17
|
@myshopify_domain = 'myshopify.com'
|
26
18
|
end
|
27
19
|
end
|
data/lib/shopify_app/engine.rb
CHANGED
@@ -18,7 +18,7 @@ module ShopifyApp
|
|
18
18
|
redirect_to return_address
|
19
19
|
else
|
20
20
|
flash[:error] = "Could not log in to Shopify store."
|
21
|
-
redirect_to :
|
21
|
+
redirect_to action: 'new'
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -26,7 +26,7 @@ module ShopifyApp
|
|
26
26
|
session[:shopify] = nil
|
27
27
|
flash[:notice] = "Successfully logged out."
|
28
28
|
|
29
|
-
redirect_to :
|
29
|
+
redirect_to action: 'new'
|
30
30
|
end
|
31
31
|
|
32
32
|
protected
|
@@ -40,7 +40,7 @@ module ShopifyApp
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def return_address
|
43
|
-
session[:return_to] || root_url
|
43
|
+
session[:return_to] || main_app.root_url
|
44
44
|
end
|
45
45
|
|
46
46
|
def sanitized_shop_name
|
data/lib/shopify_app/version.rb
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class SessionsRoutesTest < ActionController::TestCase
|
4
|
+
|
5
|
+
setup do
|
6
|
+
@routes = ShopifyApp::Engine.routes
|
7
|
+
ShopifyApp::SessionRepository.storage = InMemorySessionStore
|
8
|
+
ShopifyApp.configuration = nil
|
9
|
+
end
|
10
|
+
|
11
|
+
test "login routes to sessions#new" do
|
12
|
+
assert_routing '/login', { controller: "sessions", action: "new" }
|
13
|
+
end
|
14
|
+
|
15
|
+
test "post login routes to sessions#create" do
|
16
|
+
assert_routing({method: 'post', path: '/login'}, { controller: "sessions", action: "create" })
|
17
|
+
end
|
18
|
+
|
19
|
+
test "auth_shopify_callback routes to sessions#callback" do
|
20
|
+
assert_routing '/auth/shopify/callback', { controller: "sessions", action: "callback" }
|
21
|
+
end
|
22
|
+
|
23
|
+
test "logout routes to sessions#destroy" do
|
24
|
+
assert_routing '/logout', { controller: "sessions", action: "destroy" }
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
data/test/dummy/Rakefile
ADDED
@@ -22,6 +22,15 @@ class InstallGeneratorTest < Rails::Generators::TestCase
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
test "creates the ShopifyApp initializer for non embedded app" do
|
26
|
+
stub_embedded_false
|
27
|
+
run_generator
|
28
|
+
|
29
|
+
assert_file "config/initializers/shopify_app.rb" do |shopify_app|
|
30
|
+
assert_match "config.embedded_app = false", shopify_app
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
25
34
|
test "creats and injects into omniauth initializer" do
|
26
35
|
run_generator
|
27
36
|
assert_file "config/initializers/omniauth.rb" do |omniauth|
|
@@ -85,9 +94,10 @@ class InstallGeneratorTest < Rails::Generators::TestCase
|
|
85
94
|
end
|
86
95
|
end
|
87
96
|
|
88
|
-
test "adds home route to routes" do
|
97
|
+
test "adds engine and home route to routes" do
|
89
98
|
run_generator
|
90
99
|
assert_file "config/routes.rb" do |routes|
|
100
|
+
assert_match "mount ShopifyApp::Engine, at: '/'", routes
|
91
101
|
assert_match "root :to => 'home#index'", routes
|
92
102
|
end
|
93
103
|
end
|
@@ -19,14 +19,7 @@ class ControllerGeneratorTest < Rails::Generators::TestCase
|
|
19
19
|
assert_match "post 'login' => :create, :as => :authenticate", routes
|
20
20
|
assert_match "get 'auth/shopify/callback' => :callback", routes
|
21
21
|
assert_match "get 'logout' => :destroy, :as => :logout", routes
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
test "adds routes false to ShopifyApp initializer" do
|
26
|
-
run_generator
|
27
|
-
|
28
|
-
assert_file "config/initializers/shopify_app.rb" do |initializer|
|
29
|
-
assert_match "config.routes = false", initializer
|
22
|
+
refute_match "mount ShopifyApp::Engine, at: '/'", routes
|
30
23
|
end
|
31
24
|
end
|
32
25
|
|
@@ -14,18 +14,6 @@ class ConfigurationTest < ActiveSupport::TestCase
|
|
14
14
|
assert_equal true, ShopifyApp.configuration.embedded_app
|
15
15
|
end
|
16
16
|
|
17
|
-
test "routes enabled" do
|
18
|
-
assert_equal true, ShopifyApp.configuration.routes_enabled?
|
19
|
-
end
|
20
|
-
|
21
|
-
test "disable routes" do
|
22
|
-
ShopifyApp.configure do |config|
|
23
|
-
config.routes = false
|
24
|
-
end
|
25
|
-
|
26
|
-
assert_equal false, ShopifyApp.configuration.routes_enabled?
|
27
|
-
end
|
28
|
-
|
29
17
|
test "defaults to myshopify_domain" do
|
30
18
|
assert_equal "myshopify.com", ShopifyApp.configuration.myshopify_domain
|
31
19
|
end
|
metadata
CHANGED
@@ -1,36 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shopify_app
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0
|
4
|
+
version: 6.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
|
-
cert_chain:
|
11
|
-
-
|
12
|
-
-----BEGIN CERTIF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MC6ci2NE+yDDB7HAC8zU6LAx8Y
|
28
|
-
Iqvw7B/PSZ/pz4bUVFlTATif4mi1vO3lidRkdHRtM7UePSn2rUpOi0gtXBP3bLu5
|
29
|
-
YjHJN7wx5cugMEyroKITG5gL0Nxtu21qtOlHX4Hc4KdE2JqzCPOsS4zsZGhgwhPs
|
30
|
-
fl3hbtVFTqbOlwL9vy1fudXcolIE/ZTcxQ+er07ZFZdKCXayR9PPs64heamfn0fp
|
31
|
-
TConQSX2BnZdhIEYW+cKzEC/bLc=
|
32
|
-
-----END CERTIFICATE-----
|
33
|
-
date: 2015-05-14 00:00:00.000000000 Z
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-20 00:00:00.000000000 Z
|
34
12
|
dependencies:
|
35
13
|
- !ruby/object:Gem::Dependency
|
36
14
|
name: rails
|
@@ -204,6 +182,8 @@ files:
|
|
204
182
|
- test/app_templates/config/initializers/shopify_app.rb
|
205
183
|
- test/app_templates/config/routes.rb
|
206
184
|
- test/controllers/sessions_controller_test.rb
|
185
|
+
- test/controllers/sessions_routes_test.rb
|
186
|
+
- test/dummy/Rakefile
|
207
187
|
- test/dummy/app/controllers/application_controller.rb
|
208
188
|
- test/dummy/app/controllers/home_controller.rb
|
209
189
|
- test/dummy/config.ru
|
checksums.yaml.gz.sig
DELETED
data.tar.gz.sig
DELETED
metadata.gz.sig
DELETED
Binary file
|