* schema file undelete description * feat: v1 of the script * Flesh out remaining enums under their categories * complete UsersSettings data update script * complete DUS for relevant attributes in users and profiles tables * complete DUS for users_notification_settings * alphabetize user_settings sql file * safeguard against null values for "null: false" settings * Set up actual UsersSettings DUS and specs files * fix broken DUS script * complete specs for UsersSetting DUS * Address QA of specs * complete specs for users_notification_settings DUS * fix the typos (thanks Julianna!) * begin implementation * still building * add missing attribute "email_membership_newsletter" * complete sync code (except race condition for user profile) * complete implementation, remains tests * Address PR review and fix Travis fails * remove superfluous Profile.new * fix travis fails * feat: update the users_notification_setting attributes from the user model * feat: use the config fonts enums to display the fonts * feat: loop through the keys * fix profile = nil blowing up; add specs for notification_setting model * remove unneeded spec * remove feed validation until after sync code removed; fixes feed_import spec failures * remove spec associated with feed_url validation in user_setting model * fix failing spec 😅 * add TODO * feat: set the user settings in the user controller and use it in the customization form * feat: move some update logic to the users settings controller thats being used from customization * feat: show the updated values form the users_settingd and not the user instance * Generalize redirect back to current tab * still trying to reflect changed theme upon refresh * customizations take effect on refresh * remove 'with_feed' scope from user model Co-authored-by: Jamie Gaskins <jamie@forem.com> * start with takeover for fields previously in profiles table * Takeover code for `publishing_from_rss` section in Settings (#13914) * implement takeover code part 1 * implement takeover code * fix feed fetch * need rhymes help * complete implementation; specs pending * fix STUPID omission that caused so many headaches 😫 * implement profile fields pointing to users_settings 🎉 * run migrations * implement inbox type & guidelines takeover code; specs pending (#13911) * Point changes in notification settings to `users_notification_settings` table (#13910) * implement takeover code; remains specs * address PR feedback; remove related sync code * address PR review feedback * need help with routing and specs * address pr review * addressing pr review * Treat implementation edge cases and omissions 😅 * fix uncommented comment * fixing implementation cases * address more PR review feedback * fixing notifications use-cases * refactor settings controller * more pr review changes * solving bugs * fix broken onboarding * handle eperience_level calls * more fixes * remove unneeded mappings * add To-dos for quety updates * remove done TODO * purge done TODOs * update notification_settings-related queries * start fixing specs * fixing specs * fix notification and lrg_forem specs * fixing broken specs * still fixing * fix line dif and remove reloads from user.rb * run specs * silence bullet and other fixes * remove setting migration scripts and specs, fix more settings for specs * handle missing user for article builder and fix notification specs * fix some final controller specs and re-add incorrectly removed specs * remove deprecated data update scripts and related workers, put travis back * refactor admin tags mods controller, write/move specs for users notifications settings controller * schema cleanup and other small refactors for consistency * set field we can invalidate in spec via active record instead of at the db level * remove I think an uneccessary hook call from subscribe_to_mailchimp_newsletter * use bnefore_create to setup settings, please dont blow up the test suite * mailchimp bot fix * remove decorator in favor of single model method Co-authored-by: Arit Amana <msarit@gmail.com> Co-authored-by: Ridhwana <ridhwana.khan16@gmail.com> Co-authored-by: Arit Amana <32520970+msarit@users.noreply.github.com> Co-authored-by: Jamie Gaskins <jamie@forem.com>
109 lines
3.8 KiB
Ruby
109 lines
3.8 KiB
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe "Using the editor", type: :system do
|
|
let(:user) { create(:user) }
|
|
let(:raw_text) { "../support/fixtures/sample_article_template_spec.txt" }
|
|
# what are these
|
|
let(:dir) { "../support/fixtures/sample_article.txt" }
|
|
let(:rich_dir) { "../support/fixtures/sample_rich_article.txt" }
|
|
let(:template) { File.read(File.join(File.dirname(__FILE__), dir)) }
|
|
let(:rich_template) { File.read(File.join(File.dirname(__FILE__), rich_dir)) }
|
|
|
|
before do
|
|
sign_in user
|
|
end
|
|
|
|
def read_from_file(dir)
|
|
File.read(File.join(File.dirname(__FILE__), dir))
|
|
end
|
|
|
|
def fill_markdown_with(content)
|
|
visit "/new"
|
|
within("#article-form") { fill_in "article_body_markdown", with: content }
|
|
end
|
|
|
|
describe "Viewing the editor", js: true do
|
|
it "renders the logo_svg or Community name as expected" do
|
|
visit "/new"
|
|
expect(page).to have_css(".site-logo")
|
|
within(".truncate-at-2") do
|
|
expect(page).to have_text("DEV(local)")
|
|
end
|
|
end
|
|
end
|
|
|
|
describe "Previewing an article", js: true do
|
|
before do
|
|
fill_markdown_with(read_from_file(raw_text))
|
|
page.execute_script("window.scrollTo(0, -100000)")
|
|
find("button", text: /\APreview\z/).click
|
|
end
|
|
|
|
after do
|
|
page.evaluate_script("window.onbeforeunload = function(){}")
|
|
end
|
|
|
|
it "fills out form with rich content and click preview", cloudinary: true do
|
|
article_body = find("div.crayons-article__body")["innerHTML"]
|
|
article_body.gsub!(%r{"https://res\.cloudinary\.com/.{1,}"}, "cloudinary_link")
|
|
|
|
# TODO: Convert this to an E2E test?
|
|
# rubocop:disable Style/StringLiterals
|
|
expect(article_body).to include('<a name="multiword-heading-with-weird-punctuampation"')
|
|
.and include('<a name="emoji-heading"')
|
|
.and include('<blockquote>')
|
|
.and include('Format: <a href=cloudinary_link></a>')
|
|
# rubocop:enable Style/StringLiterals
|
|
end
|
|
end
|
|
|
|
describe "Submitting an article with v1 editor", js: true do
|
|
before { user.setting.update!(editor_version: "v1") }
|
|
|
|
it "fill out form and submit", cloudinary: true do
|
|
fill_markdown_with(read_from_file(raw_text))
|
|
find("button", text: /\ASave changes\z/).click
|
|
article_body = find(:xpath, "//div[@id='article-body']")["innerHTML"]
|
|
article_body.gsub!(%r{"https://res\.cloudinary\.com/.{1,}"}, "cloudinary_link")
|
|
|
|
# TODO: Convert this to an E2E test?
|
|
# rubocop:disable Style/StringLiterals
|
|
expect(article_body).to include('<a name="multiword-heading-with-weird-punctuampation"')
|
|
.and include('<a name="emoji-heading"')
|
|
.and include('<blockquote>')
|
|
.and include('Format: <a href=cloudinary_link></a>')
|
|
# rubocop:enable Style/StringLiterals
|
|
end
|
|
|
|
it "user write and publish an article" do
|
|
fill_markdown_with(template.gsub("false", "true"))
|
|
find("button", text: /\ASave changes\z/).click
|
|
["Sample Article", template[-200..], "test"].each do |text|
|
|
expect(page).to have_text(text)
|
|
end
|
|
end
|
|
|
|
context "without a title", js: true do
|
|
before do
|
|
fill_markdown_with(template.gsub("Sample Article", ""))
|
|
find("button", text: /\ASave changes\z/).click
|
|
end
|
|
|
|
it "shows a message that the title cannot be blank" do
|
|
expect(page).to have_text(/title: can't be blank/)
|
|
end
|
|
end
|
|
end
|
|
|
|
describe "using v2 editor", js: true do
|
|
it "fill out form with rich content and click publish" do
|
|
visit "/new"
|
|
fill_in "article-form-title", with: "This is a test"
|
|
fill_in "tag-input", with: "What, Yo"
|
|
fill_in "article_body_markdown", with: "Hello"
|
|
find("button", text: /\APublish\z/).click
|
|
expect(page).to have_text("Hello")
|
|
expect(page).to have_link("#what", href: "/t/what")
|
|
end
|
|
end
|
|
end
|