summaryrefslogtreecommitdiff
path: root/spec/features
diff options
context:
space:
mode:
Diffstat (limited to 'spec/features')
-rw-r--r--spec/features/gitlab_flavored_markdown_spec.rb2
-rw-r--r--spec/features/issues_spec.rb165
-rw-r--r--spec/features/notes_on_merge_requests_spec.rb34
-rw-r--r--spec/features/profile_spec.rb6
-rw-r--r--spec/features/security/profile_access_spec.rb2
-rw-r--r--spec/features/security/project/internal_access_spec.rb251
-rw-r--r--spec/features/security/project/private_access_spec.rb8
-rw-r--r--spec/features/security/project/public_access_spec.rb4
8 files changed, 439 insertions, 33 deletions
diff --git a/spec/features/gitlab_flavored_markdown_spec.rb b/spec/features/gitlab_flavored_markdown_spec.rb
index 2ea569a6208..a507f0314c6 100644
--- a/spec/features/gitlab_flavored_markdown_spec.rb
+++ b/spec/features/gitlab_flavored_markdown_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
describe "GitLab Flavored Markdown" do
- let(:project) { create(:project_with_code) }
+ let(:project) { create(:project) }
let(:issue) { create(:issue, project: project) }
let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let(:fred) do
diff --git a/spec/features/issues_spec.rb b/spec/features/issues_spec.rb
index 0c09279e3dc..1d225e8bad0 100644
--- a/spec/features/issues_spec.rb
+++ b/spec/features/issues_spec.rb
@@ -24,7 +24,7 @@ describe "Issues" do
end
it "should open new issue popup" do
- page.should have_content("Issue ##{issue.id}")
+ page.should have_content("Issue ##{issue.iid}")
end
describe "fill in" do
@@ -95,4 +95,167 @@ describe "Issues" do
page.should have_content 'gitlab'
end
end
+
+ describe 'filter issue' do
+ titles = ['foo','bar','baz']
+ titles.each_with_index do |title, index|
+ let!(title.to_sym) { create(:issue, title: title, project: project, created_at: Time.now - (index * 60)) }
+ end
+ let(:newer_due_milestone) { create(:milestone, due_date: '2013-12-11') }
+ let(:later_due_milestone) { create(:milestone, due_date: '2013-12-12') }
+
+ it 'sorts by newest' do
+ visit project_issues_path(project, sort: 'newest')
+
+ first_issue.should include("foo")
+ last_issue.should include("baz")
+ end
+
+ it 'sorts by oldest' do
+ visit project_issues_path(project, sort: 'oldest')
+
+ first_issue.should include("baz")
+ last_issue.should include("foo")
+ end
+
+ it 'sorts by most recently updated' do
+ baz.updated_at = Time.now + 100
+ baz.save
+ visit project_issues_path(project, sort: 'recently_updated')
+
+ first_issue.should include("baz")
+ end
+
+ it 'sorts by least recently updated' do
+ baz.updated_at = Time.now - 100
+ baz.save
+ visit project_issues_path(project, sort: 'last_updated')
+
+ first_issue.should include("baz")
+ end
+
+ describe 'sorting by milestone' do
+ before :each do
+ foo.milestone = newer_due_milestone
+ foo.save
+ bar.milestone = later_due_milestone
+ bar.save
+ end
+
+ it 'sorts by recently due milestone' do
+ visit project_issues_path(project, sort: 'milestone_due_soon')
+
+ first_issue.should include("foo")
+ end
+
+ it 'sorts by least recently due milestone' do
+ visit project_issues_path(project, sort: 'milestone_due_later')
+
+ first_issue.should include("bar")
+ end
+ end
+
+ describe 'combine filter and sort' do
+ let(:user2) { create(:user) }
+
+ before :each do
+ foo.assignee = user2
+ foo.save
+ bar.assignee = user2
+ bar.save
+ end
+
+ it 'sorts with a filter applied' do
+ visit project_issues_path(project, sort: 'oldest', assignee_id: user2.id)
+
+ first_issue.should include("bar")
+ last_issue.should include("foo")
+ page.should_not have_content 'baz'
+ end
+ end
+ end
+
+ describe 'update assignee from issue#show' do
+ let(:issue) { create(:issue, project: project, author: @user) }
+
+ context 'by autorized user' do
+
+ it 'with dropdown menu' do
+ visit project_issue_path(project, issue)
+
+ find('.edit-issue.inline-update').select(project.team.members.first.name, from: 'issue_assignee_id')
+ click_button 'Update Issue'
+
+ page.should have_content "currently assigned to"
+ page.has_select?('issue_assignee_id', :selected => project.team.members.first.name)
+ end
+ end
+
+ context 'by unauthorized user' do
+
+ let(:guest) { create(:user) }
+
+ before :each do
+ project.team << [[guest], :guest]
+ issue.assignee = @user
+ issue.save
+ end
+
+ it 'shows assignee text' do
+ logout
+ login_with guest
+
+ visit project_issue_path(project, issue)
+ page.should have_content "currently assigned to #{issue.assignee.name}"
+
+ end
+ end
+
+ end
+
+ describe 'update milestone from issue#show' do
+ let!(:issue) { create(:issue, project: project, author: @user) }
+ let!(:milestone) { create(:milestone, project: project) }
+
+ context 'by authorized user' do
+
+ it 'with dropdown menu' do
+ visit project_issue_path(project, issue)
+
+ find('.edit-issue.inline-update').select(milestone.title, from: 'issue_milestone_id')
+ click_button 'Update Issue'
+
+ page.should have_content "Attached to milestone"
+ page.has_select?('issue_assignee_id', :selected => milestone.title)
+ end
+ end
+
+ context 'by unauthorized user' do
+
+ let(:guest) { create(:user) }
+
+ before :each do
+ project.team << [[guest], :guest]
+ issue.milestone = milestone
+ issue.save
+ end
+
+ it 'shows milestone text' do
+ logout
+ login_with guest
+
+ visit project_issue_path(project, issue)
+
+ page.should have_content "Attached to milestone #{milestone.title}"
+ end
+ end
+ end
+
+ def first_issue
+ all("ul.issues-list li").first.text
+ end
+
+ def last_issue
+ all("ul.issues-list li").last.text
+ end
end
diff --git a/spec/features/notes_on_merge_requests_spec.rb b/spec/features/notes_on_merge_requests_spec.rb
index ba580d9484d..da723ae39bd 100644
--- a/spec/features/notes_on_merge_requests_spec.rb
+++ b/spec/features/notes_on_merge_requests_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
describe "On a merge request", js: true do
- let!(:project) { create(:project_with_code) }
+ let!(:project) { create(:project) }
let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let!(:note) { create(:note_on_merge_request_with_attachment, project: project) }
@@ -108,7 +108,7 @@ describe "On a merge request", js: true do
within("#note_#{note.id}") do
should have_css(".note-last-update small")
- find(".note-last-update small").text.should match(/Edited just now/)
+ find(".note-last-update small").text.should match(/Edited less than a minute ago/)
end
end
end
@@ -135,7 +135,7 @@ describe "On a merge request", js: true do
end
describe "On a merge request diff", js: true, focus: true do
- let!(:project) { create(:source_project_with_code) }
+ let!(:project) { create(:project) }
let!(:merge_request) { create(:merge_request_with_diffs, source_project: project, target_project: project) }
before do
@@ -149,7 +149,7 @@ describe "On a merge request diff", js: true, focus: true do
describe "when adding a note" do
before do
- find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185"]').click
+ find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_172_185"]').click
end
describe "the notes holder" do
@@ -159,22 +159,14 @@ describe "On a merge request diff", js: true, focus: true do
end
describe "the note form" do
- it 'should be valid' do
- within(".js-temp-notes-holder") { find("#note_noteable_type").value.should == "MergeRequest" }
- within(".js-temp-notes-holder") { find("#note_noteable_id").value.should == merge_request.id.to_s }
- within(".js-temp-notes-holder") { find("#note_commit_id").value.should == "" }
- within(".js-temp-notes-holder") { find("#note_line_code").value.should == "4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185" }
- should have_css(".js-close-discussion-note-form", text: "Cancel")
- end
-
it "shouldn't add a second form for same row" do
- find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185"]').click
+ find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_172_185"]').click
- should have_css("tr[id='4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185'] + .js-temp-notes-holder form", count: 1)
+ should have_css("tr[id='4735dfc552ad7bf15ca468adc3cad9d05b624490_172_185'] + .js-temp-notes-holder form", count: 1)
end
it "should be removed when canceled" do
- within(".file form[rel$='4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185']") do
+ within(".file form[rel$='4735dfc552ad7bf15ca468adc3cad9d05b624490_172_185']") do
find(".js-close-discussion-note-form").trigger("click")
end
@@ -184,11 +176,11 @@ describe "On a merge request diff", js: true, focus: true do
end
describe "with muliple note forms" do
- let!(:project) { create(:source_project_with_code) }
+ let!(:project) { create(:project) }
let!(:merge_request) { create(:merge_request_with_diffs, source_project: project, target_project: project) }
before do
- find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185"]').click
+ find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_172_185"]').click
find('a[data-line-code="342e16cbbd482ac2047dc679b2749d248cc1428f_18_17"]').click
end
@@ -197,7 +189,7 @@ describe "On a merge request diff", js: true, focus: true do
describe "previewing them separately" do
before do
# add two separate texts and trigger previews on both
- within("tr[id='4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185'] + .js-temp-notes-holder") do
+ within("tr[id='4735dfc552ad7bf15ca468adc3cad9d05b624490_172_185'] + .js-temp-notes-holder") do
fill_in "note[note]", with: "One comment on line 185"
find(".js-note-preview-button").trigger("click")
end
@@ -216,12 +208,6 @@ describe "On a merge request diff", js: true, focus: true do
end
end
- it do
- within("tr[id='342e16cbbd482ac2047dc679b2749d248cc1428f_18_17'] + .js-temp-notes-holder") do
- should have_no_css(".js-temp-notes-holder")
- end
- end
-
it 'should be added as discussion' do
should have_content("Another comment on line 17")
should have_css(".notes_holder")
diff --git a/spec/features/profile_spec.rb b/spec/features/profile_spec.rb
index 80c9f5d7f14..b67ce3c67f1 100644
--- a/spec/features/profile_spec.rb
+++ b/spec/features/profile_spec.rb
@@ -12,7 +12,7 @@ describe "Profile account page" do
describe "when signup is enabled" do
before do
Gitlab.config.gitlab.stub(:signup_enabled).and_return(true)
- visit account_profile_path
+ visit profile_account_path
end
it { page.should have_content("Remove account") }
@@ -26,12 +26,12 @@ describe "Profile account page" do
describe "when signup is disabled" do
before do
Gitlab.config.gitlab.stub(:signup_enabled).and_return(false)
- visit account_profile_path
+ visit profile_account_path
end
it "should not have option to remove account" do
page.should_not have_content("Remove account")
- current_path.should == account_profile_path
+ current_path.should == profile_account_path
end
end
end
diff --git a/spec/features/security/profile_access_spec.rb b/spec/features/security/profile_access_spec.rb
index 7754b28347a..078c257538f 100644
--- a/spec/features/security/profile_access_spec.rb
+++ b/spec/features/security/profile_access_spec.rb
@@ -29,7 +29,7 @@ describe "Users Security" do
end
describe "GET /profile/account" do
- subject { account_profile_path }
+ subject { profile_account_path }
it { should be_allowed_for @u1 }
it { should be_allowed_for :admin }
diff --git a/spec/features/security/project/internal_access_spec.rb b/spec/features/security/project/internal_access_spec.rb
new file mode 100644
index 00000000000..8bb1e259efa
--- /dev/null
+++ b/spec/features/security/project/internal_access_spec.rb
@@ -0,0 +1,251 @@
+require 'spec_helper'
+
+describe "Internal Project Access" do
+ let(:project) { create(:project) }
+
+ let(:master) { create(:user) }
+ let(:guest) { create(:user) }
+ let(:reporter) { create(:user) }
+
+ before do
+ # internal project
+ project.visibility_level = Gitlab::VisibilityLevel::INTERNAL
+ project.save!
+
+ # full access
+ project.team << [master, :master]
+
+ # readonly
+ project.team << [reporter, :reporter]
+
+ end
+
+ describe "Project should be internal" do
+ subject { project }
+
+ its(:internal?) { should be_true }
+ end
+
+ describe "GET /:project_path" do
+ subject { project_path(project) }
+
+ it { should be_allowed_for master }
+ it { should be_allowed_for reporter }
+ it { should be_allowed_for :admin }
+ it { should be_allowed_for guest }
+ it { should be_allowed_for :user }
+ it { should be_denied_for :visitor }
+ end
+
+ describe "GET /:project_path/tree/master" do
+ subject { project_tree_path(project, project.repository.root_ref) }
+
+ it { should be_allowed_for master }
+ it { should be_allowed_for reporter }
+ it { should be_allowed_for :admin }
+ it { should be_allowed_for guest }
+ it { should be_allowed_for :user }
+ it { should be_denied_for :visitor }
+ end
+
+ describe "GET /:project_path/commits/master" do
+ subject { project_commits_path(project, project.repository.root_ref, limit: 1) }
+
+ it { should be_allowed_for master }
+ it { should be_allowed_for reporter }
+ it { should be_allowed_for :admin }
+ it { should be_allowed_for guest }
+ it { should be_allowed_for :user }
+ it { should be_denied_for :visitor }
+ end
+
+ describe "GET /:project_path/commit/:sha" do
+ subject { project_commit_path(project, project.repository.commit) }
+
+ it { should be_allowed_for master }
+ it { should be_allowed_for reporter }
+ it { should be_allowed_for :admin }
+ it { should be_allowed_for guest }
+ it { should be_allowed_for :user }
+ it { should be_denied_for :visitor }
+ end
+
+ describe "GET /:project_path/compare" do
+ subject { project_compare_index_path(project) }
+
+ it { should be_allowed_for master }
+ it { should be_allowed_for reporter }
+ it { should be_allowed_for :admin }
+ it { should be_allowed_for guest }
+ it { should be_allowed_for :user }
+ it { should be_denied_for :visitor }
+ end
+
+ describe "GET /:project_path/team" do
+ subject { project_team_index_path(project) }
+
+ it { should be_allowed_for master }
+ it { should be_denied_for reporter }
+ it { should be_allowed_for :admin }
+ it { should be_denied_for guest }
+ it { should be_denied_for :user }
+ it { should be_denied_for :visitor }
+ end
+
+ describe "GET /:project_path/wall" do
+ subject { project_wall_path(project) }
+
+ it { should be_allowed_for master }
+ it { should be_allowed_for reporter }
+ it { should be_allowed_for :admin }
+ it { should be_allowed_for guest }
+ it { should be_allowed_for :user }
+ it { should be_denied_for :visitor }
+ end
+
+ describe "GET /:project_path/blob" do
+ before do
+ commit = project.repository.commit
+ path = commit.tree.contents.select { |i| i.is_a?(Grit::Blob) }.first.name
+ @blob_path = project_blob_path(project, File.join(commit.id, path))
+ end
+
+ it { @blob_path.should be_allowed_for master }
+ it { @blob_path.should be_allowed_for reporter }
+ it { @blob_path.should be_allowed_for :admin }
+ it { @blob_path.should be_allowed_for guest }
+ it { @blob_path.should be_allowed_for :user }
+ it { @blob_path.should be_denied_for :visitor }
+ end
+
+ describe "GET /:project_path/edit" do
+ subject { edit_project_path(project) }
+
+ it { should be_allowed_for master }
+ it { should be_denied_for reporter }
+ it { should be_allowed_for :admin }
+ it { should be_denied_for guest }
+ it { should be_denied_for :user }
+ it { should be_denied_for :visitor }
+ end
+
+ describe "GET /:project_path/deploy_keys" do
+ subject { project_deploy_keys_path(project) }
+
+ it { should be_allowed_for master }
+ it { should be_denied_for reporter }
+ it { should be_allowed_for :admin }
+ it { should be_denied_for guest }
+ it { should be_denied_for :user }
+ it { should be_denied_for :visitor }
+ end
+
+ describe "GET /:project_path/issues" do
+ subject { project_issues_path(project) }
+
+ it { should be_allowed_for master }
+ it { should be_allowed_for reporter }
+ it { should be_allowed_for :admin }
+ it { should be_allowed_for guest }
+ it { should be_allowed_for :user }
+ it { should be_denied_for :visitor }
+ end
+
+ describe "GET /:project_path/snippets" do
+ subject { project_snippets_path(project) }
+
+ it { should be_allowed_for master }
+ it { should be_allowed_for reporter }
+ it { should be_allowed_for :admin }
+ it { should be_allowed_for guest }
+ it { should be_allowed_for :user }
+ it { should be_denied_for :visitor }
+ end
+
+ describe "GET /:project_path/snippets/new" do
+ subject { new_project_snippet_path(project) }
+
+ it { should be_allowed_for master }
+ it { should be_allowed_for reporter }
+ it { should be_allowed_for :admin }
+ it { should be_denied_for guest }
+ it { should be_denied_for :user }
+ it { should be_denied_for :visitor }
+ end
+
+ describe "GET /:project_path/merge_requests" do
+ subject { project_merge_requests_path(project) }
+
+ it { should be_allowed_for master }
+ it { should be_allowed_for reporter }
+ it { should be_allowed_for :admin }
+ it { should be_allowed_for guest }
+ it { should be_allowed_for :user }
+ it { should be_denied_for :visitor }
+ end
+
+ describe "GET /:project_path/merge_requests/new" do
+ subject { new_project_merge_request_path(project) }
+
+ it { should be_allowed_for master }
+ it { should be_denied_for reporter }
+ it { should be_allowed_for :admin }
+ it { should be_denied_for guest }
+ it { should be_denied_for :user }
+ it { should be_denied_for :visitor }
+ end
+
+ describe "GET /:project_path/branches/recent" do
+ subject { recent_project_branches_path(project) }
+
+ it { should be_allowed_for master }
+ it { should be_allowed_for reporter }
+ it { should be_allowed_for :admin }
+ it { should be_allowed_for guest }
+ it { should be_allowed_for :user }
+ it { should be_denied_for :visitor }
+ end
+
+ describe "GET /:project_path/branches" do
+ subject { project_branches_path(project) }
+
+ before do
+ # Speed increase
+ Project.any_instance.stub(:branches).and_return([])
+ end
+
+ it { should be_allowed_for master }
+ it { should be_allowed_for reporter }
+ it { should be_allowed_for :admin }
+ it { should be_allowed_for guest }
+ it { should be_allowed_for :user }
+ it { should be_denied_for :visitor }
+ end
+
+ describe "GET /:project_path/tags" do
+ subject { project_tags_path(project) }
+
+ before do
+ # Speed increase
+ Project.any_instance.stub(:tags).and_return([])
+ end
+
+ it { should be_allowed_for master }
+ it { should be_allowed_for reporter }
+ it { should be_allowed_for :admin }
+ it { should be_allowed_for guest }
+ it { should be_allowed_for :user }
+ it { should be_denied_for :visitor }
+ end
+
+ describe "GET /:project_path/hooks" do
+ subject { project_hooks_path(project) }
+
+ it { should be_allowed_for master }
+ it { should be_denied_for reporter }
+ it { should be_allowed_for :admin }
+ it { should be_denied_for guest }
+ it { should be_denied_for :user }
+ it { should be_denied_for :visitor }
+ end
+end
diff --git a/spec/features/security/project/private_access_spec.rb b/spec/features/security/project/private_access_spec.rb
index 7f3f8c50f02..0402ff39735 100644
--- a/spec/features/security/project/private_access_spec.rb
+++ b/spec/features/security/project/private_access_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
describe "Private Project Access" do
- let(:project) { create(:project_with_code) }
+ let(:project) { create(:project) }
let(:master) { create(:user) }
let(:guest) { create(:user) }
@@ -15,6 +15,12 @@ describe "Private Project Access" do
project.team << [reporter, :reporter]
end
+ describe "Project should be private" do
+ subject { project }
+
+ its(:private?) { should be_true }
+ end
+
describe "GET /:project_path" do
subject { project_path(project) }
diff --git a/spec/features/security/project/public_access_spec.rb b/spec/features/security/project/public_access_spec.rb
index 267643fd8ef..7e6a39fad69 100644
--- a/spec/features/security/project/public_access_spec.rb
+++ b/spec/features/security/project/public_access_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
describe "Public Project Access" do
- let(:project) { create(:project_with_code) }
+ let(:project) { create(:project) }
let(:master) { create(:user) }
let(:guest) { create(:user) }
@@ -9,7 +9,7 @@ describe "Public Project Access" do
before do
# public project
- project.public = true
+ project.visibility_level = Gitlab::VisibilityLevel::PUBLIC
project.save!
# full access