Commit 25d29c2d22f775895afc2e01d80fff5795e7484c
1 parent
50498840
Exists in
colab
and in
4 other branches
KalibroConfigurationsController unit tests using put when testing the update
Showing
1 changed file
with
11 additions
and
11 deletions
Show diff stats
spec/controllers/kalibro_configurations_controller_spec.rb
@@ -2,11 +2,11 @@ require 'rails_helper' | @@ -2,11 +2,11 @@ require 'rails_helper' | ||
2 | 2 | ||
3 | describe KalibroConfigurationsController, :type => :controller do | 3 | describe KalibroConfigurationsController, :type => :controller do |
4 | 4 | ||
5 | - def post_method(method) | ||
6 | - unless method == :create | 5 | + def call_action(method) |
6 | + if method == :update | ||
7 | post method, :id => kalibro_configuration.id, :kalibro_configuration => kalibro_configuration_params, :attributes => attributes | 7 | post method, :id => kalibro_configuration.id, :kalibro_configuration => kalibro_configuration_params, :attributes => attributes |
8 | - else | ||
9 | - post method, :kalibro_configuration => kalibro_configuration_params, :attributes => attributes | 8 | + elsif method == :create |
9 | + put method, :kalibro_configuration => kalibro_configuration_params, :attributes => attributes | ||
10 | end | 10 | end |
11 | end | 11 | end |
12 | 12 | ||
@@ -36,7 +36,7 @@ describe KalibroConfigurationsController, :type => :controller do | @@ -36,7 +36,7 @@ describe KalibroConfigurationsController, :type => :controller do | ||
36 | 36 | ||
37 | context 'rendering the show' do | 37 | context 'rendering the show' do |
38 | before :each do | 38 | before :each do |
39 | - post_method :create | 39 | + call_action :create |
40 | end | 40 | end |
41 | 41 | ||
42 | it 'should redirect to the show view' do | 42 | it 'should redirect to the show view' do |
@@ -46,7 +46,7 @@ describe KalibroConfigurationsController, :type => :controller do | @@ -46,7 +46,7 @@ describe KalibroConfigurationsController, :type => :controller do | ||
46 | 46 | ||
47 | context 'without rendering the show view' do | 47 | context 'without rendering the show view' do |
48 | before :each do | 48 | before :each do |
49 | - post_method :create | 49 | + call_action :create |
50 | end | 50 | end |
51 | 51 | ||
52 | it { is_expected.to respond_with(:redirect) } | 52 | it { is_expected.to respond_with(:redirect) } |
@@ -231,7 +231,7 @@ describe KalibroConfigurationsController, :type => :controller do | @@ -231,7 +231,7 @@ describe KalibroConfigurationsController, :type => :controller do | ||
231 | 231 | ||
232 | context 'rendering the show' do | 232 | context 'rendering the show' do |
233 | before :each do | 233 | before :each do |
234 | - post_method :update | 234 | + call_action :update |
235 | end | 235 | end |
236 | 236 | ||
237 | it 'should redirect to the show view' do | 237 | it 'should redirect to the show view' do |
@@ -241,7 +241,7 @@ describe KalibroConfigurationsController, :type => :controller do | @@ -241,7 +241,7 @@ describe KalibroConfigurationsController, :type => :controller do | ||
241 | 241 | ||
242 | context 'without rendering the show view' do | 242 | context 'without rendering the show view' do |
243 | before :each do | 243 | before :each do |
244 | - post_method :update | 244 | + call_action :update |
245 | end | 245 | end |
246 | 246 | ||
247 | it { is_expected.to respond_with(:redirect) } | 247 | it { is_expected.to respond_with(:redirect) } |
@@ -253,7 +253,7 @@ describe KalibroConfigurationsController, :type => :controller do | @@ -253,7 +253,7 @@ describe KalibroConfigurationsController, :type => :controller do | ||
253 | KalibroConfiguration.expects(:find).with(kalibro_configuration.id).returns(kalibro_configuration) | 253 | KalibroConfiguration.expects(:find).with(kalibro_configuration.id).returns(kalibro_configuration) |
254 | KalibroConfiguration.any_instance.expects(:update).with(kalibro_configuration_params).returns(false) | 254 | KalibroConfiguration.any_instance.expects(:update).with(kalibro_configuration_params).returns(false) |
255 | 255 | ||
256 | - post_method :update | 256 | + call_action :update |
257 | end | 257 | end |
258 | 258 | ||
259 | it { is_expected.to render_template(:edit) } | 259 | it { is_expected.to render_template(:edit) } |
@@ -262,7 +262,7 @@ describe KalibroConfigurationsController, :type => :controller do | @@ -262,7 +262,7 @@ describe KalibroConfigurationsController, :type => :controller do | ||
262 | 262 | ||
263 | context 'when the user does not own the kalibro_configuration' do | 263 | context 'when the user does not own the kalibro_configuration' do |
264 | before :each do | 264 | before :each do |
265 | - post_method :update | 265 | + call_action :update |
266 | end | 266 | end |
267 | 267 | ||
268 | it { is_expected.to redirect_to kalibro_configurations_path(id: kalibro_configuration.id) } | 268 | it { is_expected.to redirect_to kalibro_configurations_path(id: kalibro_configuration.id) } |
@@ -271,7 +271,7 @@ describe KalibroConfigurationsController, :type => :controller do | @@ -271,7 +271,7 @@ describe KalibroConfigurationsController, :type => :controller do | ||
271 | 271 | ||
272 | context 'with no user logged in' do | 272 | context 'with no user logged in' do |
273 | before :each do | 273 | before :each do |
274 | - post_method :update | 274 | + call_action :update |
275 | end | 275 | end |
276 | 276 | ||
277 | it { is_expected.to redirect_to new_user_session_path } | 277 | it { is_expected.to redirect_to new_user_session_path } |