Change default value for editor version (#14063)
* Create migration * Remove explicit "v2" usages * Fix broken spec * Update spec/system/user_uses_the_editor_spec.rb Co-authored-by: Jamie Gaskins <jgaskins@hey.com> Co-authored-by: Jamie Gaskins <jgaskins@hey.com>
This commit is contained in:
parent
dd0796ec74
commit
ffe31cd5aa
11 changed files with 19 additions and 16 deletions
|
|
@ -24,7 +24,6 @@ module Admin
|
|||
username: username,
|
||||
remote_profile_image_url: ::Users::ProfileImageGenerator.call,
|
||||
saw_onboarding: false,
|
||||
editor_version: :v2,
|
||||
registered: false)
|
||||
flash[:success] = "The invite has been sent to the user's email."
|
||||
redirect_to admin_invitations_path
|
||||
|
|
|
|||
|
|
@ -80,7 +80,6 @@ class RegistrationsController < Devise::RegistrationsController
|
|||
build_resource(sign_up_params)
|
||||
resource.saw_onboarding = false
|
||||
resource.registered_at = Time.current
|
||||
resource.editor_version = "v2"
|
||||
resource.remote_profile_image_url = Users::ProfileImageGenerator.call if resource.remote_profile_image_url.blank?
|
||||
check_allowed_email(resource) if resource.email.present?
|
||||
resource.save if resource.email.present?
|
||||
|
|
|
|||
|
|
@ -125,8 +125,7 @@ module Authentication
|
|||
signup_cta_variant: cta_variant,
|
||||
registered: true,
|
||||
registered_at: Time.current,
|
||||
saw_onboarding: false,
|
||||
editor_version: :v2
|
||||
saw_onboarding: false
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
class ChangeDefaultValueForEditorVersion < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
change_column_default :users, :editor_version, from: "v1", to: "v2"
|
||||
end
|
||||
end
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2021_06_22_002941) do
|
||||
ActiveRecord::Schema.define(version: 2021_06_24_153854) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "citext"
|
||||
|
|
@ -1309,7 +1309,7 @@ ActiveRecord::Schema.define(version: 2021_06_22_002941) do
|
|||
t.boolean "display_announcements", default: true
|
||||
t.boolean "display_sponsors", default: true
|
||||
t.string "dribbble_url"
|
||||
t.string "editor_version", default: "v1"
|
||||
t.string "editor_version", default: "v2"
|
||||
t.string "education"
|
||||
t.string "email"
|
||||
t.boolean "email_badge_notifications", default: true
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ RSpec.describe ArticleWithVideoCreationService, type: :service do
|
|||
describe "#create!" do
|
||||
it "works" do
|
||||
Timecop.travel(3.weeks.ago)
|
||||
user = create(:user)
|
||||
user = create(:user, editor_version: "v1")
|
||||
Timecop.return
|
||||
test = build_stubbed(:article, user: user, video: link).attributes.symbolize_keys
|
||||
article = described_class.new(test, user).create!
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ RSpec.describe Articles::Builder, type: :service do
|
|||
let(:prefill) { nil }
|
||||
|
||||
context "when tag_user_editor_v2" do
|
||||
let(:user) { create(:user, editor_version: "v2") }
|
||||
let(:user) { create(:user) }
|
||||
let(:tag) { create(:tag) }
|
||||
let(:submission_template) { tag.submission_template_customized(user.name).to_s }
|
||||
let(:correct_attributes) do
|
||||
|
|
@ -48,7 +48,7 @@ RSpec.describe Articles::Builder, type: :service do
|
|||
end
|
||||
|
||||
context "when prefill_user_editor_v2" do
|
||||
let(:user) { create(:user, editor_version: "v2") }
|
||||
let(:user) { create(:user) }
|
||||
let(:prefill) { "dsdweewewew" }
|
||||
let(:correct_attributes) do
|
||||
{
|
||||
|
|
@ -89,6 +89,7 @@ RSpec.describe Articles::Builder, type: :service do
|
|||
end
|
||||
|
||||
context "when tag" do
|
||||
let(:user) { create(:user, editor_version: "v1") }
|
||||
let(:tag) { create(:tag) }
|
||||
let(:correct_attributes) do
|
||||
{
|
||||
|
|
@ -108,7 +109,7 @@ RSpec.describe Articles::Builder, type: :service do
|
|||
end
|
||||
|
||||
context "when user_editor_v2" do
|
||||
let(:user) { create(:user, editor_version: "v2") }
|
||||
let(:user) { create(:user) }
|
||||
let(:correct_attributes) do
|
||||
{
|
||||
user_id: user.id
|
||||
|
|
@ -125,6 +126,7 @@ RSpec.describe Articles::Builder, type: :service do
|
|||
end
|
||||
|
||||
context "when user_editor_v1" do
|
||||
let(:user) { create(:user, editor_version: "v1") }
|
||||
let(:correct_attributes) do
|
||||
body = "---\ntitle: \npublished: false\ndescription: \ntags: " \
|
||||
"\n//cover_image: https://direct_url_to_image.jpg\n---\n\n"
|
||||
|
|
|
|||
|
|
@ -134,7 +134,6 @@ seeder.create_if_doesnt_exist(User, "email", "article-editor-v2-user@forem.com")
|
|||
saw_onboarding: true,
|
||||
checked_code_of_conduct: true,
|
||||
checked_terms_and_conditions: true,
|
||||
editor_version: "v2",
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ require "rails_helper"
|
|||
RSpec.describe "Creating an article with the editor", type: :system do
|
||||
include_context "with runkit_tag"
|
||||
|
||||
let(:user) { create(:user) }
|
||||
let(:user) { create(:user, editor_version: "v1") }
|
||||
let!(:template) { file_fixture("article_published.txt").read }
|
||||
let!(:template_with_runkit_tag) do
|
||||
file_fixture("article_with_runkit_tag.txt").read
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ RSpec.describe "", type: :system do
|
|||
|
||||
it "let's the user fix a broken draft without publishing", js: true, aggregate_failures: true do
|
||||
# Create a new blog post and add content that validates correctly
|
||||
sign_in create(:user, editor_version: "v2")
|
||||
sign_in create(:user)
|
||||
visit new_path
|
||||
fill_in "article-form-title", with: "Regression spec"
|
||||
fill_in "article_body_markdown", with: correct_liquid_tag
|
||||
|
|
|
|||
|
|
@ -57,7 +57,9 @@ RSpec.describe "Using the editor", type: :system do
|
|||
end
|
||||
end
|
||||
|
||||
describe "Submitting an article", js: true do
|
||||
describe "Submitting an article with v1 editor", js: true do
|
||||
before { user.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
|
||||
|
|
@ -94,8 +96,6 @@ RSpec.describe "Using the editor", type: :system do
|
|||
end
|
||||
|
||||
describe "using v2 editor", js: true do
|
||||
before { user.update(editor_version: "v2") }
|
||||
|
||||
it "fill out form with rich content and click publish" do
|
||||
visit "/new"
|
||||
fill_in "article-form-title", with: "This is a test"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue