shopify_app 6.4.0 → 6.4.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: 9fdbb7537a49e1636bfed63000bcad7c99080486
4
- data.tar.gz: fd61682e6ec442674b7fd0e340ad25ea5c1a1ed1
3
+ metadata.gz: f747bbf0aada63a6273ade2d8a3e0f6cbd360b76
4
+ data.tar.gz: 7aa89ed00eec5148493ef63d46bfacdcee4cd9f3
5
5
  SHA512:
6
- metadata.gz: 02d042ee94d3c5a9beab3a1c2df59472b88acf4a415c70982689f28af8ff5f5552f28b16a24901afea9071a5753da6e27cd6ffb8b3e0d9675666748c109fb052
7
- data.tar.gz: 56d11b9ded7132222e769d140f60107c16ae67531dfbe3fa37351bdca0dd997eb64ff76666a2e7292e7b1076652d23669adeb270805e8db603f5720e4ab77d62
6
+ metadata.gz: 32bb09b8483aa1e7c6fc23d0216d9ab32a7f13a93b421cee0fe398f8f8bc33ade76ab5b08d7a1390670289c179bb836758c903f0b885bc7d5cae43b35f805538
7
+ data.tar.gz: 772be6347dd75c8d791a97a8080b4c519beb9ebeef0cfba97b916f2074022013223d01ff2753cbc8a40942d808afc17832e8fb4b03938fcf2223cdeb14d8155e
data/README.md CHANGED
@@ -156,7 +156,7 @@ The WebhooksManager uses ActiveJob, if ActiveJob is not configured then by defau
156
156
  ShopifyApp::SessionRepository
157
157
  -----------------------------
158
158
 
159
- `ShopifyApp::SessionRepository` allows you as a developer to define how your sessions are retrieved and stored for a shop. The `SessionRepository` is configured using the `config/initializers/shopify_session_repository.rb` file and can be set to any object the implements `self.store(shopify_session)` which stores the session and returns a unique identifier and `self.retrieve(id)` which returns a `ShopifyAPI::Session` for the passed id. See either the `InMemorySessionStore` or the `SessionStorage` module for examples.
159
+ `ShopifyApp::SessionRepository` allows you as a developer to define how your sessions are retrieved and stored for a shop. The `SessionRepository` is configured using the `config/initializers/shopify_session_repository.rb` file and can be set to any object that implements `self.store(shopify_session)` which stores the session and returns a unique identifier and `self.retrieve(id)` which returns a `ShopifyAPI::Session` for the passed id. See either the `InMemorySessionStore` or the `SessionStorage` module for examples.
160
160
 
161
161
  If you only run the install generator then by default you will have an in memory store but it **won't work** on multi-server environments including Heroku. If you ran all the generators including the shop_model generator then the Shop model itself will be the `SessionRepository`. If you look at the implementation of the generated shop model you'll see that this gem provides an activerecord mixin for the `SessionRepository`. You can use this mixin on any model that responds to `shopify_domain` and `shopify_token`.
162
162
 
@@ -0,0 +1,32 @@
1
+ require 'rails/generators/base'
2
+
3
+ module ShopifyApp
4
+ module Generators
5
+ class HomeControllerGenerator < Rails::Generators::Base
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ def create_home_controller
9
+ template 'home_controller.rb', 'app/controllers/home_controller.rb'
10
+ end
11
+
12
+ def create_home_index_view
13
+ copy_file 'index.html.erb', 'app/views/home/index.html.erb'
14
+ if embedded_app?
15
+ prepend_to_file(
16
+ 'app/views/home/index.html.erb',
17
+ File.read(File.expand_path(find_in_source_paths('shopify_app_ready_script.html.erb')))
18
+ )
19
+ end
20
+ end
21
+
22
+ def add_home_index_route
23
+ route "mount ShopifyApp::Engine, at: '/'"
24
+ route "root :to => 'home#index'"
25
+ end
26
+
27
+ def embedded_app?
28
+ ShopifyApp.configuration.embedded_app?
29
+ end
30
+ end
31
+ end
32
+ end
@@ -67,31 +67,12 @@ module ShopifyApp
67
67
  end
68
68
  end
69
69
 
70
- def create_home_controller
71
- template 'home_controller.rb', 'app/controllers/home_controller.rb'
72
- end
73
-
74
- def create_home_index_view
75
- copy_file 'index.html.erb', 'app/views/home/index.html.erb'
76
- if embedded_app?
77
- prepend_to_file(
78
- 'app/views/home/index.html.erb',
79
- File.read(File.expand_path(find_in_source_paths('shopify_app_ready_script.html.erb')))
80
- )
81
- end
82
- end
83
-
84
- def add_home_index_route
85
- route "mount ShopifyApp::Engine, at: '/'"
86
- route "root :to => 'home#index'"
87
- end
88
70
 
89
71
  private
90
72
 
91
73
  def embedded_app?
92
74
  opts[:embedded] != 'false'
93
75
  end
94
-
95
76
  end
96
77
  end
97
78
  end
@@ -9,6 +9,7 @@ module ShopifyApp
9
9
 
10
10
  def run_all_generators
11
11
  generate "shopify_app:install #{@opts.join(' ')}"
