From 480bb8cd5500d650381833b063804c35f18ac5bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 25 Aug 2021 17:29:29 +0200 Subject: [PATCH] Remove link column in dashboard actions This column wasn't used in any released Consul version since it was only used during development. For the same reason, the task to migrate the information in the `link` column to the `links` table isn't needed either. --- ...0210825152739_remove_link_from_dashboard_actions.rb | 5 +++++ db/schema.rb | 3 +-- lib/tasks/proposal_actions.rake | 10 ---------- spec/factories/proposals.rb | 5 ----- spec/models/dashboard/executed_action_spec.rb | 4 +--- 5 files changed, 7 insertions(+), 20 deletions(-) create mode 100644 db/migrate/20210825152739_remove_link_from_dashboard_actions.rb delete mode 100644 lib/tasks/proposal_actions.rake diff --git a/db/migrate/20210825152739_remove_link_from_dashboard_actions.rb b/db/migrate/20210825152739_remove_link_from_dashboard_actions.rb new file mode 100644 index 000000000..650414b24 --- /dev/null +++ b/db/migrate/20210825152739_remove_link_from_dashboard_actions.rb @@ -0,0 +1,5 @@ +class RemoveLinkFromDashboardActions < ActiveRecord::Migration[5.2] + def change + remove_column :dashboard_actions, :link, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 0537d3c8f..755e3b417 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_08_11_195800) do +ActiveRecord::Schema.define(version: 2021_08_25_152739) do # These are extensions that must be enabled in order to support this database enable_extension "pg_trgm" @@ -466,7 +466,6 @@ ActiveRecord::Schema.define(version: 2021_08_11_195800) do create_table "dashboard_actions", id: :serial, force: :cascade do |t| t.string "title", limit: 80 t.text "description" - t.string "link" t.boolean "request_to_administrators", default: false t.integer "day_offset", default: 0 t.integer "required_supports", default: 0 diff --git a/lib/tasks/proposal_actions.rake b/lib/tasks/proposal_actions.rake deleted file mode 100644 index c7aabab85..000000000 --- a/lib/tasks/proposal_actions.rake +++ /dev/null @@ -1,10 +0,0 @@ -namespace :proposal_actions do - desc "Move link attribute to links collection" - task migrate_links: :environment do - ProposalDashboardAction.where.not(link: nil).each do |action| - next if action.link.blank? - - Link.create!(label: action.title, url: action.link, linkable: action) - end - end -end diff --git a/spec/factories/proposals.rb b/spec/factories/proposals.rb index 1398bea22..925849b8d 100644 --- a/spec/factories/proposals.rb +++ b/spec/factories/proposals.rb @@ -137,7 +137,6 @@ FactoryBot.define do factory :dashboard_action, class: "Dashboard::Action" do title { Faker::Lorem.sentence[0..79].strip } description { Faker::Lorem.sentence } - link { nil } request_to_administrators { true } day_offset { 0 } required_supports { 0 } @@ -150,10 +149,6 @@ FactoryBot.define do request_to_administrators { true } end - trait :external_link do - link { Faker::Internet.url } - end - trait :inactive do active { false } end diff --git a/spec/models/dashboard/executed_action_spec.rb b/spec/models/dashboard/executed_action_spec.rb index dd6181a78..268cc6054 100644 --- a/spec/models/dashboard/executed_action_spec.rb +++ b/spec/models/dashboard/executed_action_spec.rb @@ -2,9 +2,7 @@ require "rails_helper" describe Dashboard::ExecutedAction do let(:proposal) { create :proposal } - let(:action) do - create :dashboard_action, request_to_administrators: true, link: Faker::Internet.url - end + let(:action) { create :dashboard_action, request_to_administrators: true } it "is invalid when proposal is nil" do action = build(:dashboard_executed_action, proposal: nil)