shopify_app 6.0.0 → 6.0.1

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: 2180fbad771bc170d57ca9e9d84264db64adc578
4
- data.tar.gz: 028708ad9fc92ce756fbf815468d586e2e0302ed
3
+ metadata.gz: 29d6e51ca55be46503ae5c1852d423d44f7f5949
4
+ data.tar.gz: 050e64759df2bb9aca2cb7d40faab876a3cb0b85
5
5
  SHA512:
6
- metadata.gz: d07a8720342f16795447fd929d4fb9d5933ba7cbbe27b085f8c00663548ef3ff5bd5ef826ec5062e30e00d476ac2bea7818e1eefa61b4e06f0831027f4ce309a
7
- data.tar.gz: 5c17a5290b05876ecd0bc321dc9477612d7f1d8c87689ff506d6e5ac21f0df4b2c936b1e9d28945d7d2fea0c25eacbf93fc129555fe7f47cc63400e4f80db87c
6
+ metadata.gz: cf160257914859df8d18439adcc242b7963cdc862e24145bd24f119cdce1d154555ca9fa3ff65f1a2556b00466be85db79cc5edb3b6d8458fd96956bd904e910
7
+ data.tar.gz: b28d43f8edb5e377969051cc799635c3db7117a0095c7b593d280f974142ecfbf411b298d4f9f53a097bebcebe57b77e0ac43752943dd2fe637d56b15fd92d45
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -13,12 +13,16 @@ module ShopifyApp
13
13
  # use the built in session routes?
14
14
  attr_accessor :routes
15
15
 
16
+ # configure myshopify domain for local shopify development
17
+ attr_accessor :myshopify_domain
18
+
16
19
  def routes_enabled?
17
20
  @routes
18
21
  end
19
22
 
20
23
  def initialize
21
24
  @routes = true
25
+ @myshopify_domain = 'myshopify.com'
22
26
  end
23
27
  end
24
28
 
@@ -47,18 +47,18 @@ module ShopifyApp
47
47
  @sanitized_shop_name ||= sanitize_shop_param(params)
48
48
  end
49
49
 
50
- def sanitize_shop_param(params)
51
- return unless params[:shop].present?
50
+ def sanitize_shop_param(params)
51
+ return unless params[:shop].present?
52
52
 
