docbrown/spec/system/articles/user_edits_an_article_spec.rb
Arit Amana f4bd1df21c
[Email/Password Authentication] Allow Admins to enable email/password login (#10745)
* Implement Admins ability to allow email login

* Write specs for admin allow email login

* Fix specs causing builds to fail

* Fix spec causing builds to fail

* Use dummyimage.com for spec images

Co-authored-by: Josh Puetz <joshpuetz@gmail.com>

* Use dummyimage.com

* refactor setting of SiteConfig attributes

* Address PR review comments

* fix indentation

* Use "allow to receive and return" approach for other specs

Co-authored-by: Josh Puetz <joshpuetz@gmail.com>
2020-10-12 12:54:35 -04:00

39 lines
1.6 KiB
Ruby

require "rails_helper"
RSpec.describe "Editing with an editor", type: :system, js: true do
let(:template) { file_fixture("article_published.txt").read }
let(:user) { create(:user) }
let(:article) { create(:article, user: user, body_markdown: template) }
let(:svg_image) { file_fixture("300x100.svg").read }
before do
allow(SiteConfig).to receive(:main_social_image).and_return("https://dummyimage.com/800x600.jpg")
allow(SiteConfig).to receive(:logo_png).and_return("https://dummyimage.com/800x600.png")
allow(SiteConfig).to receive(:mascot_image_url).and_return("https://dummyimage.com/800x600.jpg")
allow(SiteConfig).to receive(:suggested_tags).and_return("coding, beginners")
allow(SiteConfig).to receive(:suggested_users).and_return("romagueramica")
allow(SiteConfig).to receive(:logo_svg).and_return(svg_image)
sign_in user
end
it "user previews their changes" do
visit "/#{user.username}/#{article.slug}/edit"
fill_in "article_body_markdown", with: template.gsub("Suspendisse", "Yooo")
click_button("Preview")
expect(page).to have_text("Yooo")
end
it "user updates their post" do
visit "/#{user.username}/#{article.slug}/edit"
fill_in "article_body_markdown", with: template.gsub("Suspendisse", "Yooo")
click_button("Save changes")
expect(page).to have_text("Yooo")
end
it "user unpublishes their post" do
visit "/#{user.username}/#{article.slug}/edit"
fill_in("article_body_markdown", with: template.gsub("true", "false"), fill_options: { clear: :backspace })
click_button("Save changes")
expect(page).to have_text("Unpublished Post.")
end
end