From b846ac10597d832bd4b03ee65a026fcf4f9480f2 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 3 Aug 2012 19:39:54 +0300 Subject: [PATCH] Milestones cucumber. Renamed app security test --- features/projects/issues/milestones.feature | 18 ++++++++++++++++++ features/step_definitions/project_merge_requests_steps.rb | 38 ++++++++++++++++++++++++++++++++++++++ spec/requests/access_spec.rb | 187 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ spec/requests/milestones_spec.rb | 51 --------------------------------------------------- spec/requests/projects_security_spec.rb | 187 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 5 files changed, 243 insertions(+), 238 deletions(-) create mode 100644 features/step_definitions/project_merge_requests_steps.rb create mode 100644 spec/requests/access_spec.rb delete mode 100644 spec/requests/milestones_spec.rb delete mode 100644 spec/requests/projects_security_spec.rb diff --git a/features/projects/issues/milestones.feature b/features/projects/issues/milestones.feature index e69de29..d78096a 100644 --- a/features/projects/issues/milestones.feature +++ b/features/projects/issues/milestones.feature @@ -0,0 +1,18 @@ +Feature: Milestones + Background: + Given I signin as a user + And I own project "Shop" + And project "Shop" has milestone "v2.2" + Given I visit project "Shop" milestones page + + Scenario: I should see active milestones + Then I should see milestone "v2.2" + + Scenario: I should see milestone + Given I click link "v2.2" + Then I should see milestone "v2.2" + + Scenario: I create new milestone + Given I click link "New Milestone" + And I submit new milestone "v2.3" + Then I should see milestone "v2.3" diff --git a/features/step_definitions/project_merge_requests_steps.rb b/features/step_definitions/project_merge_requests_steps.rb new file mode 100644 index 0000000..6749773 --- /dev/null +++ b/features/step_definitions/project_merge_requests_steps.rb @@ -0,0 +1,38 @@ +Given /^project "(.*?)" has milestone "(.*?)"$/ do |arg1, arg2| + project = Project.find_by_name(arg1) + + milestone = Factory :milestone, + :title => arg2, + :project => project + + 3.times do |i| + issue = Factory :issue, + :project => project, + :milestone => milestone + end +end + +Given /^I visit project "(.*?)" milestones page$/ do |arg1| + @project = Project.find_by_name(arg1) + visit project_milestones_path(@project) +end + +Then /^I should see active milestones$/ do + milestone = @project.milestones.first + page.should have_content(milestone.title[0..10]) + page.should have_content(milestone.expires_at) + page.should have_content("Browse Issues") +end + +Then /^I should see milestone "(.*?)"$/ do |arg1| + milestone = @project.milestones.find_by_title(arg1) + page.should have_content(milestone.title[0..10]) + page.should have_content(milestone.expires_at) + page.should have_content("Browse Issues") +end + +Given /^I submit new milestone "(.*?)"$/ do |arg1| + fill_in "milestone_title", :with => arg1 + click_button "Create milestone" +end + diff --git a/spec/requests/access_spec.rb b/spec/requests/access_spec.rb new file mode 100644 index 0000000..bcca42f --- /dev/null +++ b/spec/requests/access_spec.rb @@ -0,0 +1,187 @@ +require 'spec_helper' + +describe "Application access" do + describe "GET /" do + it { root_path.should be_allowed_for :admin } + it { root_path.should be_allowed_for :user } + it { root_path.should be_denied_for :visitor } + end + + describe "GET /projects/new" do + it { new_project_path.should be_allowed_for :admin } + it { new_project_path.should be_allowed_for :user } + it { new_project_path.should be_denied_for :visitor } + end + + describe "Project" do + before do + @project = Factory :project + @u1 = Factory :user + @u2 = Factory :user + @u3 = Factory :user + # full access + @project.users_projects.create(:user => @u1, :project_access => UsersProject::MASTER) + # readonly + @project.users_projects.create(:user => @u3, :project_access => UsersProject::REPORTER) + end + + describe "GET /project_code" do + it { project_path(@project).should be_allowed_for @u1 } + it { project_path(@project).should be_allowed_for @u3 } + it { project_path(@project).should be_denied_for :admin } + it { project_path(@project).should be_denied_for @u2 } + it { project_path(@project).should be_denied_for :user } + it { project_path(@project).should be_denied_for :visitor } + end + + describe "GET /project_code/master/tree" do + it { tree_project_ref_path(@project, @project.root_ref).should be_allowed_for @u1 } + it { tree_project_ref_path(@project, @project.root_ref).should be_allowed_for @u3 } + it { tree_project_ref_path(@project, @project.root_ref).should be_denied_for :admin } + it { tree_project_ref_path(@project, @project.root_ref).should be_denied_for @u2 } + it { tree_project_ref_path(@project, @project.root_ref).should be_denied_for :user } + it { tree_project_ref_path(@project, @project.root_ref).should be_denied_for :visitor } + end + + describe "GET /project_code/commits" do + it { project_commits_path(@project).should be_allowed_for @u1 } + it { project_commits_path(@project).should be_allowed_for @u3 } + it { project_commits_path(@project).should be_denied_for :admin } + it { project_commits_path(@project).should be_denied_for @u2 } + it { project_commits_path(@project).should be_denied_for :user } + it { project_commits_path(@project).should be_denied_for :visitor } + end + + describe "GET /project_code/commit" do + it { project_commit_path(@project, @project.commit.id).should be_allowed_for @u1 } + it { project_commit_path(@project, @project.commit.id).should be_allowed_for @u3 } + it { project_commit_path(@project, @project.commit.id).should be_denied_for :admin } + it { project_commit_path(@project, @project.commit.id).should be_denied_for @u2 } + it { project_commit_path(@project, @project.commit.id).should be_denied_for :user } + it { project_commit_path(@project, @project.commit.id).should be_denied_for :visitor } + end + + describe "GET /project_code/team" do + it { team_project_path(@project).should be_allowed_for @u1 } + it { team_project_path(@project).should be_allowed_for @u3 } + it { team_project_path(@project).should be_denied_for :admin } + it { team_project_path(@project).should be_denied_for @u2 } + it { team_project_path(@project).should be_denied_for :user } + it { team_project_path(@project).should be_denied_for :visitor } + end + + describe "GET /project_code/wall" do + it { wall_project_path(@project).should be_allowed_for @u1 } + it { wall_project_path(@project).should be_allowed_for @u3 } + it { wall_project_path(@project).should be_denied_for :admin } + it { wall_project_path(@project).should be_denied_for @u2 } + it { wall_project_path(@project).should be_denied_for :user } + it { wall_project_path(@project).should be_denied_for :visitor } + end + + describe "GET /project_code/blob" do + before do + @commit = @project.commit + @path = @commit.tree.contents.select { |i| i.is_a?(Grit::Blob)}.first.name + @blob_path = blob_project_ref_path(@project, @commit.id, :path => @path) + end + + it { @blob_path.should be_allowed_for @u1 } + it { @blob_path.should be_allowed_for @u3 } + it { @blob_path.should be_denied_for :admin } + it { @blob_path.should be_denied_for @u2 } + it { @blob_path.should be_denied_for :user } + it { @blob_path.should be_denied_for :visitor } + end + + describe "GET /project_code/edit" do + it { edit_project_path(@project).should be_allowed_for @u1 } + it { edit_project_path(@project).should be_denied_for @u3 } + it { edit_project_path(@project).should be_denied_for :admin } + it { edit_project_path(@project).should be_denied_for @u2 } + it { edit_project_path(@project).should be_denied_for :user } + it { edit_project_path(@project).should be_denied_for :visitor } + end + + describe "GET /project_code/deploy_keys" do + it { project_deploy_keys_path(@project).should be_allowed_for @u1 } + it { project_deploy_keys_path(@project).should be_denied_for @u3 } + it { project_deploy_keys_path(@project).should be_denied_for :admin } + it { project_deploy_keys_path(@project).should be_denied_for @u2 } + it { project_deploy_keys_path(@project).should be_denied_for :user } + it { project_deploy_keys_path(@project).should be_denied_for :visitor } + end + + describe "GET /project_code/issues" do + it { project_issues_path(@project).should be_allowed_for @u1 } + it { project_issues_path(@project).should be_allowed_for @u3 } + it { project_issues_path(@project).should be_denied_for :admin } + it { project_issues_path(@project).should be_denied_for @u2 } + it { project_issues_path(@project).should be_denied_for :user } + it { project_issues_path(@project).should be_denied_for :visitor } + end + + describe "GET /project_code/snippets" do + it { project_snippets_path(@project).should be_allowed_for @u1 } + it { project_snippets_path(@project).should be_allowed_for @u3 } + it { project_snippets_path(@project).should be_denied_for :admin } + it { project_snippets_path(@project).should be_denied_for @u2 } + it { project_snippets_path(@project).should be_denied_for :user } + it { project_snippets_path(@project).should be_denied_for :visitor } + end + + describe "GET /project_code/merge_requests" do + it { project_merge_requests_path(@project).should be_allowed_for @u1 } + it { project_merge_requests_path(@project).should be_allowed_for @u3 } + it { project_merge_requests_path(@project).should be_denied_for :admin } + it { project_merge_requests_path(@project).should be_denied_for @u2 } + it { project_merge_requests_path(@project).should be_denied_for :user } + it { project_merge_requests_path(@project).should be_denied_for :visitor } + end + + describe "GET /project_code/repository" do + it { project_repository_path(@project).should be_allowed_for @u1 } + it { project_repository_path(@project).should be_allowed_for @u3 } + it { project_repository_path(@project).should be_denied_for :admin } + it { project_repository_path(@project).should be_denied_for @u2 } + it { project_repository_path(@project).should be_denied_for :user } + it { project_repository_path(@project).should be_denied_for :visitor } + end + + describe "GET /project_code/repository/branches" do + it { branches_project_repository_path(@project).should be_allowed_for @u1 } + it { branches_project_repository_path(@project).should be_allowed_for @u3 } + it { branches_project_repository_path(@project).should be_denied_for :admin } + it { branches_project_repository_path(@project).should be_denied_for @u2 } + it { branches_project_repository_path(@project).should be_denied_for :user } + it { branches_project_repository_path(@project).should be_denied_for :visitor } + end + + describe "GET /project_code/repository/tags" do + it { tags_project_repository_path(@project).should be_allowed_for @u1 } + it { tags_project_repository_path(@project).should be_allowed_for @u3 } + it { tags_project_repository_path(@project).should be_denied_for :admin } + it { tags_project_repository_path(@project).should be_denied_for @u2 } + it { tags_project_repository_path(@project).should be_denied_for :user } + it { tags_project_repository_path(@project).should be_denied_for :visitor } + end + + describe "GET /project_code/hooks" do + it { project_hooks_path(@project).should be_allowed_for @u1 } + it { project_hooks_path(@project).should be_allowed_for @u3 } + it { project_hooks_path(@project).should be_denied_for :admin } + it { project_hooks_path(@project).should be_denied_for @u2 } + it { project_hooks_path(@project).should be_denied_for :user } + it { project_hooks_path(@project).should be_denied_for :visitor } + end + + describe "GET /project_code/files" do + it { files_project_path(@project).should be_allowed_for @u1 } + it { files_project_path(@project).should be_allowed_for @u3 } + it { files_project_path(@project).should be_denied_for :admin } + it { files_project_path(@project).should be_denied_for @u2 } + it { files_project_path(@project).should be_denied_for :user } + it { files_project_path(@project).should be_denied_for :visitor } + end + end +end diff --git a/spec/requests/milestones_spec.rb b/spec/requests/milestones_spec.rb deleted file mode 100644 index f1d5023..0000000 --- a/spec/requests/milestones_spec.rb +++ /dev/null @@ -1,51 +0,0 @@ -require 'spec_helper' - -describe "Milestones" do - let(:project) { Factory :project } - - before do - login_as :user - project.add_access(@user, :admin) - - @milestone = Factory :milestone, :project => project - @issue = Factory :issue, :project => project - - @milestone.issues << @issue - end - - describe "GET /milestones" do - before do - visit project_milestones_path(project) - end - - subject { page } - - it { should have_content(@milestone.title[0..10]) } - it { should have_content(@milestone.expires_at) } - it { should have_content("Browse Issues") } - end - - describe "GET /milestone/:id" do - before do - visit project_milestone_path(project, @milestone) - end - - subject { page } - - it { should have_content(@milestone.title[0..10]) } - it { should have_content(@milestone.expires_at) } - it { should have_content("Browse Issues") } - end - - describe "GET /milestones/new" do - before do - visit new_project_milestone_path(project) - fill_in "milestone_title", :with => "v2.3" - click_button "Create milestone" - end - - it { current_path.should == project_milestone_path(project, project.milestones.last) } - it { page.should have_content(project.milestones.last.title[0..10]) } - it { page.should have_content(project.milestones.last.expires_at) } - end -end diff --git a/spec/requests/projects_security_spec.rb b/spec/requests/projects_security_spec.rb deleted file mode 100644 index df4d112..0000000 --- a/spec/requests/projects_security_spec.rb +++ /dev/null @@ -1,187 +0,0 @@ -require 'spec_helper' - -describe "Projects Security" do - describe "GET /" do - it { root_path.should be_allowed_for :admin } - it { root_path.should be_allowed_for :user } - it { root_path.should be_denied_for :visitor } - end - - describe "GET /projects/new" do - it { new_project_path.should be_allowed_for :admin } - it { new_project_path.should be_allowed_for :user } - it { new_project_path.should be_denied_for :visitor } - end - - describe "Project" do - before do - @project = Factory :project - @u1 = Factory :user - @u2 = Factory :user - @u3 = Factory :user - # full access - @project.users_projects.create(:user => @u1, :project_access => UsersProject::MASTER) - # readonly - @project.users_projects.create(:user => @u3, :project_access => UsersProject::REPORTER) - end - - describe "GET /project_code" do - it { project_path(@project).should be_allowed_for @u1 } - it { project_path(@project).should be_allowed_for @u3 } - it { project_path(@project).should be_denied_for :admin } - it { project_path(@project).should be_denied_for @u2 } - it { project_path(@project).should be_denied_for :user } - it { project_path(@project).should be_denied_for :visitor } - end - - describe "GET /project_code/master/tree" do - it { tree_project_ref_path(@project, @project.root_ref).should be_allowed_for @u1 } - it { tree_project_ref_path(@project, @project.root_ref).should be_allowed_for @u3 } - it { tree_project_ref_path(@project, @project.root_ref).should be_denied_for :admin } - it { tree_project_ref_path(@project, @project.root_ref).should be_denied_for @u2 } - it { tree_project_ref_path(@project, @project.root_ref).should be_denied_for :user } - it { tree_project_ref_path(@project, @project.root_ref).should be_denied_for :visitor } - end - - describe "GET /project_code/commits" do - it { project_commits_path(@project).should be_allowed_for @u1 } - it { project_commits_path(@project).should be_allowed_for @u3 } - it { project_commits_path(@project).should be_denied_for :admin } - it { project_commits_path(@project).should be_denied_for @u2 } - it { project_commits_path(@project).should be_denied_for :user } - it { project_commits_path(@project).should be_denied_for :visitor } - end - - describe "GET /project_code/commit" do - it { project_commit_path(@project, @project.commit.id).should be_allowed_for @u1 } - it { project_commit_path(@project, @project.commit.id).should be_allowed_for @u3 } - it { project_commit_path(@project, @project.commit.id).should be_denied_for :admin } - it { project_commit_path(@project, @project.commit.id).should be_denied_for @u2 } - it { project_commit_path(@project, @project.commit.id).should be_denied_for :user } - it { project_commit_path(@project, @project.commit.id).should be_denied_for :visitor } - end - - describe "GET /project_code/team" do - it { team_project_path(@project).should be_allowed_for @u1 } - it { team_project_path(@project).should be_allowed_for @u3 } - it { team_project_path(@project).should be_denied_for :admin } - it { team_project_path(@project).should be_denied_for @u2 } - it { team_project_path(@project).should be_denied_for :user } - it { team_project_path(@project).should be_denied_for :visitor } - end - - describe "GET /project_code/wall" do - it { wall_project_path(@project).should be_allowed_for @u1 } - it { wall_project_path(@project).should be_allowed_for @u3 } - it { wall_project_path(@project).should be_denied_for :admin } - it { wall_project_path(@project).should be_denied_for @u2 } - it { wall_project_path(@project).should be_denied_for :user } - it { wall_project_path(@project).should be_denied_for :visitor } - end - - describe "GET /project_code/blob" do - before do - @commit = @project.commit - @path = @commit.tree.contents.select { |i| i.is_a?(Grit::Blob)}.first.name - @blob_path = blob_project_ref_path(@project, @commit.id, :path => @path) - end - - it { @blob_path.should be_allowed_for @u1 } - it { @blob_path.should be_allowed_for @u3 } - it { @blob_path.should be_denied_for :admin } - it { @blob_path.should be_denied_for @u2 } - it { @blob_path.should be_denied_for :user } - it { @blob_path.should be_denied_for :visitor } - end - - describe "GET /project_code/edit" do - it { edit_project_path(@project).should be_allowed_for @u1 } - it { edit_project_path(@project).should be_denied_for @u3 } - it { edit_project_path(@project).should be_denied_for :admin } - it { edit_project_path(@project).should be_denied_for @u2 } - it { edit_project_path(@project).should be_denied_for :user } - it { edit_project_path(@project).should be_denied_for :visitor } - end - - describe "GET /project_code/deploy_keys" do - it { project_deploy_keys_path(@project).should be_allowed_for @u1 } - it { project_deploy_keys_path(@project).should be_denied_for @u3 } - it { project_deploy_keys_path(@project).should be_denied_for :admin } - it { project_deploy_keys_path(@project).should be_denied_for @u2 } - it { project_deploy_keys_path(@project).should be_denied_for :user } - it { project_deploy_keys_path(@project).should be_denied_for :visitor } - end - - describe "GET /project_code/issues" do - it { project_issues_path(@project).should be_allowed_for @u1 } - it { project_issues_path(@project).should be_allowed_for @u3 } - it { project_issues_path(@project).should be_denied_for :admin } - it { project_issues_path(@project).should be_denied_for @u2 } - it { project_issues_path(@project).should be_denied_for :user } - it { project_issues_path(@project).should be_denied_for :visitor } - end - - describe "GET /project_code/snippets" do - it { project_snippets_path(@project).should be_allowed_for @u1 } - it { project_snippets_path(@project).should be_allowed_for @u3 } - it { project_snippets_path(@project).should be_denied_for :admin } - it { project_snippets_path(@project).should be_denied_for @u2 } - it { project_snippets_path(@project).should be_denied_for :user } - it { project_snippets_path(@project).should be_denied_for :visitor } - end - - describe "GET /project_code/merge_requests" do - it { project_merge_requests_path(@project).should be_allowed_for @u1 } - it { project_merge_requests_path(@project).should be_allowed_for @u3 } - it { project_merge_requests_path(@project).should be_denied_for :admin } - it { project_merge_requests_path(@project).should be_denied_for @u2 } - it { project_merge_requests_path(@project).should be_denied_for :user } - it { project_merge_requests_path(@project).should be_denied_for :visitor } - end - - describe "GET /project_code/repository" do - it { project_repository_path(@project).should be_allowed_for @u1 } - it { project_repository_path(@project).should be_allowed_for @u3 } - it { project_repository_path(@project).should be_denied_for :admin } - it { project_repository_path(@project).should be_denied_for @u2 } - it { project_repository_path(@project).should be_denied_for :user } - it { project_repository_path(@project).should be_denied_for :visitor } - end - - describe "GET /project_code/repository/branches" do - it { branches_project_repository_path(@project).should be_allowed_for @u1 } - it { branches_project_repository_path(@project).should be_allowed_for @u3 } - it { branches_project_repository_path(@project).should be_denied_for :admin } - it { branches_project_repository_path(@project).should be_denied_for @u2 } - it { branches_project_repository_path(@project).should be_denied_for :user } - it { branches_project_repository_path(@project).should be_denied_for :visitor } - end - - describe "GET /project_code/repository/tags" do - it { tags_project_repository_path(@project).should be_allowed_for @u1 } - it { tags_project_repository_path(@project).should be_allowed_for @u3 } - it { tags_project_repository_path(@project).should be_denied_for :admin } - it { tags_project_repository_path(@project).should be_denied_for @u2 } - it { tags_project_repository_path(@project).should be_denied_for :user } - it { tags_project_repository_path(@project).should be_denied_for :visitor } - end - - describe "GET /project_code/hooks" do - it { project_hooks_path(@project).should be_allowed_for @u1 } - it { project_hooks_path(@project).should be_allowed_for @u3 } - it { project_hooks_path(@project).should be_denied_for :admin } - it { project_hooks_path(@project).should be_denied_for @u2 } - it { project_hooks_path(@project).should be_denied_for :user } - it { project_hooks_path(@project).should be_denied_for :visitor } - end - - describe "GET /project_code/files" do - it { files_project_path(@project).should be_allowed_for @u1 } - it { files_project_path(@project).should be_allowed_for @u3 } - it { files_project_path(@project).should be_denied_for :admin } - it { files_project_path(@project).should be_denied_for @u2 } - it { files_project_path(@project).should be_denied_for :user } - it { files_project_path(@project).should be_denied_for :visitor } - end - end -end -- libgit2 0.21.2