intro 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -4
  3. data/app/controllers/intro/tours_controller.rb +2 -1
  4. data/app/helpers/intro/application_helper.rb +0 -6
  5. data/app/views/layouts/intro/admin/application.html.erb +2 -2
  6. data/lib/generators/intro/templates/config/initializers/intro.rb.erb +4 -0
  7. data/lib/intro/configuration.rb +10 -0
  8. data/lib/intro/helpers/view_helper.rb +5 -2
  9. data/lib/intro/version.rb +1 -1
  10. data/spec/controllers/intro_admin_images_controller_spec.rb +3 -3
  11. data/spec/controllers/intro_admin_sessions_controller_spec.rb +7 -7
  12. data/spec/controllers/intro_admin_tours_controller_spec.rb +30 -30
  13. data/spec/controllers/intro_tours_controller_spec.rb +58 -58
  14. data/spec/dummy/db/test.sqlite3 +0 -0
  15. data/spec/dummy/log/test.log +16544 -0
  16. data/spec/dummy/public/uploads/intro/20201231/1609423341_QU0t0H4g.png +0 -0
  17. data/spec/dummy/public/uploads/intro/20201231/1609423496_gGoMcWZq.png +0 -0
  18. data/spec/dummy/public/uploads/intro/20201231/1609423514_DZSt9xbz.png +0 -0
  19. data/spec/dummy/public/uploads/intro/20201231/1609423672_PfpDts7p.png +0 -0
  20. data/spec/dummy/public/uploads/intro/20201231/1609423696_gvmq59Gj.png +0 -0
  21. data/spec/dummy/public/uploads/intro/20201231/1609423738_gRF8Qihc.png +0 -0
  22. data/spec/dummy/public/uploads/intro/20201231/1609423803_Tng8_Lmy.png +0 -0
  23. data/spec/dummy/public/uploads/intro/20201231/1609423857_TBa7HIyO.png +0 -0
  24. data/spec/dummy/public/uploads/intro/20201231/1609423929_yHAO4SOj.png +0 -0
  25. data/spec/dummy/public/uploads/intro/20201231/1609423947_e2Gm5aL8.png +0 -0
  26. data/spec/spec_helper.rb +3 -0
  27. metadata +37 -3
  28. data/spec/dummy/spec/models/user_spec.rb +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fec5807a475ade36af89cb12349c817841b704ad4ef7f9fa7d17b1bc588132ab
4
- data.tar.gz: 84c03af6a56bb157effb5e20e64d884c7d244b017dffbb25c35ca4edf5ab3689
3
+ metadata.gz: 57747ce7fbdd5c63d6a84e1429c5ff9f9f6f6ab9000974686e1679d53c35552c
4
+ data.tar.gz: cb9c17be30ed613bc6dba8d26fc69465d7146fe4d4b66e4a801bad0475296d9d
5
5
  SHA512:
6
- metadata.gz: 1fe27f11bd3b5f577dfc28c28649ab52ac918a94dda0cd75ece9e675f62c17b8d3745ce0f3114f7484cd2ca97b273070834ba00c1846c602bb39bfd5a971e2bc
7
- data.tar.gz: 18b2746ce0649f90485bab3b307188d197630f2c6fdc77cc4a59239982347f07c0aad8a9693ae68b256900784e5437d8b88adc7b4d87d6753c171362c62cc989
6
+ metadata.gz: 9cd050d04fc93989e6811e0879f5f8778c8a902bbf3a2e79e0db912c76b4a11582cb6306f7770514a46fedb027f57ed7e193e0bec49986fc2e36829f94f2ab1f
7
+ data.tar.gz: 23f425e999abdd82988b8f18dfe2ed02cd6b6a8c4ff111020b08e9c149f2285cb0de47e8a5474f0fcbe587f5fddb797a46990876860fbed3cb0e0549fde591a3
data/README.md CHANGED
@@ -95,14 +95,17 @@ app/javascript/packs/intro/custom.js
95
95
 
96
96
  Change them for your need.
97
97
 
98
- Last, import custom packs javascript into `intro_tag` like this:
98
+ Last, enable `custom_assets` in `config/initializers/intro.rb` like this:
99
99
 
100
100
  ```
101
- <%= intro_tags do %>
102
- <%= javascript_pack_tag('intro/custom') %>
103
- <% end %>
101
+ # config/initializers/intro.rb
102
+
103
+ # override intro tour styles
104
+ self.custom_assets = true # or 'intro/custom'
104
105
  ```
105
106
 
107
+ It will bring intro/custom assets into `intro_tags`
108
+
106
109
  ### Configuring intro
107
110
 
108
111
  see `config/initializers/intro.rb` for detail configuration.
@@ -28,7 +28,8 @@ module Intro
28
28
 
29
29
  def record
30
30
  history = Intro::TourHistory.with_user_and_tour(current_user, @tour).first_or_initialize
31
- history.increment!(:touch_count)
31
+ history.increment(:touch_count)
32
+ history.save
32
33
  render json: { message: t('intro.admin.update_success') }
33
34
  end
34
35
 
@@ -1,11 +1,5 @@
1
1
  module Intro
2
2
  module ApplicationHelper
