From 6de488259701af4b69282ad105882dba423fb666 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 3 Aug 2012 19:29:54 +0300 Subject: Remove duplicate coverage in spec requests. All features should be covered in cucumber --- features/dashboard/dashboard.feature | 2 +- features/profile/profile.feature | 6 +- features/projects/source/browse_files.feature | 23 ++++++ .../projects/source/browse_files.feature.commented | 23 ------ features/projects/source/git_blame.feature | 10 +++ features/step_definitions/browse_code_steps.rb | 10 +++ features/step_definitions/profile_steps.rb | 13 ++++ spec/requests/atom/dashboard_issues_spec.rb | 47 +++++++++++ spec/requests/atom/dashboard_spec.rb | 27 +++++++ spec/requests/commits_spec.rb | 68 ---------------- spec/requests/dashboard_issues_spec.rb | 55 ------------- spec/requests/dashboard_merge_requests_spec.rb | 40 ---------- spec/requests/dashboard_spec.rb | 39 ---------- spec/requests/file_blame_spec.rb | 25 ------ spec/requests/keys_spec.rb | 65 ---------------- spec/requests/last_push_widget_spec.rb | 52 ------------- spec/requests/profile_spec.rb | 82 -------------------- spec/requests/projects_spec.rb | 77 ------------------ spec/requests/projects_tree_spec.rb | 90 ---------------------- spec/requests/projects_wall_spec.rb | 33 -------- spec/requests/wikis_spec.rb | 35 --------- 21 files changed, 136 insertions(+), 686 deletions(-) create mode 100644 features/projects/source/browse_files.feature delete mode 100644 features/projects/source/browse_files.feature.commented create mode 100644 spec/requests/atom/dashboard_issues_spec.rb create mode 100644 spec/requests/atom/dashboard_spec.rb delete mode 100644 spec/requests/commits_spec.rb delete mode 100644 spec/requests/dashboard_issues_spec.rb delete mode 100644 spec/requests/dashboard_merge_requests_spec.rb delete mode 100644 spec/requests/dashboard_spec.rb delete mode 100644 spec/requests/file_blame_spec.rb delete mode 100644 spec/requests/keys_spec.rb delete mode 100644 spec/requests/last_push_widget_spec.rb delete mode 100644 spec/requests/profile_spec.rb delete mode 100644 spec/requests/projects_tree_spec.rb delete mode 100644 spec/requests/projects_wall_spec.rb delete mode 100644 spec/requests/wikis_spec.rb diff --git a/features/dashboard/dashboard.feature b/features/dashboard/dashboard.feature index 2d66af53b7b..a8c2205c143 100644 --- a/features/dashboard/dashboard.feature +++ b/features/dashboard/dashboard.feature @@ -10,7 +10,7 @@ Feature: Dashboard Then I should see "Shop" project link Then I should see project "Shop" activity feed - Scenario: I should see last pish widget + Scenario: I should see last push widget Then I should see last push widget And I click "Create Merge Request" link Then I see prefilled new Merge Request page diff --git a/features/profile/profile.feature b/features/profile/profile.feature index e3d71abc746..afda4b55081 100644 --- a/features/profile/profile.feature +++ b/features/profile/profile.feature @@ -6,6 +6,11 @@ Feature: Profile Given I visit profile page Then I should see my profile info + Scenario: I edit profile + Given I visit profile page + Then I change my contact info + And I should see new contact info + Scenario: I change my password Given I visit profile password page Then I change my password @@ -15,4 +20,3 @@ Feature: Profile Given I visit profile token page Then I reset my token And I should see new token - diff --git a/features/projects/source/browse_files.feature b/features/projects/source/browse_files.feature new file mode 100644 index 00000000000..04aebc19732 --- /dev/null +++ b/features/projects/source/browse_files.feature @@ -0,0 +1,23 @@ +Feature: Browse git repo + Background: + Given I signin as a user + And I own project "Shop" + Given I visit project source page + + Scenario: I browse files from master branch + Then I should see files from repository + + Scenario: I browse files for specific ref + Given I visit project source page for "8470d70" + Then I should see files from repository for "8470d70" + + Scenario: I browse file content + Given I click on file from repo + Then I should see it content + + Scenario: I browse raw file + Given I visit blob file from repo + And I click on raw button + Then I should see raw file content + + diff --git a/features/projects/source/browse_files.feature.commented b/features/projects/source/browse_files.feature.commented deleted file mode 100644 index 04aebc19732..00000000000 --- a/features/projects/source/browse_files.feature.commented +++ /dev/null @@ -1,23 +0,0 @@ -Feature: Browse git repo - Background: - Given I signin as a user - And I own project "Shop" - Given I visit project source page - - Scenario: I browse files from master branch - Then I should see files from repository - - Scenario: I browse files for specific ref - Given I visit project source page for "8470d70" - Then I should see files from repository for "8470d70" - - Scenario: I browse file content - Given I click on file from repo - Then I should see it content - - Scenario: I browse raw file - Given I visit blob file from repo - And I click on raw button - Then I should see raw file content - - diff --git a/features/projects/source/git_blame.feature b/features/projects/source/git_blame.feature index e69de29bb2d..6aa6be47deb 100644 --- a/features/projects/source/git_blame.feature +++ b/features/projects/source/git_blame.feature @@ -0,0 +1,10 @@ +Feature: Browse git repo + Background: + Given I signin as a user + And I own project "Shop" + Given I visit project source page + + Scenario: I blame file + Given I click on file from repo + And I click blame button + Then I should see git file blame diff --git a/features/step_definitions/browse_code_steps.rb b/features/step_definitions/browse_code_steps.rb index fc3cf56a83b..7f9001bb989 100644 --- a/features/step_definitions/browse_code_steps.rb +++ b/features/step_definitions/browse_code_steps.rb @@ -38,3 +38,13 @@ end Then /^I should see raw file content$/ do page.source.should == ValidCommit::BLOB_FILE end + +Given /^I click blame button$/ do + click_link "blame" +end + +Then /^I should see git file blame$/ do + page.should have_content("rubygems.org") + page.should have_content("Dmitriy Zaporozhets") + page.should have_content("bc3735004cb Moving to rails 3.2") +end diff --git a/features/step_definitions/profile_steps.rb b/features/step_definitions/profile_steps.rb index 7510c5365e1..4661139c180 100644 --- a/features/step_definitions/profile_steps.rb +++ b/features/step_definitions/profile_steps.rb @@ -36,3 +36,16 @@ Then /^I should see new token$/ do find("#token").value.should == @user.reload.private_token end +Then /^I change my contact info$/ do + fill_in "user_skype", :with => "testskype" + fill_in "user_linkedin", :with => "testlinkedin" + fill_in "user_twitter", :with => "testtwitter" + click_button "Save" + @user.reload +end + +Then /^I should see new contact info$/ do + @user.skype.should == 'testskype' + @user.linkedin.should == 'testlinkedin' + @user.twitter.should == 'testtwitter' +end diff --git a/spec/requests/atom/dashboard_issues_spec.rb b/spec/requests/atom/dashboard_issues_spec.rb new file mode 100644 index 00000000000..7260dcf47bf --- /dev/null +++ b/spec/requests/atom/dashboard_issues_spec.rb @@ -0,0 +1,47 @@ +require 'spec_helper' + +describe "User Issues Dashboard" do + describe "GET /issues" do + before do + + login_as :user + + @project1 = Factory :project, + :path => "project1", + :code => "TEST1" + + @project2 = Factory :project, + :path => "project2", + :code => "TEST2" + + @project1.add_access(@user, :read, :write) + @project2.add_access(@user, :read, :write) + + @issue1 = Factory :issue, + :author => @user, + :assignee => @user, + :project => @project1 + + @issue2 = Factory :issue, + :author => @user, + :assignee => @user, + :project => @project2 + + visit dashboard_issues_path + end + + describe "atom feed", :js => false do + it "should render atom feed via private token" do + logout + visit dashboard_issues_path(:atom, :private_token => @user.private_token) + + page.response_headers['Content-Type'].should have_content("application/atom+xml") + page.body.should have_selector("title", :text => "#{@user.name} issues") + page.body.should have_selector("author email", :text => @issue1.author_email) + page.body.should have_selector("entry summary", :text => @issue1.title) + page.body.should have_selector("author email", :text => @issue2.author_email) + page.body.should have_selector("entry summary", :text => @issue2.title) + end + end + end +end diff --git a/spec/requests/atom/dashboard_spec.rb b/spec/requests/atom/dashboard_spec.rb new file mode 100644 index 00000000000..4db8ce49ff7 --- /dev/null +++ b/spec/requests/atom/dashboard_spec.rb @@ -0,0 +1,27 @@ +require 'spec_helper' + +describe "User Dashboard" do + before { login_as :user } + + describe "GET /" do + before do + @project = Factory :project, :owner => @user + @project.add_access(@user, :read) + visit dashboard_path + end + + it "should render projects atom feed via private token" do + logout + + visit dashboard_path(:atom, :private_token => @user.private_token) + page.body.should have_selector("feed title") + end + + it "should not render projects page via private token" do + logout + + visit dashboard_path(:private_token => @user.private_token) + current_path.should == new_user_session_path + end + end +end diff --git a/spec/requests/commits_spec.rb b/spec/requests/commits_spec.rb deleted file mode 100644 index ae36a932ae0..00000000000 --- a/spec/requests/commits_spec.rb +++ /dev/null @@ -1,68 +0,0 @@ -require 'spec_helper' - -describe "Commits" do - let(:project) { Factory :project } - let!(:commit) { CommitDecorator.decorate(project.commit) } - before do - login_as :user - project.add_access(@user, :read) - end - - describe "GET /commits" do - before do - visit project_commits_path(project) - end - - it "should have valid path" do - current_path.should == project_commits_path(project) - end - - it "should have project name" do - page.should have_content(project.name) - end - - it "should list commits" do - page.should have_content(commit.description) - page.should have_content(commit.short_id(8)) - end - - it "should render atom feed" do - visit project_commits_path(project, :atom) - - page.response_headers['Content-Type'].should have_content("application/atom+xml") - page.body.should have_selector("title", :text => "Recent commits to #{project.name}") - page.body.should have_selector("author email", :text => commit.author_email) - page.body.should have_selector("entry summary", :text => commit.description) - end - - it "should render atom feed via private token" do - logout - visit project_commits_path(project, :atom, :private_token => @user.private_token) - - page.response_headers['Content-Type'].should have_content("application/atom+xml") - page.body.should have_selector("title", :text => "Recent commits to #{project.name}") - page.body.should have_selector("author email", :text => commit.author_email) - page.body.should have_selector("entry summary", :text => commit.description) - end - end - - describe "GET /commits/:id" do - before do - visit project_commit_path(project, commit.id) - end - - it "should have valid path" do - current_path.should == project_commit_path(project, commit.id) - end - end - - describe "GET /commits/compare" do - before do - visit compare_project_commits_path(project) - end - - it "should have valid path" do - current_path.should == compare_project_commits_path(project) - end - end -end diff --git a/spec/requests/dashboard_issues_spec.rb b/spec/requests/dashboard_issues_spec.rb deleted file mode 100644 index 29c79313f7e..00000000000 --- a/spec/requests/dashboard_issues_spec.rb +++ /dev/null @@ -1,55 +0,0 @@ -require 'spec_helper' - -describe "User Issues Dashboard" do - describe "GET /issues" do - before do - - login_as :user - - @project1 = Factory :project, - :path => "project1", - :code => "TEST1" - - @project2 = Factory :project, - :path => "project2", - :code => "TEST2" - - @project1.add_access(@user, :read, :write) - @project2.add_access(@user, :read, :write) - - @issue1 = Factory :issue, - :author => @user, - :assignee => @user, - :project => @project1 - - @issue2 = Factory :issue, - :author => @user, - :assignee => @user, - :project => @project2 - - visit dashboard_issues_path - end - - subject { page } - - it { should have_content(@issue1.title[0..10]) } - it { should have_content(@issue1.project.name) } - - it { should have_content(@issue2.title[0..10]) } - it { should have_content(@issue2.project.name) } - - describe "atom feed", :js => false do - it "should render atom feed via private token" do - logout - visit dashboard_issues_path(:atom, :private_token => @user.private_token) - - page.response_headers['Content-Type'].should have_content("application/atom+xml") - page.body.should have_selector("title", :text => "#{@user.name} issues") - page.body.should have_selector("author email", :text => @issue1.author_email) - page.body.should have_selector("entry summary", :text => @issue1.title) - page.body.should have_selector("author email", :text => @issue2.author_email) - page.body.should have_selector("entry summary", :text => @issue2.title) - end - end - end -end diff --git a/spec/requests/dashboard_merge_requests_spec.rb b/spec/requests/dashboard_merge_requests_spec.rb deleted file mode 100644 index f345a858ac8..00000000000 --- a/spec/requests/dashboard_merge_requests_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'spec_helper' - -describe "User MergeRequests" do - describe "GET /issues" do - before do - - login_as :user - - @project1 = Factory :project, - :path => "project1", - :code => "TEST1" - - @project2 = Factory :project, - :path => "project2", - :code => "TEST2" - - @project1.add_access(@user, :read, :write) - @project2.add_access(@user, :read, :write) - - @merge_request1 = Factory :merge_request, - :author => @user, - :assignee => @user, - :project => @project1 - - @merge_request2 = Factory :merge_request, - :author => @user, - :assignee => @user, - :project => @project2 - - visit dashboard_merge_requests_path - end - - subject { page } - - it { should have_content(@merge_request1.title[0..10]) } - it { should have_content(@merge_request1.project.name) } - it { should have_content(@merge_request2.title[0..10]) } - it { should have_content(@merge_request2.project.name) } - end -end diff --git a/spec/requests/dashboard_spec.rb b/spec/requests/dashboard_spec.rb deleted file mode 100644 index 16ededd02af..00000000000 --- a/spec/requests/dashboard_spec.rb +++ /dev/null @@ -1,39 +0,0 @@ -require 'spec_helper' - -describe "User Dashboard" do - before { login_as :user } - - describe "GET /" do - before do - @project = Factory :project, :owner => @user - @project.add_access(@user, :read) - visit dashboard_path - end - - it "should be on projects page" do - current_path.should == dashboard_path - end - - it "should have link to new project" do - page.should have_content("New Project") - end - - it "should have project" do - page.should have_content(@project.name) - end - - it "should render projects atom feed via private token" do - logout - - visit dashboard_path(:atom, :private_token => @user.private_token) - page.body.should have_selector("feed title") - end - - it "should not render projects page via private token" do - logout - - visit dashboard_path(:private_token => @user.private_token) - current_path.should == new_user_session_path - end - end -end diff --git a/spec/requests/file_blame_spec.rb b/spec/requests/file_blame_spec.rb deleted file mode 100644 index 511f340c1c8..00000000000 --- a/spec/requests/file_blame_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'spec_helper' - -describe "Blame file" do - before { login_as :user } - - describe "GET /:projectname/:commit/blob/Gemfile" do - before do - @project = Factory :project - @project.add_access(@user, :read) - - visit tree_project_ref_path(@project, @project.root_ref, :path => "Gemfile") - click_link "blame" - end - - it "should be correct path" do - current_path.should == blame_file_project_ref_path(@project, @project.root_ref, :path => "Gemfile") - end - - it "should contain file view" do - page.should have_content("rubygems.org") - page.should have_content("Dmitriy Zaporozhets") - page.should have_content("bc3735004cb Moving to rails 3.2") - end - end -end diff --git a/spec/requests/keys_spec.rb b/spec/requests/keys_spec.rb deleted file mode 100644 index 2bc7c75ba0d..00000000000 --- a/spec/requests/keys_spec.rb +++ /dev/null @@ -1,65 +0,0 @@ -require 'spec_helper' - -describe "Issues" do - before do - login_as :user - end - - describe "GET /keys" do - before do - @key = Factory :key, :user => @user - visit keys_path - end - - subject { page } - - it { should have_content(@key.title) } - - describe "Destroy" do - before { visit key_path(@key) } - - it "should remove entry" do - expect { - click_link "Remove" - }.to change { @user.keys.count }.by(-1) - end - end - end - - describe "New key" do - before do - visit keys_path - click_link "Add new" - end - - it "should open new key popup" do - page.should have_content("New key") - end - - describe "fill in" do - before do - fill_in "key_title", :with => "laptop" - fill_in "key_key", :with => "publickey234=" - end - - it { expect { click_button "Save" }.to change {Key.count}.by(1) } - - it "should add new key to table" do - click_button "Save" - - page.should_not have_content("New key") - page.should have_content "laptop" - end - end - end - - describe "Show page" do - before do - @key = Factory :key, :user => @user - visit key_path(@key) - end - - it { page.should have_content @key.title } - it { page.should have_content @key.key[0..10] } - end -end diff --git a/spec/requests/last_push_widget_spec.rb b/spec/requests/last_push_widget_spec.rb deleted file mode 100644 index 0baa20c6e94..00000000000 --- a/spec/requests/last_push_widget_spec.rb +++ /dev/null @@ -1,52 +0,0 @@ -require 'spec_helper' - -describe "Last Push widget" do - before { login_as :user } - - before do - @project = Factory :project, :owner => @user - @project.add_access(@user, :read) - create_push_event - visit dashboard_path - end - - it "should display last push widget with link to merge request page" do - page.should have_content "Your pushed to branch new_design" - page.should have_link "Create Merge Request" - end - - describe "click create MR" do - before { click_link "Create Merge Request" } - - it { current_path.should == new_project_merge_request_path(@project) } - it { find("#merge_request_source_branch").value.should == "new_design" } - it { find("#merge_request_target_branch").value.should == "master" } - it { find("#merge_request_title").value.should == "New Design" } - end - - - def create_push_event - data = { - :before => "0000000000000000000000000000000000000000", - :after => "0220c11b9a3e6c69dc8fd35321254ca9a7b98f7e", - :ref => "refs/heads/new_design", - :user_id => @user.id, - :user_name => @user.name, - :repository => { - :name => @project.name, - :url => "localhost/rubinius", - :description => "", - :homepage => "localhost/rubinius", - :private => true - } - } - - @event = Event.create( - :project => @project, - :action => Event::Pushed, - :data => data, - :author_id => @user.id - ) - end -end - diff --git a/spec/requests/profile_spec.rb b/spec/requests/profile_spec.rb deleted file mode 100644 index 6f9af6085ab..00000000000 --- a/spec/requests/profile_spec.rb +++ /dev/null @@ -1,82 +0,0 @@ -require 'spec_helper' - -describe "Profile" do - before do - login_as :user - end - - describe "Show profile" do - before do - visit profile_path - end - - it { page.should have_content(@user.name) } - end - - describe "Profile update" do - before do - visit profile_path - fill_in "user_skype", :with => "testskype" - fill_in "user_linkedin", :with => "testlinkedin" - fill_in "user_twitter", :with => "testtwitter" - click_button "Save" - @user.reload - end - - it { @user.skype.should == 'testskype' } - it { @user.linkedin.should == 'testlinkedin' } - it { @user.twitter.should == 'testtwitter' } - end - - describe "Reset private token" do - before do - visit profile_token_path - end - - it "should reset private token" do - user_first_token = @user.private_token - click_button "Reset" - @user.reload - @user.private_token.should_not == user_first_token - end - end - - describe "Password update" do - before do - visit profile_password_path - end - - it { page.should have_content("Password") } - it { page.should have_content("Password confirmation") } - - describe "change password" do - before do - @old_pwd = @user.encrypted_password - fill_in "user_password", :with => "777777" - fill_in "user_password_confirmation", :with => "777777" - click_button "Save" - @user.reload - end - - it "should redirect to signin page" do - current_path.should == new_user_session_path - end - - it "should change password" do - @user.encrypted_password.should_not == @old_pwd - end - - describe "login with new password" do - before do - fill_in "user_email", :with => @user.email - fill_in "user_password", :with => "777777" - click_button "Sign in" - end - - it "should login user" do - current_path.should == root_path - end - end - end - end -end diff --git a/spec/requests/projects_spec.rb b/spec/requests/projects_spec.rb index c9c348469cc..f96affc75bc 100644 --- a/spec/requests/projects_spec.rb +++ b/spec/requests/projects_spec.rb @@ -3,47 +3,6 @@ require 'spec_helper' describe "Projects" do before { login_as :user } - describe "GET /projects/new" do - before do - visit root_path - click_link "New Project" - end - - it "should be correct path" do - current_path.should == new_project_path - end - - it "should have labels for new project" do - page.should have_content("Project name is") - end - end - - describe "POST /projects" do - before do - visit new_project_path - fill_in 'project_name', :with => 'NewProject' - fill_in 'project_code', :with => 'NPR' - fill_in 'project_path', :with => 'newproject' - expect { click_button "Create project" }.to change { Project.count }.by(1) - @project = Project.last - end - - it "should be correct path" do - current_path.should == project_path(@project) - end - - it "should show project" do - page.should have_content(@project.name) - page.should have_content(@project.path) - page.should have_content(@project.description) - end - - it "should init repo instructions" do - page.should have_content("git remote") - page.should have_content(@project.url_to_repo) - end - end - describe "GET /projects/show" do before do @project = Factory :project, :owner => @user @@ -57,42 +16,6 @@ describe "Projects" do end end - describe "GET /projects/graph" do - before do - @project = Factory :project - @project.add_access(@user, :read) - - visit graph_project_path(@project) - end - - it "should be correct path" do - current_path.should == graph_project_path(@project) - end - - it "should have as as team member" do - page.should have_content("master") - end - end - - describe "GET /projects/team" do - before do - @project = Factory :project - @project.add_access(@user, :read) - - visit team_project_path(@project, - :path => ValidCommit::BLOB_FILE_PATH, - :commit_id => ValidCommit::ID) - end - - it "should be correct path" do - current_path.should == team_project_path(@project) - end - - it "should have as as team member" do - page.should have_content(@user.name) - end - end - describe "GET /projects/:id/edit" do before do @project = Factory :project diff --git a/spec/requests/projects_tree_spec.rb b/spec/requests/projects_tree_spec.rb deleted file mode 100644 index acc4f0b9674..00000000000 --- a/spec/requests/projects_tree_spec.rb +++ /dev/null @@ -1,90 +0,0 @@ -require 'spec_helper' - -describe "Projects" do - before { login_as :user } - - describe "GET /projects/tree" do - describe "head" do - before do - @project = Factory :project - @project.add_access(@user, :read) - - visit tree_project_ref_path(@project, @project.root_ref) - end - - it "should be correct path" do - current_path.should == tree_project_ref_path(@project, @project.root_ref) - end - - it_behaves_like :tree_view - end - - describe ValidCommit::ID do - before do - @project = Factory :project - @project.add_access(@user, :read) - - visit tree_project_ref_path(@project, ValidCommit::ID) - end - - it "should be correct path" do - current_path.should == tree_project_ref_path(@project, ValidCommit::ID) - end - - it_behaves_like :tree_view - it_behaves_like :project_side_pane - end - - describe "branch passed" do - before do - @project = Factory :project - @project.add_access(@user, :read) - - visit tree_project_ref_path(@project, @project.root_ref) - end - - it "should be correct path" do - current_path.should == tree_project_ref_path(@project, @project.root_ref) - end - - it_behaves_like :tree_view - it_behaves_like :project_side_pane - end - - # TREE FILE PREVIEW - describe "file preview" do - before do - @project = Factory :project - @project.add_access(@user, :read) - - visit tree_project_ref_path(@project, @project.root_ref, :path => "Gemfile") - end - - it "should be correct path" do - current_path.should == tree_project_ref_path(@project, @project.root_ref) - end - - it "should contain file view" do - page.should have_content("rubygems.org") - end - end - end - - # RAW FILE - describe "GET /projects/blob" do - before do - @project = Factory :project - @project.add_access(@user, :read) - - visit blob_project_ref_path(@project, ValidCommit::ID, :path => ValidCommit::BLOB_FILE_PATH) - end - - it "should be correct path" do - current_path.should == blob_project_ref_path(@project, ValidCommit::ID) - end - - it "raw file response" do - page.source.should == ValidCommit::BLOB_FILE - end - end -end diff --git a/spec/requests/projects_wall_spec.rb b/spec/requests/projects_wall_spec.rb deleted file mode 100644 index b2708fd1a57..00000000000 --- a/spec/requests/projects_wall_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'spec_helper' - -describe "Projects", "Wall" do - let(:project) { Factory :project } - - before do - login_as :user - project.add_access(@user, :read, :write) - end - - describe "View notes on wall", :js => true do - before do - Factory :note, :project => project, :note => "Project specs", :author => @user - visit wall_project_path(project) - end - - it { page.should have_content("Project specs") } - it { page.should have_content(@user.name) } - it { page.should have_content("less than a minute ago") } - end - - describe "add new note", :js => true do - before do - visit wall_project_path(project) - fill_in "note_note", :with => "my post on wall" - click_button "Add Comment" - end - - it "should conatin new note" do - page.should have_content("my post on wall") - end - end -end diff --git a/spec/requests/wikis_spec.rb b/spec/requests/wikis_spec.rb deleted file mode 100644 index fd66b5e4300..00000000000 --- a/spec/requests/wikis_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'spec_helper' - -describe "Wiki" do - let(:project) { Factory :project } - - before do - login_as :user - project.add_access(@user, :read, :write) - end - - describe "Add pages" do - before do - visit project_wiki_path(project, :index) - end - - it "should see form" do - page.should have_content("Editing page") - end - - it "should see added page" do - fill_in "Title", :with => 'Test title' - fill_in "Content", :with => '[link test](test)' - click_on "Save" - - page.should have_content("Test title") - page.should have_content("link test") - - click_link "link test" - - page.should have_content("Editing page") - end - - end - -end -- cgit v1.2.1 From b846ac10597d832bd4b03ee65a026fcf4f9480f2 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 3 Aug 2012 19:39:54 +0300 Subject: Milestones cucumber. Renamed app security test --- features/projects/issues/milestones.feature | 18 ++ .../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 e69de29bb2d..d78096a4f16 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 00000000000..6749773e2b5 --- /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 00000000000..bcca42f5298 --- /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 f1d5023e6b4..00000000000 --- 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 df4d11221c3..00000000000 --- 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 -- cgit v1.2.1 From 1281c122c7a4edf2873aad13c22ea09ce6dc57c3 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 3 Aug 2012 19:49:54 +0300 Subject: Issues cucumber. refactored step_definitoons --- features/projects/issues/issues.feature | 30 +++- features/step_definitions/browse_code_steps.rb | 50 ------- .../step_definitions/profile/profile_keys_steps.rb | 34 +++++ features/step_definitions/profile/profile_steps.rb | 51 +++++++ features/step_definitions/profile_keys_steps.rb | 34 ----- features/step_definitions/profile_steps.rb | 51 ------- .../step_definitions/project/browse_code_steps.rb | 50 +++++++ .../project/project_commits_steps.rb | 61 ++++++++ .../project/project_issues_steps.rb | 47 +++++++ .../project/project_merge_requests_steps.rb | 38 +++++ .../step_definitions/project/project_team_steps.rb | 63 +++++++++ .../step_definitions/project/project_wiki_steps.rb | 18 +++ .../step_definitions/project/projects_steps.rb | 68 +++++++++ features/step_definitions/project_commits_steps.rb | 61 -------- features/step_definitions/project_issues_steps.rb | 22 --- .../project_merge_requests_steps.rb | 38 ----- features/step_definitions/project_team_steps.rb | 63 --------- features/step_definitions/project_wiki_steps.rb | 18 --- features/step_definitions/projects_steps.rb | 68 --------- spec/requests/atom/issues_spec.rb | 40 ++++++ spec/requests/issues_notes_spec.rb | 27 ---- spec/requests/issues_spec.rb | 155 --------------------- 22 files changed, 498 insertions(+), 589 deletions(-) delete mode 100644 features/step_definitions/browse_code_steps.rb create mode 100644 features/step_definitions/profile/profile_keys_steps.rb create mode 100644 features/step_definitions/profile/profile_steps.rb delete mode 100644 features/step_definitions/profile_keys_steps.rb delete mode 100644 features/step_definitions/profile_steps.rb create mode 100644 features/step_definitions/project/browse_code_steps.rb create mode 100644 features/step_definitions/project/project_commits_steps.rb create mode 100644 features/step_definitions/project/project_issues_steps.rb create mode 100644 features/step_definitions/project/project_merge_requests_steps.rb create mode 100644 features/step_definitions/project/project_team_steps.rb create mode 100644 features/step_definitions/project/project_wiki_steps.rb create mode 100644 features/step_definitions/project/projects_steps.rb delete mode 100644 features/step_definitions/project_commits_steps.rb delete mode 100644 features/step_definitions/project_issues_steps.rb delete mode 100644 features/step_definitions/project_merge_requests_steps.rb delete mode 100644 features/step_definitions/project_team_steps.rb delete mode 100644 features/step_definitions/project_wiki_steps.rb delete mode 100644 features/step_definitions/projects_steps.rb create mode 100644 spec/requests/atom/issues_spec.rb delete mode 100644 spec/requests/issues_notes_spec.rb diff --git a/features/projects/issues/issues.feature b/features/projects/issues/issues.feature index 0ca0792dd8a..a45dd801696 100644 --- a/features/projects/issues/issues.feature +++ b/features/projects/issues/issues.feature @@ -7,6 +7,32 @@ Feature: Issues And I visit project "Shop" issues page Scenario: I should see open issues - Given I should see "Release 0.4" open issue - And I should not see "Release 0.3" closed issue + Given I should see "Release 0.4" in issues + And I should not see "Release 0.3" in issues + Scenario: I should see closed issues + Given I click link "Closed" + Then I should see "Release 0.3" in issues + And I should not see "Release 0.4" in issues + + Scenario: I should see all issues + Given I click link "All" + Then I should see "Release 0.3" in issues + And I should see "Release 0.4" in issues + + Scenario: I visit issue page + Given I click link "Release 0.4" + Then I should see issue "Release 0.4" + + @javascript + Scenario: I submit new unassigned issue + Given I click link "New Issue" + And I submit new issue "500 error on profile" + Given I click link "500 error on profile" + Then I should see issue "500 error on profile" + + @javascript + Scenario: I comment issue + Given I visit issue page "Release 0.4" + And I leave a comment like "XML attached" + Then I should see commetn "XML attached" diff --git a/features/step_definitions/browse_code_steps.rb b/features/step_definitions/browse_code_steps.rb deleted file mode 100644 index 7f9001bb989..00000000000 --- a/features/step_definitions/browse_code_steps.rb +++ /dev/null @@ -1,50 +0,0 @@ -Given /^I visit project source page$/ do - visit tree_project_ref_path(@project, @project.root_ref) -end - -Then /^I should see files from repository$/ do - page.should have_content("app") - page.should have_content("History") - page.should have_content("Gemfile") -end - -Given /^I visit project source page for "(.*?)"$/ do |arg1| - visit tree_project_ref_path(@project, arg1) -end - -Then /^I should see files from repository for "(.*?)"$/ do |arg1| - current_path.should == tree_project_ref_path(@project, arg1) - page.should have_content("app") - page.should have_content("History") - page.should have_content("Gemfile") -end - -Given /^I click on file from repo$/ do - click_link "Gemfile" -end - -Then /^I should see it content$/ do - page.should have_content("rubygems.org") -end - -Given /^I click on raw button$/ do - click_link "raw" -end - -Given /^I visit blob file from repo$/ do - visit tree_project_ref_path(@project, ValidCommit::ID, :path => ValidCommit::BLOB_FILE_PATH) -end - -Then /^I should see raw file content$/ do - page.source.should == ValidCommit::BLOB_FILE -end - -Given /^I click blame button$/ do - click_link "blame" -end - -Then /^I should see git file blame$/ do - page.should have_content("rubygems.org") - page.should have_content("Dmitriy Zaporozhets") - page.should have_content("bc3735004cb Moving to rails 3.2") -end diff --git a/features/step_definitions/profile/profile_keys_steps.rb b/features/step_definitions/profile/profile_keys_steps.rb new file mode 100644 index 00000000000..5ab7e0480ad --- /dev/null +++ b/features/step_definitions/profile/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/profile/profile_steps.rb b/features/step_definitions/profile/profile_steps.rb new file mode 100644 index 00000000000..4661139c180 --- /dev/null +++ b/features/step_definitions/profile/profile_steps.rb @@ -0,0 +1,51 @@ +Given /^I visit profile page$/ do + visit profile_path +end + +Then /^I should see my profile info$/ do + page.should have_content "Profile" + page.should have_content @user.name + page.should have_content @user.email +end + +Given /^I visit profile password page$/ do + visit profile_password_path +end + +Then /^I change my password$/ do + fill_in "user_password", :with => "222333" + fill_in "user_password_confirmation", :with => "222333" + click_button "Save" +end + +Then /^I should be redirected to sign in page$/ do + current_path.should == new_user_session_path +end + +Given /^I visit profile token page$/ do + visit profile_token_path +end + +Then /^I reset my token$/ do + @old_token = @user.private_token + click_button "Reset" +end + +Then /^I should see new token$/ do + find("#token").value.should_not == @old_token + find("#token").value.should == @user.reload.private_token +end + +Then /^I change my contact info$/ do + fill_in "user_skype", :with => "testskype" + fill_in "user_linkedin", :with => "testlinkedin" + fill_in "user_twitter", :with => "testtwitter" + click_button "Save" + @user.reload +end + +Then /^I should see new contact info$/ do + @user.skype.should == 'testskype' + @user.linkedin.should == 'testlinkedin' + @user.twitter.should == 'testtwitter' +end diff --git a/features/step_definitions/profile_keys_steps.rb b/features/step_definitions/profile_keys_steps.rb deleted file mode 100644 index 5ab7e0480ad..00000000000 --- a/features/step_definitions/profile_keys_steps.rb +++ /dev/null @@ -1,34 +0,0 @@ -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/profile_steps.rb b/features/step_definitions/profile_steps.rb deleted file mode 100644 index 4661139c180..00000000000 --- a/features/step_definitions/profile_steps.rb +++ /dev/null @@ -1,51 +0,0 @@ -Given /^I visit profile page$/ do - visit profile_path -end - -Then /^I should see my profile info$/ do - page.should have_content "Profile" - page.should have_content @user.name - page.should have_content @user.email -end - -Given /^I visit profile password page$/ do - visit profile_password_path -end - -Then /^I change my password$/ do - fill_in "user_password", :with => "222333" - fill_in "user_password_confirmation", :with => "222333" - click_button "Save" -end - -Then /^I should be redirected to sign in page$/ do - current_path.should == new_user_session_path -end - -Given /^I visit profile token page$/ do - visit profile_token_path -end - -Then /^I reset my token$/ do - @old_token = @user.private_token - click_button "Reset" -end - -Then /^I should see new token$/ do - find("#token").value.should_not == @old_token - find("#token").value.should == @user.reload.private_token -end - -Then /^I change my contact info$/ do - fill_in "user_skype", :with => "testskype" - fill_in "user_linkedin", :with => "testlinkedin" - fill_in "user_twitter", :with => "testtwitter" - click_button "Save" - @user.reload -end - -Then /^I should see new contact info$/ do - @user.skype.should == 'testskype' - @user.linkedin.should == 'testlinkedin' - @user.twitter.should == 'testtwitter' -end diff --git a/features/step_definitions/project/browse_code_steps.rb b/features/step_definitions/project/browse_code_steps.rb new file mode 100644 index 00000000000..7f9001bb989 --- /dev/null +++ b/features/step_definitions/project/browse_code_steps.rb @@ -0,0 +1,50 @@ +Given /^I visit project source page$/ do + visit tree_project_ref_path(@project, @project.root_ref) +end + +Then /^I should see files from repository$/ do + page.should have_content("app") + page.should have_content("History") + page.should have_content("Gemfile") +end + +Given /^I visit project source page for "(.*?)"$/ do |arg1| + visit tree_project_ref_path(@project, arg1) +end + +Then /^I should see files from repository for "(.*?)"$/ do |arg1| + current_path.should == tree_project_ref_path(@project, arg1) + page.should have_content("app") + page.should have_content("History") + page.should have_content("Gemfile") +end + +Given /^I click on file from repo$/ do + click_link "Gemfile" +end + +Then /^I should see it content$/ do + page.should have_content("rubygems.org") +end + +Given /^I click on raw button$/ do + click_link "raw" +end + +Given /^I visit blob file from repo$/ do + visit tree_project_ref_path(@project, ValidCommit::ID, :path => ValidCommit::BLOB_FILE_PATH) +end + +Then /^I should see raw file content$/ do + page.source.should == ValidCommit::BLOB_FILE +end + +Given /^I click blame button$/ do + click_link "blame" +end + +Then /^I should see git file blame$/ do + page.should have_content("rubygems.org") + page.should have_content("Dmitriy Zaporozhets") + page.should have_content("bc3735004cb Moving to rails 3.2") +end diff --git a/features/step_definitions/project/project_commits_steps.rb b/features/step_definitions/project/project_commits_steps.rb new file mode 100644 index 00000000000..9b3b0aa1f81 --- /dev/null +++ b/features/step_definitions/project/project_commits_steps.rb @@ -0,0 +1,61 @@ +Given /^I visit project commits page$/ do + visit project_commits_path(@project) +end + +Then /^I see project commits$/ do + current_path.should == project_commits_path(@project) + + commit = @project.commit + page.should have_content(@project.name) + page.should have_content(commit.message) + page.should have_content(commit.id.to_s[0..5]) +end + +Given /^I click atom feed link$/ do + click_link "Feed" +end + +Then /^I see commits atom feed$/ do + commit = CommitDecorator.decorate(@project.commit) + page.response_headers['Content-Type'].should have_content("application/atom+xml") + page.body.should have_selector("title", :text => "Recent commits to #{@project.name}") + page.body.should have_selector("author email", :text => commit.author_email) + page.body.should have_selector("entry summary", :text => commit.description) +end + +Given /^I click on commit link$/ do + visit project_commit_path(@project, ValidCommit::ID) +end + +Then /^I see commit info$/ do + page.should have_content ValidCommit::MESSAGE + page.should have_content "Showing 1 changed file" +end + +Given /^I visit compare refs page$/ do + visit compare_project_commits_path(@project) +end + +Given /^I fill compare fields with refs$/ do + fill_in "from", :with => "master" + fill_in "to", :with => "stable" + click_button "Compare" +end + +Given /^I see compared refs$/ do + page.should have_content "Commits (27)" + page.should have_content "Compare View" + page.should have_content "Showing 73 changed files" +end + +Given /^I visit project branches page$/ do + visit branches_project_repository_path(@project) +end + +Given /^I visit project commit page$/ do + visit project_commit_path(@project, ValidCommit::ID) +end + +Given /^I visit project tags page$/ do + visit tags_project_repository_path(@project) +end diff --git a/features/step_definitions/project/project_issues_steps.rb b/features/step_definitions/project/project_issues_steps.rb new file mode 100644 index 00000000000..2c47f37233e --- /dev/null +++ b/features/step_definitions/project/project_issues_steps.rb @@ -0,0 +1,47 @@ +Given /^project "(.*?)" have "(.*?)" open issue$/ do |arg1, arg2| + project = Project.find_by_name(arg1) + Factory.create(:issue, :title => arg2, :project => project, :author => project.users.first) +end + +Given /^project "(.*?)" have "(.*?)" closed issue$/ do |arg1, arg2| + project = Project.find_by_name(arg1) + Factory.create(:issue, :title => arg2, :project => project, :author => project.users.first, :closed => true) +end + +Given /^I visit project "(.*?)" issues page$/ do |arg1| + visit project_issues_path(Project.find_by_name(arg1)) +end + +Given /^I should see "(.*?)" in issues$/ do |arg1| + page.should have_content arg1 +end + +Given /^I should not see "(.*?)" in issues$/ do |arg1| + page.should_not have_content arg1 +end + +Then /^I should see issue "(.*?)"$/ do |arg1| + issue = Issue.find_by_title(arg1) + page.should have_content issue.title + page.should have_content issue.author_name + page.should have_content issue.project.name +end + +Given /^I visit issue page "(.*?)"$/ do |arg1| + issue = Issue.find_by_title(arg1) + visit project_issue_path(issue.project, issue) +end + +Given /^I leave a comment like "(.*?)"$/ do |arg1| + fill_in "note_note", :with => arg1 + click_button "Add Comment" +end + +Then /^I should see commetn "(.*?)"$/ do |arg1| + page.should have_content(arg1) +end + +Given /^I submit new issue "(.*?)"$/ do |arg1| + fill_in "issue_title", :with => arg1 + click_button "Submit new issue" +end diff --git a/features/step_definitions/project/project_merge_requests_steps.rb b/features/step_definitions/project/project_merge_requests_steps.rb new file mode 100644 index 00000000000..6749773e2b5 --- /dev/null +++ b/features/step_definitions/project/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/features/step_definitions/project/project_team_steps.rb b/features/step_definitions/project/project_team_steps.rb new file mode 100644 index 00000000000..f0bab29a6f8 --- /dev/null +++ b/features/step_definitions/project/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/project/project_wiki_steps.rb b/features/step_definitions/project/project_wiki_steps.rb new file mode 100644 index 00000000000..10de38d9ae3 --- /dev/null +++ b/features/step_definitions/project/project_wiki_steps.rb @@ -0,0 +1,18 @@ +Given /^I visit project wiki page$/ do + visit project_wiki_path(@project, :index) +end + +Given /^I create Wiki page$/ do + fill_in "Title", :with => 'Test title' + fill_in "Content", :with => '[link test](test)' + click_on "Save" +end + +Then /^I should see newly created wiki page$/ do + page.should have_content("Test title") + page.should have_content("link test") + + click_link "link test" + + page.should have_content("Editing page") +end diff --git a/features/step_definitions/project/projects_steps.rb b/features/step_definitions/project/projects_steps.rb new file mode 100644 index 00000000000..bca1213908d --- /dev/null +++ b/features/step_definitions/project/projects_steps.rb @@ -0,0 +1,68 @@ +include LoginMacros + +Given /^I signin as a user$/ do + login_as :user +end + +When /^I visit new project page$/ do + visit new_project_path +end + +When /^fill project form with valid data$/ do + fill_in 'project_name', :with => 'NewProject' + fill_in 'project_code', :with => 'NPR' + fill_in 'project_path', :with => 'newproject' + click_button "Create project" +end + +Then /^I should see project page$/ do + current_path.should == project_path(Project.last) + page.should have_content('NewProject') +end + +Then /^I should see empty project instuctions$/ do + page.should have_content("git init") + page.should have_content("git remote") + page.should have_content(Project.last.url_to_repo) +end + +Given /^I own project "(.*?)"$/ do |arg1| + @project = Factory :project, :name => arg1 + @project.add_access(@user, :admin) +end + +Given /^I visit project "(.*?)" wall page$/ do |arg1| + project = Project.find_by_name(arg1) + visit wall_project_path(project) +end + +Then /^I should see project wall note "(.*?)"$/ do |arg1| + page.should have_content arg1 +end + +Given /^project "(.*?)" has comment "(.*?)"$/ do |arg1, arg2| + project = Project.find_by_name(arg1) + project.notes.create(:note => arg1, :author => project.users.first) +end + +Given /^I write new comment "(.*?)"$/ do |arg1| + fill_in "note_note", :with => arg1 + click_button "Add Comment" +end + +Given /^I visit project "(.*?)" network page$/ do |arg1| + project = Project.find_by_name(arg1) + visit graph_project_path(project) +end + +Given /^show me page$/ do + save_and_open_page +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 +end diff --git a/features/step_definitions/project_commits_steps.rb b/features/step_definitions/project_commits_steps.rb deleted file mode 100644 index 9b3b0aa1f81..00000000000 --- a/features/step_definitions/project_commits_steps.rb +++ /dev/null @@ -1,61 +0,0 @@ -Given /^I visit project commits page$/ do - visit project_commits_path(@project) -end - -Then /^I see project commits$/ do - current_path.should == project_commits_path(@project) - - commit = @project.commit - page.should have_content(@project.name) - page.should have_content(commit.message) - page.should have_content(commit.id.to_s[0..5]) -end - -Given /^I click atom feed link$/ do - click_link "Feed" -end - -Then /^I see commits atom feed$/ do - commit = CommitDecorator.decorate(@project.commit) - page.response_headers['Content-Type'].should have_content("application/atom+xml") - page.body.should have_selector("title", :text => "Recent commits to #{@project.name}") - page.body.should have_selector("author email", :text => commit.author_email) - page.body.should have_selector("entry summary", :text => commit.description) -end - -Given /^I click on commit link$/ do - visit project_commit_path(@project, ValidCommit::ID) -end - -Then /^I see commit info$/ do - page.should have_content ValidCommit::MESSAGE - page.should have_content "Showing 1 changed file" -end - -Given /^I visit compare refs page$/ do - visit compare_project_commits_path(@project) -end - -Given /^I fill compare fields with refs$/ do - fill_in "from", :with => "master" - fill_in "to", :with => "stable" - click_button "Compare" -end - -Given /^I see compared refs$/ do - page.should have_content "Commits (27)" - page.should have_content "Compare View" - page.should have_content "Showing 73 changed files" -end - -Given /^I visit project branches page$/ do - visit branches_project_repository_path(@project) -end - -Given /^I visit project commit page$/ do - visit project_commit_path(@project, ValidCommit::ID) -end - -Given /^I visit project tags page$/ do - visit tags_project_repository_path(@project) -end diff --git a/features/step_definitions/project_issues_steps.rb b/features/step_definitions/project_issues_steps.rb deleted file mode 100644 index e83c0e7f399..00000000000 --- a/features/step_definitions/project_issues_steps.rb +++ /dev/null @@ -1,22 +0,0 @@ -Given /^project "(.*?)" have "(.*?)" open issue$/ do |arg1, arg2| - project = Project.find_by_name(arg1) - Factory.create(:issue, :title => arg2, :project => project, :author => project.users.first) -end - -Given /^project "(.*?)" have "(.*?)" closed issue$/ do |arg1, arg2| - project = Project.find_by_name(arg1) - Factory.create(:issue, :title => arg2, :project => project, :author => project.users.first, :closed => true) -end - -Given /^I visit project "(.*?)" issues page$/ do |arg1| - visit project_issues_path(Project.find_by_name(arg1)) -end - -Given /^I should see "(.*?)" open issue$/ do |arg1| - page.should have_content arg1 -end - -Given /^I should not see "(.*?)" closed issue$/ do |arg1| - page.should_not have_content arg1 -end - diff --git a/features/step_definitions/project_merge_requests_steps.rb b/features/step_definitions/project_merge_requests_steps.rb deleted file mode 100644 index 6749773e2b5..00000000000 --- a/features/step_definitions/project_merge_requests_steps.rb +++ /dev/null @@ -1,38 +0,0 @@ -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/features/step_definitions/project_team_steps.rb b/features/step_definitions/project_team_steps.rb deleted file mode 100644 index f0bab29a6f8..00000000000 --- a/features/step_definitions/project_team_steps.rb +++ /dev/null @@ -1,63 +0,0 @@ -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/project_wiki_steps.rb b/features/step_definitions/project_wiki_steps.rb deleted file mode 100644 index 10de38d9ae3..00000000000 --- a/features/step_definitions/project_wiki_steps.rb +++ /dev/null @@ -1,18 +0,0 @@ -Given /^I visit project wiki page$/ do - visit project_wiki_path(@project, :index) -end - -Given /^I create Wiki page$/ do - fill_in "Title", :with => 'Test title' - fill_in "Content", :with => '[link test](test)' - click_on "Save" -end - -Then /^I should see newly created wiki page$/ do - page.should have_content("Test title") - page.should have_content("link test") - - click_link "link test" - - page.should have_content("Editing page") -end diff --git a/features/step_definitions/projects_steps.rb b/features/step_definitions/projects_steps.rb deleted file mode 100644 index bca1213908d..00000000000 --- a/features/step_definitions/projects_steps.rb +++ /dev/null @@ -1,68 +0,0 @@ -include LoginMacros - -Given /^I signin as a user$/ do - login_as :user -end - -When /^I visit new project page$/ do - visit new_project_path -end - -When /^fill project form with valid data$/ do - fill_in 'project_name', :with => 'NewProject' - fill_in 'project_code', :with => 'NPR' - fill_in 'project_path', :with => 'newproject' - click_button "Create project" -end - -Then /^I should see project page$/ do - current_path.should == project_path(Project.last) - page.should have_content('NewProject') -end - -Then /^I should see empty project instuctions$/ do - page.should have_content("git init") - page.should have_content("git remote") - page.should have_content(Project.last.url_to_repo) -end - -Given /^I own project "(.*?)"$/ do |arg1| - @project = Factory :project, :name => arg1 - @project.add_access(@user, :admin) -end - -Given /^I visit project "(.*?)" wall page$/ do |arg1| - project = Project.find_by_name(arg1) - visit wall_project_path(project) -end - -Then /^I should see project wall note "(.*?)"$/ do |arg1| - page.should have_content arg1 -end - -Given /^project "(.*?)" has comment "(.*?)"$/ do |arg1, arg2| - project = Project.find_by_name(arg1) - project.notes.create(:note => arg1, :author => project.users.first) -end - -Given /^I write new comment "(.*?)"$/ do |arg1| - fill_in "note_note", :with => arg1 - click_button "Add Comment" -end - -Given /^I visit project "(.*?)" network page$/ do |arg1| - project = Project.find_by_name(arg1) - visit graph_project_path(project) -end - -Given /^show me page$/ do - save_and_open_page -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 -end diff --git a/spec/requests/atom/issues_spec.rb b/spec/requests/atom/issues_spec.rb new file mode 100644 index 00000000000..8d0b6c4f3fd --- /dev/null +++ b/spec/requests/atom/issues_spec.rb @@ -0,0 +1,40 @@ +require 'spec_helper' + +describe "Issues" do + let(:project) { Factory :project } + + before do + login_as :user + project.add_access(@user, :read, :write) + end + + describe "GET /issues" do + before do + @issue = Factory :issue, + :author => @user, + :assignee => @user, + :project => project + + visit project_issues_path(project) + end + + it "should render atom feed" do + visit project_issues_path(project, :atom) + + page.response_headers['Content-Type'].should have_content("application/atom+xml") + page.body.should have_selector("title", :text => "#{project.name} issues") + page.body.should have_selector("author email", :text => @issue.author_email) + page.body.should have_selector("entry summary", :text => @issue.title) + end + + it "should render atom feed via private token" do + logout + visit project_issues_path(project, :atom, :private_token => @user.private_token) + + page.response_headers['Content-Type'].should have_content("application/atom+xml") + page.body.should have_selector("title", :text => "#{project.name} issues") + page.body.should have_selector("author email", :text => @issue.author_email) + page.body.should have_selector("entry summary", :text => @issue.title) + end + end +end diff --git a/spec/requests/issues_notes_spec.rb b/spec/requests/issues_notes_spec.rb deleted file mode 100644 index 538098e60bd..00000000000 --- a/spec/requests/issues_notes_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'spec_helper' - -describe "Issues" do - let(:project) { Factory :project } - - before do - login_as :user - project.add_access(@user, :read, :write) - - @issue = Factory :issue, - :author => @user, - :assignee => @user, - :project => project - end - - describe "add new note", :js => true do - before do - visit project_issue_path(project, @issue) - fill_in "note_note", :with => "I commented this issue" - click_button "Add Comment" - end - - it "should conatin new note" do - page.should have_content("I commented this issue") - end - end -end diff --git a/spec/requests/issues_spec.rb b/spec/requests/issues_spec.rb index 2c8650a8402..ad7b0432f42 100644 --- a/spec/requests/issues_spec.rb +++ b/spec/requests/issues_spec.rb @@ -11,161 +11,6 @@ describe "Issues" do project.add_access(@user2, :read, :write) end - describe "GET /issues" do - before do - @issue = Factory :issue, - :author => @user, - :assignee => @user, - :project => project - - visit project_issues_path(project) - end - - subject { page } - - it { should have_content(@issue.title[0..20]) } - it { should have_content(@issue.project.name) } - it { should have_content(@issue.assignee.name) } - - it "should render atom feed" do - visit project_issues_path(project, :atom) - - page.response_headers['Content-Type'].should have_content("application/atom+xml") - page.body.should have_selector("title", :text => "#{project.name} issues") - page.body.should have_selector("author email", :text => @issue.author_email) - page.body.should have_selector("entry summary", :text => @issue.title) - end - - it "should render atom feed via private token" do - logout - visit project_issues_path(project, :atom, :private_token => @user.private_token) - - page.response_headers['Content-Type'].should have_content("application/atom+xml") - page.body.should have_selector("title", :text => "#{project.name} issues") - page.body.should have_selector("author email", :text => @issue.author_email) - page.body.should have_selector("entry summary", :text => @issue.title) - end - - describe "statuses" do - before do - @closed_issue = Factory :issue, - :author => @user, - :assignee => @user, - :project => project, - :closed => true - end - - it "should show only open" do - should have_content(@issue.title[0..25]) - should have_no_content(@closed_issue.title) - end - - it "should show only closed" do - click_link "Closed" - should have_no_content(@issue.title) - should have_content(@closed_issue.title[0..25]) - end - - it "should show all" do - click_link "All" - should have_content(@issue.title[0..25]) - should have_content(@closed_issue.title[0..25]) - end - end - end - - describe "New issue", :js => true do - before do - visit project_issues_path(project) - click_link "New Issue" - end - - it "should open new issue form" do - page.should have_content("New Issue") - end - - describe "fill in" do - describe 'assign to me' do - before do - fill_in "issue_title", :with => "bug 345" - page.execute_script("$('#issue_assignee_id').show();") - select @user.name, :from => "issue_assignee_id" - end - - it { expect { click_button "Submit new issue" }.to change {Issue.count}.by(1) } - - it "should add new issue to table" do - click_button "Submit new issue" - - page.should_not have_content("Add new issue") - page.should have_content @user.name - page.should have_content "bug 345" - page.should have_content project.name - end - - it "should call send mail" do - Notify.should_not_receive(:new_issue_email) - click_button "Submit new issue" - end - end - - describe 'assign to other' do - before do - fill_in "issue_title", :with => "bug 345" - page.execute_script("$('#issue_assignee_id').show();") - select @user2.name, :from => "issue_assignee_id" - end - - it { expect { click_button "Submit new issue" }.to change {Issue.count}.by(1) } - - it "should add new issue to table" do - click_button "Submit new issue" - - page.should_not have_content("Add new issue") - page.should have_content @user2.name - page.should have_content "bug 345" - page.should have_content project.name - end - - it "should call send mail" do - Issue.observers.enable :issue_observer do - Notify.should_receive(:new_issue_email).and_return(stub(:deliver => true)) - click_button "Submit new issue" - end - end - - it "should send valid email to user" do - Issue.observers.enable :issue_observer do - with_resque do - click_button "Submit new issue" - end - issue = Issue.last - email = ActionMailer::Base.deliveries.last - email.subject.should have_content("New Issue was created") - email.body.should have_content(issue.title) - end - end - - end - end - end - - describe "Show issue" do - before do - @issue = Factory :issue, - :author => @user, - :assignee => @user, - :project => project - - visit project_issue_path(project, @issue) - end - - it "should have valid show page for issue" do - page.should have_content @issue.title - page.should have_content @user.name - end - end - describe "Edit issue", :js => true do before do @issue = Factory :issue, -- cgit v1.2.1 From 9844ddd43f20e84754759688fea39e1a0241bb06 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 3 Aug 2012 19:59:55 +0300 Subject: Comments cucumber. More refactoring. Cucumber -> branches, tags --- features/projects/commits/branches.feature | 12 +- features/projects/commits/commit_comments.feature | 5 +- features/projects/commits/tags.feature | 3 +- features/projects/issues/issues.feature | 2 +- features/projects/project.feature | 11 ++ features/projects/wiki.feature | 6 + .../project/project_commits_steps.rb | 27 +++ .../project/project_issues_steps.rb | 9 - .../step_definitions/project/projects_steps.rb | 14 ++ spec/monkeypatch.rb | 6 +- spec/requests/access_spec.rb | 187 --------------------- spec/requests/commits_notes_spec.rb | 28 --- spec/requests/repositories_spec.rb | 49 ------ spec/requests/security/profile_access_spec.rb | 34 ++++ spec/requests/security/project_access_spec.rb | 187 +++++++++++++++++++++ spec/requests/team_members_spec.rb | 68 -------- spec/requests/user_security_spec.rb | 37 ---- spec/requests/wikis_notes_spec.rb | 29 ---- 18 files changed, 301 insertions(+), 413 deletions(-) create mode 100644 features/projects/project.feature delete mode 100644 spec/requests/access_spec.rb delete mode 100644 spec/requests/commits_notes_spec.rb delete mode 100644 spec/requests/repositories_spec.rb create mode 100644 spec/requests/security/profile_access_spec.rb create mode 100644 spec/requests/security/project_access_spec.rb delete mode 100644 spec/requests/team_members_spec.rb delete mode 100644 spec/requests/user_security_spec.rb delete mode 100644 spec/requests/wikis_notes_spec.rb diff --git a/features/projects/commits/branches.feature b/features/projects/commits/branches.feature index 2b136e1b582..74575c51c5a 100644 --- a/features/projects/commits/branches.feature +++ b/features/projects/commits/branches.feature @@ -2,9 +2,19 @@ Feature: Browse branches Background: Given I signin as a user And I own project "Shop" + And project "Shop" has protected branches Given I visit project branches page - Scenario: I can see all git branches + Scenario: I can see project recent git branches + Then I should see "Shop" recent branches list + + Scenario: I can see project all git branches + Given I click link "All" + Then I should see "Shop" all branches list + + Scenario: I can see project protected git branches + Given I click link "Protected" + Then I should see "Shop" protected branches list Scenario: I can download project by branch diff --git a/features/projects/commits/commit_comments.feature b/features/projects/commits/commit_comments.feature index bdf47b88fc3..9bd56d29f1e 100644 --- a/features/projects/commits/commit_comments.feature +++ b/features/projects/commits/commit_comments.feature @@ -4,4 +4,7 @@ Feature: Comment commit And I own project "Shop" Given I visit project commit page - Scenario: I leave a comment for commit + @javascript + Scenario: I comment commit + Given I leave a comment like "XML attached" + Then I should see comment "XML attached" diff --git a/features/projects/commits/tags.feature b/features/projects/commits/tags.feature index 81221748500..f7899fc3ce0 100644 --- a/features/projects/commits/tags.feature +++ b/features/projects/commits/tags.feature @@ -5,7 +5,6 @@ Feature: Browse tags Given I visit project tags page Scenario: I can see all git tags + Then I should see "Shop" all tags list Scenario: I can download project by tag - - diff --git a/features/projects/issues/issues.feature b/features/projects/issues/issues.feature index a45dd801696..180710cf6bc 100644 --- a/features/projects/issues/issues.feature +++ b/features/projects/issues/issues.feature @@ -35,4 +35,4 @@ Feature: Issues Scenario: I comment issue Given I visit issue page "Release 0.4" And I leave a comment like "XML attached" - Then I should see commetn "XML attached" + Then I should see comment "XML attached" diff --git a/features/projects/project.feature b/features/projects/project.feature new file mode 100644 index 00000000000..895a928ff81 --- /dev/null +++ b/features/projects/project.feature @@ -0,0 +1,11 @@ +Feature: Project + Background: + Given I signin as a user + And I own project "Shop" + And I visit project "Shop" page + + Scenario: I should see project activity + + Scenario: I edit project + + Scenario: I visit attachments diff --git a/features/projects/wiki.feature b/features/projects/wiki.feature index ed69e87c91a..4441ada2847 100644 --- a/features/projects/wiki.feature +++ b/features/projects/wiki.feature @@ -7,3 +7,9 @@ Feature: Wiki Scenario: Add new page Given I create Wiki page Then I should see newly created wiki page + + @javascript + Scenario: I comment wiki page + Given I create Wiki page + And I leave a comment like "XML attached" + Then I should see comment "XML attached" diff --git a/features/step_definitions/project/project_commits_steps.rb b/features/step_definitions/project/project_commits_steps.rb index 9b3b0aa1f81..35fcb4d11ab 100644 --- a/features/step_definitions/project/project_commits_steps.rb +++ b/features/step_definitions/project/project_commits_steps.rb @@ -59,3 +59,30 @@ end Given /^I visit project tags page$/ do visit tags_project_repository_path(@project) end + +Then /^I should see "(.*?)" recent branches list$/ do |arg1| + page.should have_content("Branches") + page.should have_content("master") +end + +Then /^I should see "(.*?)" all branches list$/ do |arg1| + page.should have_content("Branches") + page.should have_content("master") +end + +Then /^I should see "(.*?)" all tags list$/ do |arg1| + page.should have_content("Tags") + page.should have_content("v1.2.1") +end + +Then /^I should see "(.*?)" protected branches list$/ do |arg1| + within "table" do + page.should have_content "stable" + page.should_not have_content "master" + end +end + +Given /^project "(.*?)" has protected branches$/ do |arg1| + project = Project.find_by_name(arg1) + project.protected_branches.create(:name => "stable") +end diff --git a/features/step_definitions/project/project_issues_steps.rb b/features/step_definitions/project/project_issues_steps.rb index 2c47f37233e..00a1721f8de 100644 --- a/features/step_definitions/project/project_issues_steps.rb +++ b/features/step_definitions/project/project_issues_steps.rb @@ -32,15 +32,6 @@ Given /^I visit issue page "(.*?)"$/ do |arg1| visit project_issue_path(issue.project, issue) end -Given /^I leave a comment like "(.*?)"$/ do |arg1| - fill_in "note_note", :with => arg1 - click_button "Add Comment" -end - -Then /^I should see commetn "(.*?)"$/ do |arg1| - page.should have_content(arg1) -end - Given /^I submit new issue "(.*?)"$/ do |arg1| fill_in "issue_title", :with => arg1 click_button "Submit new issue" diff --git a/features/step_definitions/project/projects_steps.rb b/features/step_definitions/project/projects_steps.rb index bca1213908d..c9af346e7cf 100644 --- a/features/step_definitions/project/projects_steps.rb +++ b/features/step_definitions/project/projects_steps.rb @@ -50,6 +50,11 @@ Given /^I write new comment "(.*?)"$/ do |arg1| click_button "Add Comment" end +Given /^I visit project "(.*?)" page$/ do |arg1| + project = Project.find_by_name(arg1) + visit project_path(project) +end + Given /^I visit project "(.*?)" network page$/ do |arg1| project = Project.find_by_name(arg1) visit graph_project_path(project) @@ -66,3 +71,12 @@ Given /^page should have network graph$/ do page.should have_content "notes_refacto..." end end + +Given /^I leave a comment like "(.*?)"$/ do |arg1| + fill_in "note_note", :with => arg1 + click_button "Add Comment" +end + +Then /^I should see comment "(.*?)"$/ do |arg1| + page.should have_content(arg1) +end diff --git a/spec/monkeypatch.rb b/spec/monkeypatch.rb index 6133631c5de..93dda0174c6 100644 --- a/spec/monkeypatch.rb +++ b/spec/monkeypatch.rb @@ -44,4 +44,8 @@ class FakeSatellite end end - +class ProtectedBranch + def update_repository + true + end +end diff --git a/spec/requests/access_spec.rb b/spec/requests/access_spec.rb deleted file mode 100644 index bcca42f5298..00000000000 --- a/spec/requests/access_spec.rb +++ /dev/null @@ -1,187 +0,0 @@ -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/commits_notes_spec.rb b/spec/requests/commits_notes_spec.rb deleted file mode 100644 index fde42a8f55e..00000000000 --- a/spec/requests/commits_notes_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'spec_helper' - -describe "Issues" do - let(:project) { Factory :project } - let!(:commit) { project.repo.commits.first } - - before do - login_as :user - project.add_access(@user, :read, :write) - end - - describe "add new note", :js => true do - before do - visit project_commit_path(project, commit) - fill_in "note_note", :with => "I commented this commit" - click_button "Add Comment" - end - - it "should conatin new note" do - page.should have_content("I commented this commit") - end - - it "should be displayed when i visit this commit again" do - visit project_commit_path(project, commit) - page.should have_content("I commented this commit") - end - end -end diff --git a/spec/requests/repositories_spec.rb b/spec/requests/repositories_spec.rb deleted file mode 100644 index 1bf4c8d24b7..00000000000 --- a/spec/requests/repositories_spec.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'spec_helper' - -describe "Repository" do - - before do - @user = Factory :user - @project = Factory :project - @project.add_access(@user, :read, :write) - login_with @user - end - - describe "GET /:project_name/repository" do - before do - visit project_repository_path(@project) - end - - it "should be on projects page" do - current_path.should == project_repository_path(@project) - end - - it "should have link to last commit for activities tab" do - page.should have_content(@project.commit.safe_message[0..20]) - end - end - - describe "GET /:project_name/repository/branches" do - before do - visit branches_project_repository_path(@project) - end - - it "should have link to repo activities" do - page.should have_content("Branches") - page.should have_content("master") - end - end - - # TODO: Add new repo to seeds with tags list - describe "GET /:project_name/repository/tags" do - before do - visit tags_project_repository_path(@project) - end - - it "should have link to repo activities" do - page.should have_content("Tags") - page.should have_content("v1.2.1") - end - end -end - diff --git a/spec/requests/security/profile_access_spec.rb b/spec/requests/security/profile_access_spec.rb new file mode 100644 index 00000000000..b8ed27f031c --- /dev/null +++ b/spec/requests/security/profile_access_spec.rb @@ -0,0 +1,34 @@ +require 'spec_helper' + +describe "Users Security" do + describe "Project" do + before do + @u1 = Factory :user + end + + describe "GET /login" do + it { new_user_session_path.should_not be_404_for :visitor } + end + + describe "GET /keys" do + it { keys_path.should be_allowed_for @u1 } + it { keys_path.should be_allowed_for :admin } + it { keys_path.should be_allowed_for :user } + it { keys_path.should be_denied_for :visitor } + end + + describe "GET /profile" do + it { profile_path.should be_allowed_for @u1 } + it { profile_path.should be_allowed_for :admin } + it { profile_path.should be_allowed_for :user } + it { profile_path.should be_denied_for :visitor } + end + + describe "GET /profile/password" do + it { profile_password_path.should be_allowed_for @u1 } + it { profile_password_path.should be_allowed_for :admin } + it { profile_password_path.should be_allowed_for :user } + it { profile_password_path.should be_denied_for :visitor } + end + end +end diff --git a/spec/requests/security/project_access_spec.rb b/spec/requests/security/project_access_spec.rb new file mode 100644 index 00000000000..bcca42f5298 --- /dev/null +++ b/spec/requests/security/project_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/team_members_spec.rb b/spec/requests/team_members_spec.rb deleted file mode 100644 index 34e34f59bdb..00000000000 --- a/spec/requests/team_members_spec.rb +++ /dev/null @@ -1,68 +0,0 @@ -require 'spec_helper' - -describe "TeamMembers" do - before do - login_as :user - @project = Factory :project - @project.add_access(@user, :read, :admin) - end - - describe "Update profile", :js => true do - it "should update user role" do - @project.master_access_for?(@user).should be_true - visit team_project_path(@project) - select "Developer", :from => "team_member_project_access" - @project.master_access_for?(@user).should be_false - @project.dev_access_for?(@user).should be_true - end - end - - describe "View profile" do - it "should be available" do - visit(team_project_path(@project)) - click_link(@user.name) - page.should have_content @user.skype - page.should_not have_content 'Twitter' - end - end - - describe "New Team member" do - before do - @user_1 = Factory :user - visit team_project_path(@project) - click_link "New Team Member" - end - - it "should open new team member popup" do - page.should have_content("New Team member") - end - - describe "fill in" do - before do - within "#new_team_member" do - select @user_1.name, :from => "team_member_user_id" - select "Reporter", :from => "team_member_project_access" - end - end - - it { expect { click_button "Save";sleep(1) }.to change {UsersProject.count}.by(1) } - - it "should add new member to table" do - click_button "Save" - @member = UsersProject.last - - page.should have_content @user_1.name - - @member.reload - @member.project_access.should == UsersProject::REPORTER - end - end - end - - describe "Cancel membership" do - it "should cancel membership" do - visit project_team_member_path(@project, @project.users_projects.last) - expect { click_link "Remove from team" }.to change { UsersProject.count }.by(-1) - end - end -end diff --git a/spec/requests/user_security_spec.rb b/spec/requests/user_security_spec.rb deleted file mode 100644 index b75a1779a8a..00000000000 --- a/spec/requests/user_security_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'spec_helper' - -describe "Users Security" do - describe "Project" do - before do - @u1 = Factory :user - end - - describe "GET /login" do - #it { new_user_session_path.should be_denied_for @u1 } - #it { new_user_session_path.should be_denied_for :admin } - #it { new_user_session_path.should be_denied_for :user } - it { new_user_session_path.should_not be_404_for :visitor } - end - - describe "GET /keys" do - it { keys_path.should be_allowed_for @u1 } - it { keys_path.should be_allowed_for :admin } - it { keys_path.should be_allowed_for :user } - it { keys_path.should be_denied_for :visitor } - end - - describe "GET /profile" do - it { profile_path.should be_allowed_for @u1 } - it { profile_path.should be_allowed_for :admin } - it { profile_path.should be_allowed_for :user } - it { profile_path.should be_denied_for :visitor } - end - - describe "GET /profile/password" do - it { profile_password_path.should be_allowed_for @u1 } - it { profile_password_path.should be_allowed_for :admin } - it { profile_password_path.should be_allowed_for :user } - it { profile_password_path.should be_denied_for :visitor } - end - end -end diff --git a/spec/requests/wikis_notes_spec.rb b/spec/requests/wikis_notes_spec.rb deleted file mode 100644 index 144d0318bea..00000000000 --- a/spec/requests/wikis_notes_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'spec_helper' - -describe "Wikis" do - let(:project) { Factory :project } - - before do - login_as :user - project.add_access(@user, :read, :write) - end - - describe "add new note", :js => true do - before do - visit project_wiki_path(project, :index) - - fill_in "Title", :with => 'Test title' - fill_in "Content", :with => '[link test](test)' - click_on "Save" - - page.should have_content("Test title") - - fill_in "note_note", :with => "Comment on wiki!" - click_button "Add Comment" - end - - it "should contain the new note" do - page.should have_content("Comment on wiki!") - end - end -end -- cgit v1.2.1