fix volunteer_show_assignments_test

parent e7b34355
......@@ -2,13 +2,15 @@ require 'application_system_test_case'
class VolunteerShowAssignmentsTest < ApplicationSystemTestCase
def setup
@superadmin = create :user
@superadmin = create :superadmin
@volunteer = create :volunteer
@assignment = create :assignment, volunteer: @volunteer, period_start: 2.weeks.ago,
@assignment = create :assignment, client: create(:client), volunteer: @volunteer, period_start: 3.weeks.ago,
period_end: nil, creator: @superadmin
@assignment_log = create(:assignment, volunteer: @volunteer, period_start: 2.weeks.ago,
period_end: 2.days.ago, creator: @superadmin, termination_submitted_at: 2.days.ago,
termination_submitted_by: @volunteer.user, period_end_set_by: @superadmin)
@log_creator = create :superadmin
@log_client = create :client
@assignment_log = create(:assignment, client: @log_client, volunteer: @volunteer, period_start: 2.weeks.ago,
period_end: 2.days.ago, creator: @log_creator, termination_submitted_at: 2.days.ago,
termination_submitted_by: @volunteer.user, period_end_set_by: @log_creator)
@assignment_log.verify_termination(@superadmin)
@assignment_log.update(termination_verified_at: 2.days.ago)
end
......@@ -17,18 +19,21 @@ class VolunteerShowAssignmentsTest < ApplicationSystemTestCase
login_as @superadmin
visit volunteer_path(@volunteer)
within '.assignments-table' do
assert page.has_text? "#{@assignment.client.contact.full_name} "\
"#{I18n.l(@assignment.period_start)} #{@assignment.creator.full_name}"
refute page.has_text? "#{@assignment_log.client.contact.full_name} "\
"#{I18n.l(@assignment_log.period_start)} #{I18n.l(@assignment_log.period_end)} "\
"#{@assignment_log.creator.full_name}"
refute page.has_text? start_end_localized(@assignment_log), wait: 1
assert page.has_text? start_end_localized(@assignment)
client_creator_names(@assignment).each do |name|
assert page.has_text? name
end
end
within '.assignment-logs-table' do
refute page.has_text? "#{@assignment.client.contact.full_name} "\
"#{I18n.l(@assignment.period_start)} #{@assignment.creator.full_name}"
assert page.has_text? "#{@assignment_log.client.contact.full_name} "\
"#{I18n.l(@assignment_log.period_start)} #{I18n.l(@assignment_log.period_end)} "\
"#{@assignment_log.creator.full_name}"
refute page.has_text? start_end_localized(@assignment), wait: 1
assert page.has_text? start_end_localized(@assignment_log)
client_creator_names(@assignment_log).each do |name|
assert page.has_text? name
end
end
end
......@@ -36,18 +41,29 @@ class VolunteerShowAssignmentsTest < ApplicationSystemTestCase
login_as @volunteer.user
visit volunteer_path(@volunteer)
within '.assignments-table' do
assert page.has_text? "#{@assignment.client.contact.full_name} "\
"#{I18n.l(@assignment.period_start)} #{@assignment.creator.full_name}"
refute page.has_text? "#{@assignment_log.client.contact.full_name} "\
"#{I18n.l(@assignment_log.period_start)} #{I18n.l(@assignment_log.period_end)} "\
"#{@assignment_log.creator.full_name}"
refute page.has_text? start_end_localized(@assignment_log), wait: 1
assert page.has_text? start_end_localized(@assignment)
client_creator_names(@assignment).each do |name|
assert page.has_text? name
end
end
within '.assignment-logs-table' do
refute page.has_text? "#{@assignment.client.contact.full_name} "\
"#{I18n.l(@assignment.period_start)} #{@assignment.creator.full_name}"
assert page.has_text? "#{@assignment_log.client.contact.full_name} "\
"#{I18n.l(@assignment_log.period_start)} #{I18n.l(@assignment_log.period_end)} "\
"#{@assignment_log.creator.full_name}"
assert_not page.has_text? start_end_localized(@assignment), wait: 1
assert page.has_text? start_end_localized(@assignment_log)
client_creator_names(@assignment_log).each do |name|
assert page.has_text? name
end
end
end
def client_creator_names(assignment)
[assignment.client.contact.full_name, assignment.creator.full_name]
end
def start_end_localized(assignment)
assignment.attributes.values_at('period_start', 'period_end').compact.map { |d| I18n.l(d) }.join(' ')
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment