From caa9e1cd49f8af86ea81ba661e37af3c7f4dad46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Mon, 21 Jan 2019 13:34:25 +0100 Subject: [PATCH] Enable soft_deletion of Poll::Question::Translations --- ...121123230_add_hidden_at_to_poll_question_translations.rb | 6 ++++++ db/schema.rb | 2 ++ spec/models/poll/question_spec.rb | 4 ++++ 3 files changed, 12 insertions(+) create mode 100644 db/migrate/20190121123230_add_hidden_at_to_poll_question_translations.rb diff --git a/db/migrate/20190121123230_add_hidden_at_to_poll_question_translations.rb b/db/migrate/20190121123230_add_hidden_at_to_poll_question_translations.rb new file mode 100644 index 000000000..62a14f1c6 --- /dev/null +++ b/db/migrate/20190121123230_add_hidden_at_to_poll_question_translations.rb @@ -0,0 +1,6 @@ +class AddHiddenAtToPollQuestionTranslations < ActiveRecord::Migration[4.2] + def change + add_column :poll_question_translations, :hidden_at, :datetime + add_index :poll_question_translations, :hidden_at + end +end diff --git a/db/schema.rb b/db/schema.rb index e882755bc..6076e9cf3 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1161,6 +1161,8 @@ ActiveRecord::Schema.define(version: 20190607160900) do t.datetime "created_at", null: false t.datetime "updated_at", null: false t.string "title" + t.datetime "hidden_at" + t.index ["hidden_at"], name: "index_poll_question_translations_on_hidden_at", using: :btree t.index ["locale"], name: "index_poll_question_translations_on_locale", using: :btree t.index ["poll_question_id"], name: "index_poll_question_translations_on_poll_question_id", using: :btree end diff --git a/spec/models/poll/question_spec.rb b/spec/models/poll/question_spec.rb index 7adee447d..c10ca1c32 100644 --- a/spec/models/poll/question_spec.rb +++ b/spec/models/poll/question_spec.rb @@ -3,6 +3,10 @@ require "rails_helper" RSpec.describe Poll::Question, type: :model do let(:poll_question) { build(:poll_question) } + describe "Concerns" do + it_behaves_like "acts as paranoid", :poll_question + end + describe "#poll_question_id" do it "is invalid if a poll is not selected" do poll_question.poll_id = nil