Merge `author_name` with `author_identifier`
This commit is contained in:
parent
abcef9758b
commit
9bcf1a80ad
|
@ -8,7 +8,7 @@ class Ajax::InboxController < AjaxController
|
||||||
|
|
||||||
question = Question.create!(content: QuestionGenerator.generate,
|
question = Question.create!(content: QuestionGenerator.generate,
|
||||||
author_is_anonymous: true,
|
author_is_anonymous: true,
|
||||||
author_name: 'justask',
|
author_identifier: 'justask',
|
||||||
user: current_user)
|
user: current_user)
|
||||||
|
|
||||||
inbox = Inbox.create!(user: current_user, question_id: question.id, new: true)
|
inbox = Inbox.create!(user: current_user, question_id: question.id, new: true)
|
||||||
|
|
|
@ -7,7 +7,7 @@ class Inbox < ApplicationRecord
|
||||||
before_create do
|
before_create do
|
||||||
raise "User does not want to receive anonymous questions" if !returning &&
|
raise "User does not want to receive anonymous questions" if !returning &&
|
||||||
question.author_is_anonymous &&
|
question.author_is_anonymous &&
|
||||||
(question.author_name != "justask") &&
|
(question.author_identifier != "justask") &&
|
||||||
!user.privacy_allow_anonymous_questions?
|
!user.privacy_allow_anonymous_questions?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ class ExportWorker
|
||||||
exporter.export
|
exporter.export
|
||||||
question = Question.create(content: "Your #{APP_CONFIG['site_name']} data export is ready! You can download it " +
|
question = Question.create(content: "Your #{APP_CONFIG['site_name']} data export is ready! You can download it " +
|
||||||
"from the settings page under the \"Export\" tab.", author_is_anonymous: true,
|
"from the settings page under the \"Export\" tab.", author_is_anonymous: true,
|
||||||
author_name: "retrospring_exporter")
|
author_identifier: "retrospring_exporter")
|
||||||
Inbox.create(user_id: user_id, question_id: question.id, new: true)
|
Inbox.create(user_id: user_id, question_id: question.id, new: true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
class DropAuthorNameFieldFromQuestions < ActiveRecord::Migration[6.1]
|
||||||
|
def change
|
||||||
|
execute "update questions set author_identifier = author_name where author_name is not null and author_identifier is null;"
|
||||||
|
remove_column :questions, :author_name
|
||||||
|
end
|
||||||
|
end
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2022_07_06_172257) do
|
ActiveRecord::Schema.define(version: 2022_07_06_174120) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -166,7 +166,6 @@ ActiveRecord::Schema.define(version: 2022_07_06_172257) do
|
||||||
create_table "questions", id: :bigint, default: -> { "gen_timestamp_id('questions'::text)" }, force: :cascade do |t|
|
create_table "questions", id: :bigint, default: -> { "gen_timestamp_id('questions'::text)" }, force: :cascade do |t|
|
||||||
t.string "content"
|
t.string "content"
|
||||||
t.boolean "author_is_anonymous"
|
t.boolean "author_is_anonymous"
|
||||||
t.string "author_name"
|
|
||||||
t.string "author_identifier"
|
t.string "author_identifier"
|
||||||
t.bigint "user_id"
|
t.bigint "user_id"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
|
|
|
@ -23,7 +23,7 @@ describe Ajax::InboxController, :ajax_controller, type: :controller do
|
||||||
allow(QuestionGenerator).to receive(:generate).and_return("Is Mayonnaise an instrument?")
|
allow(QuestionGenerator).to receive(:generate).and_return("Is Mayonnaise an instrument?")
|
||||||
expect { subject }.to(change { user.inboxes.count }.by(1))
|
expect { subject }.to(change { user.inboxes.count }.by(1))
|
||||||
expect(user.inboxes.last.question.author_is_anonymous).to eq(true)
|
expect(user.inboxes.last.question.author_is_anonymous).to eq(true)
|
||||||
expect(user.inboxes.last.question.author_name).to eq("justask")
|
expect(user.inboxes.last.question.author_identifier).to eq("justask")
|
||||||
expect(user.inboxes.last.question.user).to eq(user)
|
expect(user.inboxes.last.question.user).to eq(user)
|
||||||
expect(user.inboxes.last.question.content).to eq("Is Mayonnaise an instrument?")
|
expect(user.inboxes.last.question.content).to eq("Is Mayonnaise an instrument?")
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue