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 | 2 | |
| 3 | 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 | 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 | 10 | end |
| 11 | 11 | end |
| 12 | 12 | |
| ... | ... | @@ -36,7 +36,7 @@ describe KalibroConfigurationsController, :type => :controller do |
| 36 | 36 | |
| 37 | 37 | context 'rendering the show' do |
| 38 | 38 | before :each do |
| 39 | - post_method :create | |
| 39 | + call_action :create | |
| 40 | 40 | end |
| 41 | 41 | |
| 42 | 42 | it 'should redirect to the show view' do |
| ... | ... | @@ -46,7 +46,7 @@ describe KalibroConfigurationsController, :type => :controller do |
| 46 | 46 | |
| 47 | 47 | context 'without rendering the show view' do |
| 48 | 48 | before :each do |
| 49 | - post_method :create | |
| 49 | + call_action :create | |
| 50 | 50 | end |
| 51 | 51 | |
| 52 | 52 | it { is_expected.to respond_with(:redirect) } |
| ... | ... | @@ -231,7 +231,7 @@ describe KalibroConfigurationsController, :type => :controller do |
| 231 | 231 | |
| 232 | 232 | context 'rendering the show' do |
| 233 | 233 | before :each do |
| 234 | - post_method :update | |
| 234 | + call_action :update | |
| 235 | 235 | end |
| 236 | 236 | |
| 237 | 237 | it 'should redirect to the show view' do |
| ... | ... | @@ -241,7 +241,7 @@ describe KalibroConfigurationsController, :type => :controller do |
| 241 | 241 | |
| 242 | 242 | context 'without rendering the show view' do |
| 243 | 243 | before :each do |
| 244 | - post_method :update | |
| 244 | + call_action :update | |
| 245 | 245 | end |
| 246 | 246 | |
| 247 | 247 | it { is_expected.to respond_with(:redirect) } |
| ... | ... | @@ -253,7 +253,7 @@ describe KalibroConfigurationsController, :type => :controller do |
| 253 | 253 | KalibroConfiguration.expects(:find).with(kalibro_configuration.id).returns(kalibro_configuration) |
| 254 | 254 | KalibroConfiguration.any_instance.expects(:update).with(kalibro_configuration_params).returns(false) |
| 255 | 255 | |
| 256 | - post_method :update | |
| 256 | + call_action :update | |
| 257 | 257 | end |
| 258 | 258 | |
| 259 | 259 | it { is_expected.to render_template(:edit) } |
| ... | ... | @@ -262,7 +262,7 @@ describe KalibroConfigurationsController, :type => :controller do |
| 262 | 262 | |
| 263 | 263 | context 'when the user does not own the kalibro_configuration' do |
| 264 | 264 | before :each do |
| 265 | - post_method :update | |
| 265 | + call_action :update | |
| 266 | 266 | end |
| 267 | 267 | |
| 268 | 268 | it { is_expected.to redirect_to kalibro_configurations_path(id: kalibro_configuration.id) } |
| ... | ... | @@ -271,7 +271,7 @@ describe KalibroConfigurationsController, :type => :controller do |
| 271 | 271 | |
| 272 | 272 | context 'with no user logged in' do |
| 273 | 273 | before :each do |
| 274 | - post_method :update | |
| 274 | + call_action :update | |
| 275 | 275 | end |
| 276 | 276 | |
| 277 | 277 | it { is_expected.to redirect_to new_user_session_path } | ... | ... |