3
- include ::Webpacker::Helper
4
-
5
- def current_webpacker_instance
6
- Intro.webpacker
7
- end
8
-
9
3
  def sign_out_admin_intro_path
10
4
  Intro.config.sign_out_admin_path.presence || sign_out_admin_sessions_path
11
5
  end
@@ -3,8 +3,8 @@
3
3
  <head>
4
4
  <meta charset='utf-8'>
5
5
  <title><%= [yield(:doc_title).presence, t('intro.admin.title')].compact.join(' · ') %></title>
6
- <%= stylesheet_pack_tag "intro/admin/application", media: "all" %>
7
- <%= javascript_pack_tag "intro/admin/application" %>
6
+ <%= intro_webpacker_helper.stylesheet_pack_tag "intro/admin/application", media: "all" %>
7
+ <%= intro_webpacker_helper.javascript_pack_tag "intro/admin/application" %>
8
8
  <%= csrf_meta_tags %>
9
9
  <%= yield(:head_content) %>
10
10
  </head>
@@ -33,4 +33,8 @@ Intro.configure do
33
33
 
34
34
  # display tour without signing in, default: false
35
35
  # self.visible_without_signing_in = true
36
+
37
+ # override intro tour styles, default: false
38
+ # self.custom_assets = true
39
+ # self.custom_assets = 'intro/custom'
36
40
  end
@@ -36,6 +36,9 @@ module Intro
36
36
  # display tour without signing in, default: false
37
37
  attr_accessor :visible_without_signing_in
38
38
 
39
+ # override intro tour styles, default: false
40
+ attr_accessor :custom_assets
41
+
39
42
  def initialize
40
43
  @enable = true
41
44
 
@@ -46,10 +49,17 @@ module Intro
46
49
  @max_touch_count = 1
47
50
 
48
51
  @carrierwave_storage = :file
52
+
53
+ @custom_assets = false
49
54
  end
50
55
 
51
56
  def admin_username_digest
52
57
  @admin_username_digest ||= Digest::SHA1.hexdigest(admin_username.to_s)
53
58
  end
59
+
60
+ def custom_assets_with_default
61
+ return unless custom_assets
62
+ custom_assets.is_a?(String) ? custom_assets : 'intro/custom'
63
+ end
54
64
  end
55
65
  end
@@ -1,7 +1,7 @@
1
1
  module Intro
2
2
  module Helpers
3
3
  module ViewHelper
4
- def intro_tags(options = {}, &block)
4
+ def intro_tags(options = {})
5
5
  return unless options[:enable] || enable_intro?
6
6
 
7
7
  intro_options = {
@@ -16,11 +16,14 @@ module Intro
16
16
  shepherd_options: options[:shepherd] || {}
17
17
  }.freeze
18
18
 
19
+ custom_assets = Intro.config.custom_assets_with_default
20
+ custom_assets_tag = "#{javascript_pack_tag(custom_assets)} #{stylesheet_pack_tag(custom_assets)}" if custom_assets
21
+
19
22
  <<-HTML.html_safe
20
23
  <script>window._intro = #{ intro_options.to_json }</script>
21
24
  #{intro_webpacker_helper.javascript_pack_tag('intro/application')}
22
25
  #{intro_webpacker_helper.stylesheet_pack_tag('intro/application')}
23
- #{capture(&block) if block_given?}
26
+ #{custom_assets_tag}
24
27
  HTML
25
28
  end
26
29
 
@@ -1,3 +1,3 @@
1
1
  module Intro
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -3,7 +3,7 @@ require 'rails_helper'
3
3
  describe Intro::Admin::ImagesController, type: :controller do
4
4
  routes { Intro::Engine.routes }
5
5
 
6
- let(:image) { fixture_file_upload('ruby.png', 'image/png') }
6
+ let(:image) { Rack::Test::UploadedFile.new('spec/fixtures/ruby.png', 'image/png') }
7
7
 
8
8
  context 'unauthorized' do
9
9
  it 'should get unauthorized status' do
@@ -30,9 +30,9 @@ describe Intro::Admin::ImagesController, type: :controller do
30
30
  it 'should successfully upload with image' do
31
31
  self.class.fixture_path = File.expand_path('../../fixtures', __FILE__) if self.class.respond_to?(:fixture_path) && !self.class.fixture_path
32
32
 
33
- post :create, image: image, format: :json
33
+ post :create, params: { image: image }, format: :json
34
34
 
35
- expect(response).to be_success
35
+ expect(response.successful?).to be true
36
36
  expect(json_body[:data]).not_to be_nil
37
37
  expect(json_body[:data][:url]).not_to be_nil
38
38
  end
@@ -6,7 +6,7 @@ describe Intro::Admin::SessionsController, type: :controller do
6
6
  context '#new' do
7
7
  it 'should has same action' do
8
8
  get :new
9
- expect(response).to be_success
9
+ expect(response.successful?).to be true
10
10
  end
11
11
 
12
12
  it 'should render same template' do
@@ -17,7 +17,7 @@ describe Intro::Admin::SessionsController, type: :controller do
17
17
 
18
18
  context '#create' do
19
19
  it 'should be authenticated with valid intro admin account' do
