summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/team_members_controller.rb28
-rw-r--r--spec/requests/team_members_spec.rb26
2 files changed, 29 insertions, 25 deletions
diff --git a/app/controllers/team_members_controller.rb b/app/controllers/team_members_controller.rb
index 5fb2710dad7..84addf8d7bb 100644
--- a/app/controllers/team_members_controller.rb
+++ b/app/controllers/team_members_controller.rb
@@ -8,35 +8,16 @@ class TeamMembersController < ApplicationController
def show
@team_member = project.users_projects.find(params[:id])
-
- respond_to do |format|
- format.html # show.html.erb
- format.js
- end
end
def new
@team_member = project.users_projects.new
-
- respond_to do |format|
- format.html # new.html.erb
- format.js
- end
end
def create
@team_member = UsersProject.new(params[:team_member])
@team_member.project = project
-
- 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
+ @team_member.save
end
def update
@@ -45,7 +26,12 @@ class TeamMembersController < ApplicationController
respond_to do |format|
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
diff --git a/spec/requests/team_members_spec.rb b/spec/requests/team_members_spec.rb
index dd92febf700..ec0af3214a9 100644
--- a/spec/requests/team_members_spec.rb
+++ b/spec/requests/team_members_spec.rb
@@ -29,19 +29,37 @@ describe "TeamMembers" do
describe "fill in" do
before do
- check "team_member_read"
click_link "Select user"
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
- 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
click_button "Save"
+ @member = UsersProject.last
- page.should_not have_content("Add new member")
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