Refactor nested documentable spec

This commit is contained in:
Senén Rodero Rodríguez
2017-08-23 21:16:06 +02:00
parent 0db49fda4e
commit d34216b5a7

View File

@@ -19,18 +19,14 @@ shared_examples "nested documentable" do |documentable_factory_name, path, docum
end end
context "Nested documents" do scenario "Should show new document link when max documents allowed limit is not reached" do
context "On documentable new page" do
scenario "Should show new document link" do
login_as user login_as user
visit send(path, arguments) visit send(path, arguments)
expect(page).to have_selector "#new_document_link", visible: true expect(page).to have_selector "#new_document_link", visible: true
end end
scenario "Should not show new document when documentable max documents allowed limit is reached", :js do scenario "Should not show new document link when documentable max documents allowed limit is reached", :js do
login_as user login_as user
visit send(path, arguments) visit send(path, arguments)
@@ -63,7 +59,7 @@ shared_examples "nested documentable" do |documentable_factory_name, path, docum
expect(page).to have_selector ".max-documents-notice", visible: true expect(page).to have_selector ".max-documents-notice", visible: true
end end
scenario "Should hide max documents warning after any document link", :js do scenario "Should hide max documents warning after any document removal", :js do
login_as user login_as user
visit send(path, arguments) visit send(path, arguments)
@@ -219,7 +215,7 @@ shared_examples "nested documentable" do |documentable_factory_name, path, docum
expect(page).to have_content documentable_success_notice expect(page).to have_content documentable_success_notice
end end
scenario "Should show new resource with new document after successful creation with one uploaded file", :js do scenario "Should show new document after successful creation with one uploaded file", :js do
login_as user login_as user
visit send(path, arguments) visit send(path, arguments)
send(fill_resource_method_name) if fill_resource_method_name send(fill_resource_method_name) if fill_resource_method_name
@@ -232,7 +228,7 @@ shared_examples "nested documentable" do |documentable_factory_name, path, docum
expect(page).to have_content "Documents (1)" expect(page).to have_content "Documents (1)"
end end
scenario "Should show created resource with new document after successful creation with maximum allowed uploaded files", :js do scenario "Should show resource with new document after successful creation with maximum allowed uploaded files", :js do
login_as user login_as user
visit send(path, arguments) visit send(path, arguments)
send(fill_resource_method_name) if fill_resource_method_name send(fill_resource_method_name) if fill_resource_method_name
@@ -249,10 +245,6 @@ shared_examples "nested documentable" do |documentable_factory_name, path, docum
end end
end
end
def redirected_to_resource_show_or_navigate_to def redirected_to_resource_show_or_navigate_to
find("a", text: "Not now, go to my proposal") find("a", text: "Not now, go to my proposal")
click_on "Not now, go to my proposal" click_on "Not now, go to my proposal"