2011-10-08 23:36:38 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe "TeamMembers" do
|
2011-10-26 15:46:25 +02:00
|
|
|
before do
|
2011-10-08 23:36:38 +02:00
|
|
|
login_as :user
|
|
|
|
@project = Factory :project
|
|
|
|
@project.add_access(@user, :read, :admin)
|
|
|
|
end
|
|
|
|
|
2011-10-21 14:56:37 +02:00
|
|
|
describe "View profile" do
|
|
|
|
it "should be available" do
|
|
|
|
visit(team_project_path(@project))
|
2011-10-26 15:46:25 +02:00
|
|
|
within "#team-table" do
|
2011-10-25 06:32:02 +02:00
|
|
|
click_link(@user.name)
|
|
|
|
end
|
2011-10-21 14:56:37 +02:00
|
|
|
page.should have_content @user.skype
|
|
|
|
page.should_not have_content 'Twitter'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-10-26 15:46:25 +02:00
|
|
|
describe "New Team member", :js => true do
|
|
|
|
before do
|
2011-10-08 23:36:38 +02:00
|
|
|
@user_1 = Factory :user
|
|
|
|
visit team_project_path(@project)
|
|
|
|
click_link "Add new"
|
|
|
|
end
|
|
|
|
|
2011-10-26 15:46:25 +02:00
|
|
|
it "should open new team member popup" do
|
2011-10-08 23:36:38 +02:00
|
|
|
page.should have_content("Add new member to project")
|
|
|
|
end
|
|
|
|
|
2011-10-26 15:46:25 +02:00
|
|
|
describe "fill in" do
|
2011-10-08 23:36:38 +02:00
|
|
|
before do
|
|
|
|
click_link "Select user"
|
|
|
|
click_link @user_1.name
|
2011-10-21 21:44:08 +02:00
|
|
|
|
2011-10-26 15:46:25 +02:00
|
|
|
within "#team_member_new" do
|
2011-10-21 21:44:08 +02:00
|
|
|
check "team_member_read"
|
|
|
|
check "team_member_write"
|
|
|
|
end
|
2011-10-08 23:36:38 +02:00
|
|
|
end
|
|
|
|
|
2011-10-21 21:44:08 +02:00
|
|
|
it { expect { click_button "Save";sleep(1) }.to change {UsersProject.count}.by(1) }
|
2011-10-08 23:36:38 +02:00
|
|
|
|
2011-10-26 15:46:25 +02:00
|
|
|
it "should add new member to table" do
|
2011-10-08 23:36:38 +02:00
|
|
|
click_button "Save"
|
2011-10-21 21:44:08 +02:00
|
|
|
@member = UsersProject.last
|
2011-10-08 23:36:38 +02:00
|
|
|
|
|
|
|
page.should have_content @user_1.name
|
2011-10-21 21:44:08 +02:00
|
|
|
|
|
|
|
@member.read.should be_true
|
|
|
|
@member.write.should be_true
|
|
|
|
@member.admin.should be_false
|
|
|
|
end
|
|
|
|
|
2011-10-26 15:46:25 +02:00
|
|
|
it "should not allow creation without access selected" do
|
|
|
|
within "#team_member_new" do
|
2011-10-21 21:44:08 +02:00
|
|
|
uncheck "team_member_read"
|
|
|
|
uncheck "team_member_write"
|
|
|
|
uncheck "team_member_admin"
|
|
|
|
end
|
|
|
|
|
|
|
|
expect { click_button "Save" }.to_not change {UsersProject.count}
|
|
|
|
page.should have_content("Please choose at least one Role in the Access list")
|
2011-10-08 23:36:38 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-10-26 15:46:25 +02:00
|
|
|
describe "Cancel membership" do
|
|
|
|
it "should cancel membership" do
|
2011-10-08 23:36:38 +02:00
|
|
|
visit team_project_path(@project)
|
|
|
|
expect { click_link "Cancel" }.to change { UsersProject.count }.by(-1)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|