Files
nairobi/spec/features/admin/milestone_statuses_spec.rb
Javi Martín 7ca55c44e0 Apply Rails/SaveBang rubocop rule
Having exceptions is better than having silent bugs.

There are a few methods I've kept the same way they were.

The `RelatedContentScore#score_with_opposite` method is a bit peculiar:
it creates scores for both itself and the opposite related content,
which means the opposite related content will try to create the same
scores as well.

We've already got a test to check `Budget::Ballot#add_investment` when
creating a line fails ("Edge case voting a non-elegible investment").

Finally, the method `User#send_oauth_confirmation_instructions` doesn't
update the record when the email address isn't already present, leading
to the test "Try to register with the email of an already existing user,
when an unconfirmed email was provided by oauth" fo fail if we raise an
exception for an invalid user. That's because updating a user's email
doesn't update the database automatically, but instead a confirmation
email is sent.

There are also a few false positives for classes which don't have bang
methods (like the GraphQL classes) or destroying attachments.

For these reasons, I'm adding the rule with a "Refactor" severity,
meaning it's a rule we can break if necessary.
2019-10-23 14:39:31 +02:00

96 lines
2.5 KiB
Ruby

require "rails_helper"
describe "Admin milestone statuses" do
before do
admin = create(:administrator)
login_as(admin.user)
end
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
click_link "Delete"
end
expect(page).not_to have_content status.name
expect(page).not_to have_content status.description
end
end
end