From 22d6dc2b3b1392341c765932b706bd867c66c5f9 Mon Sep 17 00:00:00 2001 From: randx Date: Mon, 18 Jun 2012 19:34:09 +0300 Subject: [PATCH] Cucumber features: Team, SSH keys --- app/views/team_members/_show.html.haml | 2 +- features/profile/ssh_keys.feature | 22 +++++++ features/projects/team_management.feature | 35 +++++++++++ features/step_definitions/dashboard_steps.rb | 2 +- .../step_definitions/profile_keys_steps.rb | 34 ++++++++++ ...mits_steps.rb => project_commits_steps.rb} | 0 .../step_definitions/project_team_steps.rb | 63 +++++++++++++++++++ .../{wiki_steps.rb => project_wiki_steps.rb} | 0 features/step_definitions/projects_steps.rb | 12 ++-- 9 files changed, 162 insertions(+), 8 deletions(-) create mode 100644 features/step_definitions/profile_keys_steps.rb rename features/step_definitions/{commits_steps.rb => project_commits_steps.rb} (100%) create mode 100644 features/step_definitions/project_team_steps.rb rename features/step_definitions/{wiki_steps.rb => project_wiki_steps.rb} (100%) diff --git a/app/views/team_members/_show.html.haml b/app/views/team_members/_show.html.haml index 60b3c9bd4d4..9f023c416ae 100644 --- a/app/views/team_members/_show.html.haml +++ b/app/views/team_members/_show.html.haml @@ -1,6 +1,6 @@ - user = member.user - allow_admin = can? current_user, :admin_project, @project -%tr{:id => dom_id(member), :class => "team_member_row"} +%tr{:id => dom_id(member), :class => "team_member_row user_#{user.id}"} %td .right - if @project.owner == user diff --git a/features/profile/ssh_keys.feature b/features/profile/ssh_keys.feature index e69de29bb2d..c3a92f30ee0 100644 --- a/features/profile/ssh_keys.feature +++ b/features/profile/ssh_keys.feature @@ -0,0 +1,22 @@ +Feature: SSH Keys + Background: + Given I signin as a user + And I have ssh keys: + | title | + | Work | + | Home | + And I visit profile keys page + + Scenario: I should see SSH keys + Then I should see my ssh keys + + Scenario: Add new ssh key + Given I click link "Add new" + And I submit new ssh key "Laptop" + Then I should see new ssh key "Laptop" + + Scenario: Remove ssh key + Given I click link "Work" + And I click link "Remove" + Then I visit profile keys page + And I should not see "Work" ssh key diff --git a/features/projects/team_management.feature b/features/projects/team_management.feature index e69de29bb2d..b5b485e2dc0 100644 --- a/features/projects/team_management.feature +++ b/features/projects/team_management.feature @@ -0,0 +1,35 @@ +Feature: Project Team management + Background: + Given I signin as a user + And I own project "Shop" + And gitlab user "Mike" + And gitlab user "Sam" + And "Sam" is "Shop" developer + And I visit project "Shop" team page + + Scenario: See all team members + Then I should be able to see myself in team + And I should see "Sam" in team list + + Scenario: Add user to project + Given I click link "New Team Member" + And I select "Mike" as "Reporter" + Then I should see "Mike" in team list as "Reporter" + + @javascript + Scenario: Update user access + Given I should see "Sam" in team list as "Developer" + And I change "Sam" role to "Reporter" + Then I visit project "Shop" team page + And I should see "Sam" in team list as "Reporter" + + Scenario: View team member profile + Given I click link "Sam" + Then I should see "Sam" team profile + + Scenario: Cancel team member + Given I click link "Sam" + And I click link "Remove from team" + Then I visit project "Shop" team page + And I should not see "Sam" in team list + diff --git a/features/step_definitions/dashboard_steps.rb b/features/step_definitions/dashboard_steps.rb index a7353facca5..ef48a850324 100644 --- a/features/step_definitions/dashboard_steps.rb +++ b/features/step_definitions/dashboard_steps.rb @@ -47,7 +47,7 @@ Then /^I should see last push widget$/ do end Then /^I click "(.*?)" link$/ do |arg1| - click_link "Create Merge Request" + click_link arg1 #Create Merge Request" end Then /^I see prefilled new Merge Request page$/ do diff --git a/features/step_definitions/profile_keys_steps.rb b/features/step_definitions/profile_keys_steps.rb new file mode 100644 index 00000000000..5ab7e0480ad --- /dev/null +++ b/features/step_definitions/profile_keys_steps.rb @@ -0,0 +1,34 @@ +Given /^I visit profile keys page$/ do + visit keys_path +end + +Then /^I should see my ssh keys$/ do + @user.keys.each do |key| + page.should have_content(key.title) + end +end + +Given /^I have ssh keys:$/ do |table| + table.hashes.each do |row| + Factory :key, :user => @user, :title => row[:title], :key => "jfKLJDFKSFJSHFJ#{row[:title]}" + end +end + +Given /^I submit new ssh key "(.*?)"$/ do |arg1| + fill_in "key_title", :with => arg1 + fill_in "key_key", :with => "publickey234=" + click_button "Save" +end + +Then /^I should see new ssh key "(.*?)"$/ do |arg1| + key = Key.find_by_title(arg1) + page.should have_content(key.title) + page.should have_content(key.key) + current_path.should == key_path(key) +end + +Then /^I should not see "(.*?)" ssh key$/ do |arg1| + within "#keys-table" do + page.should_not have_content(arg1) + end +end diff --git a/features/step_definitions/commits_steps.rb b/features/step_definitions/project_commits_steps.rb similarity index 100% rename from features/step_definitions/commits_steps.rb rename to features/step_definitions/project_commits_steps.rb diff --git a/features/step_definitions/project_team_steps.rb b/features/step_definitions/project_team_steps.rb new file mode 100644 index 00000000000..f0bab29a6f8 --- /dev/null +++ b/features/step_definitions/project_team_steps.rb @@ -0,0 +1,63 @@ +Given /^gitlab user "(.*?)"$/ do |arg1| + Factory :user, :name => arg1 +end + +Given /^"(.*?)" is "(.*?)" developer$/ do |arg1, arg2| + user = User.find_by_name(arg1) + project = Project.find_by_name(arg2) + project.add_access(user, :write) +end + +Given /^I visit project "(.*?)" team page$/ do |arg1| + visit team_project_path(Project.find_by_name(arg1)) +end + +Then /^I should be able to see myself in team$/ do + page.should have_content(@user.name) + page.should have_content(@user.email) +end + +Then /^I should see "(.*?)" in team list$/ do |arg1| + user = User.find_by_name(arg1) + page.should have_content(user.name) + page.should have_content(user.email) +end + +Given /^I click link "(.*?)"$/ do |arg1| + click_link arg1 +end + +Given /^I select "(.*?)" as "(.*?)"$/ do |arg1, arg2| + user = User.find_by_name(arg1) + within "#new_team_member" do + select user.name, :from => "team_member_user_id" + select arg2, :from => "team_member_project_access" + end + click_button "Save" +end + +Then /^I should see "(.*?)" in team list as "(.*?)"$/ do |arg1, arg2| + user = User.find_by_name(arg1) + role_id = find(".user_#{user.id} #team_member_project_access").value + role_id.should == UsersProject.access_roles[arg2].to_s +end + +Given /^I change "(.*?)" role to "(.*?)"$/ do |arg1, arg2| + user = User.find_by_name(arg1) + within ".user_#{user.id}" do + select arg2, :from => "team_member_project_access" + end +end + +Then /^I should see "(.*?)" team profile$/ do |arg1| + user = User.find_by_name(arg1) + page.should have_content(user.name) + page.should have_content(user.email) + page.should have_content("To team list") +end + +Then /^I should not see "(.*?)" in team list$/ do |arg1| + user = User.find_by_name(arg1) + page.should_not have_content(user.name) + page.should_not have_content(user.email) +end diff --git a/features/step_definitions/wiki_steps.rb b/features/step_definitions/project_wiki_steps.rb similarity index 100% rename from features/step_definitions/wiki_steps.rb rename to features/step_definitions/project_wiki_steps.rb diff --git a/features/step_definitions/projects_steps.rb b/features/step_definitions/projects_steps.rb index 6155e9065fb..bca1213908d 100644 --- a/features/step_definitions/projects_steps.rb +++ b/features/step_definitions/projects_steps.rb @@ -28,7 +28,7 @@ end Given /^I own project "(.*?)"$/ do |arg1| @project = Factory :project, :name => arg1 - @project.add_access(@user, :read, :write) + @project.add_access(@user, :admin) end Given /^I visit project "(.*?)" wall page$/ do |arg1| @@ -60,9 +60,9 @@ Given /^show me page$/ do end Given /^page should have network graph$/ do - #page.should have_content "Project Network Graph" - #within ".graph" do - #page.should have_content "stable" - #page.should have_content "notes_refacto..." - #end + page.should have_content "Project Network Graph" + within ".graph" do + page.should have_content "stable" + page.should have_content "notes_refacto..." + end end