diff --git a/app/assets/stylesheets/proposal.scss b/app/assets/stylesheets/proposal.scss index 8b6b6a911..4eb3ff94f 100644 --- a/app/assets/stylesheets/proposal.scss +++ b/app/assets/stylesheets/proposal.scss @@ -245,4 +245,8 @@ .body { padding: 1rem 1.5rem 1rem 1.5rem; } + + .proposal-dashboard-action-links { + margin-bottom: 15pt; + } } diff --git a/app/controllers/admin/proposal_dashboard/actions_controller.rb b/app/controllers/admin/proposal_dashboard/actions_controller.rb index 66f508efa..1e4c5ec0f 100644 --- a/app/controllers/admin/proposal_dashboard/actions_controller.rb +++ b/app/controllers/admin/proposal_dashboard/actions_controller.rb @@ -2,7 +2,7 @@ class Admin::ProposalDashboard::ActionsController < Admin::ProposalDashboard::Ba helper_method :proposal_dashboard_action, :resource def index - @proposal_dashboard_actions = ProposalDashboardAction.all + @proposal_dashboard_actions = ProposalDashboardAction.order(required_supports: :asc) end def new @@ -53,7 +53,11 @@ class Admin::ProposalDashboard::ActionsController < Admin::ProposalDashboard::Ba def proposal_dashboard_action_params params .require(:proposal_dashboard_action) - .permit(:title, :description, :link, :request_to_administrators, :day_offset, :required_supports, :order, :active, :action_type) + .permit( + :title, :description, :short_description, :request_to_administrators, :day_offset, :required_supports, :order, :active, :action_type, + documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy], + links_attributes: [:id, :label, :url, :open_in_new_tab, :_destroy] + ) end diff --git a/app/controllers/proposals_dashboard_controller.rb b/app/controllers/proposals_dashboard_controller.rb index 558d526d0..9aff111ca 100644 --- a/app/controllers/proposals_dashboard_controller.rb +++ b/app/controllers/proposals_dashboard_controller.rb @@ -16,7 +16,7 @@ class ProposalsDashboardController < Dashboard::BaseController authorize! :dashboard, proposal ProposalExecutedDashboardAction.create(proposal: proposal, proposal_dashboard_action: proposal_dashboard_action, executed_at: Time.now) - redirect_to proposal_dashboard_index_path(proposal.to_param) + redirect_to progress_proposal_dashboard_index_path(proposal.to_param) end def new_request @@ -27,11 +27,11 @@ class ProposalsDashboardController < Dashboard::BaseController def create_request authorize! :dashboard, proposal - source_params = proposal_executed_dashboard_action_params.merge( + source_params = { proposal: proposal, proposal_dashboard_action: proposal_dashboard_action, executed_at: Time.now - ) + } @proposal_executed_dashboard_action = ProposalExecutedDashboardAction.new(source_params) if @proposal_executed_dashboard_action.save @@ -54,9 +54,6 @@ class ProposalsDashboardController < Dashboard::BaseController private - def proposal_executed_dashboard_action_params - params.require(:proposal_executed_dashboard_action).permit(:comments) - end def proposal_dashboard_action @proposal_dashboard_action ||= ProposalDashboardAction.find(params[:id]) diff --git a/app/models/abilities/common.rb b/app/models/abilities/common.rb index 3629d03b8..407615d6a 100644 --- a/app/models/abilities/common.rb +++ b/app/models/abilities/common.rb @@ -58,7 +58,9 @@ module Abilities can [:create, :destroy], Follow - can [:destroy], Document, documentable: { author_id: user.id } + can [:destroy], Document do |document| + document.documentable.try(:author_id) == user.id + end can [:destroy], Image, imageable: { author_id: user.id } diff --git a/app/models/concerns/linkable.rb b/app/models/concerns/linkable.rb new file mode 100644 index 000000000..c064b31ed --- /dev/null +++ b/app/models/concerns/linkable.rb @@ -0,0 +1,9 @@ +module Linkable + extend ActiveSupport::Concern + + included do + has_many :links, as: :linkable, dependent: :destroy + accepts_nested_attributes_for :links, allow_destroy: true + end +end + diff --git a/app/models/link.rb b/app/models/link.rb new file mode 100644 index 000000000..10261e9c0 --- /dev/null +++ b/app/models/link.rb @@ -0,0 +1,7 @@ +class Link < ActiveRecord::Base + belongs_to :linkable, polymorphic: true + + validates :label, presence: true + validates :url, presence: true + validates :linkable, presence: true +end diff --git a/app/models/proposal_dashboard_action.rb b/app/models/proposal_dashboard_action.rb index dcf08331c..4eb1e8a69 100644 --- a/app/models/proposal_dashboard_action.rb +++ b/app/models/proposal_dashboard_action.rb @@ -1,4 +1,11 @@ class ProposalDashboardAction < ActiveRecord::Base + include Documentable + documentable max_documents_allowed: 3, + max_file_size: 3.megabytes, + accepted_content_types: [ 'application/pdf' ] + + include Linkable + acts_as_paranoid column: :hidden_at include ActsAsParanoidAliases @@ -14,8 +21,7 @@ class ProposalDashboardAction < ActiveRecord::Base validates :description, presence: true, - allow_blank: false, - length: { in: 4..255 } + allow_blank: false validates :action_type, presence: true @@ -33,11 +39,6 @@ class ProposalDashboardAction < ActiveRecord::Base greater_than_or_equal_to: 0 } - validates :link, - presence: true, - allow_blank: false, - unless: :request_to_administrators? - default_scope { order(order: :asc, title: :asc) } scope :active, -> { where(active: true) } diff --git a/app/models/proposal_executed_dashboard_action.rb b/app/models/proposal_executed_dashboard_action.rb index f54642d0b..8b7b2f918 100644 --- a/app/models/proposal_executed_dashboard_action.rb +++ b/app/models/proposal_executed_dashboard_action.rb @@ -7,9 +7,4 @@ class ProposalExecutedDashboardAction < ActiveRecord::Base validates :proposal, presence: true, uniqueness: { scope: :proposal_dashboard_action } validates :proposal_dashboard_action, presence: true validates :executed_at, presence: true - validates :comments, presence: true, allow_blank: false, if: :comments_required? - - def comments_required? - proposal_dashboard_action&.request_to_administrators? || false - end end diff --git a/app/views/admin/proposal_dashboard/actions/_form.html.erb b/app/views/admin/proposal_dashboard/actions/_form.html.erb index 322f34c96..f4f25cec5 100644 --- a/app/views/admin/proposal_dashboard/actions/_form.html.erb +++ b/app/views/admin/proposal_dashboard/actions/_form.html.erb @@ -1,5 +1,4 @@ <%= form_for [:admin, proposal_dashboard_action] do |f| %> - <%= render 'shared/errors' %>
@@ -11,31 +10,33 @@
- <%= f.label :description %> - <%= f.text_field :description, label: false %> + <%= f.label :short_description %> + <%= f.text_field :short_description, label: false %>
-
- <%= f.label :action_type %> - <% ProposalDashboardAction.action_types.keys.each do |action_type_value| %> - <%= f.radio_button :action_type, action_type_value, label: false %> - <%= f.label "action_type_#{action_type_value}", t("admin.proposal_dashboard_actions.action_type.#{action_type_value}") %> -
- <% end %> -
- -
- <%= f.check_box :request_to_administrators, label: ProposalDashboardAction.human_attribute_name(:request_to_administrators) %> -
-
- <%= f.label :link%> - <%= f.text_field :link, label: false %> + <%= f.cktext_area :description, + ckeditor: { language: I18n.locale } %>
+
+
+ <%= f.label :action_type %> + <% ProposalDashboardAction.action_types.keys.each do |action_type_value| %> + <%= f.radio_button :action_type, action_type_value, label: false %> + <%= f.label "action_type_#{action_type_value}", t("admin.proposal_dashboard_actions.action_type.#{action_type_value}") %> +
+ <% end %> +
+
+ +
+ <%= f.check_box :request_to_administrators, label: ProposalDashboardAction.human_attribute_name(:request_to_administrators) %> +
+
<%= f.label :day_offset %> @@ -57,6 +58,26 @@ <%= f.check_box :active, label: ProposalDashboardAction.human_attribute_name(:active) %>
+
+
+
+ +
+ <%= render 'documents/nested_documents', documentable: proposal_dashboard_action, f: f %> +
+ +
+
+
+ + + +
+
+
+
<%= f.submit(class: 'button expanded', value: t('admin.proposal_dashboard_actions.form.submit_button')) %> diff --git a/app/views/admin/proposal_dashboard/actions/index.html.erb b/app/views/admin/proposal_dashboard/actions/index.html.erb index a12bb416a..997df7dac 100644 --- a/app/views/admin/proposal_dashboard/actions/index.html.erb +++ b/app/views/admin/proposal_dashboard/actions/index.html.erb @@ -10,7 +10,8 @@ <%= ProposalDashboardAction.human_attribute_name(:title) %> <%= ProposalDashboardAction.human_attribute_name(:action_type) %> - <%= ProposalDashboardAction.human_attribute_name(:active) %> + <%= ProposalDashboardAction.human_attribute_name(:required_supports) %> + <%= ProposalDashboardAction.human_attribute_name(:active) %> @@ -26,8 +27,9 @@ <%= action.title %> <%= t("admin.proposal_dashboard_actions.action_type.#{action.action_type}") %> - <%= active_human_readable(action.active) %> - + <%= action.required_supports %> + <%= active_human_readable(action.active) %> + <%= link_to t('admin.proposal_dashboard_actions.index.edit'), edit_admin_proposal_dashboard_action_path(action), class: 'edit-banner button hollow' %> diff --git a/app/views/admin/proposal_dashboard/administrator_tasks/_form.html.erb b/app/views/admin/proposal_dashboard/administrator_tasks/_form.html.erb index 20985eda3..c1bfc7655 100644 --- a/app/views/admin/proposal_dashboard/administrator_tasks/_form.html.erb +++ b/app/views/admin/proposal_dashboard/administrator_tasks/_form.html.erb @@ -3,7 +3,6 @@
<%=t '.proposal', title: administrator_task.source.proposal.title %>

