BigW Consortium Gitlab

Commit ecd462a6 by gitlabhq

test cov

parent ce9b8e7b
...@@ -8,35 +8,16 @@ class TeamMembersController < ApplicationController ...@@ -8,35 +8,16 @@ class TeamMembersController < ApplicationController
def show def show
@team_member = project.users_projects.find(params[:id]) @team_member = project.users_projects.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.js
end
end end
def new def new
@team_member = project.users_projects.new @team_member = project.users_projects.new
respond_to do |format|
format.html # new.html.erb
format.js
end
end end
def create def create
@team_member = UsersProject.new(params[:team_member]) @team_member = UsersProject.new(params[:team_member])
@team_member.project = project @team_member.project = project
@team_member.save
respond_to do |format|
if @team_member.save
format.html { redirect_to @team_member, notice: 'Team member was successfully created.' }
format.js
else
format.html { render action: "new" }
format.js
end
end
end end
def update def update
...@@ -45,7 +26,12 @@ class TeamMembersController < ApplicationController ...@@ -45,7 +26,12 @@ class TeamMembersController < ApplicationController
respond_to do |format| respond_to do |format|
format.js format.js
format.html { redirect_to team_project_path(@project)} format.html do
unless @team_member.valid?
flash[:alert] = "User should have at least one role"
end
redirect_to team_project_path(@project)
end
end end
end end
......
...@@ -29,19 +29,37 @@ describe "TeamMembers" do ...@@ -29,19 +29,37 @@ describe "TeamMembers" do
describe "fill in" do describe "fill in" do
before do before do
check "team_member_read"
click_link "Select user" click_link "Select user"
click_link @user_1.name click_link @user_1.name
#select @user_1.name, :from => "team_member_user_id"
within "#team_member_new" do
check "team_member_read"
check "team_member_write"
end
end end
it { expect { click_button "Save" }.to change {UsersProject.count}.by(1) } it { expect { click_button "Save";sleep(1) }.to change {UsersProject.count}.by(1) }
it "should add new member to table" do it "should add new member to table" do
click_button "Save" click_button "Save"
@member = UsersProject.last
page.should_not have_content("Add new member")
page.should have_content @user_1.name page.should have_content @user_1.name
@member.read.should be_true
@member.write.should be_true
@member.admin.should be_false
end
it "should not allow creation without access selected" do
within "#team_member_new" do
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")
end end
end end
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