20
- post :create, { username: Intro.config.admin_username, password: Intro.config.admin_password }
20
+ post :create, params: { username: Intro.config.admin_username, password: Intro.config.admin_password }
21
21
 
22
22
  expect(flash[:alert]).to be_nil
23
23
  expect(response).to have_http_status(:redirect)
@@ -25,12 +25,12 @@ describe Intro::Admin::SessionsController, type: :controller do
25
25
  end
26
26
 
27
27
  it 'should be unauthenticated with invalid admin username or password' do
28
- post :create, { username: 'test_user', password: Intro.config.admin_password }
28
+ post :create, params: { username: 'test_user', password: Intro.config.admin_password }
29
29
 
30
30
  expect(flash[:alert]).not_to be_empty
31
31
  expect(response).to render_template(:new)
32
32
 
33
- post :create, { username: Intro.config.admin_username, password: 'qwe123' }
33
+ post :create, params: { username: Intro.config.admin_username, password: 'qwe123' }
34
34
 
35
35
  expect(flash[:alert]).not_to be_empty
36
36
  expect(response).to render_template(:new)
@@ -40,7 +40,7 @@ describe Intro::Admin::SessionsController, type: :controller do
40
40
  revert_intro_config do
41
41
  Intro.config.admin_authenticate_account = -> { params[:username] == 'root' && params[:password] == 'qwe123' }
42
42
 
43
- post :create, { username: 'root', password: 'qwe123' }
43
+ post :create, params: { username: 'root', password: 'qwe123' }
44
44
 
45
45
  expect(flash[:alert]).to be_nil
46
46
  expect(response).to have_http_status(:redirect)
@@ -52,7 +52,7 @@ describe Intro::Admin::SessionsController, type: :controller do
52
52
  revert_intro_config do
53
53
  Intro.config.admin_authenticate_account = -> { params[:username] == 'root' && params[:password] == 'qwe123' }
54
54
 
55
- post :create, { username: 'test', password: 'test123' }
55
+ post :create, params: { username: 'test', password: 'test123' }
56
56
 
57
57
  expect(flash[:alert]).not_to be_empty
58
58
  expect(response).to render_template(:new)
@@ -62,7 +62,7 @@ describe Intro::Admin::SessionsController, type: :controller do
62
62
 
63
63
  context '#sign_out' do
64
64
  it 'should clear session for signed user' do
65
- post :create, { username: Intro.config.admin_username, password: Intro.config.admin_password }
65
+ post :create, params: { username: Intro.config.admin_username, password: Intro.config.admin_password }
66
66
  expect(session[:intro_admin_authenticated]).not_to be_nil
67
67
 
68
68
  delete :sign_out
@@ -22,19 +22,19 @@ describe Intro::Admin::ToursController, type: :controller do
22
22
  post :attempt
23
23
  expect(response).to redirect_to unauthenticated_path
24
24
 
25
- get :show, id: 0
25
+ get :show, params: {id: 0}
26
26
  expect(response).to redirect_to unauthenticated_path
27
27
 
28
- get :edit, id: 0
28
+ get :edit, params: {id: 0}
29
29
  expect(response).to redirect_to unauthenticated_path
30
30
 
31
- put :update, id: 0
31
+ put :update, params: {id: 0}
32
32
  expect(response).to redirect_to unauthenticated_path
33
33
 
34
- delete :destroy, id: 0
34
+ delete :destroy, params: {id: 0}
35
35
  expect(response).to redirect_to unauthenticated_path
36
36
 
37
- put :publish, id: 0
37
+ put :publish, params: {id: 0}
38
38
  expect(response).to redirect_to unauthenticated_path
39
39
  end
40
40
 
@@ -59,7 +59,7 @@ describe Intro::Admin::ToursController, type: :controller do
59
59
  context '#index' do
60
60
  it 'should render index template' do
61
61
  get :index
62
- expect(response).to be_success
62
+ expect(response.successful?).to be true
63
63
  expect(response).to render_template(:index)
64
64
  expect(response).to have_http_status(:success)
65
65
  end
@@ -74,7 +74,7 @@ describe Intro::Admin::ToursController, type: :controller do
74
74
  context '#new' do
75
75
  it 'should render new template' do
76
76
  get :new
77
- expect(response).to be_success
77
+ expect(response.successful?).to be true
78
78
  expect(response).to render_template(:new)
79
79
  expect(response).to have_http_status(:success)
80
80
  end
@@ -88,13 +88,13 @@ describe Intro::Admin::ToursController, type: :controller do
88
88
 
89
89
  context '#create' do
90
90
  it 'should successfully create tour with ident' do
91
- expect { post :create, tour: { ident: random_string } }.to change { Intro::Tour.count }.by(1)
91
+ expect { post :create, params: { tour: { ident: random_string } } }.to change { Intro::Tour.count }.by(1)
92
92
  expect(response).to have_http_status(:redirect)
93
93
  expect(response).to redirect_to admin_tour_path(assigns(:tour))
94
94
  end
95
95
 
96
96
  it 'failed to create tour without ident' do
97
- expect { post :create, tour: {} }.to change { Intro::Tour.count }.by(0)
97
+ expect { post :create, params: { tour: {} } }.to change { Intro::Tour.count }.by(0)
98
98
  expect(assigns(:tour)).not_to be_nil