<%=t '.request', title: administrator_task.source.proposal_dashboard_action.title %>

- <%== administrator_task.source.comments unless administrator_task.source.comments.blank? %> <%= link_to t('.check_details'), proposal_path(administrator_task.source.proposal), target: '_blank' %>
diff --git a/app/views/links/_link_fields.html.erb b/app/views/links/_link_fields.html.erb new file mode 100644 index 000000000..6a615399f --- /dev/null +++ b/app/views/links/_link_fields.html.erb @@ -0,0 +1,20 @@ + + diff --git a/app/views/links/_nested_links.html.erb b/app/views/links/_nested_links.html.erb new file mode 100644 index 000000000..c46209798 --- /dev/null +++ b/app/views/links/_nested_links.html.erb @@ -0,0 +1,22 @@ + + diff --git a/app/views/proposals_dashboard/_form.html.erb b/app/views/proposals_dashboard/_form.html.erb index c4bebac28..4b5ae62d0 100644 --- a/app/views/proposals_dashboard/_form.html.erb +++ b/app/views/proposals_dashboard/_form.html.erb @@ -1,12 +1,8 @@ -<%= form_for @proposal_executed_dashboard_action, - url: create_request_proposal_dashboard_url(proposal, proposal_dashboard_action) do |f| %> - <%= render 'shared/errors', resource: @proposal_executed_dashboard_action %> - -
- <%= f.label :comments %> - <%= f.cktext_area :comments, ckeditor: { language: I18n.locale }, label: false %> -
-
- <%= f.submit(class: 'button', value: t('.request')) %> -
+<% if proposal_dashboard_action.request_to_administrators %> + <%= form_for @proposal_executed_dashboard_action, + url: create_request_proposal_dashboard_url(proposal, proposal_dashboard_action) do |f| %> +
+ <%= f.submit(class: 'button hollow expanded', value: t('.request')) %> +
+ <% end %> <% end %> diff --git a/app/views/proposals_dashboard/_menu.html.erb b/app/views/proposals_dashboard/_menu.html.erb index 79b4e186f..a56ff4a52 100644 --- a/app/views/proposals_dashboard/_menu.html.erb +++ b/app/views/proposals_dashboard/_menu.html.erb @@ -32,12 +32,10 @@ <% resources.each do |resource| %>
  • > - <% if resource.request_to_administrators? %> - <%= link_to new_request_proposal_dashboard_path(proposal, resource) do %> - <%= resource.title %> - <% end %> - <% else %> - <%= link_to resource.title, resource.link, target: '_blank' %> + <%= link_to new_request_proposal_dashboard_path(proposal, resource) do %> + + <%= resource.title %> + <% end %>
  • <% end %> diff --git a/app/views/proposals_dashboard/_proposed_action.html.erb b/app/views/proposals_dashboard/_proposed_action.html.erb index b91a6c736..3cf8d458e 100644 --- a/app/views/proposals_dashboard/_proposed_action.html.erb +++ b/app/views/proposals_dashboard/_proposed_action.html.erb @@ -1,30 +1,18 @@ - <% if action.link.blank? %> - + <%= link_to new_request_proposal_dashboard_path(proposal, action) do %> + <%= action.title %> - <% else %> - <%= link_to action.link, target: '_blank' do %> - - <%= action.title %> - - <% end %> <% end %> <% if action.proposals.where(id: proposal.id).any? %> <%=l action.proposal_executed_dashboard_actions.find_by(proposal: proposal).executed_at, format: :short %> <% else %> - <% if action.request_to_administrators? %> - <%= link_to t('.execute'), - new_request_proposal_dashboard_path(proposal, action) %> - <% else %> - <%= link_to t('.execute'), - execute_proposal_dashboard_path(proposal.to_param, action.to_param), - method: 'post', - data: { confirm: t('admin.actions.confirm') } %> - <% end %> + <%= link_to t('.execute'), + execute_proposal_dashboard_path(proposal, action), + method: 'post' %> <% end %> diff --git a/app/views/proposals_dashboard/new_request.html.erb b/app/views/proposals_dashboard/new_request.html.erb index e52a2aa2d..7e2e6dec6 100644 --- a/app/views/proposals_dashboard/new_request.html.erb +++ b/app/views/proposals_dashboard/new_request.html.erb @@ -1,15 +1,25 @@ -<% content_for :action_title, t('.title') %> - -
    +<% content_for :action_title, proposal_dashboard_action.title %> +
    - <%= back_link_to %> + <%== proposal_dashboard_action.description %> +
    -

    <%= proposal_dashboard_action.title %>

    -
    - <%= proposal_dashboard_action.description %> -
    +
    + <% if proposal_dashboard_action.links.any? %> + + <% end %> + <%= render 'documents/documents', documents: proposal_dashboard_action.documents %> <%= render 'proposals_dashboard/form' %>
    diff --git a/config/locales/en/activerecord.yml b/config/locales/en/activerecord.yml index f2454734c..6e0838c8b 100644 --- a/config/locales/en/activerecord.yml +++ b/config/locales/en/activerecord.yml @@ -112,6 +112,9 @@ en: administrator_task: one: Task other: Tasks + link: + one: Link + other: Links attributes: budget: name: "Name" @@ -267,6 +270,7 @@ en: limit: Number of items proposal_dashboard_action: title: Title + short_description: Short description description: Description link: External link request_to_administrators: Admin request @@ -275,12 +279,13 @@ en: order: Order active: Active action_type: Type - proposal_executed_dashboard_action: - comments: Comments for the administrator administrator_task: source: Source user: Executed by - executed_at: Executed at + link: + label: Title + url: Link + open_in_new_tab: Open in new tab errors: models: user: diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml index e4f521acc..2bf232593 100644 --- a/config/locales/en/general.yml +++ b/config/locales/en/general.yml @@ -531,7 +531,7 @@ en: retire: Retire send_notification: Send notification new_request: - title: Administrator request + links: Links dashboard: polls: form: @@ -943,3 +943,12 @@ en: text_sign_in: login text_sign_up: sign up title: How I can comment this document? + links: + nested_links: + title: Links + note: Add the links that are of interest + add_new_link: Add new link + link_fields: + label_placeholder: Link title + url_placeholder: Link address + destroy: Remove link diff --git a/config/locales/es/activerecord.yml b/config/locales/es/activerecord.yml index 0b17a6f4c..976ad6847 100644 --- a/config/locales/es/activerecord.yml +++ b/config/locales/es/activerecord.yml @@ -112,6 +112,9 @@ es: administrator_task: one: Tarea other: Tareas + link: + one: Enlace + other: Enlaces attributes: budget: name: "Nombre" @@ -268,6 +271,7 @@ es: limit: Número de elementos proposal_dashboard_action: title: Título + short_description: Descripción corta description: Descripción link: Enlace externo request_to_administrators: Petición para administrador @@ -276,12 +280,14 @@ es: order: Orden active: Activa action_type: Tipo - proposal_executed_dashboard_action: - comments: Comentarios para el administrador administrator_task: source: Fuente user: Ejecutado por executed_at: Ejecutado el + link: + label: Título + url: Enlace + open_in_new_tab: Abrir en ventana nueva errors: models: user: diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml index 78aa4c351..22515db26 100644 --- a/config/locales/es/general.yml +++ b/config/locales/es/general.yml @@ -531,7 +531,7 @@ es: retire: Retirar send_notification: Enviar notificación new_request: - title: Petición al administrador + liks: Enlaces dashboard: polls: form: @@ -942,3 +942,12 @@ es: text_sign_in: iniciar sesión text_sign_up: registrarte title: "¿Cómo puedo comentar este documento?" + links: + nested_links: + title: Enlaces + note: Añade los enlaces que sean de interés. + add_new_link: Añadir nuevo enlace + link_fields: + label_placeholder: Título del enlace + url_placeholder: Dirección del enlace + destroy: Borrar enlace diff --git a/db/migrate/20180702050717_add_short_description_to_proposal_dashboard_actions.rb b/db/migrate/20180702050717_add_short_description_to_proposal_dashboard_actions.rb new file mode 100644 index 000000000..5921b93c0 --- /dev/null +++ b/db/migrate/20180702050717_add_short_description_to_proposal_dashboard_actions.rb @@ -0,0 +1,6 @@ +class AddShortDescriptionToProposalDashboardActions < ActiveRecord::Migration + def change + add_column :proposal_dashboard_actions, :short_description, :string + change_column :proposal_dashboard_actions, :description, :text + end +end diff --git a/db/migrate/20180702060913_create_links.rb b/db/migrate/20180702060913_create_links.rb new file mode 100644 index 000000000..cbe0ac431 --- /dev/null +++ b/db/migrate/20180702060913_create_links.rb @@ -0,0 +1,12 @@ +class CreateLinks < ActiveRecord::Migration + def change + create_table :links do |t| + t.string :label + t.string :url + t.boolean :open_in_new_tab + t.references :linkable, polymorphic: true, index: true + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20180702085737_remove_comments_from_proposal_executed_dashboard_action.rb b/db/migrate/20180702085737_remove_comments_from_proposal_executed_dashboard_action.rb new file mode 100644 index 000000000..1f15c7bb1 --- /dev/null +++ b/db/migrate/20180702085737_remove_comments_from_proposal_executed_dashboard_action.rb @@ -0,0 +1,5 @@ +class RemoveCommentsFromProposalExecutedDashboardAction < ActiveRecord::Migration + def change + remove_column :proposal_executed_dashboard_actions, :comments, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index 6998489f7..7942e3844 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180625075520) do +ActiveRecord::Schema.define(version: 20180702085737) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -635,6 +635,18 @@ ActiveRecord::Schema.define(version: 20180625075520) do add_index "legislation_questions", ["hidden_at"], name: "index_legislation_questions_on_hidden_at", using: :btree add_index "legislation_questions", ["legislation_process_id"], name: "index_legislation_questions_on_legislation_process_id", using: :btree + create_table "links", force: :cascade do |t| + t.string "label" + t.string "url" + t.boolean "open_in_new_tab" + t.integer "linkable_id" + t.string "linkable_type" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "links", ["linkable_type", "linkable_id"], name: "index_links_on_linkable_type_and_linkable_id", using: :btree + create_table "local_census_records", force: :cascade do |t| t.string "document_number", null: false t.string "document_type", null: false @@ -895,7 +907,7 @@ ActiveRecord::Schema.define(version: 20180625075520) do create_table "proposal_dashboard_actions", force: :cascade do |t| t.string "title", limit: 80 - t.string "description" + t.text "description" t.string "link" t.boolean "request_to_administrators", default: false t.integer "day_offset", default: 0 @@ -904,13 +916,13 @@ ActiveRecord::Schema.define(version: 20180625075520) do t.boolean "active", default: true t.datetime "hidden_at" t.integer "action_type", default: 0, null: false + t.string "short_description" end create_table "proposal_executed_dashboard_actions", force: :cascade do |t| t.integer "proposal_id" t.integer "proposal_dashboard_action_id" t.datetime "executed_at" - t.text "comments" t.datetime "created_at", null: false t.datetime "updated_at", null: false end diff --git a/lib/tasks/proposal_actions.rake b/lib/tasks/proposal_actions.rake new file mode 100644 index 000000000..ba72c1191 --- /dev/null +++ b/lib/tasks/proposal_actions.rake @@ -0,0 +1,13 @@ +namespace :proposal_actions do + desc 'Move link attribute to links collection' + task migrate_links: :environment do + ProposalDashboardAction.where.not(link: nil).each do |action| + Link.create!( + label: action.title, + url: action.link, + open_in_new_tab: true, + linkable: action + ) + end + end +end diff --git a/spec/factories.rb b/spec/factories.rb index 9ffb97b35..625a121eb 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -1076,14 +1076,10 @@ LOREM_IPSUM proposal proposal_dashboard_action executed_at { Time.current } - - trait :with_comments do - comments { Faker::Lorem.sentence(10) } - end end factory :administrator_task do - source { |s| s.association(:proposal_executed_dashboard_action, :with_comments) } + source { |s| s.association(:proposal_executed_dashboard_action) } user executed_at { Time.current } @@ -1097,4 +1093,15 @@ LOREM_IPSUM executed_at { Time.current } end end + + factory :link do + linkable { |s| s.association(:proposal_dashboard_action) } + label { Faker::Lorem.sentence } + url { Faker::Internet.url } + open_in_new_tab false + + trait :open_in_new_tab do + open_in_new_tab true + end + end end diff --git a/spec/features/admin/administrator_tasks_spec.rb b/spec/features/admin/administrator_tasks_spec.rb index 08a1bac3b..7830f5663 100644 --- a/spec/features/admin/administrator_tasks_spec.rb +++ b/spec/features/admin/administrator_tasks_spec.rb @@ -55,10 +55,6 @@ describe 'Administrator tasks' do expect(page).to have_button('Mark as solved') end - scenario 'shows the comments added by the user during the request' do - expect(page).to have_content(task.source.comments) - end - context 'and the Mark as solved button is pressed' do before do click_button 'Mark as solved' diff --git a/spec/models/link_spec.rb b/spec/models/link_spec.rb new file mode 100644 index 000000000..aa905d1fb --- /dev/null +++ b/spec/models/link_spec.rb @@ -0,0 +1,29 @@ +require 'rails_helper' + +describe Link do + subject do + build :link, + linkable: proposal_dashboard_action, + label: label, + url: url, + open_in_new_tab: true + end + + let(:proposal_dashboard_action) { build :proposal_dashboard_action } + let(:label) { Faker::Lorem.sentence } + let(:url) { Faker::Internet.url } + + it { should be_valid } + + context 'when label is blank' do + let(:label) { '' } + + it { should_not be_valid } + end + + context 'when url is blank' do + let(:url) { '' } + + it { should_not be_valid } + end +end diff --git a/spec/models/proposal_dashboard_action_spec.rb b/spec/models/proposal_dashboard_action_spec.rb index 13383cc4f..83d7d568a 100644 --- a/spec/models/proposal_dashboard_action_spec.rb +++ b/spec/models/proposal_dashboard_action_spec.rb @@ -7,7 +7,6 @@ describe ProposalDashboardAction do description: description, day_offset: day_offset, required_supports: required_supports, - link: link, request_to_administrators: request_to_administrators, action_type: action_type end @@ -16,7 +15,6 @@ describe ProposalDashboardAction do let(:description) { Faker::Lorem.sentence } let(:day_offset) { 0 } let(:required_supports) { 0 } - let(:link) { nil } let(:request_to_administrators) { true } let(:action_type) { 'resource' } @@ -48,18 +46,6 @@ describe ProposalDashboardAction do it { should_not be_valid } end - - context 'and description is very short' do - let(:description) { 'abc' } - - it { should_not be_valid } - end - - context 'and description is very long' do - let(:description) { 'a' * 256 } - - it { should_not be_valid } - end end context 'when validating day_offset' do @@ -102,32 +88,6 @@ describe ProposalDashboardAction do end end - context 'when url is blank' do - let(:link) { nil } - - context 'and no request_to_administrators' do - let(:request_to_administrators) { false } - - it { should_not be_valid } - end - - context 'and request_to_administrators' do - let(:request_to_administrators) { true } - - it { should be_valid } - end - end - - context 'when url is not blank' do - let(:link) { Faker::Internet.url } - - context 'and no request_to_administrators' do - let(:request_to_administrators) { false } - - it { should be_valid } - end - end - context 'when action type is nil' do let(:action_type) { nil } diff --git a/spec/models/proposal_executed_dashboard_action_spec.rb b/spec/models/proposal_executed_dashboard_action_spec.rb index 6072d4867..19c522ed3 100644 --- a/spec/models/proposal_executed_dashboard_action_spec.rb +++ b/spec/models/proposal_executed_dashboard_action_spec.rb @@ -5,8 +5,7 @@ describe ProposalExecutedDashboardAction do build :proposal_executed_dashboard_action, proposal: proposal, proposal_dashboard_action: proposal_dashboard_action, - executed_at: executed_at, - comments: comments + executed_at: executed_at end let(:proposal) { create :proposal } @@ -15,7 +14,6 @@ describe ProposalExecutedDashboardAction do end let(:request_to_administrators) { false } let(:executed_at) { Time.current } - let(:comments) { '' } it { should be_valid } @@ -40,17 +38,7 @@ describe ProposalExecutedDashboardAction do context 'when the action sends a request to the administrators' do let(:request_to_administrators) { true } - context 'and comments are blank' do - let(:comments) { '' } - - it { should_not be_valid } - end - - context 'and comments have value' do - let(:comments) { Faker::Lorem.sentence } - - it { should be_valid } - end + it { should be_valid } end context 'when it has been already executed' do