Files
nairobi/spec/features/admin/dashboard/administrator_tasks_spec.rb
Javi Martín db97f9d08c Add and apply rubocop rules for empty lines
We were very inconsistent regarding these rules.

Personally I prefer no empty lines around blocks, clases, etc... as
recommended by the Ruby style guide [1], and they're the default values
in rubocop, so those are the settings I'm applying.

The exception is the `private` access modifier, since we were leaving
empty lines around it most of the time. That's the default rubocop rule
as well. Personally I don't have a strong preference about this one.


[1] https://rubystyle.guide/#empty-lines-around-bodies
2019-10-24 17:11:47 +02:00

73 lines
2.0 KiB
Ruby

require "rails_helper"
describe "Admin administrator tasks" do
let(:admin) { create :administrator }
before do
login_as(admin.user)
end
context "when visiting index" do
context "and no pending tasks" do
before do
visit admin_dashboard_administrator_tasks_path
end
scenario "shows that there are no records available" do
expect(page).to have_content("There are no resources requested")
end
end
context "and actions defined" do
let!(:task) { create :dashboard_administrator_task, :pending }
before do
visit admin_dashboard_administrator_tasks_path
end
scenario "shows the task data" do
expect(page).to have_content(task.source.proposal.title)
expect(page).to have_content(task.source.action.title)
end
scenario "has a link that allows solving the request" do
expect(page).to have_link("Solve")
end
end
end
context "when solving a task" do
let!(:task) { create :dashboard_administrator_task, :pending }
before do
visit admin_dashboard_administrator_tasks_path
click_link "Solve"
end
scenario "Shows task details and link to proposal" do
expect(page).to have_link(task.source.proposal.title)
expect(page).to have_content(task.source.action.title)
end
scenario "contains a button that solves the request" do
expect(page).to have_button("Mark as solved")
end
scenario "After it is solved appears on solved filter" do
click_button "Mark as solved"
expect(page).not_to have_link(task.source.proposal.title)
expect(page).not_to have_content(task.source.action.title)
expect(page).to have_content("The task has been marked as solved")
within("#filter-subnav") do
click_link "Solved"
end
expect(page).to have_content(task.source.proposal.title)
expect(page).to have_content(task.source.action.title)
expect(page).not_to have_link("Solve")
end
end
end