99
99
  expect(response).to render_template(:new)
100
100
  expect(response).to have_http_status(:success)
@@ -103,7 +103,7 @@ describe Intro::Admin::ToursController, type: :controller do
103
103
 
104
104
  context '#route' do
105
105
  it 'should get route with path' do
106
- get :route, path: '/intro/admin/tours?xyz=1', format: :json
106
+ get :route, params: { path: '/intro/admin/tours?xyz=1' }, format: :json
107
107
 
108
108
  expect(response).to have_http_status(:success)
109
109
  expect(response.body).not_to be_nil
@@ -117,7 +117,7 @@ describe Intro::Admin::ToursController, type: :controller do
117
117
 
118
118
  context '#attempt' do
119
119
  it 'should get tour options with options' do
120
- post :attempt, tour: { options: { title: 'title', content: 'content' } }, format: :json
120
+ post :attempt, params: { tour: { options: { title: 'title', content: 'content' } } }, format: :json
121
121
 
122
122
  expect(response).to have_http_status(:success)
123
123
  expect(json_body[:data]).not_to be_nil
@@ -127,7 +127,7 @@ describe Intro::Admin::ToursController, type: :controller do
127
127
  end
128
128
 
129
129
  it 'should not get tour options without options' do
130
- post :attempt, tour: {}, format: :json
130
+ post :attempt, params: { tour: {} }, format: :json
131
131
 
132
132
  expect(response).to have_http_status(:success)
133
133
  expect(json_body[:data]).not_to be_nil
@@ -137,22 +137,22 @@ describe Intro::Admin::ToursController, type: :controller do
137
137
 
138
138
  context 'without tour' do
139
139
  it 'should get not found' do
140
- get :show, id: 0
140
+ get :show, params: {id: 0}
141
141
  expect(response).to redirect_to admin_tours_path
142
142
 
143
- get :show, id: 0, format: :json
143
+ get :show, params: {id: 0}, format: :json
144
144
  expect(response).to have_http_status(:not_found)
145
145
 
146
- get :edit, id: 0
146
+ get :edit, params: {id: 0}
147
147
  expect(response).to redirect_to admin_tours_path
148
148
 
149
- put :update, id: 0
149
+ put :update, params: {id: 0}
150
150
  expect(response).to redirect_to admin_tours_path
151
151
 
152
- delete :destroy, id: 0
152
+ delete :destroy, params: {id: 0}
153
153
  expect(response).to redirect_to admin_tours_path
154
154
 
155
- put :publish, id: 0
155
+ put :publish, params: {id: 0}
156
156
  expect(response).to redirect_to admin_tours_path
157
157
  end
158
158
  end
@@ -160,7 +160,7 @@ describe Intro::Admin::ToursController, type: :controller do
160
160
  context 'with tour' do
161
161
  context '#show' do
162
162
  it 'should render edit template' do
163
- get :show, id: tour.id
163
+ get :show, params: { id: tour.id }
164
164
  expect(assigns(:tour)).not_to be_nil
165
165
  expect(response).to render_template(:edit)
166
166
  expect(response).to have_http_status(:success)
@@ -169,7 +169,7 @@ describe Intro::Admin::ToursController, type: :controller do
169
169
 
170
170
  context '#edit' do
171
171
  it 'should render edit template' do
172
- get :show, id: tour.id
172
+ get :show, params: { id: tour.id }
173
173
  expect(assigns(:tour)).not_to be_nil
174
174
  expect(response).to render_template(:edit)
175
175
  expect(response).to have_http_status(:success)
@@ -178,35 +178,35 @@ describe Intro::Admin::ToursController, type: :controller do
178
178
 
179
179
  context '#update' do
180
180
  it 'should render edit template' do
181
- put :update, id: tour.id, tour: { ident: "new-#{tour.ident}" }
181
+ put :update, params: { id: tour.id, tour: { ident: "new-#{tour.ident}" } }
182
182
  expect(assigns(:tour)).not_to be_nil
183
183
  expect(response).to render_template(:edit)
184
184
  end
185
185
 
186
186
  it 'should successfully update tour with valid ident' do
187
187
  new_ident = "new-#{tour.ident}"
188
- put :update, id: tour.id, tour: { ident: new_ident }
188
+ put :update, params: { id: tour.id, tour: { ident: new_ident } }
189
189
  expect(assigns(:tour).previous_changes).to have_key('ident')
190
190
  expect(assigns(:tour).ident).to eq new_ident
191
191
  end
192
192
 
193
193
  it 'should successfully update tour with valid controller' do
194
194
  new_controller = "new-#{tour.controller_path}"
195
- put :update, id: tour.id, tour: { controller_path: new_controller }
195
+ put :update, params: { id: tour.id, tour: { controller_path: new_controller } }
196
196
  expect(assigns(:tour).previous_changes).to have_key('controller_path')
197
197
  expect(assigns(:tour).controller_path).to eq new_controller
198
198
  end
199
199
 
200
200
  it 'should successfully update tour with valid action' do
201
201
  new_action = "new-#{tour.action_name}"
