shopify_app 6.0.6 → 6.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa3c2e95ba729a7e13c6db591e5034800bd13e22
4
- data.tar.gz: 9b322e1fae0cd56fe577df5b754ab58158e2b1ef
3
+ metadata.gz: 75b41ef7f4d4ae9853a762bfb050494599f5c26a
4
+ data.tar.gz: ff8d4b05b617c4ea2118121859541afa1af867f0
5
5
  SHA512:
6
- metadata.gz: 7be84e1af14c4c44f350857d5098455df023f4e18a32abba4e839afbb4cecbbf876fb5315cdd791a5e98b0841372fc5a63813b1687b586c2181cca4300c9a417
7
- data.tar.gz: 63ab0d6e674c004e687e0d9893d3a51bcc9106938214fec5ce71e0685a492ccb0bc75f913e45d7ee9d997cdd409ebdc755774bf382180bdb8af1c59715f1de53
6
+ metadata.gz: f879ca0a0bcadbc8966ee68d70e7b2bf6f66c642259d5623d9a0913b9c016acc936b0244a3e5fda574e57fe1b848516c00e3ece21cfec108d67f53dc63a5fc3e
7
+ data.tar.gz: e7d0b4717e650a1c6adc802c502d474252c1e71e25c0a46471def03f3b79d2b8da7765468cfe441fbd580f6f3d6a26e54a7de8ca81af2d9645dac15d86db9d73
data/config/routes.rb CHANGED
@@ -1,10 +1,8 @@
1
- if ShopifyApp.configuration.routes_enabled?
2
- ShopifyApp::Engine.routes.draw do
3
- controller :sessions do
4
- get 'login' => :new, :as => :login
5
- post 'login' => :create, :as => :authenticate
6
- get 'auth/shopify/callback' => :callback
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,4 +1,5 @@
1
1
  class HomeController < ApplicationController
2
+ before_action :login_again_if_different_shop
2
3
  around_filter :shopify_session
3
4
  <% if embedded_app? -%>
4
5
  layout 'embedded_app'
@@ -1,6 +1,6 @@
1
1
  ShopifyApp.configure do |config|
2
- config.api_key = "<%= opts[:api_key] || '<api_key>' %>"
3
- config.secret = "<%= opts[:secret] || '<secret>' %>"
4
- config.scope = "<%= opts[:scope] || 'read_orders, read_products' %>"
5
- config.embedded_app = <%= opts[:embedded_app] || true %>
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
- inject_into_file(
14
- 'config/initializers/shopify_app.rb',
15
- " config.routes = false\n",
16
- before: 'end'
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
@@ -1,5 +1,5 @@
1
1
  module ShopifyApp
2
2
  class Engine < Rails::Engine
3
- isolate_namespace ShopifyApp
3
+ engine_name 'shopify_app'
4
4
  end
5
5
  end
@@ -42,5 +42,11 @@ module ShopifyApp
42
42
  redirect_to login_path
43
43
  end
44
44
 
45
+ def login_path(params = {})
46
+ main_app.login_path(params)
47
+ rescue NoMethodError => e
48
+ shopify_app.login_path(params)
49
+ end
50
+
45
51
  end
46
52
  end
@@ -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 :action => 'new'
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 :action => 'new'
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
@@ -1,3 +1,3 @@
1
1
  module ShopifyApp
2
- VERSION = "6.0.6"
2
+ VERSION = "6.1.0"
3
3
  end
@@ -1,3 +1,4 @@
1
1
  Rails.application.routes.draw do
2
+ mount ShopifyApp::Engine, at: '/'
2
3
  root to: "application#show"
3
4
  end
@@ -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
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
@@ -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
- end
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.6
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 CERTIFICATE-----
13
- MIIDcDCCAligAwIBAgIBATANBgkqhkiG9w0BAQUFADA/MQ8wDQYDVQQDDAZhZG1p
14
- bnMxFzAVBgoJkiaJk/IsZAEZFgdzaG9waWZ5MRMwEQYKCZImiZPyLGQBGRYDY29t
15
- MB4XDTE0MDUxNTIwMzM0OFoXDTE1MDUxNTIwMzM0OFowPzEPMA0GA1UEAwwGYWRt
16
- aW5zMRcwFQYKCZImiZPyLGQBGRYHc2hvcGlmeTETMBEGCgmSJomT8ixkARkWA2Nv
17
- bTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL0/81O3e1vh5smcwp2G
18
- MpLQ6q0kejQLa65bPYPxdzWA1SYOKyGfw+yR9LdFzsuKpwWzKq6zX35lj1IckWS4
19
- bNBEQzxmufUxU0XPM02haFB8fOfDJzdXsWte9Ge4IFwahwn68gpMqN+BvxL+KMYz
20
- Iut9YmN44d4LZdsENEIO5vmybuG2vYDz7R56qB0PA+Q2P2CdhymsBad2DQs69FBo
21
- uico9V6VMYYctL9lCYdzu9IXrOYNTt88suKIVzzAlHOKeN0Ng5qdztFoTR8sfxDr
22
- Ydg3KHl5n47wlpgd8R0f/4b5gGxW+v9pyJCgQnLlRu7DedVSvv7+GMtj3g9r3nhJ
23
- KqECAwEAAaN3MHUwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFI/o
24
- maf34HXbUOQsdoLHacEKQgunMB0GA1UdEQQWMBSBEmFkbWluc0BzaG9waWZ5LmNv
25
- bTAdBgNVHRIEFjAUgRJhZG1pbnNAc2hvcGlmeS5jb20wDQYJKoZIhvcNAQEFBQAD
26
- ggEBADkK9aj5T0HPExsov4EoMWFnO+G7RQ28C30VAfKxnL2UxG6i4XMHVs6Xi94h
27
- qXFw1ec9Y2eDUqaolT3bviOk9BB197+A8Vz/k7MC6ci2NE+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
@@ -1,2 +0,0 @@
1
- 5xlq�e�]̓K
2
- a*Z����:�}t��� ��Y�.������a���u~�`�e��KO�{vp�Nǣ:@\V��:YCp��Цd��d?���C��7���pb!F:zve��'���]�R�ni�X��$������?#�飤�^��6N�6Z >��o1Q �̀��X1��ńj�8�ۂO��! (I�0��ߏY�;��)KcZ��
data.tar.gz.sig DELETED
@@ -1,2 +0,0 @@
1
- ��~N��NS"��*�P9`rNw�O�B�Q�g�*���*)�QA.~����x�!��7�Y���<�Ya�S�@����^�rݟ�^[��8���˾����ƭ"��U�;�W�=4�5T&��.��hN�1į����
2
- �$���l`�5��E��)��_�J��8hh�%�ή=��FC�Y���4ܸY YJN�}Q(��;���ҥLZ%?�p 2��a����Z Jh;9��w�Kq�O������ryq�}��Pf"m4\��
metadata.gz.sig DELETED
Binary file