53
- name = params[:shop].to_s.strip
54
- name += ".myshopify.com" if !name.include?("myshopify.com") && !name.include?(".")
55
- name.sub!(%r|https?://|, '')
53
+ name = params[:shop].to_s.strip
54
+ name += ".#{ShopifyApp.configuration.myshopify_domain}" if !name.include?("#{ShopifyApp.configuration.myshopify_domain}") && !name.include?(".")
55
+ name.sub!(%r|https?://|, '')
56
56
 
57
- u = URI("http://#{name}")
58
- u.host && u.host.ends_with?(".myshopify.com") ? u.host : nil
59
- rescue URI::InvalidURIError
60
- nil
61
- end
57
+ u = URI("http://#{name}")
58
+ u.host && u.host.ends_with?(".#{ShopifyApp.configuration.myshopify_domain}") ? u.host : nil
59
+ rescue URI::InvalidURIError
60
+ nil
61
+ end
62
62
 
63
63
  end
64
64
  end
@@ -1,3 +1,3 @@
1
1
  module ShopifyApp
2
- VERSION = "6.0.0"
2
+ VERSION = "6.0.1"
3
3
  end
@@ -4,22 +4,25 @@ class SessionsControllerTest < ActionController::TestCase
4
4
 
5
5
  setup do
6
6
  ShopifyApp::SessionRepository.storage = InMemorySessionStore
7
+ ShopifyApp.configuration = nil
7
8
  end
8
9
 
9
10
  test "#new should authenticate the shop if the shop param exists" do
11
+ ShopifyApp.configuration.embedded_app = true
10
12
  auth_url = '/auth/shopify?shop=my-shop.myshopify.com'
11
13
  get :new, shop: 'my-shop'
12
14
  assert response.body.match(/window\.top\.location\.href = "#{Regexp.escape(auth_url)}"/)
13
15
  end
14
16
 
15
17
  test "#new should authenticate the shop if the shop param exists non embedded" do
16
- ShopifyApp.configuration.stubs(:embedded_app?).returns(false)
18
+ ShopifyApp.configuration.embedded_app = false
17
19
  auth_url = '/auth/shopify?shop=my-shop.myshopify.com'
18
20
  get :new, shop: 'my-shop'
19
21
  assert_match "http://test.host/auth/shopify?shop=my-shop.myshopify.com", response.body
20
22
  end
21
23
 
22
24
  test "#new should trust the shop param over the current session" do
25
+ ShopifyApp.configuration.embedded_app = true
23
26
  previously_logged_in_shop_id = 1
24
27
  session[:shopify] = previously_logged_in_shop_id
25
28
  new_shop_domain = "new-shop.myshopify.com"
@@ -36,12 +39,23 @@ class SessionsControllerTest < ActionController::TestCase
36
39
 
37
40
  ['my-shop', 'my-shop.myshopify.com', 'https://my-shop.myshopify.com', 'http://my-shop.myshopify.com'].each do |good_url|
38
41
  test "#create should authenticate the shop for the URL (#{good_url})" do
42
+ ShopifyApp.configuration.embedded_app = true
39
43
  auth_url = '/auth/shopify?shop=my-shop.myshopify.com'
40
44
  post :create, shop: good_url
41
45
  assert response.body.match(/window\.top\.location\.href = "#{Regexp.escape(auth_url)}"/)
42
46
  end
43
47
  end
44
48
 
49
+ ['my-shop', 'my-shop.myshopify.io', 'https://my-shop.myshopify.io', 'http://my-shop.myshopify.io'].each do |good_url|
50
+ test "#create should authenticate the shop for the URL (#{good_url}) with custom myshopify_domain" do
51
+ ShopifyApp.configuration.embedded_app = true
52
+ ShopifyApp.configuration.myshopify_domain = 'myshopify.io'
53
+ auth_url = '/auth/shopify?shop=my-shop.myshopify.io'
54
+ post :create, shop: good_url
55
+ assert response.body.match(/window\.top\.location\.href = "#{Regexp.escape(auth_url)}"/)
56
+ end
57
+ end
58
+
45
59
  ['myshop.com', 'myshopify.com', 'shopify.com', 'two words', 'store.myshopify.com.evil.com', '/foo/bar'].each do |bad_url|
46
60
  test "#create should return an error for a non-myshopify URL (#{bad_url})" do
47
61
  post :create, shop: bad_url
@@ -2,6 +2,10 @@ require 'test_helper'
2
2
 
3
3
  class ConfigurationTest < ActiveSupport::TestCase
4
4
 
5
+ setup do
6
+ ShopifyApp.configuration = nil
7
+ end
8
+
5
9
  test "configure" do
6
10
  ShopifyApp.configure do |config|
7
11
  config.embedded_app = true
@@ -10,8 +14,28 @@ class ConfigurationTest < ActiveSupport::TestCase
10
14
  assert_equal true, ShopifyApp.configuration.embedded_app
11
15
  end
12
16
 
13
- test "routes enabled" do
17
+ test "routes enabled" do
14
18
  assert_equal true, ShopifyApp.configuration.routes_enabled?
15
19
  end
16
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
+ test "defaults to myshopify_domain" do
30
+ assert_equal "myshopify.com", ShopifyApp.configuration.myshopify_domain
31
+ end
32
+
33
+ test "can set myshopify_domain" do
34
+ ShopifyApp.configure do |config|
35
+ config.myshopify_domain = 'myshopify.io'
36
+ end
37
+
38
+ assert_equal "myshopify.io", ShopifyApp.configuration.myshopify_domain
39
+ end
40
+
17
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify_app
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0
4
+ version: 6.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
metadata.gz.sig CHANGED
Binary file