202
- put :update, id: tour.id, tour: { action_name: new_action }
202
+ put :update, params: { id: tour.id, tour: { action_name: new_action } }
203
203
  expect(assigns(:tour).previous_changes).to have_key('action_name')
204
204
  expect(assigns(:tour).action_name).to eq new_action
205
205
  end
206
206
 
207
207
  it 'should successfully update tour with valid options' do
208
208
  options = { title: 'title' }
209
- put :update, id: tour.id, tour: { options: options }
209
+ put :update, params: { id: tour.id, tour: { options: options } }
210
210
  expect(assigns(:tour).previous_changes).to have_key('options')
211
211
  expect(assigns(:tour).options).not_to be_nil
212
212
  expect(assigns(:tour).options['title']).to eq 'title'
@@ -214,7 +214,7 @@ describe Intro::Admin::ToursController, type: :controller do
214
214
 
215
215
  it 'should successfully update tour with valid route' do
216
216
  route = { simple: '/' }
217
- put :update, id: tour.id, tour: { route: route }
217
+ put :update, params: { id: tour.id, tour: { route: route } }
218
218
  expect(assigns(:tour).previous_changes).to have_key('route')
219
219
  expect(assigns(:tour).route).not_to be_nil
220
220
  expect(assigns(:tour).route['simple']).to eq '/'
@@ -222,7 +222,7 @@ describe Intro::Admin::ToursController, type: :controller do
222
222
 
223
223
  it 'should successfully update tour with valid expired time' do
224
224
  new_expired_at = 1.day.since.strftime('%F')
225
- put :update, id: tour.id, tour: { expired_at: new_expired_at }
225
+ put :update, params: { id: tour.id, tour: { expired_at: new_expired_at } }
226
226
  expect(assigns(:tour).previous_changes).to have_key('expired_at')
227
227
  expect(assigns(:tour).expired_at.strftime('%F')).to eq new_expired_at
228
228
  end
@@ -230,7 +230,7 @@ describe Intro::Admin::ToursController, type: :controller do
230
230
 
231
231
  context '#destroy' do
232
232
  it 'should successfully destroy tour' do
233
- delete :destroy, id: tour.id
233
+ delete :destroy, params: { id: tour.id }
234
234
  expect(assigns(:tour).destroyed?).to be true
235
235
  expect(response).to redirect_to admin_tours_path
236
236
  end
@@ -238,12 +238,12 @@ describe Intro::Admin::ToursController, type: :controller do
238
238
 
239
239
  context '#publish' do
240
240
  it 'should get published tour with active params' do
241
- put :publish, id: tour.id, published: 'true'
241
+ put :publish, params: { id: tour.id, published: 'true' }
242
242
  expect(assigns(:tour).published).to be true
243
243
  end
244
244
 
245
245
  it 'should get unpublished tour with inactive params' do
246
- put :publish, id: tour.id, published: 'false'
246
+ put :publish, params: { id: tour.id, published: 'false' }
247
247
  expect(assigns(:tour).published).to be false
248
248
  end
249
249
  end
@@ -15,7 +15,7 @@ describe Intro::ToursController, type: :controller do
15
15
  it 'should get unauthorized response if disable `visible_without_signing_in`' do
16
16
  revert_intro_config do
17
17
  Intro.config.visible_without_signing_in = false
18
- get :index, controller_path: 'x', action_name: 'x', format: :json
18
+ get :index, params: { controller_path: 'x', action_name: 'x' }, format: :json
19
19
  expect(response).to have_http_status(:unauthorized)
20
20
  end
21
21
  end
@@ -23,7 +23,7 @@ describe Intro::ToursController, type: :controller do
23
23
  it 'should get ok response if enable `visible_without_signing_in`' do
24
24
  revert_intro_config do
25
25
  Intro.config.visible_without_signing_in = true
26
- get :index, controller_path: 'x', action_name: 'x', format: :json
26
+ get :index, params: { controller_path: 'x', action_name: 'x' }, format: :json
27
27
  expect(response).to have_http_status(:ok)
28
28
  end
29
29
  end
@@ -33,8 +33,8 @@ describe Intro::ToursController, type: :controller do
33
33
  Intro.config.visible_without_signing_in = true
34
34
  published_tour
35
35
 
36
- get :index, controller_path: 'intro/admin/tours', action_name: 'new'
37
- expect(response).to be_success
36
+ get :index, params: { controller_path: 'intro/admin/tours', action_name: 'new' }
37
+ expect(response.successful?).to be true
38
38
  expect(json_body).not_to be_nil
39
39
  expect(json_body[:data]).to be_empty
40
40
  end
@@ -46,8 +46,8 @@ describe Intro::ToursController, type: :controller do
46
46
  published_tour.options['not_sign_visible'] = true
47
47
  published_tour.save
48
48
 
49
- get :index, controller_path: 'intro/admin/tours', action_name: 'new'
50
- expect(response).to be_success
49
+ get :index, params: { controller_path: 'intro/admin/tours', action_name: 'new' }
50
+ expect(response.successful?).to be true
51
51
  expect(json_body).not_to be_nil
52
52
  expect(json_body[:data]).not_to be_empty
53
53
  end
@@ -56,7 +56,7 @@ describe Intro::ToursController, type: :controller do
56
56
 
57
57
  context '#record' do
