docbrown/spec/features/user_edits_a_comment_spec.rb
Anna Buyanova 7b1c4084a8 Basic feature specs for the stories (#1269)
* Added stories feature specs

* Structure feature specs

* Spec for the articles by tag page

* Disable example length for feature specs

* Spec for clicking "week" button on the tag page
2018-12-07 10:32:38 -05:00

37 lines
1,011 B
Ruby

require "rails_helper"
RSpec.describe "Editing A Comment", type: :feature, js: true do
let(:user) { create(:user) }
let!(:article) { create(:article, show_comments: true) }
let(:new_comment_text) { Faker::Lorem.paragraph }
before do
comment = create(:comment, commentable: article, user: user, body_markdown: Faker::Lorem.paragraph)
Notification.send_new_comment_notifications(comment)
sign_in user
end
def assert_updated
expect(page).to have_css("textarea[autofocus='autofocus']")
fill_in "text-area", with: new_comment_text
click_button("SUBMIT")
expect(page).to have_text(new_comment_text)
end
context "when user edits comment on the bottom of the article" do
it "updates" do
visit article.path.to_s
click_link("EDIT")
assert_updated
end
end
context "when user edits via permalinks" do
it "updates" do
user.reload
visit user.comments.last.path.to_s
click_link("EDIT")
assert_updated
end
end
end