shopify_app 5.0.2 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/.gitignore +4 -1
  5. data/.travis.yml +9 -0
  6. data/CHANGELOG +12 -1
  7. data/README.md +73 -108
  8. data/Rakefile +0 -1
  9. data/app/controllers/sessions_controller.rb +3 -0
  10. data/app/views/sessions/new.html.erb +17 -0
  11. data/config/routes.rb +10 -0
  12. data/lib/generators/shopify_app/controllers/controllers_generator.rb +29 -0
  13. data/lib/generators/shopify_app/install/install_generator.rb +83 -0
  14. data/lib/generators/shopify_app/install/templates/embedded_app.html.erb +22 -0
  15. data/lib/generators/shopify_app/install/templates/home_controller.rb +11 -0
  16. data/lib/generators/shopify_app/install/templates/index.html.erb +12 -0
  17. data/lib/generators/shopify_app/install/templates/omniauth.rb +2 -0
  18. data/lib/generators/shopify_app/install/templates/shopify_app.rb +6 -0
  19. data/lib/generators/shopify_app/install/templates/shopify_app_ready_script.html +8 -0
  20. data/lib/generators/shopify_app/install/templates/shopify_provider.rb +11 -0
  21. data/lib/generators/shopify_app/{templates/config/initializers → install/templates}/shopify_session_repository.rb +3 -3
  22. data/lib/generators/shopify_app/routes/routes_generator.rb +31 -0
  23. data/lib/generators/shopify_app/routes/templates/routes.rb +7 -0
  24. data/lib/generators/shopify_app/shop_model/shop_model_generator.rb +42 -0
  25. data/lib/generators/shopify_app/shop_model/templates/db/migrate/create_shops.rb +15 -0
  26. data/lib/generators/shopify_app/shop_model/templates/session_storage.rb +16 -0
  27. data/lib/generators/shopify_app/shop_model/templates/shop.rb +3 -0
  28. data/lib/generators/shopify_app/shop_model/templates/shopify_session_repository.rb +7 -0
  29. data/lib/generators/shopify_app/shopify_app_generator.rb +10 -63
  30. data/lib/generators/shopify_app/views/views_generator.rb +29 -0
  31. data/lib/shopify_app.rb +14 -13
  32. data/lib/shopify_app/configuration.rb +26 -36
  33. data/lib/shopify_app/controller.rb +18 -0
  34. data/lib/shopify_app/engine.rb +5 -0
  35. data/lib/shopify_app/login_protection.rb +34 -32
  36. data/lib/shopify_app/sessions_controller.rb +64 -0
  37. data/lib/shopify_app/shop.rb +15 -0
  38. data/lib/shopify_app/shopify_session_repository.rb +23 -21
  39. data/lib/shopify_app/version.rb +1 -1
  40. data/shopify_app.gemspec +5 -10
  41. data/test/app_templates/app/controllers/application_controller.rb +2 -0
  42. data/test/app_templates/config/application.rb +24 -0
  43. data/test/app_templates/config/initializers/shopify_app.rb +6 -0
  44. data/test/app_templates/config/routes.rb +3 -0
  45. data/test/controllers/sessions_controller_test.rb +82 -0
  46. data/test/dummy/app/controllers/application_controller.rb +3 -0
  47. data/test/dummy/app/controllers/home_controller.rb +7 -0
  48. data/test/dummy/config.ru +4 -0
  49. data/test/dummy/config/application.rb +26 -0
  50. data/test/dummy/config/boot.rb +5 -0
  51. data/test/dummy/config/database.yml +25 -0
  52. data/test/dummy/config/environment.rb +5 -0
  53. data/test/dummy/config/environments/test.rb +42 -0
  54. data/test/dummy/config/initializers/shopify_app.rb +6 -0
  55. data/test/dummy/config/routes.rb +10 -0
  56. data/test/dummy/config/secrets.yml +17 -0
  57. data/test/generators/install_generator_test.rb +103 -0
  58. data/test/generators/routes_generator_test.rb +33 -0
  59. data/test/generators/shop_model_generator_test.rb +40 -0
  60. data/test/generators/shopify_app_generator.rb +15 -0
  61. data/test/generators/views_generator_test.rb +15 -0
  62. data/test/shopify_app/configuration_test.rb +17 -0
  63. data/test/{lib/shopify_app → shopify_app}/in_memory_session_store_test.rb +6 -6
  64. data/test/{lib/shopify_app → shopify_app}/login_protection_test.rb +10 -7
  65. data/test/shopify_app/shopify_session_repository_test.rb +73 -0
  66. data/test/support/generator_test_helpers.rb +29 -0
  67. data/test/test_helper.rb +11 -3
  68. metadata +79 -61
  69. metadata.gz.sig +0 -0
  70. data/install.rb +0 -25
  71. data/lib/generators/shopify_app/README +0 -23
  72. data/lib/generators/shopify_app/USAGE +0 -22
  73. data/lib/generators/shopify_app/templates/app/assets/images/favicon.png +0 -0
  74. data/lib/generators/shopify_app/templates/app/assets/images/grid-18px.png +0 -0
  75. data/lib/generators/shopify_app/templates/app/assets/images/shopify-114.png +0 -0
  76. data/lib/generators/shopify_app/templates/app/assets/images/shopify-57.png +0 -0
  77. data/lib/generators/shopify_app/templates/app/assets/images/shopify-72.png +0 -0
  78. data/lib/generators/shopify_app/templates/app/assets/images/shopify.png +0 -0
  79. data/lib/generators/shopify_app/templates/app/assets/javascripts/application.js +0 -15
  80. data/lib/generators/shopify_app/templates/app/assets/stylesheets/application.css +0 -10
  81. data/lib/generators/shopify_app/templates/app/assets/stylesheets/imports.css.less +0 -5
  82. data/lib/generators/shopify_app/templates/app/assets/stylesheets/shopify_app.css.scss +0 -150
  83. data/lib/generators/shopify_app/templates/app/assets/stylesheets/shopify_app_buttons.css.less +0 -77
  84. data/lib/generators/shopify_app/templates/app/controllers/application_controller.rb +0 -13
  85. data/lib/generators/shopify_app/templates/app/controllers/home_controller.rb +0 -18
  86. data/lib/generators/shopify_app/templates/app/controllers/sessions_controller.rb +0 -52
  87. data/lib/generators/shopify_app/templates/app/helpers/home_helper.rb +0 -9
  88. data/lib/generators/shopify_app/templates/app/helpers/login_helper.rb +0 -3
  89. data/lib/generators/shopify_app/templates/app/helpers/tabs_helper.rb +0 -11
  90. data/lib/generators/shopify_app/templates/app/views/home/design.html.erb +0 -3542
  91. data/lib/generators/shopify_app/templates/app/views/home/index.html.erb +0 -168
  92. data/lib/generators/shopify_app/templates/app/views/home/welcome.html.erb +0 -110
  93. data/lib/generators/shopify_app/templates/app/views/layouts/application.html.erb +0 -79
  94. data/lib/generators/shopify_app/templates/app/views/sessions/new.html.erb +0 -21
  95. data/lib/generators/shopify_app/templates/config/initializers/omniauth.rb +0 -14
  96. data/lib/generators/shopify_app/templates/config/initializers/rails_4_shim.rb +0 -1
  97. data/lib/generators/shopify_app/templates/public/404.html +0 -40
  98. data/lib/generators/shopify_app/templates/public/422.html +0 -40
  99. data/lib/generators/shopify_app/templates/public/500.html +0 -40
  100. data/lib/generators/shopify_app/templates/public/favicon.png +0 -0
  101. data/lib/generators/shopify_app/templates/public/shopify-114.png +0 -0
  102. data/lib/generators/shopify_app/templates/public/shopify-57.png +0 -0
  103. data/lib/generators/shopify_app/templates/public/shopify-72.png +0 -0
  104. data/lib/shopify_app/railtie.rb +0 -17
  105. data/test/config/development_config_file.yml +0 -8
  106. data/test/config/empty_config_file.yml +0 -1
  107. data/test/config/other_config_file.yml +0 -4
  108. data/test/config/shopify_app.yml +0 -4
  109. data/test/lib/shopify_app/configuration_test.rb +0 -91
  110. data/test/lib/shopify_app/shopify_session_repository_test.rb +0 -70
