PHP
- 4 ответа
- 0 вопросов
7
Вклад в тег
describe 'POST #create' do
sign_in_user
context 'with valid attributes' do
it 'saves answer in database' do
expect { post :create, question_id: question, answer: attributes_for(:answer), format: :js }.to change(question.answers, :count).by(1)
end
it 'assigns answer with current user' do
post :create, question_id: question, answer: attributes_for(:answer), format: :js
assigning_answer = assigns(:answer)
expect(assigning_answer.user_id).to eq subject.current_user.id
end
it 'render create template' do
post :create, question_id: question, answer: attributes_for(:answer), format: :js
expect(response).to render_template :create
end
end