summaryrefslogtreecommitdiff
path: root/spec/features
diff options
context:
space:
mode:
Diffstat (limited to 'spec/features')
-rw-r--r--spec/features/admin/admin_hooks_spec.rb2
-rw-r--r--spec/features/admin/admin_projects_spec.rb42
-rw-r--r--spec/features/admin/admin_users_spec.rb20
-rw-r--r--spec/features/gitlab_flavored_markdown_spec.rb79
-rw-r--r--spec/features/notes_on_merge_requests_spec.rb199
-rw-r--r--spec/features/profile_spec.rb6
-rw-r--r--spec/features/projects_deploy_keys_spec.rb67
-rw-r--r--spec/features/projects_spec.rb1
-rw-r--r--spec/features/security/project_access_spec.rb278
9 files changed, 377 insertions, 317 deletions
diff --git a/spec/features/admin/admin_hooks_spec.rb b/spec/features/admin/admin_hooks_spec.rb
index bc0586b2712..102a1b928f5 100644
--- a/spec/features/admin/admin_hooks_spec.rb
+++ b/spec/features/admin/admin_hooks_spec.rb
@@ -12,7 +12,7 @@ describe "Admin::Hooks" do
describe "GET /admin/hooks" do
it "should be ok" do
visit admin_root_path
- within ".main_menu" do
+ within ".main-nav" do
click_on "Hooks"
end
current_path.should == admin_hooks_path
diff --git a/spec/features/admin/admin_projects_spec.rb b/spec/features/admin/admin_projects_spec.rb
index c9ddf1f4534..23370891244 100644
--- a/spec/features/admin/admin_projects_spec.rb
+++ b/spec/features/admin/admin_projects_spec.rb
@@ -31,46 +31,4 @@ describe "Admin::Projects" do
page.should have_content(@project.name)
end
end
-
- describe "GET /admin/projects/:id/edit" do
- before do
- visit admin_projects_path
- click_link "edit_project_#{@project.id}"
- end
-
- it "should have project edit page" do
- page.should have_content("Edit project")
- page.should have_button("Save Project")
- end
-
- describe "Update project" do
- before do
- fill_in "project_name", with: "Big Bang"
- click_button "Save Project"
- @project.reload
- end
-
- it "should show page with new data" do
- page.should have_content("Big Bang")
- end
-
- it "should change project entry" do
- @project.name.should == "Big Bang"
- end
- end
- end
-
- describe "Add new team member" do
- before do
- @new_user = create(:user)
- visit admin_project_path(@project)
- end
-
- it "should create new user" do
- select @new_user.name, from: "user_ids"
- expect { click_button "Add" }.to change { UsersProject.count }.by(1)
- page.should have_content @new_user.name
- current_path.should == admin_project_path(@project)
- end
- end
end
diff --git a/spec/features/admin/admin_users_spec.rb b/spec/features/admin/admin_users_spec.rb
index 22d1ee91480..bec43e5029c 100644
--- a/spec/features/admin/admin_users_spec.rb
+++ b/spec/features/admin/admin_users_spec.rb
@@ -30,11 +30,19 @@ describe "Admin::Users" do
end
it "should create new user" do
- expect { click_button "Save" }.to change {User.count}.by(1)
+ expect { click_button "Create user" }.to change {User.count}.by(1)
+ end
+
+ it "should apply defaults to user" do
+ click_button "Create user"
+ user = User.last
+ user.projects_limit.should == Gitlab.config.gitlab.default_projects_limit
+ user.can_create_group.should == Gitlab.config.gitlab.default_can_create_group
+ user.can_create_team.should == Gitlab.config.gitlab.default_can_create_team
end
it "should create user with valid data" do
- click_button "Save"
+ click_button "Create user"
user = User.last
user.name.should == "Big Bang"
user.email.should == "bigbang@mail.com"
@@ -44,14 +52,14 @@ describe "Admin::Users" do
Notify.should_receive(:new_user_email)
User.observers.enable :user_observer do
- click_button "Save"
+ click_button "Create user"
end
end
it "should send valid email to user with email & password" do
Gitlab.config.gitlab.stub(:signup_enabled).and_return(false)
User.observers.enable :user_observer do
- click_button "Save"
+ click_button "Create user"
user = User.last
email = ActionMailer::Base.deliveries.last
email.subject.should have_content("Account was created")
@@ -63,7 +71,7 @@ describe "Admin::Users" do
it "should send valid email to user with email without password when signup is enabled" do
Gitlab.config.gitlab.stub(:signup_enabled).and_return(true)
User.observers.enable :user_observer do
- click_button "Save"
+ click_button "Create user"
user = User.last
email = ActionMailer::Base.deliveries.last
email.subject.should have_content("Account was created")
@@ -102,7 +110,7 @@ describe "Admin::Users" do
fill_in "user_name", with: "Big Bang"
fill_in "user_email", with: "bigbang@mail.com"
check "user_admin"
- click_button "Save"
+ click_button "Save changes"
end
it "should show page with new data" do
diff --git a/spec/features/gitlab_flavored_markdown_spec.rb b/spec/features/gitlab_flavored_markdown_spec.rb
index a57e34ac5d2..53d31766a00 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) }
+describe "GitLab Flavored Markdown" do
+ let(:project) { create(:project_with_code) }
let(:issue) { create(:issue, project: project) }
let(:merge_request) { create(:merge_request, project: project) }
let(:fred) do
@@ -11,29 +11,10 @@ describe "Gitlab Flavored Markdown" do
end
before do
- # add test branch
- @branch_name = "gfm-test"
- r = project.repo
- i = r.index
- # add test file
- @test_file = "gfm_test_file"
- i.add(@test_file, "foo\nbar\n")
- # add commit with gfm
- i.commit("fix ##{issue.id}\n\nask @#{fred.username} for details", head: @branch_name)
-
- # add test tag
- @tag_name = "gfm-test-tag"
- r.git.native(:tag, {}, @tag_name, commit.id)
+ Commit.any_instance.stub(title: "fix ##{issue.id}\n\nask @#{fred.username} for details")
end
- after do
- # delete test branch and tag
- project.repo.git.native(:branch, {D: true}, @branch_name)
- project.repo.git.native(:tag, {d: true}, @tag_name)
- project.repo.gc_auto
- end
-
- let(:commit) { project.repository.commits(@branch_name).first }
+ let(:commit) { project.repository.commit }
before do
login_as :user
@@ -42,7 +23,7 @@ describe "Gitlab Flavored Markdown" do
describe "for commits" do
it "should render title in commits#index" do
- visit project_commits_path(project, @branch_name, limit: 1)
+ visit project_commits_path(project, 'master', limit: 1)
page.should have_link("##{issue.id}")
end
@@ -59,23 +40,6 @@ describe "Gitlab Flavored Markdown" do
page.should have_link("@#{fred.username}")
end
- it "should render title in refs#tree", js: true do
- visit project_tree_path(project, @branch_name)
-
- within(".tree_commit") do
- page.should have_link("##{issue.id}")
- end
- end
-
- # @wip
- #it "should render title in refs#blame" do
- #visit project_blame_path(project, File.join(@branch_name, @test_file))
-
- #within(".blame_commit") do
- #page.should have_link("##{issue.id}")
- #end
- #end
-
it "should render title in repositories#branches" do
visit branches_project_repository_path(project)
@@ -164,37 +128,4 @@ describe "Gitlab Flavored Markdown" do
page.should have_link("@#{fred.username}")
end
end
-
-
- describe "for notes" do
- it "should render in commits#show", js: true do
- visit project_commit_path(project, commit)
- within ".new_note.js-main-target-form" do
- fill_in "note_note", with: "see ##{issue.id}"
- click_button "Add Comment"
- end
-
- page.should have_link("##{issue.id}")
- end
-
- it "should render in issue#show", js: true do
- visit project_issue_path(project, issue)
- within ".new_note.js-main-target-form" do
- fill_in "note_note", with: "see ##{issue.id}"
- click_button "Add Comment"
- end
-
- page.should have_link("##{issue.id}")
- end
-
- it "should render in merge_request#show", js: true do
- visit project_merge_request_path(project, merge_request)
- within ".new_note.js-main-target-form" do
- fill_in "note_note", with: "see ##{issue.id}"
- click_button "Add Comment"
- end
-
- page.should have_link("##{issue.id}")
- end
- end
end
diff --git a/spec/features/notes_on_merge_requests_spec.rb b/spec/features/notes_on_merge_requests_spec.rb
index 670762e8005..24f5437efff 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) }
+ let!(:project) { create(:project_with_code) }
let!(:merge_request) { create(:merge_request, project: project) }
before do
@@ -14,20 +14,11 @@ describe "On a merge request", js: true do
subject { page }
describe "the note form" do
- # main target form creation
- it { should have_css(".js-main-target-form", visible: true, count: 1) }
-
- # button initalization
- it { find(".js-main-target-form input[type=submit]").value.should == "Add Comment" }
- it { within(".js-main-target-form") { should_not have_link("Cancel") } }
-
- # notifiactions
- it { within(".js-main-target-form") { should have_unchecked_field("Notify team via email") } }
- it { within(".js-main-target-form") { should_not have_checked_field("Notify commit author") } }
- it { within(".js-main-target-form") { should_not have_unchecked_field("Notify commit author") } }
-
- describe "without text" do
- it { within(".js-main-target-form") { should have_css(".js-note-preview-button", visible: false) } }
+ it 'should be valid' do
+ should have_css(".js-main-target-form", visible: true, count: 1)
+ find(".js-main-target-form input[type=submit]").value.should == "Add Comment"
+ within(".js-main-target-form") { should_not have_link("Cancel") }
+ within(".js-main-target-form") { should have_css(".js-note-preview-button", visible: false) }
end
describe "with text" do
@@ -37,9 +28,10 @@ describe "On a merge request", js: true do
end
end
- it { within(".js-main-target-form") { should_not have_css(".js-comment-button[disabled]") } }
-
- it { within(".js-main-target-form") { should have_css(".js-note-preview-button", visible: true) } }
+ it 'should have enable submit button and preview button' do
+ within(".js-main-target-form") { should_not have_css(".js-comment-button[disabled]") }
+ within(".js-main-target-form") { should have_css(".js-note-preview-button", visible: true) }
+ end
end
describe "with preview" do
@@ -50,10 +42,11 @@ describe "On a merge request", js: true do
end
end
- it { within(".js-main-target-form") { should have_css(".js-note-preview", text: "This is awesome", visible: true) } }
-
- it { within(".js-main-target-form") { should have_css(".js-note-preview-button", visible: false) } }
- it { within(".js-main-target-form") { should have_css(".js-note-edit-button", visible: true) } }
+ it 'should have text and visible edit button' do
+ within(".js-main-target-form") { should have_css(".js-note-preview", text: "This is awesome", visible: true) }
+ within(".js-main-target-form") { should have_css(".js-note-preview-button", visible: false) }
+ within(".js-main-target-form") { should have_css(".js-note-edit-button", visible: true) }
+ end
end
end
@@ -66,73 +59,57 @@ describe "On a merge request", js: true do
end
end
- # note added
- it { should have_content("This is awsome!") }
-
- # reset form
- it { within(".js-main-target-form") { should have_no_field("note[note]", with: "This is awesome!") } }
-
- # return from preview
- it { within(".js-main-target-form") { should have_css(".js-note-preview", visible: false) } }
- it { within(".js-main-target-form") { should have_css(".js-note-text", visible: true) } }
-
+ it 'should be added and form reset' do
+ should have_content("This is awsome!")
+ within(".js-main-target-form") { should have_no_field("note[note]", with: "This is awesome!") }
+ within(".js-main-target-form") { should have_css(".js-note-preview", visible: false) }
+ within(".js-main-target-form") { should have_css(".js-note-text", visible: true) }
+ end
it "should be removable" do
- find(".js-note-delete").trigger("click")
-
+ find('.note').hover
+ find(".js-note-delete").click
should_not have_css(".note")
end
end
end
-
-
describe "On a merge request diff", js: true, focus: true do
- let!(:project) { create(:project) }
+ let!(:project) { create(:project_with_code) }
let!(:merge_request) { create(:merge_request_with_diffs, project: project) }
before do
login_as :user
project.team << [@user, :master]
-
visit diffs_project_merge_request_path(project, merge_request)
-
- within '.diffs-tab' do
- click_link("Diff")
- end
end
subject { page }
describe "when adding a note" do
before do
- find("#4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185.line_holder .js-add-diff-note-button").trigger("click")
+ find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185"]').click
end
describe "the notes holder" do
- it { should have_css("#4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185.line_holder + .js-temp-notes-holder") }
+ it { should have_css(".js-temp-notes-holder") }
it { within(".js-temp-notes-holder") { should have_css(".new_note") } }
end
describe "the note form" do
- # set up hidden fields correctly
- it { within(".js-temp-notes-holder") { find("#note_noteable_type").value.should == "MergeRequest" } }
- it { within(".js-temp-notes-holder") { find("#note_noteable_id").value.should == merge_request.id.to_s } }
- it { within(".js-temp-notes-holder") { find("#note_commit_id").value.should == "" } }
- it { within(".js-temp-notes-holder") { find("#note_line_code").value.should == "4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185" } }
-
- # buttons
- it { should have_button("Add Comment") }
- it { should have_css(".js-close-discussion-note-form", text: "Cancel") }
-
- # notification options
- it { should have_unchecked_field("Notify team via email") }
+ 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("#4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185.line_holder .js-add-diff-note-button").trigger("click")
+ find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185"]').click
- should have_css("#4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185.line_holder + .js-temp-notes-holder form", count: 1)
+ should have_css("tr[id='4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185'] + .js-temp-notes-holder form", count: 1)
end
it "should be removed when canceled" do
@@ -147,87 +124,95 @@ describe "On a merge request diff", js: true, focus: true do
describe "with muliple note forms" do
before do
- find("#4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185.line_holder .js-add-diff-note-button").trigger("click")
- find("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder .js-add-diff-note-button").trigger("click")
+ find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185"]').click
+ find('a[data-line-code="342e16cbbd482ac2047dc679b2749d248cc1428f_18_17"]').click
end
- # has two line forms
it { should have_css(".js-temp-notes-holder", count: 2) }
describe "previewing them separately" do
before do
# add two separate texts and trigger previews on both
- within("#4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185.line_holder + .js-temp-notes-holder") do
+ within("tr[id='4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185'] + .js-temp-notes-holder") do
fill_in "note[note]", with: "One comment on line 185"
find(".js-note-preview-button").trigger("click")
end
- within("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .js-temp-notes-holder") do
+ within("tr[id='342e16cbbd482ac2047dc679b2749d248cc1428f_18_17'] + .js-temp-notes-holder") do
fill_in "note[note]", with: "Another comment on line 17"
find(".js-note-preview-button").trigger("click")
end
end
- # check if previews were rendered separately
- it { within("#4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185.line_holder + .js-temp-notes-holder") { should have_css(".js-note-preview", text: "One comment on line 185") } }
- it { within("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .js-temp-notes-holder") { should have_css(".js-note-preview", text: "Another comment on line 17") } }
+ # TODO: fix
+ #it 'should check if previews were rendered separately' do
+ #within("tr[id='4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185'] + .js-temp-notes-holder") do
+ #should have_css(".js-note-preview", text: "One comment on line 185")
+ #end
+
+ #within("tr[id='342e16cbbd482ac2047dc679b2749d248cc1428f_18_17'] + .js-temp-notes-holder") do
+ #should have_css(".js-note-preview", text: "Another comment on line 17")
+ #end
+ #end
end
describe "posting a note" do
before do
- within("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .js-temp-notes-holder") do
+ within("tr[id='342e16cbbd482ac2047dc679b2749d248cc1428f_18_17'] + .js-temp-notes-holder") do
fill_in "note[note]", with: "Another comment on line 17"
click_button("Add Comment")
end
end
- # removed form after submit
- it { should have_no_css("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .js-temp-notes-holder") }
-
- # added discussion
- it { should have_content("Another comment on line 17") }
- it { should have_css("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .notes_holder") }
- it { should have_css("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .notes_holder .note", count: 1) }
- it { should have_link("Reply") }
-
- it "should remove last note of a discussion" do
- within("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .notes_holder") do
- find(".js-note-delete").trigger("click")
+ it do
+ within("tr[id='342e16cbbd482ac2047dc679b2749d248cc1428f_18_17'] + .js-temp-notes-holder") do
+ should have_no_css(".js-temp-notes-holder")
end
-
- # removed whole discussion
- should_not have_css(".note_holder")
- should have_css("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + #342e16cbbd482ac2047dc679b2749d248cc1428f_18_18.line_holder")
end
- end
- end
- describe "when replying to a note" do
- before do
- # create first note
- find("#4735dfc552ad7bf15ca468adc3cad9d05b624490_184_184.line_holder .js-add-diff-note-button").trigger("click")
- within("#4735dfc552ad7bf15ca468adc3cad9d05b624490_184_184.line_holder + .js-temp-notes-holder") do
- fill_in "note[note]", with: "One comment on line 184"
- click_button("Add Comment")
+ it 'should be added as discussion' do
+ should have_content("Another comment on line 17")
+ should have_css(".notes_holder")
+ should have_css(".notes_holder .note", count: 1)
+ should have_link("Reply")
end
- # create second note
- within("#4735dfc552ad7bf15ca468adc3cad9d05b624490_184_184.line_holder + .notes_holder") do
- find(".js-discussion-reply-button").trigger("click")
- fill_in "note[note]", with: "An additional comment in reply"
- click_button("Add Comment")
- end
- end
- # inserted note
- it { should have_content("An additional comment in reply") }
- it { within("#4735dfc552ad7bf15ca468adc3cad9d05b624490_184_184.line_holder + .notes_holder") { should have_css(".note", count: 2) } }
+ # TODO: fix
+ #it "should remove last note of a discussion" do
+ #within("tr[id='342e16cbbd482ac2047dc679b2749d248cc1428f_18_17'] + .notes-holder") do
+ #find(".js-note-delete").click
+ #end
- # removed form after reply
- it { within("#4735dfc552ad7bf15ca468adc3cad9d05b624490_184_184.line_holder + .notes_holder") { should have_no_css("form") } }
- it { within("#4735dfc552ad7bf15ca468adc3cad9d05b624490_184_184.line_holder + .notes_holder") { should have_link("Reply") } }
+ #should_not have_css(".note_holder")
+ #end
+ end
end
-end
-
+ # TODO: fix
+ #describe "when replying to a note" do
+ #before do
+ ## create first note
+ #find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_184_184"]').click
+
+ #within(".js-temp-notes-holder") do
+ #fill_in "note[note]", with: "One comment on line 184"
+ #click_button("Add Comment")
+ #end
+
+ #within(".js-temp-notes-holder") do
+ #find(".js-discussion-reply-button").click
+ #fill_in "note[note]", with: "An additional comment in reply"
+ #click_button("Add Comment")
+ #end
+ #end
+
+ #it 'should be inserted and form removed from reply' do
+ #should have_content("An additional comment in reply")
+ #within(".notes_holder") { should have_css(".note", count: 2) }
+ #within(".notes_holder") { should have_no_css("form") }
+ #within(".notes_holder") { should have_link("Reply") }
+ #end
+ #end
+end
describe "On merge request discussion", js: true do
describe "with merge request diff note"
diff --git a/spec/features/profile_spec.rb b/spec/features/profile_spec.rb
index c18d8f921a3..d46882d4e42 100644
--- a/spec/features/profile_spec.rb
+++ b/spec/features/profile_spec.rb
@@ -1,6 +1,7 @@
require 'spec_helper'
describe "Profile account page" do
+ before(:each) { enable_observers }
let(:user) { create(:user) }
before do
@@ -12,8 +13,9 @@ describe "Profile account page" do
Gitlab.config.gitlab.stub(:signup_enabled).and_return(true)
visit account_profile_path
end
+
it { page.should have_content("Remove account") }
-
+
it "should delete the account", js: true do
expect { click_link "Delete account" }.to change {User.count}.by(-1)
current_path.should == new_user_session_path
@@ -45,4 +47,4 @@ describe "Profile account page" do
current_path.should == account_profile_path
end
end
-end \ No newline at end of file
+end
diff --git a/spec/features/projects_deploy_keys_spec.rb b/spec/features/projects_deploy_keys_spec.rb
deleted file mode 100644
index 25b1da9ebd8..00000000000
--- a/spec/features/projects_deploy_keys_spec.rb
+++ /dev/null
@@ -1,67 +0,0 @@
-require 'spec_helper'
-
-describe "Projects", "DeployKeys" do
- let(:project) { create(:project) }
-
- before do
- login_as :user
- project.team << [@user, :master]
- end
-
- describe "GET /keys" do
- before do
- @key = create(:key, project: project)
- visit project_deploy_keys_path(project)
- end
-
- subject { page }
-
- it { should have_content(@key.title) }
-
- describe "Destroy" do
- before { visit project_deploy_key_path(project, @key) }
-
- it "should remove entry" do
- expect {
- click_link "Remove"
- }.to change { project.deploy_keys.count }.by(-1)
- end
- end
- end
-
- describe "New key" do
- before do
- visit project_deploy_keys_path(project)
- click_link "New Deploy Key"
- end
-
- it "should open new key popup" do
- page.should have_content("New Deploy key")
- end
-
- describe "fill in" do
- before do
- fill_in "key_title", with: "laptop"
- fill_in "key_key", with: "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAzrEJUIR6Y03TCE9rIJ+GqTBvgb8t1jI9h5UBzCLuK4VawOmkLornPqLDrGbm6tcwM/wBrrLvVOqi2HwmkKEIecVO0a64A4rIYScVsXIniHRS6w5twyn1MD3sIbN+socBDcaldECQa2u1dI3tnNVcs8wi77fiRe7RSxePsJceGoheRQgC8AZ510UdIlO+9rjIHUdVN7LLyz512auAfYsgx1OfablkQ/XJcdEwDNgi9imI6nAXhmoKUm1IPLT2yKajTIC64AjLOnE0YyCh6+7RFMpiMyu1qiOCpdjYwTgBRiciNRZCH8xIedyCoAmiUgkUT40XYHwLuwiPJICpkAzp7Q== user@laptop"
- 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 have_content "laptop"
- end
- end
- end
-
- describe "Show page" do
- before do
- @key = create(:key, project: project)
- visit project_deploy_key_path(project, @key)
- end
-
- it { page.should have_content @key.title }
- it { page.should have_content @key.key[0..10] }
- end
-end
diff --git a/spec/features/projects_spec.rb b/spec/features/projects_spec.rb
index 1ffc28bfa4e..f0a1f75e1e0 100644
--- a/spec/features/projects_spec.rb
+++ b/spec/features/projects_spec.rb
@@ -1,6 +1,7 @@
require 'spec_helper'
describe "Projects" do
+ before(:each) { enable_observers }
before { login_as :user }
describe "DELETE /projects/:id" do
diff --git a/spec/features/security/project_access_spec.rb b/spec/features/security/project_access_spec.rb
index b89844013c3..8c65af061e0 100644
--- a/spec/features/security/project_access_spec.rb
+++ b/spec/features/security/project_access_spec.rb
@@ -14,7 +14,7 @@ describe "Application access" do
end
describe "Project" do
- let(:project) { create(:project) }
+ let(:project) { create(:project_with_code) }
let(:master) { create(:user) }
let(:guest) { create(:user) }
@@ -33,7 +33,7 @@ describe "Application access" do
it { should be_allowed_for master }
it { should be_allowed_for reporter }
- it { should be_denied_for :admin }
+ it { should be_allowed_for :admin }
it { should be_denied_for guest }
it { should be_denied_for :user }
it { should be_denied_for :visitor }
@@ -44,7 +44,7 @@ describe "Application access" do
it { should be_allowed_for master }
it { should be_allowed_for reporter }
- it { should be_denied_for :admin }
+ it { should be_allowed_for :admin }
it { should be_denied_for guest }
it { should be_denied_for :user }
it { should be_denied_for :visitor }
@@ -55,7 +55,7 @@ describe "Application access" do
it { should be_allowed_for master }
it { should be_allowed_for reporter }
- it { should be_denied_for :admin }
+ it { should be_allowed_for :admin }
it { should be_denied_for guest }
it { should be_denied_for :user }
it { should be_denied_for :visitor }
@@ -66,7 +66,7 @@ describe "Application access" do
it { should be_allowed_for master }
it { should be_allowed_for reporter }
- it { should be_denied_for :admin }
+ it { should be_allowed_for :admin }
it { should be_denied_for guest }
it { should be_denied_for :user }
it { should be_denied_for :visitor }
@@ -77,7 +77,7 @@ describe "Application access" do
it { should be_allowed_for master }
it { should be_allowed_for reporter }
- it { should be_denied_for :admin }
+ it { should be_allowed_for :admin }
it { should be_denied_for guest }
it { should be_denied_for :user }
it { should be_denied_for :visitor }
@@ -88,7 +88,7 @@ describe "Application access" do
it { should be_allowed_for master }
it { should be_allowed_for reporter }
- it { should be_denied_for :admin }
+ it { should be_allowed_for :admin }
it { should be_denied_for guest }
it { should be_denied_for :user }
it { should be_denied_for :visitor }
@@ -99,7 +99,7 @@ describe "Application access" do
it { should be_allowed_for master }
it { should be_allowed_for reporter }
- it { should be_denied_for :admin }
+ it { should be_allowed_for :admin }
it { should be_denied_for guest }
it { should be_denied_for :user }
it { should be_denied_for :visitor }
@@ -114,7 +114,7 @@ describe "Application access" do
it { @blob_path.should be_allowed_for master }
it { @blob_path.should be_allowed_for reporter }
- it { @blob_path.should be_denied_for :admin }
+ it { @blob_path.should be_allowed_for :admin }
it { @blob_path.should be_denied_for guest }
it { @blob_path.should be_denied_for :user }
it { @blob_path.should be_denied_for :visitor }
@@ -125,7 +125,7 @@ describe "Application access" do
it { should be_allowed_for master }
it { should be_denied_for reporter }
- it { should be_denied_for :admin }
+ it { should be_allowed_for :admin }
it { should be_denied_for guest }
it { should be_denied_for :user }
it { should be_denied_for :visitor }
@@ -136,7 +136,7 @@ describe "Application access" do
it { should be_allowed_for master }
it { should be_denied_for reporter }
- it { should be_denied_for :admin }
+ it { should be_allowed_for :admin }
it { should be_denied_for guest }
it { should be_denied_for :user }
it { should be_denied_for :visitor }
@@ -147,7 +147,7 @@ describe "Application access" do
it { should be_allowed_for master }
it { should be_allowed_for reporter }
- it { should be_denied_for :admin }
+ it { should be_allowed_for :admin }
it { should be_denied_for guest }
it { should be_denied_for :user }
it { should be_denied_for :visitor }
@@ -158,7 +158,7 @@ describe "Application access" do
it { should be_allowed_for master }
it { should be_allowed_for reporter }
- it { should be_denied_for :admin }
+ it { should be_allowed_for :admin }
it { should be_denied_for guest }
it { should be_denied_for :user }
it { should be_denied_for :visitor }
@@ -169,7 +169,7 @@ describe "Application access" do
it { should be_allowed_for master }
it { should be_allowed_for reporter }
- it { should be_denied_for :admin }
+ it { should be_allowed_for :admin }
it { should be_denied_for guest }
it { should be_denied_for :user }
it { should be_denied_for :visitor }
@@ -180,7 +180,7 @@ describe "Application access" do
it { should be_allowed_for master }
it { should be_allowed_for reporter }
- it { should be_denied_for :admin }
+ it { should be_allowed_for :admin }
it { should be_denied_for guest }
it { should be_denied_for :user }
it { should be_denied_for :visitor }
@@ -196,7 +196,7 @@ describe "Application access" do
it { should be_allowed_for master }
it { should be_allowed_for reporter }
- it { should be_denied_for :admin }
+ it { should be_allowed_for :admin }
it { should be_denied_for guest }
it { should be_denied_for :user }
it { should be_denied_for :visitor }
@@ -212,7 +212,7 @@ describe "Application access" do
it { should be_allowed_for master }
it { should be_allowed_for reporter }
- it { should be_denied_for :admin }
+ it { should be_allowed_for :admin }
it { should be_denied_for guest }
it { should be_denied_for :user }
it { should be_denied_for :visitor }
@@ -223,10 +223,252 @@ describe "Application access" do
it { should be_allowed_for master }
it { should be_allowed_for reporter }
- it { should be_denied_for :admin }
+ 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
+
+
+ describe "PublicProject" do
+ let(:project) { create(:project_with_code) }
+
+ let(:master) { create(:user) }
+ let(:guest) { create(:user) }
+ let(:reporter) { create(:user) }
+
+ let(:admin) { create(:user) }
+
+ before do
+ # public project
+ project.public = true
+ project.save!
+
+ # full access
+ project.team << [master, :master]
+
+ # readonly
+ project.team << [reporter, :reporter]
+
+ end
+
+ describe "Project should be public" do
+ subject { project }
+
+ its(:public?) { should be_true }
+ end
+
+ describe "GET /project_code" 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_code/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_code/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_code/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_code/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_code/team" do
+ subject { project_team_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_code/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_code/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_code/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_code/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_code/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_code/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_code/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_code/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_code/repository" do
+ subject { project_repository_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_code/repository/branches" do
+ subject { branches_project_repository_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_code/repository/tags" do
+ subject { tags_project_repository_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_code/hooks" do
+ subject { project_hooks_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
+ end
end