@@ -1,40 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>500 Error: Something went horribly wrong</title>
5
-
6
- <style>
7
- .container { text-align:center;}
8
- .navbar .brand { float:none;}
9
- </style>
10
- </head>
11
-
12
- <body>
13
- <div class="navbar navbar-fixed-top">
14
- <div class="navbar-inner">
15
- <div class="container">
16
- <a href="/" class="brand">Shopify Demo App</a>
17
- </div>
18
- </div>
19
- </div>
20
-
21
- <div class="container">
22
- <div class="content">
23
-
24
- <div class="page-header">
25
- <h1>AH! 500 Error!</h1>
26
- </div>
27
-
28
- <h3><i class="icon-warning-sign" style="margin-top:6px; opacity:.5;"></i> We're sorry, but something went wrong.</h3>
29
- <p class="muted">The developer of this app has been notified.</p>
30
-
31
- <p><button type="button" value ="back" onClick="window.history.back();" class='btn btn-primary'><i class="icon-chevron-left" style="opacity:.25"></i> Back to the app</button></p>
32
-
33
- </div>
34
-
35
- <footer>
36
- <p>A Shopify app by (company name here)</p>
37
- </footer>
38
- </div> <!-- /container -->
39
- </body>
40
- </html>
@@ -1,17 +0,0 @@
1
- require 'rails'
2
-
3
- class ShopifyApp::Railtie < ::Rails::Railtie
4
-
5
- config.before_configuration do
6
- config.shopify = ShopifyApp.configuration
7
- end
8
-
9
- initializer "shopify_app.action_controller_integration" do
10
- ActionController::Base.send :include, ShopifyApp::LoginProtection
11
- ActionController::Base.send :helper_method, :shop_session
12
- end
13
-
14
- initializer "shopify_app.setup_session" do
15
- ShopifyApp.setup_session
16
- end
17
- end
@@ -1,8 +0,0 @@
1
- common:
2
- api_key: should never see this api key value
3
- secret: should never see this secret value
4
-
5
- development:
6
- api_key: development key
7
- secret: development secret
8
- myshopify_domain: myshopify.com
@@ -1 +0,0 @@
1
- common:
@@ -1,4 +0,0 @@
1
- common:
2
- api_key: api key from other file
3
- secret: secret from other file
4
- myshopify_domain: example.com
@@ -1,4 +0,0 @@
1
- common:
2
- api_key: api key from default file
3
- secret: secret from default file
4
- myshopify_domain: myshopify.com
@@ -1,91 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ConfigurationTest < Minitest::Test
4
- def setup
5
- Rails.stubs(:env).returns('development')
6
- Rails.stubs(:root).returns(File.expand_path('../..', File.dirname(__FILE__)))
7
- end
8
-
9
- def config_file(filename)
10
- filepath = File.expand_path("../../config/#{filename}", File.dirname(__FILE__))
11
- end
12
-
13
- def test_define_method_creates_readers
14
- config = ShopifyApp::Configuration.new
15
- config.respond_to?(:api_key)
16
- config.respond_to?(:secret)
17
- config.respond_to?(:myshopify_domain)
18
- end
19
-
20
- def test_defaults_to_empty_string
21
- config = ShopifyApp::Configuration.new(config_file: config_file('empty_config_file.yml'))
22
-
23
- assert_equal '', config.api_key
24
- assert_equal '', config.secret
25
- assert_equal '', config.myshopify_domain
26
- end
27
-
28
- def test_environment_has_precedence_over_common
29
- config = ShopifyApp::Configuration.new(config_file: config_file('development_config_file.yml'))
30
-
31
- assert_equal 'development key', config.api_key
32
- assert_equal 'development secret', config.secret
33
- assert_equal 'myshopify.com', config.myshopify_domain
34
- end
35
-
36
- def test_rails_has_precedence_over_environment
37
- config = ShopifyApp::Configuration.new(config_file: config_file('development_config_file.yml'))
38
-
39
- assert_equal 'development key', config.api_key
40
- assert_equal 'development secret', config.secret
41
- assert_equal 'myshopify.com', config.myshopify_domain
42
-
43
- config.api_key = 'rails key'
44
- config.secret = 'rails secret'
45
- config.myshopify_domain = 'example.com'
46
-
47
- assert_equal 'rails key', config.api_key
48
- assert_equal 'rails secret', config.secret
49
- assert_equal 'example.com', config.myshopify_domain
50
- end
51
-
52
- def test_env_has_precedence_over_rails
53
- config = ShopifyApp::Configuration.new
54
- config.api_key = 'rails key'
55
- config.secret = 'rails secret'
56
- config.myshopify_domain = 'myshopify.com'
57
-
58
- assert_equal 'rails key', config.api_key
59
- assert_equal 'rails secret', config.secret
60
- assert_equal 'myshopify.com', config.myshopify_domain
61
-
62
- ENV.expects(:[]).with('SHOPIFY_APP_API_KEY').returns('env key')
63
- ENV.expects(:[]).with('SHOPIFY_APP_SECRET').returns('env secret')
64
- ENV.expects(:[]).with('SHOPIFY_APP_MYSHOPIFY_DOMAIN').returns('example.com')
65
-
66
- assert_equal 'env key', config.api_key
67
- assert_equal 'env secret', config.secret
68
- assert_equal 'example.com', config.myshopify_domain
69
- end
70
-
71
- def test_reads_config_from_default_config_file
72
- config = ShopifyApp::Configuration.new
73
- assert_equal 'api key from default file', config.api_key
74
- assert_equal 'secret from default file', config.secret
75
- assert_equal 'myshopify.com', config.myshopify_domain
76
- end
77
-
78
- def test_reads_config_from_specified_config_file
79
- config = ShopifyApp::Configuration.new(config_file: config_file('other_config_file.yml'))
80
- assert_equal 'api key from other file', config.api_key
81
- assert_equal 'secret from other file', config.secret
82
- assert_equal 'example.com', config.myshopify_domain
83
- end
84
-
85
- def test_handles_missing_config_file
86
- config = ShopifyApp::Configuration.new(config_file: config_file('missing_config_file.yml'))
87
- assert_equal '', config.api_key
88
- assert_equal '', config.secret
89
- assert_equal '', config.myshopify_domain
90
- end
91
- end
@@ -1,70 +0,0 @@
1
- require 'test_helper'
2
-
3
- class TestSessionStore
4
- attr_reader :storage
5
- def initialize
6
- @storage = []
7
- end
8
-
9
- def retrieve(id)
10
- storage[id]
11
- end
12
-
13
- def store(session)
14
- id = storage.length
15
- storage[id] = session
16
- id
17
- end
18
- end
19
-
20
- class TestSessionStoreClass
21
- def self.store(session)
22
- end
23
-
24
- def self.retrieve(id)
25
- end
26
- end
27
-
28
- class ShopifySessionRepositoryTest < Minitest::Test
29
- attr_reader :session_store, :session
30
- def setup
31
- @session_store = TestSessionStore.new
32
- @session = ShopifyAPI::Session.new('shop.myshopify.com', 'abracadabra')
33
- ShopifySessionRepository.storage = session_store
34
- end
35
-
36
- def teardown
37
- ShopifySessionRepository.storage = nil
38
- end
39
-
40
- def test_adding_a_session_to_the_repository
41
- assert_equal 0, ShopifySessionRepository.store(session)
42
- assert_equal session, session_store.retrieve(0)
43
- end
44
-
45
- def test_retrieving_a_session_from_the_repository
46
- session_store.storage[9] = session
47
- assert_equal session, ShopifySessionRepository.retrieve(9)
48
- end
49
-
50
- def test_retrieving_a_session_for_an_id_that_does_not_exist
51
- ShopifySessionRepository.store(session)
52
- assert !ShopifySessionRepository.retrieve(100), "The session with id 100 should not exist in the Repository"
53
- end
54
-
55
- def test_retrieving_a_session_for_a_misconfigured_shops_repository
56
- ShopifySessionRepository.storage = nil
57
- assert_raises ShopifySessionRepository::ConfigurationError do
58
- ShopifySessionRepository.retrieve(0)
59
- end
60
-
61
- assert_raises ShopifySessionRepository::ConfigurationError do
62
- ShopifySessionRepository.store(session)
63
- end
64
- end
65
-
66
- def test_accepts_a_string_and_constantizes_it
67
- ShopifySessionRepository.storage = 'TestSessionStoreClass'
68
- assert_equal TestSessionStoreClass, ShopifySessionRepository.storage
69
- end
70
- end