diff --git a/app/controllers/admin/dashboard/actions_controller.rb b/app/controllers/admin/dashboard/actions_controller.rb index 5435fb6b5..e04e3a7a5 100644 --- a/app/controllers/admin/dashboard/actions_controller.rb +++ b/app/controllers/admin/dashboard/actions_controller.rb @@ -1,4 +1,5 @@ class Admin::Dashboard::ActionsController < Admin::Dashboard::BaseController + include DocumentAttributes helper_method :dashboard_action, :resource def index @@ -58,7 +59,7 @@ class Admin::Dashboard::ActionsController < Admin::Dashboard::BaseController .permit( :title, :description, :short_description, :request_to_administrators, :day_offset, :required_supports, :order, :active, :action_type, :published_proposal, - documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy], + documents_attributes: document_attributes, links_attributes: [:id, :label, :url, :_destroy] ) end diff --git a/app/controllers/admin/legislation/processes_controller.rb b/app/controllers/admin/legislation/processes_controller.rb index 39d636d57..7396ca654 100644 --- a/app/controllers/admin/legislation/processes_controller.rb +++ b/app/controllers/admin/legislation/processes_controller.rb @@ -1,6 +1,7 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseController include Translatable include ImageAttributes + include DocumentAttributes has_filters %w[active all], only: :index @@ -71,7 +72,7 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll :font_color, :related_sdg_list, translation_params(::Legislation::Process), - documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy], + documents_attributes: document_attributes, image_attributes: image_attributes ] end diff --git a/app/controllers/admin/milestones_controller.rb b/app/controllers/admin/milestones_controller.rb index c3019443a..619b3859d 100644 --- a/app/controllers/admin/milestones_controller.rb +++ b/app/controllers/admin/milestones_controller.rb @@ -1,6 +1,7 @@ class Admin::MilestonesController < Admin::BaseController include Translatable include ImageAttributes + include DocumentAttributes before_action :load_milestoneable, only: [:index, :new, :create, :edit, :update, :destroy] before_action :load_milestone, only: [:edit, :update, :destroy] @@ -42,10 +43,9 @@ class Admin::MilestonesController < Admin::BaseController private def milestone_params - documents_attributes = [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy] attributes = [:publication_date, :status_id, translation_params(Milestone), - image_attributes: image_attributes, documents_attributes: documents_attributes] + image_attributes: image_attributes, documents_attributes: document_attributes] params.require(:milestone).permit(*attributes) end diff --git a/app/controllers/admin/poll/questions/answers/images_controller.rb b/app/controllers/admin/poll/questions/answers/images_controller.rb index a312ec7d2..37e4cfcc8 100644 --- a/app/controllers/admin/poll/questions/answers/images_controller.rb +++ b/app/controllers/admin/poll/questions/answers/images_controller.rb @@ -1,4 +1,6 @@ class Admin::Poll::Questions::Answers::ImagesController < Admin::Poll::BaseController + include ImageAttributes + before_action :load_answer, except: :destroy def index @@ -33,7 +35,7 @@ class Admin::Poll::Questions::Answers::ImagesController < Admin::Poll::BaseContr def images_params params.require(:poll_question_answer).permit(:answer_id, - images_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]) + images_attributes: image_attributes) end def load_answer diff --git a/app/controllers/admin/poll/questions/answers_controller.rb b/app/controllers/admin/poll/questions/answers_controller.rb index c75524a60..e5334d483 100644 --- a/app/controllers/admin/poll/questions/answers_controller.rb +++ b/app/controllers/admin/poll/questions/answers_controller.rb @@ -1,5 +1,6 @@ class Admin::Poll::Questions::AnswersController < Admin::Poll::BaseController include Translatable + include DocumentAttributes before_action :load_answer, only: [:show, :edit, :update, :documents] @@ -50,9 +51,8 @@ class Admin::Poll::Questions::AnswersController < Admin::Poll::BaseController private def answer_params - documents_attributes = [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy] attributes = [:title, :description, :given_order, :question_id, - documents_attributes: documents_attributes] + documents_attributes: document_attributes] params.require(:poll_question_answer).permit( *attributes, translation_params(Poll::Question::Answer) diff --git a/app/controllers/budgets/investments_controller.rb b/app/controllers/budgets/investments_controller.rb index e4ef6ae62..a5931cf24 100644 --- a/app/controllers/budgets/investments_controller.rb +++ b/app/controllers/budgets/investments_controller.rb @@ -5,6 +5,8 @@ module Budgets include FlagActions include RandomSeed include ImageAttributes + include DocumentAttributes + include MapLocationAttributes include Translatable include InvestmentFilters @@ -135,8 +137,8 @@ module Budgets attributes = [:heading_id, :tag_list, :organization_name, :location, :terms_of_service, :skip_map, :related_sdg_list, image_attributes: image_attributes, - documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy], - map_location_attributes: [:latitude, :longitude, :zoom]] + documents_attributes: document_attributes, + map_location_attributes: map_location_attributes] params.require(:budget_investment).permit(attributes, translation_params(Budget::Investment)) end diff --git a/app/controllers/concerns/document_attributes.rb b/app/controllers/concerns/document_attributes.rb new file mode 100644 index 000000000..d23b38b8c --- /dev/null +++ b/app/controllers/concerns/document_attributes.rb @@ -0,0 +1,7 @@ +module DocumentAttributes + extend ActiveSupport::Concern + + def document_attributes + [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy] + end +end diff --git a/app/controllers/concerns/map_location_attributes.rb b/app/controllers/concerns/map_location_attributes.rb new file mode 100644 index 000000000..5c49d8469 --- /dev/null +++ b/app/controllers/concerns/map_location_attributes.rb @@ -0,0 +1,7 @@ +module MapLocationAttributes + extend ActiveSupport::Concern + + def map_location_attributes + [:latitude, :longitude, :zoom] + end +end diff --git a/app/controllers/dashboard/polls_controller.rb b/app/controllers/dashboard/polls_controller.rb index 26f638f17..45e760737 100644 --- a/app/controllers/dashboard/polls_controller.rb +++ b/app/controllers/dashboard/polls_controller.rb @@ -1,4 +1,5 @@ class Dashboard::PollsController < Dashboard::BaseController + include DocumentAttributes helper_method :poll before_action :authorize_manage_polls @@ -70,11 +71,7 @@ class Dashboard::PollsController < Dashboard::BaseController def question_answers_attributes [:id, :_destroy, :title, :description, :given_order, :question_id, - documents_attributes: documents_attributes] - end - - def documents_attributes - [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy] + documents_attributes: document_attributes] end def authorize_manage_polls diff --git a/app/controllers/management/budgets/investments_controller.rb b/app/controllers/management/budgets/investments_controller.rb index b15bc3071..d612317a7 100644 --- a/app/controllers/management/budgets/investments_controller.rb +++ b/app/controllers/management/budgets/investments_controller.rb @@ -1,5 +1,8 @@ class Management::Budgets::InvestmentsController < Management::BaseController include Translatable + include ImageAttributes + include DocumentAttributes + include MapLocationAttributes include FeatureFlags feature_flag :budgets @@ -57,7 +60,10 @@ class Management::Budgets::InvestmentsController < Management::BaseController end def investment_params - attributes = [:external_url, :heading_id, :tag_list, :organization_name, :location, :skip_map] + attributes = [:external_url, :heading_id, :tag_list, :organization_name, :location, :skip_map, + image_attributes: image_attributes, + documents_attributes: document_attributes, + map_location_attributes: map_location_attributes] params.require(:budget_investment).permit(attributes, translation_params(Budget::Investment)) end diff --git a/app/controllers/management/proposals_controller.rb b/app/controllers/management/proposals_controller.rb index 26025b26e..2e7cd1aca 100644 --- a/app/controllers/management/proposals_controller.rb +++ b/app/controllers/management/proposals_controller.rb @@ -2,6 +2,7 @@ class Management::ProposalsController < Management::BaseController include HasOrders include CommentableActions include Translatable + include MapLocationAttributes before_action :only_verified_users, except: :print before_action :set_proposal, only: [:vote, :show] @@ -56,7 +57,7 @@ class Management::ProposalsController < Management::BaseController def proposal_params attributes = [:video_url, :responsible_name, :tag_list, :terms_of_service, :geozone_id, - :skip_map, map_location_attributes: [:latitude, :longitude, :zoom]] + :skip_map, map_location_attributes: map_location_attributes] params.require(:proposal).permit(attributes, translation_params(Proposal)) end diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index 8b28e1f79..d99a402cd 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -3,6 +3,8 @@ class ProposalsController < ApplicationController include CommentableActions include FlagActions include ImageAttributes + include DocumentAttributes + include MapLocationAttributes include Translatable before_action :load_categories, only: [:index, :new, :create, :edit, :map, :summary] @@ -101,9 +103,8 @@ class ProposalsController < ApplicationController attributes = [:video_url, :responsible_name, :tag_list, :terms_of_service, :geozone_id, :skip_map, :related_sdg_list, image_attributes: image_attributes, - documents_attributes: [:id, :title, :attachment, :cached_attachment, - :user_id, :_destroy], - map_location_attributes: [:latitude, :longitude, :zoom]] + documents_attributes: document_attributes, + map_location_attributes: map_location_attributes] translations_attributes = translation_params(Proposal, except: :retired_explanation) params.require(:proposal).permit(attributes, translations_attributes) end diff --git a/spec/shared/system/mappable.rb b/spec/shared/system/mappable.rb index f7588710c..004ec9dc9 100644 --- a/spec/shared/system/mappable.rb +++ b/spec/shared/system/mappable.rb @@ -43,7 +43,9 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name, find("#new_map_location").click send("submit_#{mappable_factory_name}_form") - expect(page).to have_css(".map_location") + within ".map_location" do + expect(page).to have_css(".map-icon") + end end scenario "Can not display map on #{mappable_factory_name} when not fill marker on map" do @@ -319,12 +321,7 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name, end def do_login_for(user) - if management - login_managed_user(user) - login_as_manager - else - login_as(user) - end + common_do_login_for(user, management: management) end def fill_in_proposal_form diff --git a/spec/shared/system/nested_documentable.rb b/spec/shared/system/nested_documentable.rb index 9ac9d4b3d..c25baeb20 100644 --- a/spec/shared/system/nested_documentable.rb +++ b/spec/shared/system/nested_documentable.rb @@ -1,4 +1,6 @@ -shared_examples "nested documentable" do |login_as_name, documentable_factory_name, path, documentable_path_arguments, fill_resource_method_name, submit_button, documentable_success_notice| +shared_examples "nested documentable" do |login_as_name, documentable_factory_name, path, + documentable_path_arguments, fill_resource_method_name, + submit_button, documentable_success_notice, management: false| let!(:administrator) { create(:user) } let!(:user) { create(:user, :level_two) } let!(:arguments) { {} } @@ -8,6 +10,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na let!(:documentable) { create(documentable_factory_name, author: user) } end let!(:user_to_login) { send(login_as_name) } + let(:management) { management } before do create(:administrator, user: administrator) @@ -19,7 +22,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na describe "at #{path}" do scenario "Should show new document link when max documents allowed limit is not reached" do - login_as user_to_login + do_login_for user_to_login visit send(path, arguments) expect(page).to have_css "#new_document_link" @@ -27,7 +30,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na scenario "Should not show new document link when documentable max documents allowed limit is reached" do - login_as user_to_login + do_login_for user_to_login visit send(path, arguments) documentable.class.max_documents_allowed.times.each do @@ -38,14 +41,14 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na end scenario "Should not show max documents warning when no documents added" do - login_as user_to_login + do_login_for user_to_login visit send(path, arguments) expect(page).not_to have_css ".max-documents-notice" end scenario "Should show max documents warning when max documents allowed limit is reached" do - login_as user_to_login + do_login_for user_to_login visit send(path, arguments) documentable.class.max_documents_allowed.times.each do documentable_attach_new_file(Rails.root.join("spec/fixtures/files/empty.pdf")) @@ -56,7 +59,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na end scenario "Should hide max documents warning after any document removal" do - login_as user_to_login + do_login_for user_to_login visit send(path, arguments) documentable.class.max_documents_allowed.times.each do @@ -69,7 +72,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na end scenario "Should update nested document file name after choosing a file" do - login_as user_to_login + do_login_for user_to_login visit send(path, arguments) click_link "Add new document" @@ -89,7 +92,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na scenario "Should update nested document file title with file name after choosing a file when no title defined" do - login_as user_to_login + do_login_for user_to_login visit send(path, arguments) documentable_attach_new_file(Rails.root.join("spec/fixtures/files/empty.pdf")) @@ -99,7 +102,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na scenario "Should not update nested document file title with file name after choosing a file when title already defined" do - login_as user_to_login + do_login_for user_to_login visit send(path, arguments) click_link "Add new document" @@ -120,7 +123,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na end scenario "Should update loading bar style after valid file upload" do - login_as user_to_login + do_login_for user_to_login visit send(path, arguments) documentable_attach_new_file(Rails.root.join("spec/fixtures/files/empty.pdf")) @@ -129,7 +132,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na end scenario "Should update loading bar style after invalid file upload" do - login_as user_to_login + do_login_for user_to_login visit send(path, arguments) documentable_attach_new_file( @@ -141,7 +144,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na end scenario "Should update document cached_attachment field after valid file upload" do - login_as user_to_login + do_login_for user_to_login visit send(path, arguments) documentable_attach_new_file(Rails.root.join("spec/fixtures/files/empty.pdf")) @@ -150,7 +153,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na end scenario "Should not update document cached_attachment field after invalid file upload" do - login_as user_to_login + do_login_for user_to_login visit send(path, arguments) documentable_attach_new_file( @@ -163,7 +166,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na scenario "Should show document errors after documentable submit with empty document fields" do - login_as user_to_login + do_login_for user_to_login visit send(path, arguments) click_link "Add new document" @@ -175,7 +178,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na end scenario "Should delete document after valid file upload and click on remove button" do - login_as user_to_login + do_login_for user_to_login visit send(path, arguments) documentable_attach_new_file(Rails.root.join("spec/fixtures/files/empty.pdf")) @@ -186,7 +189,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na scenario "Should show successful notice when resource filled correctly without any nested documents" do - login_as user_to_login + do_login_for user_to_login visit send(path, arguments) send(fill_resource_method_name) if fill_resource_method_name @@ -197,7 +200,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na scenario "Should show successful notice when resource filled correctly and after valid file uploads" do - login_as user_to_login + do_login_for user_to_login visit send(path, arguments) send(fill_resource_method_name) if fill_resource_method_name @@ -211,7 +214,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na if documentable_factory_name == "dashboard_action" skip("Not render Documents count on dashboard_actions") end - login_as user_to_login + do_login_for user_to_login visit send(path, arguments) send(fill_resource_method_name) if fill_resource_method_name @@ -233,7 +236,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na if documentable_factory_name == "dashboard_action" skip("Not render Documents count on dashboard_actions") end - login_as user_to_login + do_login_for user_to_login visit send(path, arguments) send(fill_resource_method_name) if fill_resource_method_name @@ -251,7 +254,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na if path.include? "edit" scenario "Should show persisted documents and remove nested_field" do create(:document, documentable: documentable) - login_as user_to_login + do_login_for user_to_login visit send(path, arguments) expect(page).to have_css ".document", count: 1 @@ -260,7 +263,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na scenario "Should not show add document button when documentable has reached maximum of documents allowed" do create_list(:document, documentable.class.max_documents_allowed, documentable: documentable) - login_as user_to_login + do_login_for user_to_login visit send(path, arguments) expect(page).not_to have_css "#new_document_link" @@ -268,7 +271,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na scenario "Should show add document button after destroy one document" do create_list(:document, documentable.class.max_documents_allowed, documentable: documentable) - login_as user_to_login + do_login_for user_to_login visit send(path, arguments) last_document = all("#nested-documents .document").last within last_document do @@ -280,7 +283,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na scenario "Should remove nested field after remove document" do create(:document, documentable: documentable) - login_as user_to_login + do_login_for user_to_login visit send(path, arguments) click_on "Remove document" @@ -294,7 +297,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na end scenario "Add new document button should not be available" do - login_as user_to_login + do_login_for user_to_login visit send(path, arguments) expect(page).not_to have_content("Add new document") @@ -303,6 +306,10 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na end end +def do_login_for(user) + common_do_login_for(user, management: management) +end + def documentable_redirected_to_resource_show_or_navigate_to find("a", text: "Not now, go to my proposal") click_on "Not now, go to my proposal" diff --git a/spec/shared/system/nested_imageable.rb b/spec/shared/system/nested_imageable.rb index 8f1048a2b..06ba5f63e 100644 --- a/spec/shared/system/nested_imageable.rb +++ b/spec/shared/system/nested_imageable.rb @@ -1,7 +1,10 @@ -shared_examples "nested imageable" do |imageable_factory_name, path, imageable_path_arguments, fill_resource_method_name, submit_button, imageable_success_notice, has_many_images = false| +shared_examples "nested imageable" do |imageable_factory_name, path, imageable_path_arguments, + fill_resource_method_name, submit_button, imageable_success_notice, + has_many_images = false, management: false| let!(:user) { create(:user, :level_two) } let!(:arguments) { {} } let!(:imageable) { create(imageable_factory_name) } + let(:management) { management } before do create(:administrator, user: user) @@ -15,14 +18,14 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p describe "at #{path}" do scenario "Should show new image link when imageable has not an associated image defined" do - login_as user + do_login_for user visit send(path, arguments) expect(page).to have_selector "#new_image_link" end scenario "Should hide new image link after adding one image" do - login_as user + do_login_for user visit send(path, arguments) click_on "Add image" @@ -31,7 +34,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p end scenario "Should update nested image file name after choosing any file" do - login_as user + do_login_for user visit send(path, arguments) click_link "Add image" @@ -46,7 +49,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p end scenario "Should update nested image file title with file name after choosing a file when no title defined" do - login_as user + do_login_for user visit send(path, arguments) imageable_attach_new_file( @@ -58,7 +61,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p end scenario "Should not update nested image file title with file name after choosing a file when title already defined" do - login_as user + do_login_for user visit send(path, arguments) click_link "Add image" @@ -79,7 +82,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p end scenario "Should update loading bar style after valid file upload" do - login_as user + do_login_for user visit send(path, arguments) imageable_attach_new_file( @@ -91,7 +94,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p end scenario "Should update loading bar style after invalid file upload" do - login_as user + do_login_for user visit send(path, arguments) imageable_attach_new_file( @@ -104,7 +107,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p end scenario "Should update image cached_attachment field after valid file upload" do - login_as user + do_login_for user visit send(path, arguments) imageable_attach_new_file( @@ -116,7 +119,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p end scenario "Should not update image cached_attachment field after invalid file upload" do - login_as user + do_login_for user visit send(path, arguments) imageable_attach_new_file( @@ -129,7 +132,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p end scenario "Should show nested image errors after invalid form submit" do - login_as user + do_login_for user visit send(path, arguments) click_link "Add image" @@ -145,7 +148,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p end scenario "Should remove nested image after valid file upload and click on remove button" do - login_as user + do_login_for user visit send(path, arguments) imageable_attach_new_file( @@ -164,7 +167,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p if has_many_images skip "no need to test, there are no attributes for the parent resource" else - login_as user + do_login_for user visit send(path, arguments) send(fill_resource_method_name) if fill_resource_method_name @@ -174,7 +177,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p end scenario "Should show successful notice when resource filled correctly and after valid file uploads" do - login_as user + do_login_for user visit send(path, arguments) send(fill_resource_method_name) if fill_resource_method_name @@ -191,7 +194,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p end scenario "Should show new image after successful creation with one uploaded file" do - login_as user + do_login_for user visit send(path, arguments) send(fill_resource_method_name) if fill_resource_method_name @@ -216,7 +219,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p if path.include? "edit" scenario "Should show persisted image" do create(:image, imageable: imageable) - login_as user + do_login_for user visit send(path, arguments) expect(page).to have_css ".image", count: 1 @@ -224,7 +227,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p scenario "Should not show add image button when image already exists" do create(:image, imageable: imageable) - login_as user + do_login_for user visit send(path, arguments) expect(page).not_to have_css "a#new_image_link" @@ -232,7 +235,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p scenario "Should remove nested field after remove image" do create(:image, imageable: imageable) - login_as user + do_login_for user visit send(path, arguments) click_on "Remove image" @@ -241,7 +244,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p scenario "Should show add image button after remove image" do create(:image, imageable: imageable) - login_as user + do_login_for user visit send(path, arguments) click_on "Remove image" @@ -251,6 +254,10 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p end end +def do_login_for(user) + common_do_login_for(user, management: management) +end + def imageable_redirected_to_resource_show_or_navigate_to find("a", text: "Not now, go to my proposal") click_on "Not now, go to my proposal" diff --git a/spec/support/common_actions/users.rb b/spec/support/common_actions/users.rb index d5fde76d4..59d86682f 100644 --- a/spec/support/common_actions/users.rb +++ b/spec/support/common_actions/users.rb @@ -81,4 +81,13 @@ module Users def expect_not_to_be_signed_in expect(find(".top-bar-right")).not_to have_content "My account" end + + def common_do_login_for(user, management:) + if management + login_managed_user(user) + login_as_manager + else + login_as(user) + end + end end diff --git a/spec/system/management/budget_investments_spec.rb b/spec/system/management/budget_investments_spec.rb index 53bf0f87a..4d35c64d3 100644 --- a/spec/system/management/budget_investments_spec.rb +++ b/spec/system/management/budget_investments_spec.rb @@ -7,6 +7,25 @@ describe "Budget Investments" do let(:heading) { create(:budget_heading, group: group, name: "Health") } let(:user) { create(:user, :level_two) } + it_behaves_like "nested documentable", + "user", + "budget_investment", + "new_management_budget_investment_path", + { "budget_id": "budget_id" }, + "documentable_fill_new_valid_budget_investment", + "Create Investment", + "Investment created successfully.", + management: true + + it_behaves_like "nested imageable", + "budget_investment", + "new_management_budget_investment_path", + { "budget_id": "budget_id" }, + "imageable_fill_new_valid_budget_investment", + "Create Investment", + "Investment created successfully.", + management: true + it_behaves_like "mappable", "budget_investment", "investment",