Skip to content

Commit

Permalink
Added tests for showing empty programmes as related items.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin De Pelseneer authored and stuzart committed Mar 27, 2023
1 parent f74b8fd commit 0b80f2e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
21 changes: 20 additions & 1 deletion test/functional/people_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ def test_should_add_nofollow_to_links_in_show_page
assert_select '.pagination-container li.active', text: '1'
assert_select '.list_items_container .collapse', count: 3


get :index, params: { view: 'table' }
assert_response :success
assert_equal 3, assigns(:per_page)
Expand Down Expand Up @@ -824,6 +824,25 @@ def test_should_add_nofollow_to_links_in_show_page
end
end

test 'should show empty programme as related item if programme administrator' do
person1 = Factory(:programme_administrator_not_in_project)
prog1 = Factory(:min_programme, programme_administrators: [person1])

assert person1.projects.empty?

get :show, params: { id: person1.id }
assert_response :success

assert_select 'h2', text: /Related items/i
assert_select 'div.list_items_container' do
assert_select 'div.list_item' do
assert_select 'div.list_item_title' do
assert_select 'a[href=?]', programme_path(prog1), text: prog1.title
end
end
end
end

test 'related investigations should show where person is creator' do
person = Factory(:person)
inv1 = Factory(:investigation, contributor: Factory(:person), policy: Factory(:public_policy))
Expand Down
19 changes: 19 additions & 0 deletions test/unit/person_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,25 @@ def test_work_groups
refute_includes person1.programmes, prog2
end

test 'show related empty programmes' do
person1 = Factory(:programme_administrator_not_in_project)
person2 = Factory(:programme_administrator_not_in_project)
person3 = Factory(:programme_administrator_not_in_project) # Programme administrator not in empty_programme1
empty_programme1 = Factory(:min_programme, programme_administrators: [person1, person2])

[person1, person2].each do |p|
assert_includes p.related_programmes, empty_programme1
end
refute_includes person3.related_programmes, empty_programme1

person4 = Factory(:person_in_project) # Member of a project in prog 2, not a programme administrator
prog2 = Factory(:programme, projects: person4.projects, programme_administrators: [person1, person3])

[person1, person3, person4].each do |p|
assert_includes p.related_programmes, prog2
end
end

test 'can be administered by' do
admin = Factory(:admin)
admin2 = Factory(:admin)
Expand Down

0 comments on commit 0b80f2e

Please sign in to comment.