Adding filtering to Users and Enterprises report

This commit is contained in:
Rob Harrington
2014-11-14 16:17:36 +11:00
parent 79a83ee206
commit d9d6b7bee4
4 changed files with 148 additions and 35 deletions

View File

@@ -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