58
58
  it 'should get unauthorized response' do
59
- post :record, id: 0
59
+ post :record, params: {id: 0}
60
60
  expect(response).to have_http_status(:unauthorized)
61
61
  end
62
62
  end
@@ -77,8 +77,8 @@ describe Intro::ToursController, type: :controller do
77
77
  end
78
78
 
79
79
  it 'should get empty data with invalid controller, action' do
80
- get :index, controller_path: 'x', action_name: 'x', format: :json
81
- expect(response).to be_success
80
+ get :index, params: { controller_path: 'x', action_name: 'x' }, format: :json
81
+ expect(response.successful?).to be true
82
82
  expect(json_body).not_to be_nil
83
83
  expect(json_body[:data]).to be_empty
84
84
  end
@@ -86,8 +86,8 @@ describe Intro::ToursController, type: :controller do
86
86
  it 'should get empty data with valid controller, action without published tour' do
87
87
  unpublished_tour
88
88
 
89
- get :index, controller_path: 'intro/admin/tours', action_name: 'new'
90
- expect(response).to be_success
89
+ get :index, params: { controller_path: 'intro/admin/tours', action_name: 'new' }
90
+ expect(response.successful?).to be true
91
91
  expect(json_body).not_to be_nil
92
92
  expect(json_body[:data]).to be_empty
93
93
  end
@@ -95,18 +95,18 @@ describe Intro::ToursController, type: :controller do
95
95
  it 'should get tours data with valid controller, action and published record' do
96
96
  published_tour
97
97
 
98
- get :index, controller_path: 'intro/admin/tours', action_name: 'new'
99
- expect(response).to be_success
98
+ get :index, params: { controller_path: 'intro/admin/tours', action_name: 'new' }
99
+ expect(response.successful?).to be true
100
100
  expect(json_body).not_to be_nil
101
101
  expect(json_body[:data]).not_to be_empty
102
102
  end
103
103
 
104
104
  it 'should get empty data with valid controller, action and expired time' do
105
- published_tour.update_attributes(expired_at: 1.day.ago)
105
+ published_tour.update(expired_at: 1.day.ago)
106
106
 
107
- get :index, controller_path: 'intro/admin/tours', action_name: 'new'
107
+ get :index, params: { controller_path: 'intro/admin/tours', action_name: 'new' }
108
108
 
109
- expect(response).to be_success
109
+ expect(response.successful?).to be true
110
110
  expect(json_body).not_to be_nil
111
111
  expect(json_body[:data]).to be_empty
112
112
  end
@@ -114,9 +114,9 @@ describe Intro::ToursController, type: :controller do
114
114
  it 'should get empty data with valid controller, action and max_touch_count' do
115
115
  published_tour.tour_histories.create(user_id: User.first_or_create.id, touch_count: Intro.config.max_touch_count)
116
116
 
117
- get :index, controller_path: 'intro/admin/tours', action_name: 'new'
117
+ get :index, params: { controller_path: 'intro/admin/tours', action_name: 'new' }
118
118
 
119
- expect(response).to be_success
119
+ expect(response.successful?).to be true
120
120
  expect(json_body).not_to be_nil
121
121
  expect(json_body[:data]).to be_empty
122
122
  end
@@ -124,89 +124,89 @@ describe Intro::ToursController, type: :controller do
124
124
  it 'should get tours data with valid controller, action without max_touch_count' do
125
125
  published_tour.tour_histories.create(user_id: User.first_or_create.id)
126
126
 
127
- get :index, controller_path: 'intro/admin/tours', action_name: 'new'
127
+ get :index, params: { controller_path: 'intro/admin/tours', action_name: 'new' }
128
128
 
129
- expect(response).to be_success
129
+ expect(response.successful?).to be true
130
130
  expect(json_body).not_to be_nil
131
131
  expect(json_body[:data]).not_to be_empty
132
132
  end
133
133
 
134
134
  it 'should get tours data with valid controller, action and same simple route on strict' do
135
- published_tour.update_attributes(route: { simple: '/intro/admin/tours/new', strict: true })
135
+ published_tour.update(route: { simple: '/intro/admin/tours/new', strict: true })
136
136
 
137
- get :index, controller_path: 'intro/admin/tours', action_name: 'new', original_url: '/intro/admin/tours/new'
138
- expect(response).to be_success
137
+ get :index, params: { controller_path: 'intro/admin/tours', action_name: 'new', original_url: '/intro/admin/tours/new' }
138
+ expect(response.successful?).to be true
139
139
  expect(json_body).not_to be_nil
140
140
  expect(json_body[:data]).not_to be_empty
141
141
 
142
- get :index, controller_path: 'intro/admin/tours', action_name: 'new', original_url: 'http://localhost:3000/intro/admin/tours/new'
142
+ get :index, params: { controller_path: 'intro/admin/tours', action_name: 'new', original_url: 'http://localhost:3000/intro/admin/tours/new' }
143
143
  expect(json_body).not_to be_nil
144
144
  expect(json_body[:data]).not_to be_empty
145
145
 
146
- published_tour.update_attributes(route: { simple: 'http://localhost:3000/intro/admin/tours/new' })
146
+ published_tour.update(route: { simple: 'http://localhost:3000/intro/admin/tours/new' })
147
147
 
