Skip to content

Commit

Permalink
Fix the missing password confirmation test case
Browse files Browse the repository at this point in the history
Add `require 'pathname'` to the spec_helper.rb to avoid `Uninitialized Pathname constant` error

Use expect(response.body).to include('password_confirmation') to avoid errors caused by changes in responses on different Rails' versions
  • Loading branch information
texpert committed Jan 13, 2025
1 parent 97f00ae commit d9036f0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions spec/requests/admin/users_controller/updated_ajax_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@
patch "/admin/users/#{current_user.id}/updated_ajax", params: { password: { password: 'new password' } }

expect(response.status).to eql(400)
expect(response.body).to eql(
'ERROR: ActionController::ParameterMissing, ' \
'param is missing or the value is empty or invalid: password_confirmation'
expect(response.body).to start_with(
'ERROR: ActionController::ParameterMissing, param is missing or the value is empty'
)
expect(response.body).to include('password_confirmation')
expect(current_user.reload.authenticate('secret')).to be_truthy
expect(current_user.reload.authenticate('new password')).to be_falsey
end
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ENV['RAILS_ENV'] ||= 'test'

require 'pathname'
CAMALEON_CMS_ROOT = Pathname.new(__FILE__).join('../..')

require File.expand_path('dummy/config/environment.rb', __dir__)
Expand Down

0 comments on commit d9036f0

Please # to comment.