This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Place all the behaviors and hooks related to the matching controller here. | |
# All this logic will automatically be available in application.js. | |
# You can use CoffeeScript in this file: http://coffeescript.org/ | |
# Объявляем функцию ready, внутри которой можно поместить обработчики событий и другой код, | |
# который должен выполняться при загрузке страницы | |
ready = -> # оборачиваем все до строки 15 в функцию ready | |
# Это наш функция-обработчик, перенесенная сюда из document.ready ($ ->) | |
$('.edit-answer-link').click (e) -> # событие ниже работает по клику на элемент с классом .edit-answer-link |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rails_helper' | |
RSpec.describe AnswersController, type: :controller do | |
sign_in_user | |
let!(:question) { create(:question) } | |
let!(:answer) { create(:answer, user: @user) } | |
describe 'DELETE #destroy' do | |
before { answer } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- if answer.persisted? | |
= answer.body | |
- if current_user&.author_of? answer | |
p= link_to "delete answer", answer_path(answer), method: :delete | |
p= link_to 'edit', '', class: 'edit-answer-link', data: { answer_id: answer.id } | |
p |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- if answer.persisted? | |
= answer.body | |
- if current_user&.author_of? answer | |
p= link_to "delete answer", answer_path(answer), method: :delete | |
p= link_to 'edit', '', class: 'edit-answer-link', data: { answer_id: answer.id } | |
p |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ubuntu@rails-dev-box:~/www/qna$ rspec spec/acceptance/answer_question_spec.rb | |
F.. | |
Failures: | |
1) User answers a question | |
In order to answer a question | |
I want to be able to fill the answer form on a page of a question | |
Authenticated user answers a question |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ubuntu@rails-dev-box:~/www/qna$ rspec spec/acceptance/answer_question_spec.rb | |
F.. | |
Failures: | |
1) User answers a question | |
In order to answer a question | |
I want to be able to fill the answer form on a page of a question | |
Authenticated user answers a question | |
Failure/Error: visit new_user_session_path # юзер идет на страницу логина |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ubuntu@rails-dev-box:~/www/qna$ bundle | |
error: cannot open .git/FETCH_HEAD: Permission denied | |
Retrying `git fetch --force --quiet --tags "/home/ubuntu/.bundle/cache/git/shoulda-matchers-e04e9ade87805b3667f97d976fd84556605e66f8"` due to error (2/4): Bundler::Source::Git::GitCommandError Git error: command `git fetch --force --quiet --tags "/home/ubuntu/.bundle/cache/git/shoulda-matchers-e04e9ade87805b3667f97d976fd84556605e66f8"` in directory /var/lib/gems/2.4.0/bundler/gems/shoulda-matchers-ead87017a6c1 has failed. | |
If this error persists you could try removing the cache directory '/home/ubuntu/.bundle/cache/git/shoulda-matchers-e04e9ade87805b3667f97d976fd84556605e66f8'error: cannot open .git/FETCH_HEAD: Permission denied | |
Retrying `git fetch --force --quiet --tags "/home/ubuntu/.bundle/cache/git/shoulda-matchers-e04e9ade87805b3667f97d976fd84556605e66f8"` due to error (3/4): Bundler::Source::Git::GitCommandError Git error: command `git fetch --force --quiet --tags "/home/ubuntu/.bundle/cache/git/shoulda-matcher |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rails_helper' | |
RSpec.describe AnswersController, type: :controller do | |
sign_in_user | |
let(:question) { create(:question) } | |
let(:answer) { create(:answer, question: question) } | |
describe 'DELETE #destroy' do | |
before { answer } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ubuntu@rails-dev-box:~/www/qna$ rspec spec/controllers/answers_controller_spec.rb | |
F....... | |
Failures: | |
1) AnswersController DELETE #destroy 1) user deletes his answer deletes users answer | |
Failure/Error: | |
expect { delete :destroy, params: { question_id: answer.question, id: answer } } | |
.to change(answer.user.answers, :count).by(-1) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rails_helper' | |
RSpec.describe QuestionsController, type: :controller do | |
sign_in_user | |
let(:question) { create(:question, user: user) } | |
let(:user) { create(:user) } | |
describe 'GET #index' do | |
let(:questions) { create_list(:question, 2) } | |
before { get :index } |