docbrown/spec/system/articles/user_edits_an_article_spec.rb
Michael Kohl 6dfabd578f
Rename SiteConfig to Settings::General (#13573)
* Rename SiteConfig

* More renaming

* Update spec

* Update mandatory settings mapping

* More renaming

* e2e test fixes

* You have a rename, and you have a rename

* Spec fix

* More changes

* Temporarily disable specs

* After-merge update

* Undo rename for migration

* undo rename of DUS

* Fix DUS

* Fix merge problem

* Remove redundant DUS

* Fix specs

* Remove unused code

* Change wrong class name

* More cleanup

* Re-add missing values to constant

* Fix constant

* Fix spec

* Remove obsolete fields

* Add accidentally removed field

* Update spec

* Move methods from Settings::General to ForemInstance

* Remove unneeded model

* Change mentions of 'site config'
2021-05-21 14:45:37 +02:00

39 lines
1.7 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(Settings::General).to receive(:main_social_image).and_return("https://dummyimage.com/800x600.jpg")
allow(Settings::General).to receive(:logo_png).and_return("https://dummyimage.com/800x600.png")
allow(Settings::General).to receive(:mascot_image_url).and_return("https://dummyimage.com/800x600.jpg")
allow(Settings::General).to receive(:suggested_tags).and_return("coding, beginners")
allow(Settings::General).to receive(:suggested_users).and_return("romagueramica")
allow(Settings::General).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