Move login_as after creating data for a test

It doesn't really affect the tests, but it helps isolate useless
assignments, and we already did it this way 94% of the time.
This commit is contained in:
Javi Martín
2019-09-23 00:51:37 +02:00
parent 24aa4744f1
commit 5cbd160f11
15 changed files with 64 additions and 84 deletions

View File

@@ -253,8 +253,8 @@ 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
login_as user_to_login
create(:document, documentable: documentable)
login_as user_to_login
visit send(path, arguments)
expect(page).to have_css ".document", count: 1
@@ -262,16 +262,16 @@ 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", :js do
login_as user_to_login
create_list(:document, documentable.class.max_documents_allowed, documentable: documentable)
login_as user_to_login
visit send(path, arguments)
expect(page).to have_css "#new_document_link", visible: false
end
scenario "Should show add document button after destroy one document", :js do
login_as user_to_login
create_list(:document, documentable.class.max_documents_allowed, documentable: documentable)
login_as user_to_login
visit send(path, arguments)
last_document = all("#nested-documents .document").last
within last_document do
@@ -282,8 +282,8 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
end
scenario "Should remove nested field after remove document", :js do
login_as user_to_login
create(:document, documentable: documentable)
login_as user_to_login
visit send(path, arguments)
click_on "Remove document"