I'm really stuck here. I have a Language
model, that gets updated in this method:
def update
@language = Language.find(params[:id])
if @language.update_attributes(language_params)
flash[:success] = 'Language information updated.'
redirect_to @language
else
@skill_errors = @language.errors
render 'edit'
end
end
The intended behaviour for a successful update reproduces when I run it on my local server, object gets updated, flash appears and redirect to @language
happens.
In the test, however, I only get the 200: Success
response, and the object doesn't get updated. Here's the test code:
test 'should allow update when logged in as admin user' do
sign_in(@admin)
patch language_path(@ruby_language), params: { language: { name: 'Test'} }
assert_not flash.empty?
assert_redirected_to @ruby_language
@ruby_language.reload
assert_equal 'Test', @ruby_language.name
end
@admin_user
and @ruby_language
are defined in fixtures. All the asserts in this test fail, including the last one, with reload
. My guess is that there might be some routing glitch caused by my usage of Devise
and/or Kaminari
gems? On the other hand, my Language
routes are very simple: resources :languages, concerns: :paginatable
(the concern is here for human-readable URL formatting). Please, keep in mind that everything works as intended, only tests fail for some reason... Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire