fix tests

This commit is contained in:
Andrey Kumanyaev 2013-01-23 23:39:47 +04:00 committed by Dmitriy Zaporozhets
parent eb99feb4a7
commit 690db9693f
10 changed files with 47 additions and 47 deletions

View file

@ -30,11 +30,8 @@ class Admin::Teams::MembersController < Admin::Teams::ApplicationController
end
def destroy
if 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."
else
redirect_to admin_team_members(user_team), notice: "Something is wrong."
end
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."
end
protected

View file

@ -20,7 +20,7 @@ class Teams::MembersController < Teams::ApplicationController
user_team.add_members(user_ids, access, is_admin)
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
def edit
@ -30,18 +30,15 @@ class Teams::MembersController < Teams::ApplicationController
def update
options = {default_projects_access: params[:default_project_access], group_admin: params[:group_admin]}
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
render :edit
end
end
def destroy
if user_team.remove_member(team_member)
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
user_team.remove_member(team_member)
redirect_to team_path(user_team), notice: "Member #{team_member.name} was successfully removed from Team of users."
end
protected

View file

@ -52,7 +52,7 @@
%th Team access
%th.cred.span3 Danger Zone!
- @team.members.each do |member|
%tr.member
%tr.member{ class: "user_#{member.id}"}
%td
= link_to [:admin, member] do
= member.name
@ -62,7 +62,7 @@
%td.bgred
= link_to 'Edit', edit_admin_team_member_path(@team, member), class: "btn small"
&nbsp;
= 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
%legend
@ -84,7 +84,7 @@
%td.bgred
= link_to 'Edit', edit_admin_team_project_path(@team, project), class: "btn small"
&nbsp;
= 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
$(function(){

View file

@ -13,7 +13,7 @@
%hr
%table
%table.projects-table
%thead
%tr
%th Project name

View file

@ -1,9 +1,6 @@
Feature: Admin Teams
Background:
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"
Scenario: Create a team

View file

@ -83,8 +83,7 @@ class AdminTeams < Spinach::FeatureSteps
end
Then 'I should see empty projects table' do
projects_list = find("#projects_list")
projects_list.has_content?("Relegate").must_equal false
page.has_no_css?("#projects_list").must_equal true
end
When 'I select project "Shop" with max access "Reporter"' do
@ -177,11 +176,13 @@ class AdminTeams < Spinach::FeatureSteps
end
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
When 'I click on remove "Jimm" user link' do
user = User.find_by_name("Jimm")
click_link "remove_member_#{user.id}"
end
Then 'I should be redirected to "HardCoders" team admin page' do
@ -189,15 +190,18 @@ class AdminTeams < Spinach::FeatureSteps
end
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
When 'I click on "Relegate" link on "Shop" project' do
project = Project.find_by_name("Shop")
click_link "relegate_project_#{project.id}"
end
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
Then 'I should see "John" user with role "Reporter" in team table' do

View file

@ -175,7 +175,12 @@ class Userteams < Spinach::FeatureSteps
end
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
Then 'I should see user "John" in team list' do
@ -185,7 +190,7 @@ class Userteams < Spinach::FeatureSteps
end
And 'I have my own project without teams' do
project = create :project, creator: current_user
@project = create :project, creator: current_user
end
And 'I visit my team page' do
@ -197,27 +202,26 @@ class Userteams < Spinach::FeatureSteps
click_link "Projects"
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
project = current_user.projects.first
projects_select = find("#project_ids")
projects_select.should have_content(project.name)
projects_select.should have_content(@project.name)
end
When 'I submit form with selected project and max access' do
project = current_user.projects.first
within "#team_projects" do
select project.name, :from => "project_ids"
within "#assign_projects" do
select @project.name, :from => "project_ids"
select "Reporter", :from => "greatest_project_access"
end
click_button "Add"
end
Then 'I should see my own project in team projects list' do
project = current_user.projects.first
projects = all("table .project")
projects.each do |project_row|
project_row.should have_content(project.name)
end
projects = find(".projects-table")
projects.should have_content(@project.name)
end
When 'I click link "New Team Member"' do
@ -227,7 +231,7 @@ class Userteams < Spinach::FeatureSteps
protected
def current_team
@user_team ||= Team.first
@user_team ||= UserTeam.first
end
def project

View file

@ -21,7 +21,7 @@ Dir["#{Rails.root}/features/steps/shared/*.rb"].each {|file| require file}
include GitoliteStub
WebMock.allow_net_connect!
Spinach.config.save_and_open_page_on_failure = true
#
# JS driver
#

View file

@ -70,6 +70,7 @@ Feature: UserTeams
And I have my own project without teams
And I visit my team page
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
When I submit form with selected project and max access
Then I should see my own project in team projects list

View file

@ -95,20 +95,20 @@ describe Admin::ProjectsController, "routing" do
end
end
# edit_admin_team_member GET /admin/team_members/:id/edit(.:format) admin/team_members#edit
# admin_team_member PUT /admin/team_members/:id(.:format) admin/team_members#update
# DELETE /admin/team_members/:id(.:format) admin/team_members#destroy
describe Admin::TeamMembersController, "routing" do
# edit_admin_project_member GET /admin/projects/:project_id/members/:id/edit(.:format) admin/projects/members#edit {:id=>/[^\/]+/, :project_id=>/[^\/]+/}
# admin_project_member PUT /admin/projects/:project_id/members/:id(.:format) admin/projects/members#update {:id=>/[^\/]+/, :project_id=>/[^\/]+/}
# DELETE /admin/projects/:project_id/members/:id(.:format) admin/projects/members#destroy {:id=>/[^\/]+/, :project_id=>/[^\/]+/}
describe Admin::Projects::MembersController, "routing" 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
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
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