mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-13 04:00:21 +00:00
Adding filtering to Users and Enterprises report
This commit is contained in:
@@ -166,4 +166,50 @@ feature %q{
|
||||
].sort
|
||||
end
|
||||
end
|
||||
|
||||
describe "users and enterprises report" do
|
||||
let!(:enterprise1) { create( :enterprise, owner: create_enterprise_user ) }
|
||||
let!(:enterprise2) { create( :enterprise, owner: create_enterprise_user ) }
|
||||
let!(:enterprise3) { create( :enterprise, owner: create_enterprise_user ) }
|
||||
|
||||
before do
|
||||
enterprise3.enterprise_roles.build( user: enterprise1.owner ).save
|
||||
|
||||
login_to_admin_section
|
||||
click_link 'Reports'
|
||||
|
||||
click_link 'Users & Enterprises'
|
||||
end
|
||||
|
||||
it "shows users and enterprises report" do
|
||||
rows = find("table#users_and_enterprises").all("tr")
|
||||
table = rows.map { |r| r.all("th,td").map { |c| c.text.strip }[0..2] }
|
||||
|
||||
table.sort.should == [
|
||||
[ "User", "Relationship", "Enterprise" ],
|
||||
[ enterprise1.owner.email, "owns", enterprise1.name ],
|
||||
[ enterprise1.owner.email, "manages", enterprise1.name ],
|
||||
[ enterprise2.owner.email, "owns", enterprise2.name ],
|
||||
[ enterprise2.owner.email, "manages", enterprise2.name ],
|
||||
[ enterprise3.owner.email, "owns", enterprise3.name ],
|
||||
[ enterprise3.owner.email, "manages", enterprise3.name ],
|
||||
[ enterprise1.owner.email, "manages", enterprise3.name ]
|
||||
].sort
|
||||
end
|
||||
|
||||
it "filters the list" do
|
||||
select enterprise3.name, from: "enterprise_id_in"
|
||||
select enterprise1.owner.email, from: "user_id_in"
|
||||
|
||||
click_button "Search"
|
||||
|
||||
rows = find("table#users_and_enterprises").all("tr")
|
||||
table = rows.map { |r| r.all("th,td").map { |c| c.text.strip }[0..2] }
|
||||
|
||||
table.sort.should == [
|
||||
[ "User", "Relationship", "Enterprise" ],
|
||||
[ enterprise1.owner.email, "manages", enterprise3.name ]
|
||||
].sort
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user