148
- get :index, controller_path: 'intro/admin/tours', action_name: 'new', original_url: 'http://localhost:3000/intro/admin/tours/new'
148
+ get :index, params: { controller_path: 'intro/admin/tours', action_name: 'new', original_url: 'http://localhost:3000/intro/admin/tours/new' }
149
149
  expect(json_body).not_to be_nil
150
150
  expect(json_body[:data]).not_to be_empty
151
151
 
152
- published_tour.update_attributes(route: { simple: 'http://localhost:3000/intro/admin/tours/new?xyz=1' })
152
+ published_tour.update(route: { simple: 'http://localhost:3000/intro/admin/tours/new?xyz=1' })
153
153
 
154
- get :index, controller_path: 'intro/admin/tours', action_name: 'new', original_url: 'http://localhost:3000/intro/admin/tours/new?xyz=1'
154
+ get :index, params: { controller_path: 'intro/admin/tours', action_name: 'new', original_url: 'http://localhost:3000/intro/admin/tours/new?xyz=1' }
155
155
  expect(json_body).not_to be_nil
156
156
  expect(json_body[:data]).not_to be_empty
157
157
  end
158
158
 
159
159
  it 'should get empty data with valid controller, action without same simple route on strict' do
160
- published_tour.update_attributes(route: { simple: '/intro/admin/tours/new', strict: true })
160
+ published_tour.update(route: { simple: '/intro/admin/tours/new', strict: true })
161
161
 
162
- get :index, controller_path: 'intro/admin/tours', action_name: 'new', original_url: '/intro/admin/tours/new2'
163
- expect(response).to be_success
162
+ get :index, params: { controller_path: 'intro/admin/tours', action_name: 'new', original_url: '/intro/admin/tours/new2' }
163
+ expect(response.successful?).to be true
164
164
  expect(json_body).not_to be_nil
165
165
  expect(json_body[:data]).to be_empty
166
166
 
167
- get :index, controller_path: 'intro/admin/tours', action_name: 'new', original_url: 'http://localhost:3000/intro/admin/tours/new2'
167
+ get :index, params: { controller_path: 'intro/admin/tours', action_name: 'new', original_url: 'http://localhost:3000/intro/admin/tours/new2' }
168
168
  expect(json_body).not_to be_nil
169
169
  expect(json_body[:data]).to be_empty
170
170
 
171
- published_tour.update_attributes(route: { simple: 'http://localhost:3000/intro/admin/tours/new' })
171
+ published_tour.update(route: { simple: 'http://localhost:3000/intro/admin/tours/new' })
172
172
 
173
- get :index, controller_path: 'intro/admin/tours', action_name: 'new', original_url: 'http://localhost:3000/intro/admin/tours/new2'
173
+ get :index, params: { controller_path: 'intro/admin/tours', action_name: 'new', original_url: 'http://localhost:3000/intro/admin/tours/new2' }
174
174
  expect(json_body).not_to be_nil
175
175
  expect(json_body[:data]).to be_empty
176
176
 
177
- published_tour.update_attributes(route: { simple: 'http://localhost:3000/intro/admin/tours/new?xyz=1' })
177
+ published_tour.update(route: { simple: 'http://localhost:3000/intro/admin/tours/new?xyz=1' })
178
178
 
179
- get :index, controller_path: 'intro/admin/tours', action_name: 'new', original_url: 'http://localhost:3000/intro/admin/tours/new?xyz=2'
179
+ get :index, params: { controller_path: 'intro/admin/tours', action_name: 'new', original_url: 'http://localhost:3000/intro/admin/tours/new?xyz=2' }
180
180
  expect(json_body).not_to be_nil
181
181
  expect(json_body[:data]).to be_empty
182
182
  end
183
183
 
184
184
  it 'should get tours data with valid controller, action and path params' do
185
- published_tour.update_attributes(controller_path: 'intro/admin/tours', action_name: 'edit')
185
+ published_tour.update(controller_path: 'intro/admin/tours', action_name: 'edit')
186
186
 
187
- get :index, controller_path: 'intro/admin/tours', action_name: 'edit', original_url: '/intro/admin/tours/13/edit'
188
- expect(response).to be_success
187
+ get :index, params: { controller_path: 'intro/admin/tours', action_name: 'edit', original_url: '/intro/admin/tours/13/edit' }
188
+ expect(response.successful?).to be true
189
189
  expect(json_body).not_to be_nil
190
190
  expect(json_body[:data]).not_to be_empty
191
191
 
192
- published_tour.update_attributes(controller_path: 'intro/admin/tours', action_name: 'edit', route: { simple: '/intro/admin/tours/13/edit' })
192
+ published_tour.update(controller_path: 'intro/admin/tours', action_name: 'edit', route: { simple: '/intro/admin/tours/13/edit' })
193
193
 
194
- get :index, controller_path: 'intro/admin/tours', action_name: 'edit', original_url: '/intro/admin/tours/13/edit'
194
+ get :index, params: { controller_path: 'intro/admin/tours', action_name: 'edit', original_url: '/intro/admin/tours/13/edit' }
195
195
  expect(json_body).not_to be_nil
