fix tests
This commit is contained in:
parent
eb99feb4a7
commit
690db9693f
10 changed files with 47 additions and 47 deletions
|
@ -30,11 +30,8 @@ class Admin::Teams::MembersController < Admin::Teams::ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
if user_team.remove_member(team_member)
|
user_team.remove_member(team_member)
|
||||||
redirect_to admin_team_path(user_team), notice: "Member #{team_member.name} was successfully removed from Team of users."
|
redirect_to admin_team_path(user_team), notice: "Member #{team_member.name} was successfully removed from Team of users."
|
||||||
else
|
|
||||||
redirect_to admin_team_members(user_team), notice: "Something is wrong."
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
|
@ -20,7 +20,7 @@ class Teams::MembersController < Teams::ApplicationController
|
||||||
user_team.add_members(user_ids, access, is_admin)
|
user_team.add_members(user_ids, access, is_admin)
|
||||||
end
|
end
|
||||||
|
|
||||||
redirect_to team_path(user_team), notice: 'Members was successfully added into Team of users.'
|
redirect_to team_members_path(user_team), notice: 'Members was successfully added into Team of users.'
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
|
@ -30,18 +30,15 @@ class Teams::MembersController < Teams::ApplicationController
|
||||||
def update
|
def update
|
||||||
options = {default_projects_access: params[:default_project_access], group_admin: params[:group_admin]}
|
options = {default_projects_access: params[:default_project_access], group_admin: params[:group_admin]}
|
||||||
if user_team.update_membership(team_member, options)
|
if user_team.update_membership(team_member, options)
|
||||||
redirect_to team_path(user_team), notice: "Membership for #{team_member.name} was successfully updated in Team of users."
|
redirect_to team_members_path(user_team), notice: "Membership for #{team_member.name} was successfully updated in Team of users."
|
||||||
else
|
else
|
||||||
render :edit
|
render :edit
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
if user_team.remove_member(team_member)
|
user_team.remove_member(team_member)
|
||||||
redirect_to team_path(user_team), notice: "Member #{team_member.name} was successfully removed from Team of users."
|
redirect_to team_path(user_team), notice: "Member #{team_member.name} was successfully removed from Team of users."
|
||||||
else
|
|
||||||
redirect_to team_members(user_team), notice: "Something is wrong."
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
%th Team access
|
%th Team access
|
||||||
%th.cred.span3 Danger Zone!
|
%th.cred.span3 Danger Zone!
|
||||||
- @team.members.each do |member|
|
- @team.members.each do |member|
|
||||||
%tr.member
|
%tr.member{ class: "user_#{member.id}"}
|
||||||
%td
|
%td
|
||||||
= link_to [:admin, member] do
|
= link_to [:admin, member] do
|
||||||
= member.name
|
= member.name
|
||||||
|
@ -62,7 +62,7 @@
|
||||||
%td.bgred
|
%td.bgred
|
||||||
= link_to 'Edit', edit_admin_team_member_path(@team, member), class: "btn small"
|
= link_to 'Edit', edit_admin_team_member_path(@team, member), class: "btn small"
|
||||||
|
|
||||||
= link_to 'Remove', admin_team_member_path(@team, member), confirm: 'Remove member from team. Are you sure?', method: :delete, class: "btn danger small"
|
= link_to 'Remove', admin_team_member_path(@team, member), confirm: 'Remove member from team. Are you sure?', method: :delete, class: "btn danger small", id: "remove_member_#{member.id}"
|
||||||
|
|
||||||
%fieldset
|
%fieldset
|
||||||
%legend
|
%legend
|
||||||
|
@ -84,7 +84,7 @@
|
||||||
%td.bgred
|
%td.bgred
|
||||||
= link_to 'Edit', edit_admin_team_project_path(@team, project), class: "btn small"
|
= link_to 'Edit', edit_admin_team_project_path(@team, project), class: "btn small"
|
||||||
|
|
||||||
= link_to 'Relegate', admin_team_project_path(@team, project), confirm: 'Remove project from team. Are you sure?', method: :delete, class: "btn danger small"
|
= link_to 'Relegate', admin_team_project_path(@team, project), confirm: 'Remove project from team. Are you sure?', method: :delete, class: "btn danger small", id: "relegate_project_#{project.id}"
|
||||||
|
|
||||||
:javascript
|
:javascript
|
||||||
$(function(){
|
$(function(){
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
%hr
|
%hr
|
||||||
|
|
||||||
%table
|
%table.projects-table
|
||||||
%thead
|
%thead
|
||||||
%tr
|
%tr
|
||||||
%th Project name
|
%th Project name
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
Feature: Admin Teams
|
Feature: Admin Teams
|
||||||
Background:
|
Background:
|
||||||
Given I sign in as an admin
|
Given I sign in as an admin
|
||||||
#And there are projects in system
|
|
||||||
#And system has users
|
|
||||||
#And I have own project
|
|
||||||
And Create gitlab user "John"
|
And Create gitlab user "John"
|
||||||
|
|
||||||
Scenario: Create a team
|
Scenario: Create a team
|
||||||
|
|
|
@ -83,8 +83,7 @@ class AdminTeams < Spinach::FeatureSteps
|
||||||
end
|
end
|
||||||
|
|
||||||
Then 'I should see empty projects table' do
|
Then 'I should see empty projects table' do
|
||||||
projects_list = find("#projects_list")
|
page.has_no_css?("#projects_list").must_equal true
|
||||||
projects_list.has_content?("Relegate").must_equal false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
When 'I select project "Shop" with max access "Reporter"' do
|
When 'I select project "Shop" with max access "Reporter"' do
|
||||||
|
@ -177,11 +176,13 @@ class AdminTeams < Spinach::FeatureSteps
|
||||||
end
|
end
|
||||||
|
|
||||||
And 'I should see "Shop" in projects list' do
|
And 'I should see "Shop" in projects list' do
|
||||||
|
project = Project.find_by_name("Shop")
|
||||||
|
find_in_list("#projects_list .project", project).must_equal true
|
||||||
end
|
end
|
||||||
|
|
||||||
When 'I click on remove "Jimm" user link' do
|
When 'I click on remove "Jimm" user link' do
|
||||||
|
user = User.find_by_name("Jimm")
|
||||||
|
click_link "remove_member_#{user.id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
Then 'I should be redirected to "HardCoders" team admin page' do
|
Then 'I should be redirected to "HardCoders" team admin page' do
|
||||||
|
@ -189,15 +190,18 @@ class AdminTeams < Spinach::FeatureSteps
|
||||||
end
|
end
|
||||||
|
|
||||||
And 'I should not to see "Jimm" user in members list' do
|
And 'I should not to see "Jimm" user in members list' do
|
||||||
|
user = User.find_by_name("Jimm")
|
||||||
|
find_in_list("#members_list .member", user).must_equal false
|
||||||
end
|
end
|
||||||
|
|
||||||
When 'I click on "Relegate" link on "Shop" project' do
|
When 'I click on "Relegate" link on "Shop" project' do
|
||||||
|
project = Project.find_by_name("Shop")
|
||||||
|
click_link "relegate_project_#{project.id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
Then 'I should see projects liston team page without "Shop" project' do
|
Then 'I should see projects liston team page without "Shop" project' do
|
||||||
|
project = Project.find_by_name("Shop")
|
||||||
|
find_in_list("#projects_list .project", project).must_equal false
|
||||||
end
|
end
|
||||||
|
|
||||||
Then 'I should see "John" user with role "Reporter" in team table' do
|
Then 'I should see "John" user with role "Reporter" in team table' do
|
||||||
|
|
|
@ -175,7 +175,12 @@ class Userteams < Spinach::FeatureSteps
|
||||||
end
|
end
|
||||||
|
|
||||||
And 'I select user "John" from list with role "Reporter"' do
|
And 'I select user "John" from list with role "Reporter"' do
|
||||||
pending 'step not implemented'
|
user = User.find_by_name("John")
|
||||||
|
within "#team_members" do
|
||||||
|
select user.name, :from => "user_ids"
|
||||||
|
select "Reporter", :from => "default_project_access"
|
||||||
|
end
|
||||||
|
click_button "Add"
|
||||||
end
|
end
|
||||||
|
|
||||||
Then 'I should see user "John" in team list' do
|
Then 'I should see user "John" in team list' do
|
||||||
|
@ -185,7 +190,7 @@ class Userteams < Spinach::FeatureSteps
|
||||||
end
|
end
|
||||||
|
|
||||||
And 'I have my own project without teams' do
|
And 'I have my own project without teams' do
|
||||||
project = create :project, creator: current_user
|
@project = create :project, creator: current_user
|
||||||
end
|
end
|
||||||
|
|
||||||
And 'I visit my team page' do
|
And 'I visit my team page' do
|
||||||
|
@ -197,27 +202,26 @@ class Userteams < Spinach::FeatureSteps
|
||||||
click_link "Projects"
|
click_link "Projects"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
And 'I click link "Assign project to Team"' do
|
||||||
|
click_link "Assign project to Team"
|
||||||
|
end
|
||||||
|
|
||||||
Then 'I should see form with my own project in avaliable projects list' do
|
Then 'I should see form with my own project in avaliable projects list' do
|
||||||
project = current_user.projects.first
|
|
||||||
projects_select = find("#project_ids")
|
projects_select = find("#project_ids")
|
||||||
projects_select.should have_content(project.name)
|
projects_select.should have_content(@project.name)
|
||||||
end
|
end
|
||||||
|
|
||||||
When 'I submit form with selected project and max access' do
|
When 'I submit form with selected project and max access' do
|
||||||
project = current_user.projects.first
|
within "#assign_projects" do
|
||||||
within "#team_projects" do
|
select @project.name, :from => "project_ids"
|
||||||
select project.name, :from => "project_ids"
|
|
||||||
select "Reporter", :from => "greatest_project_access"
|
select "Reporter", :from => "greatest_project_access"
|
||||||
end
|
end
|
||||||
click_button "Add"
|
click_button "Add"
|
||||||
end
|
end
|
||||||
|
|
||||||
Then 'I should see my own project in team projects list' do
|
Then 'I should see my own project in team projects list' do
|
||||||
project = current_user.projects.first
|
projects = find(".projects-table")
|
||||||
projects = all("table .project")
|
projects.should have_content(@project.name)
|
||||||
projects.each do |project_row|
|
|
||||||
project_row.should have_content(project.name)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
When 'I click link "New Team Member"' do
|
When 'I click link "New Team Member"' do
|
||||||
|
@ -227,7 +231,7 @@ class Userteams < Spinach::FeatureSteps
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def current_team
|
def current_team
|
||||||
@user_team ||= Team.first
|
@user_team ||= UserTeam.first
|
||||||
end
|
end
|
||||||
|
|
||||||
def project
|
def project
|
||||||
|
|
|
@ -21,7 +21,7 @@ Dir["#{Rails.root}/features/steps/shared/*.rb"].each {|file| require file}
|
||||||
include GitoliteStub
|
include GitoliteStub
|
||||||
|
|
||||||
WebMock.allow_net_connect!
|
WebMock.allow_net_connect!
|
||||||
|
Spinach.config.save_and_open_page_on_failure = true
|
||||||
#
|
#
|
||||||
# JS driver
|
# JS driver
|
||||||
#
|
#
|
||||||
|
|
|
@ -70,6 +70,7 @@ Feature: UserTeams
|
||||||
And I have my own project without teams
|
And I have my own project without teams
|
||||||
And I visit my team page
|
And I visit my team page
|
||||||
When I click on link "Projects"
|
When I click on link "Projects"
|
||||||
|
And I click link "Assign project to Team"
|
||||||
Then I should see form with my own project in avaliable projects list
|
Then I should see form with my own project in avaliable projects list
|
||||||
When I submit form with selected project and max access
|
When I submit form with selected project and max access
|
||||||
Then I should see my own project in team projects list
|
Then I should see my own project in team projects list
|
||||||
|
|
|
@ -95,20 +95,20 @@ describe Admin::ProjectsController, "routing" do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# edit_admin_team_member GET /admin/team_members/:id/edit(.:format) admin/team_members#edit
|
# edit_admin_project_member GET /admin/projects/:project_id/members/:id/edit(.:format) admin/projects/members#edit {:id=>/[^\/]+/, :project_id=>/[^\/]+/}
|
||||||
# admin_team_member PUT /admin/team_members/:id(.:format) admin/team_members#update
|
# admin_project_member PUT /admin/projects/:project_id/members/:id(.:format) admin/projects/members#update {:id=>/[^\/]+/, :project_id=>/[^\/]+/}
|
||||||
# DELETE /admin/team_members/:id(.:format) admin/team_members#destroy
|
# DELETE /admin/projects/:project_id/members/:id(.:format) admin/projects/members#destroy {:id=>/[^\/]+/, :project_id=>/[^\/]+/}
|
||||||
describe Admin::TeamMembersController, "routing" do
|
describe Admin::Projects::MembersController, "routing" do
|
||||||
it "to #edit" do
|
it "to #edit" do
|
||||||
get("/admin/team_members/1/edit").should route_to('admin/team_members#edit', id: '1')
|
get("/admin/projects/test/members/1/edit").should route_to('admin/projects/members#edit', project_id: 'test', id: '1')
|
||||||
end
|
end
|
||||||
|
|
||||||
it "to #update" do
|
it "to #update" do
|
||||||
put("/admin/team_members/1").should route_to('admin/team_members#update', id: '1')
|
put("/admin/projects/test/members/1").should route_to('admin/projects/members#update', project_id: 'test', id: '1')
|
||||||
end
|
end
|
||||||
|
|
||||||
it "to #destroy" do
|
it "to #destroy" do
|
||||||
delete("/admin/team_members/1").should route_to('admin/team_members#destroy', id: '1')
|
delete("/admin/projects/test/members/1").should route_to('admin/projects/members#destroy', project_id: 'test', id: '1')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue