В этом разделе я должен ограничить пользователь может редактировать и обновлять только свой профиль. Все мои тесты проходят до этого момента, кроме этого:
describe "as wrong user" do
let(:user) { FactoryGirl.create(:user) }
let(:wrong_user) { FactoryGirl.create(:user, email: "[email protected]") }
before { sign_in user }
describe "visiting Users#edit page" do
before { visit edit_user_path(wrong_user) }
it { should_not have_selector('title', text: full_title('Edit user')) }
end
describe "submitting a PUT request to the Users#update action" do
before { put user_path(wrong_user) }
specify { response.should redirect_to(root_path) }
end
end
В частности, последняя часть, перенаправление, это то, что я получаю, когда запускаю тест:
1) Authentication authorization as wrong user submitting a PUT request to the Users#update action
Failure/Error: specify { response.should redirect_to(root_path) }
Expected response to be a redirect to <http://www.example.com/> but was a redirect to <http://www.example.com/signin>
# ./spec/requests/authentication_spec.rb:86:in `block (5 levels) in <top (required)>'
Но на веб-сайте, когда я пытаюсь сделать то же самое, все работает нормально, пользователь перенаправляется на root_path приложения.