12
+ generate "shopify_app:home_controller"
12
13
  generate "shopify_app:shop_model"
13
14
 
14
15
  generate "shopify_app:controllers"
@@ -1,3 +1,3 @@
1
1
  module ShopifyApp
2
- VERSION = '6.4.0'
2
+ VERSION = '6.4.1'
3
3
  end
@@ -0,0 +1,50 @@
1
+ require 'test_helper'
2
+ require 'generators/shopify_app/home_controller/home_controller_generator'
3
+
4
+ class HomeControllerGeneratorTest < Rails::Generators::TestCase
5
+ tests ShopifyApp::Generators::HomeControllerGenerator
6
+ destination File.expand_path("../tmp", File.dirname(__FILE__))
7
+
8
+ setup do
9
+ ShopifyApp.configure do |config|
10
+ config.embedded_app = true
11
+ end
12
+
13
+ prepare_destination
14
+ provide_existing_application_file
15
+ provide_existing_routes_file
16
+ provide_existing_application_controller
17
+ end
18
+
19
+ test "creates the home controller" do
20
+ run_generator
21
+ assert_file "app/controllers/home_controller.rb"
22
+ end
23
+
24
+ test "creates the home index view with embedded options" do
25
+ run_generator
26
+ assert_file "app/views/home/index.html.erb" do |index|
27
+ assert_match "ShopifyApp.ready", index
28
+ end
29
+ end
30
+
31
+ test "creates the home index view with embedded false" do
32
+ stub_embedded_false
33
+ run_generator
34
+ assert_file "app/views/home/index.html.erb" do |index|
35
+ refute_match "ShopifyApp.ready", index
36
+ end
37
+ end
38
+
39
+ test "adds engine and home route to routes" do
40
+ run_generator
41
+ assert_file "config/routes.rb" do |routes|
42
+ assert_match "mount ShopifyApp::Engine, at: '/'", routes
43
+ assert_match "root :to => 'home#index'", routes
44
+ end
45
+ end
46
+
47
+ def stub_embedded_false
48
+ ShopifyApp.configuration.embedded_app = false
49
+ end
50
+ end
@@ -76,34 +76,6 @@ class InstallGeneratorTest < Rails::Generators::TestCase
76
76
  assert_file "app/views/layouts/_flash_messages.html.erb"
77
77
  end
78
78
 
79
- test "creates the home controller" do
80
- run_generator
81
- assert_file "app/controllers/home_controller.rb"
82
- end
83
-
84
- test "creates the home index view with embedded options" do
85
- run_generator
86
- assert_file "app/views/home/index.html.erb" do |index|
87
- assert_match "ShopifyApp.ready", index
88
- end
89
- end
90
-
91
- test "creates the home index view with embedded false" do
92
- stub_embedded_false
93
- run_generator
94
- assert_file "app/views/home/index.html.erb" do |index|
95
- refute_match "ShopifyApp.ready", index
96
- end
97
- end
98
-
99
- test "adds engine and home route to routes" do
100
- run_generator
101
- assert_file "config/routes.rb" do |routes|
102
- assert_match "mount ShopifyApp::Engine, at: '/'", routes
103
- assert_match "root :to => 'home#index'", routes
104
- end
105
- end
106
-
107
79
  private
108
80
 
109
81
  def stub_embedded_false
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify_app
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.4.0
4
+ version: 6.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-05 00:00:00.000000000 Z
11
+ date: 2016-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -149,14 +149,15 @@ files:
149
149
  - app/views/sessions/new.html.erb
150
150
  - config/routes.rb
151
151
  - lib/generators/shopify_app/controllers/controllers_generator.rb
152
+ - lib/generators/shopify_app/home_controller/home_controller_generator.rb
153
+ - lib/generators/shopify_app/home_controller/templates/home_controller.rb
154
+ - lib/generators/shopify_app/home_controller/templates/index.html.erb
155
+ - lib/generators/shopify_app/home_controller/templates/shopify_app_ready_script.html.erb
152
156
  - lib/generators/shopify_app/install/install_generator.rb
153
157
  - lib/generators/shopify_app/install/templates/_flash_messages.html.erb
154
158
  - lib/generators/shopify_app/install/templates/embedded_app.html.erb
155
- - lib/generators/shopify_app/install/templates/home_controller.rb
156
- - lib/generators/shopify_app/install/templates/index.html.erb
157
159
  - lib/generators/shopify_app/install/templates/omniauth.rb
158
160
  - lib/generators/shopify_app/install/templates/shopify_app.rb
159
- - lib/generators/shopify_app/install/templates/shopify_app_ready_script.html.erb
160
161
  - lib/generators/shopify_app/install/templates/shopify_provider.rb
161
162
  - lib/generators/shopify_app/install/templates/shopify_session_repository.rb
162
163
  - lib/generators/shopify_app/routes/routes_generator.rb
@@ -204,6 +205,7 @@ files:
204
205
  - test/dummy/config/routes.rb
205
206
  - test/dummy/config/secrets.yml
206
207
  - test/generators/controllers_generator_test.rb
208
+ - test/generators/home_controller_generator_test.rb
207
209
  - test/generators/install_generator_test.rb
208
210
  - test/generators/routes_generator_test.rb
209
211
  - test/generators/shop_model_generator_test.rb