From 42abdf69d59ecf28688af5994ff2e324c50a6d33 Mon Sep 17 00:00:00 2001 From: randx Date: Mon, 22 Oct 2012 21:42:06 +0300 Subject: [PATCH] More group tests with spinach --- features/admin/groups.feature | 10 ++++++++ features/group/group.feature | 10 ++++++++ features/steps/admin/admin_groups.rb | 24 ++++++++++++++++++ features/steps/group/group.rb | 38 +++++++++++++++++++++++++--- features/steps/shared/paths.rb | 20 +++++++++++++++ 5 files changed, 98 insertions(+), 4 deletions(-) create mode 100644 features/admin/groups.feature create mode 100644 features/steps/admin/admin_groups.rb diff --git a/features/admin/groups.feature b/features/admin/groups.feature new file mode 100644 index 00000000000..e5eab8e6ecb --- /dev/null +++ b/features/admin/groups.feature @@ -0,0 +1,10 @@ +Feature: Admin Groups + Background: + Given I sign in as an admin + And I visit admin groups page + + Scenario: Create a group + When I click new group link + And submit form with new group info + Then I should be redirected to group page + And I should see newly created group diff --git a/features/group/group.feature b/features/group/group.feature index dbddb92ccce..07308112270 100644 --- a/features/group/group.feature +++ b/features/group/group.feature @@ -7,3 +7,13 @@ Feature: Groups When I visit group page Then I should see projects list And I should see projects activity feed + + Scenario: I should see group issues list + Given project from group has issues assigned to me + When I visit group issues page + Then I should see issues from this group assigned to me + + Scenario: I should see group merge requests list + Given project from group has merge requests assigned to me + When I visit group merge requests page + Then I should see merge requests from this group assigned to me diff --git a/features/steps/admin/admin_groups.rb b/features/steps/admin/admin_groups.rb new file mode 100644 index 00000000000..e1759013ce7 --- /dev/null +++ b/features/steps/admin/admin_groups.rb @@ -0,0 +1,24 @@ +class AdminGroups < Spinach::FeatureSteps + include SharedAuthentication + include SharedPaths + include SharedActiveTab + + When 'I click new group link' do + click_link "New Group" + end + + And 'submit form with new group info' do + fill_in 'group_name', :with => 'gitlab' + fill_in 'group_code', :with => 'gitlab' + click_button "Save group" + end + + Then 'I should see newly created group' do + page.should have_content "Group: gitlab" + end + + Then 'I should be redirected to group page' do + current_path.should == admin_group_path(Group.last) + end +end + diff --git a/features/steps/group/group.rb b/features/steps/group/group.rb index 798c62c3a11..51581a1ec7b 100644 --- a/features/steps/group/group.rb +++ b/features/steps/group/group.rb @@ -2,10 +2,6 @@ class Groups < Spinach::FeatureSteps include SharedAuthentication include SharedPaths - When 'I visit group page' do - visit group_path(current_group) - end - Then 'I should see projects list' do current_user.projects.each do |project| page.should have_link project.name @@ -24,9 +20,43 @@ class Groups < Spinach::FeatureSteps page.should have_content 'closed issue' end + Then 'I should see issues from this group assigned to me' do + assigned_to_me(:issues).each do |issue| + page.should have_content issue.title + end + end + + Then 'I should see merge requests from this group assigned to me' do + assigned_to_me(:merge_requests).each do |issue| + page.should have_content issue.title + end + end + + Given 'project from group has issues assigned to me' do + create :issue, + project: project, + assignee: current_user, + author: current_user + end + + Given 'project from group has merge requests assigned to me' do + create :merge_request, + project: project, + assignee: current_user, + author: current_user + end + protected def current_group @group ||= Group.first end + + def project + current_group.projects.first + end + + def assigned_to_me key + project.send(key).where(assignee_id: current_user.id) + end end diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb index eda5ab94116..b4e4b810c20 100644 --- a/features/steps/shared/paths.rb +++ b/features/steps/shared/paths.rb @@ -5,6 +5,22 @@ module SharedPaths visit new_project_path end + # ---------------------------------------- + # Group + # ---------------------------------------- + + When 'I visit group page' do + visit group_path(current_group) + end + + When 'I visit group issues page' do + visit issues_group_path(current_group) + end + + When 'I visit group merge requests page' do + visit merge_requests_group_path(current_group) + end + # ---------------------------------------- # Dashboard # ---------------------------------------- @@ -85,6 +101,10 @@ module SharedPaths visit admin_resque_path end + And 'I visit admin groups page' do + visit admin_groups_path + end + # ---------------------------------------- # Generic Project # ---------------------------------------- -- GitLab