docbrown/spec/features/user_edits_an_article_spec.rb
rhymes e588fa7ece Code cleanups (#659)
* Initial automatic cleanup with rubocop

* Fix syntax error introduced by rubocop

* Cleanup seeds file

* Cleanup lib folder

* Exclude bin folder because it contains auto generated files

* Make Rubocop a little bit more chatty

* Block length should not include comments in the count

* Cleanup config folder

* Cleanup specs

* Updated Rubocop version and generated a todo file

* Fix broken ArticlesApi spec

* Fix tests

* Restored rubocop pre-commit hook
2018-08-07 11:00:13 -04:00

37 lines
1 KiB
Ruby

require "rails_helper"
describe "Editing with an editor" do
let(:user) { create(:user) }
let(:dir) { "../support/fixtures/sample_article.txt" }
let(:template) { File.read(File.join(File.dirname(__FILE__), dir)) }
let(:article) do
create(:article,
user_id: user.id,
body_markdown: template.gsub("false", "true"),
body_html: "")
end
before do
sign_in user
end
it "user click the edit-post button", js: true, retry: 3 do
link = "/#{user.username}/#{article.slug}"
visit link
find("#action-space").click
expect(page).to have_current_path(link + "/edit")
end
it "user preview their edit post" do
visit "/#{user.username}/#{article.slug}/edit"
click_button("previewbutt")
expect(page).to have_text(template[-200..-1])
end
it "user update their post" do
visit "/#{user.username}/#{article.slug}/edit"
fill_in "article_body_markdown", with: template.gsub("true", "false")
click_button("article-submit")
expect(page).to have_text("Unpublished Post.")
end
end