196
196
  expect(json_body[:data]).not_to be_empty
197
197
  end
198
198
 
199
199
  it 'should get empty data with valid controller, action without path params' do
200
- published_tour.update_attributes(controller_path: 'intro/admin/tours', action_name: 'edit')
200
+ published_tour.update(controller_path: 'intro/admin/tours', action_name: 'edit')
201
201
 
202
- get :index, controller_path: 'intro/admin/tours', action_name: 'edit', original_url: '/intro/admin/tours/13'
203
- expect(response).to be_success
202
+ get :index, params: {controller_path: 'intro/admin/tours', action_name: 'edit', original_url: '/intro/admin/tours/13'}
203
+ expect(response.successful?).to be true
204
204
  expect(json_body).not_to be_nil
205
205
  expect(json_body[:data]).to be_empty
206
206
 
207
- published_tour.update_attributes(controller_path: 'intro/admin/tours', action_name: 'edit', route: { simple: '/intro/admin/tours/13/edit' })
207
+ published_tour.update(controller_path: 'intro/admin/tours', action_name: 'edit', route: { simple: '/intro/admin/tours/13/edit' })
208
208
 
209
- get :index, controller_path: 'intro/admin/tours', action_name: 'edit', original_url: '/intro/admin/tours/13'
209
+ get :index, params: { controller_path: 'intro/admin/tours', action_name: 'edit', original_url: '/intro/admin/tours/13' }
210
210
  expect(json_body).not_to be_nil
211
211
  expect(json_body[:data]).to be_empty
212
212
  end
@@ -214,18 +214,18 @@ describe Intro::ToursController, type: :controller do
214
214
  it 'should get tours data with valid controller, action and query string' do
215
215
  published_tour
216
216
 
217
- get :index, controller_path: 'intro/admin/tours', action_name: 'new', original_url: '/intro/admin/tours/new?xyz=1'
218
- expect(response).to be_success
217
+ get :index, params: { controller_path: 'intro/admin/tours', action_name: 'new', original_url: '/intro/admin/tours/new?xyz=1' }
218
+ expect(response.successful?).to be true
219
219
  expect(json_body).not_to be_nil
220
220
  expect(json_body[:data]).not_to be_empty
221
221
 
222
- published_tour.update_attributes(route: { query: 'xyz=1' })
222
+ published_tour.update(route: { query: 'xyz=1' })
223
223
 
224
- get :index, controller_path: 'intro/admin/tours', action_name: 'new', original_url: '/intro/admin/tours/new?xyz=1'
224
+ get :index, params: { controller_path: 'intro/admin/tours', action_name: 'new', original_url: '/intro/admin/tours/new?xyz=1' }
225
225
  expect(json_body).not_to be_nil
226
226
  expect(json_body[:data]).not_to be_empty
227
227
 
228
- get :index, controller_path: 'intro/admin/tours', action_name: 'new', original_url: '/intro/admin/tours/new?xyz=1&abc=2'
228
+ get :index, params: { controller_path: 'intro/admin/tours', action_name: 'new', original_url: '/intro/admin/tours/new?xyz=1&abc=2' }
229
229
  expect(json_body).not_to be_nil
230
230
  expect(json_body[:data]).not_to be_empty
231
231
  end
@@ -235,8 +235,8 @@ describe Intro::ToursController, type: :controller do
235
235
  Intro.config.visible_without_signing_in = true
236
236
  published_tour
237
237
 
238
- get :index, controller_path: 'intro/admin/tours', action_name: 'new'
239
- expect(response).to be_success
238
+ get :index, params: { controller_path: 'intro/admin/tours', action_name: 'new' }
239
+ expect(response.successful?).to be true
240
240
  expect(json_body).not_to be_nil
241
241
  expect(json_body[:data]).not_to be_empty
242
242
  end
@@ -248,8 +248,8 @@ describe Intro::ToursController, type: :controller do
248
248
  published_tour.options['not_sign_visible'] = true
249
249
  published_tour.save
250
250
 
251
- get :index, controller_path: 'intro/admin/tours', action_name: 'new'
252
- expect(response).to be_success
251
+ get :index, params: { controller_path: 'intro/admin/tours', action_name: 'new' }
252
+ expect(response.successful?).to be true
253
253
  expect(json_body).not_to be_nil
254
254
  expect(json_body[:data]).not_to be_empty
255
255
  end
@@ -258,15 +258,15 @@ describe Intro::ToursController, type: :controller do
258
258
 
259
259
  context '#record' do
260
260
  it 'should get not_found without tour' do
261
- post :record, id: 0
261
+ post :record, params: { id: 0 }
262
262
  expect(response).to have_http_status(:not_found)
263
263
  end
264
264
 
265
265
  it 'should increment touch_count' do
266
266
  expect(published_tour.tour_histories).to be_empty
267
- expect { post :record, id: published_tour.id }.to change { published_tour.tour_histories.count }.by(1)
267
+ expect { post :record, params: { id: published_tour.id } }.to change { published_tour.tour_histories.count }.by(1)
268
268
  expect(published_tour.tour_histories.first.touch_count).to eq 1
269
- expect(response).to be_success
269
+ expect(response.successful?).to be true
270
270
  end
271
271
  end
272
272
  end