Files
nairobi/spec/system/admin/milestone_statuses_spec.rb
Javi Martín 92ddcb7aef Use JavaScript in system tests by default
JavaScript is used by about 98% of web users, so by testing without it
enabled, we're only testing that the application works for a very
reduced number of users.

We proceeded this way in the past because CONSUL started using Rails 4.2
and truncating the database between JavaScript tests with database
cleaner, which made these tests terribly slow.

When we upgraded to Rails 5.1 and introduced system tests, we started
using database transactions in JavaScript tests, making these tests much
faster. So now we can use JavaScript tests everywhere without critically
slowing down our test suite.
2021-04-07 14:41:06 +02:00

89 lines
2.4 KiB
Ruby

require "rails_helper"
describe "Admin milestone statuses", :admin do
context "Index" do
scenario "Displaying only not hidden statuses" do
status1 = create(:milestone_status)
status2 = create(:milestone_status)
status1.destroy!
visit admin_milestone_statuses_path
expect(page).not_to have_content status1.name
expect(page).not_to have_content status1.description
expect(page).to have_content status2.name
expect(page).to have_content status2.description
end
scenario "Displaying no statuses text" do
visit admin_milestone_statuses_path
expect(page).to have_content("There are no milestone statuses created")
end
end
context "New" do
scenario "Create status" do
visit admin_milestone_statuses_path
click_link "Create new milestone status"
fill_in "milestone_status_name", with: "New status name"
fill_in "milestone_status_description", with: "This status description"
click_button "Create Milestone Status"
expect(page).to have_content "New status name"
expect(page).to have_content "This status description"
end
scenario "Show validation errors in status form" do
visit admin_milestone_statuses_path
click_link "Create new milestone status"
fill_in "milestone_status_description", with: "This status description"
click_button "Create Milestone Status"
within "#new_milestone_status" do
expect(page).to have_content "can't be blank", count: 1
end
end
end
context "Edit" do
scenario "Change name and description" do
status = create(:milestone_status)
visit admin_milestone_statuses_path
within("#milestone_status_#{status.id}") do
click_link "Edit"
end
fill_in "milestone_status_name", with: "Other status name"
fill_in "milestone_status_description", with: "Other status description"
click_button "Update Milestone Status"
expect(page).to have_content "Other status name"
expect(page).to have_content "Other status description"
end
end
context "Delete" do
scenario "Hides status" do
status = create(:milestone_status)
visit admin_milestone_statuses_path
within("#milestone_status_#{status.id}") do
accept_confirm { click_link "Delete" }
end
expect(page).not_to have_content status.name
expect(page).not_to have_content status.description
end
end
end