diff --git a/spec/shared/system/nested_documentable.rb b/spec/shared/system/nested_documentable.rb index 51cba390f..4afca1ce1 100644 --- a/spec/shared/system/nested_documentable.rb +++ b/spec/shared/system/nested_documentable.rb @@ -316,54 +316,3 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na end 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" -rescue - nil -end - -def documentable_attach_new_file(path, success = true) - click_link "Add new document" - - document = all(".document").last - attach_file "Choose document", path - - within document do - if success - expect(page).to have_css ".loading-bar.complete" - else - expect(page).to have_css ".loading-bar.errors" - end - end -end - -def expect_document_has_title(index, title) - document = all(".document")[index] - - within document do - expect(find("input[name$='[title]']").value).to eq title - end -end - -def documentable_fill_new_valid_proposal - fill_in_new_proposal_title with: "Proposal title #{rand(9999)}" - fill_in "Proposal summary", with: "Proposal summary" - check :proposal_terms_of_service -end - -def documentable_fill_new_valid_dashboard_action - fill_in :dashboard_action_title, with: "Dashboard title" - fill_in_ckeditor "Description", with: "Dashboard description" -end - -def documentable_fill_new_valid_budget_investment - fill_in_new_investment_title with: "Budget investment title" - fill_in_ckeditor "Description", with: "Budget investment description" - check :budget_investment_terms_of_service -end diff --git a/spec/support/common_actions.rb b/spec/support/common_actions.rb index 7207c5c57..8085637d8 100644 --- a/spec/support/common_actions.rb +++ b/spec/support/common_actions.rb @@ -4,6 +4,7 @@ module CommonActions include Budgets include Comments include Debates + include Documents include Emails include Maps include Notifications diff --git a/spec/support/common_actions/documents.rb b/spec/support/common_actions/documents.rb new file mode 100644 index 000000000..52aa9b4d4 --- /dev/null +++ b/spec/support/common_actions/documents.rb @@ -0,0 +1,52 @@ +module Documents + 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" + rescue + nil + end + + def documentable_attach_new_file(path, success = true) + click_link "Add new document" + + document = all(".document").last + attach_file "Choose document", path + + within document do + if success + expect(page).to have_css ".loading-bar.complete" + else + expect(page).to have_css ".loading-bar.errors" + end + end + end + + def expect_document_has_title(index, title) + document = all(".document")[index] + + within document do + expect(find("input[name$='[title]']").value).to eq title + end + end + + def documentable_fill_new_valid_proposal + fill_in_new_proposal_title with: "Proposal title #{rand(9999)}" + fill_in "Proposal summary", with: "Proposal summary" + check :proposal_terms_of_service + end + + def documentable_fill_new_valid_dashboard_action + fill_in :dashboard_action_title, with: "Dashboard title" + fill_in_ckeditor "Description", with: "Dashboard description" + end + + def documentable_fill_new_valid_budget_investment + fill_in_new_investment_title with: "Budget investment title" + fill_in_ckeditor "Description", with: "Budget investment description" + check :budget_investment_terms_of_service + end +end