diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/blob_controller_spec.rb | 12 | ||||
-rw-r--r-- | spec/controllers/commit_controller_spec.rb | 52 | ||||
-rw-r--r-- | spec/controllers/commits_controller_spec.rb | 7 | ||||
-rw-r--r-- | spec/controllers/help_controller_spec.rb | 16 | ||||
-rw-r--r-- | spec/controllers/projects/compare_controller_spec.rb | 7 | ||||
-rw-r--r-- | spec/controllers/projects/merge_requests_controller_spec.rb | 62 | ||||
-rw-r--r-- | spec/controllers/projects/refs_controller_spec.rb | 17 | ||||
-rw-r--r-- | spec/controllers/projects_controller_spec.rb | 16 | ||||
-rw-r--r-- | spec/controllers/tree_controller_spec.rb | 12 | ||||
-rw-r--r-- | spec/features/atom/users_spec.rb | 19 | ||||
-rw-r--r-- | spec/lib/gitlab/asciidoc_spec.rb | 14 | ||||
-rw-r--r-- | spec/lib/votes_spec.rb | 7 | ||||
-rw-r--r-- | spec/requests/api/project_members_spec.rb | 5 | ||||
-rw-r--r-- | spec/services/merge_requests/refresh_service_spec.rb | 6 | ||||
-rw-r--r-- | spec/services/projects/fork_service_spec.rb | 6 |
15 files changed, 178 insertions, 80 deletions
diff --git a/spec/controllers/blob_controller_spec.rb b/spec/controllers/blob_controller_spec.rb index a1102f28340..eb91e577b87 100644 --- a/spec/controllers/blob_controller_spec.rb +++ b/spec/controllers/blob_controller_spec.rb @@ -18,8 +18,10 @@ describe Projects::BlobController do render_views before do - get(:show, namespace_id: project.namespace.to_param, - project_id: project.to_param, id: id) + get(:show, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + id: id) end context "valid branch, valid file" do @@ -42,8 +44,10 @@ describe Projects::BlobController do render_views before do - get(:show, namespace_id: project.namespace.to_param, - project_id: project.to_param, id: id) + get(:show, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + id: id) controller.instance_variable_set(:@blob, nil) end diff --git a/spec/controllers/commit_controller_spec.rb b/spec/controllers/commit_controller_spec.rb index 2cfa399a047..2dfc8e2821f 100644 --- a/spec/controllers/commit_controller_spec.rb +++ b/spec/controllers/commit_controller_spec.rb @@ -13,8 +13,11 @@ describe Projects::CommitController do describe "#show" do shared_examples "export as" do |format| it "should generally work" do - get(:show, namespace_id: project.namespace.to_param, - project_id: project.to_param, id: commit.id, format: format) + get(:show, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + id: commit.id, + format: format) expect(response).to be_success end @@ -22,13 +25,17 @@ describe Projects::CommitController do it "should generate it" do expect_any_instance_of(Commit).to receive(:"to_#{format}") - get(:show, namespace_id: project.namespace.to_param, - project_id: project.to_param, id: commit.id, format: format) + get(:show, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + id: commit.id, format: format) end it "should render it" do - get(:show, namespace_id: project.namespace.to_param, - project_id: project.to_param, id: commit.id, format: format) + get(:show, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + id: commit.id, format: format) expect(response.body).to eq(commit.send(:"to_#{format}")) end @@ -37,8 +44,10 @@ describe Projects::CommitController do allow_any_instance_of(Commit).to receive(:"to_#{format}"). and_return('HTML entities &<>" ') - get(:show, namespace_id: project.namespace.to_param, - project_id: project.to_param, id: commit.id, format: format) + get(:show, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + id: commit.id, format: format) expect(response.body).to_not include('&') expect(response.body).to_not include('>') @@ -52,8 +61,11 @@ describe Projects::CommitController do let(:format) { :diff } it "should really only be a git diff" do - get(:show, namespace_id: project.namespace.to_param, - project_id: project.to_param, id: commit.id, format: format) + get(:show, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + id: commit.id, + format: format) expect(response.body).to start_with("diff --git") end @@ -64,15 +76,21 @@ describe Projects::CommitController do let(:format) { :patch } it "should really be a git email patch" do - get(:show, namespace_id: project.namespace.to_param, - project_id: project.to_param, id: commit.id, format: format) + get(:show, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + id: commit.id, + format: format) expect(response.body).to start_with("From #{commit.id}") end it "should contain a git diff" do - get(:show, namespace_id: project.namespace.to_param, - project_id: project.to_param, id: commit.id, format: format) + get(:show, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + id: commit.id, + format: format) expect(response.body).to match(/^diff --git/) end @@ -81,8 +99,10 @@ describe Projects::CommitController do describe "#branches" do it "contains branch and tags information" do - get(:branches, namespace_id: project.namespace.to_param, - project_id: project.to_param, id: commit.id) + get(:branches, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + id: commit.id) expect(assigns(:branches)).to include("master", "feature_conflict") expect(assigns(:tags)).to include("v1.1.0") diff --git a/spec/controllers/commits_controller_spec.rb b/spec/controllers/commits_controller_spec.rb index 2184b35152e..7d8089c4bc6 100644 --- a/spec/controllers/commits_controller_spec.rb +++ b/spec/controllers/commits_controller_spec.rb @@ -12,8 +12,11 @@ describe Projects::CommitsController do describe "GET show" do context "as atom feed" do it "should render as atom" do - get(:show, namespace_id: project.namespace.to_param, - project_id: project.to_param, id: "master", format: "atom") + get(:show, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + id: "master", + format: "atom") expect(response).to be_success expect(response.content_type).to eq('application/atom+xml') end diff --git a/spec/controllers/help_controller_spec.rb b/spec/controllers/help_controller_spec.rb index 93535ced7ae..1f7fd517342 100644 --- a/spec/controllers/help_controller_spec.rb +++ b/spec/controllers/help_controller_spec.rb @@ -35,8 +35,10 @@ describe HelpController do context 'for image formats' do context 'when requested file exists' do it 'renders the raw file' do - get :show, category: 'workflow/protected_branches', - file: 'protected_branches1', format: :png + get :show, + category: 'workflow/protected_branches', + file: 'protected_branches1', + format: :png expect(response).to be_success expect(response.content_type).to eq 'image/png' expect(response.headers['Content-Disposition']).to match(/^inline;/) @@ -45,7 +47,10 @@ describe HelpController do context 'when requested file is missing' do it 'renders not found' do - get :show, category: 'foo', file: 'bar', format: :png + get :show, + category: 'foo', + file: 'bar', + format: :png expect(response).to be_not_found end end @@ -53,7 +58,10 @@ describe HelpController do context 'for other formats' do it 'always renders not found' do - get :show, category: 'ssh', file: 'README', format: :foo + get :show, + category: 'ssh', + file: 'README', + format: :foo expect(response).to be_not_found end end diff --git a/spec/controllers/projects/compare_controller_spec.rb b/spec/controllers/projects/compare_controller_spec.rb index 23e1566b8f3..b643b354073 100644 --- a/spec/controllers/projects/compare_controller_spec.rb +++ b/spec/controllers/projects/compare_controller_spec.rb @@ -12,8 +12,11 @@ describe Projects::CompareController do end it 'compare should show some diffs' do - get(:show, namespace_id: project.namespace.to_param, - project_id: project.to_param, from: ref_from, to: ref_to) + get(:show, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + from: ref_from, + to: ref_to) expect(response).to be_success expect(assigns(:diffs).length).to be >= 1 diff --git a/spec/controllers/projects/merge_requests_controller_spec.rb b/spec/controllers/projects/merge_requests_controller_spec.rb index 5cc5bd78cd7..bda931666f7 100644 --- a/spec/controllers/projects/merge_requests_controller_spec.rb +++ b/spec/controllers/projects/merge_requests_controller_spec.rb @@ -13,8 +13,11 @@ describe Projects::MergeRequestsController do describe "#show" do shared_examples "export merge as" do |format| it "should generally work" do - get(:show, namespace_id: project.namespace.to_param, - project_id: project.to_param, id: merge_request.iid, format: format) + get(:show, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + id: merge_request.iid, + format: format) expect(response).to be_success end @@ -22,13 +25,19 @@ describe Projects::MergeRequestsController do it "should generate it" do expect_any_instance_of(MergeRequest).to receive(:"to_#{format}") - get(:show, namespace_id: project.namespace.to_param, - project_id: project.to_param, id: merge_request.iid, format: format) + get(:show, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + id: merge_request.iid, + format: format) end it "should render it" do - get(:show, namespace_id: project.namespace.to_param, - project_id: project.to_param, id: merge_request.iid, format: format) + get(:show, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + id: merge_request.iid, + format: format) expect(response.body).to eq((merge_request.send(:"to_#{format}",user)).to_s) end @@ -37,8 +46,11 @@ describe Projects::MergeRequestsController do allow_any_instance_of(MergeRequest).to receive(:"to_#{format}"). and_return('HTML entities &<>" ') - get(:show, namespace_id: project.namespace.to_param, - project_id: project.to_param, id: merge_request.iid, format: format) + get(:show, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + id: merge_request.iid, + format: format) expect(response.body).to_not include('&') expect(response.body).to_not include('>') @@ -52,8 +64,11 @@ describe Projects::MergeRequestsController do let(:format) { :diff } it "should really only be a git diff" do - get(:show, namespace_id: project.namespace.to_param, - project_id: project.to_param, id: merge_request.iid, format: format) + get(:show, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + id: merge_request.iid, + format: format) expect(response.body).to start_with("diff --git") end @@ -64,15 +79,20 @@ describe Projects::MergeRequestsController do let(:format) { :patch } it "should really be a git email patch with commit" do - get(:show, namespace_id: project.namespace.to_param, - project_id: project.to_param, id: merge_request.iid, format: format) + get(:show, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + id: merge_request.iid, format: format) expect(response.body[0..100]).to start_with("From #{merge_request.commits.last.id}") end it "should contain git diffs" do - get(:show, namespace_id: project.namespace.to_param, - project_id: project.to_param, id: merge_request.iid, format: format) + get(:show, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + id: merge_request.iid, + format: format) expect(response.body).to match(/^diff --git/) end @@ -81,8 +101,11 @@ describe Projects::MergeRequestsController do describe 'GET diffs' do def go(format: 'html') - get :diffs, namespace_id: project.namespace.to_param, - project_id: project.to_param, id: merge_request.iid, format: format + get :diffs, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + id: merge_request.iid, + format: format end context 'as html' do @@ -126,8 +149,11 @@ describe Projects::MergeRequestsController do describe 'GET commits' do def go(format: 'html') - get :commits, namespace_id: project.namespace.to_param, - project_id: project.to_param, id: merge_request.iid, format: format + get :commits, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + id: merge_request.iid, + format: format end context 'as html' do diff --git a/spec/controllers/projects/refs_controller_spec.rb b/spec/controllers/projects/refs_controller_spec.rb index c254ab7cb6e..abd45a74e2d 100644 --- a/spec/controllers/projects/refs_controller_spec.rb +++ b/spec/controllers/projects/refs_controller_spec.rb @@ -11,15 +11,20 @@ describe Projects::RefsController do describe 'GET #logs_tree' do def default_get(format = :html) - get :logs_tree, namespace_id: project.namespace.to_param, - project_id: project.to_param, id: 'master', - path: 'foo/bar/baz.html', format: format + get :logs_tree, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + id: 'master', + path: 'foo/bar/baz.html', + format: format end def xhr_get(format = :html) - xhr :get, :logs_tree, namespace_id: project.namespace.to_param, - project_id: project.to_param, id: 'master', - path: 'foo/bar/baz.html', format: format + xhr :get, + :logs_tree, + namespace_id: project.namespace.to_param, + project_id: project.to_param, id: 'master', + path: 'foo/bar/baz.html', format: format end it 'never throws MissingTemplate' do diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index a1b82a32150..29233e9fae6 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -16,30 +16,34 @@ describe ProjectsController do get :show, "go-get" => "1", namespace_id: "bogus_namespace", id: "bogus_project" expect(response.body).to include("name='go-import'") - + content = "localhost/bogus_namespace/bogus_project git http://localhost/bogus_namespace/bogus_project.git" expect(response.body).to include("content='#{content}'") end end end - + describe "POST #toggle_star" do it "toggles star if user is signed in" do sign_in(user) expect(user.starred?(public_project)).to be_falsey - post(:toggle_star, namespace_id: public_project.namespace.to_param, + post(:toggle_star, + namespace_id: public_project.namespace.to_param, id: public_project.to_param) expect(user.starred?(public_project)).to be_truthy - post(:toggle_star, namespace_id: public_project.namespace.to_param, + post(:toggle_star, + namespace_id: public_project.namespace.to_param, id: public_project.to_param) expect(user.starred?(public_project)).to be_falsey end it "does nothing if user is not signed in" do - post(:toggle_star, namespace_id: project.namespace.to_param, + post(:toggle_star, + namespace_id: project.namespace.to_param, id: public_project.to_param) expect(user.starred?(public_project)).to be_falsey - post(:toggle_star, namespace_id: project.namespace.to_param, + post(:toggle_star, + namespace_id: project.namespace.to_param, id: public_project.to_param) expect(user.starred?(public_project)).to be_falsey end diff --git a/spec/controllers/tree_controller_spec.rb b/spec/controllers/tree_controller_spec.rb index 7b219819bbc..e09caf5df13 100644 --- a/spec/controllers/tree_controller_spec.rb +++ b/spec/controllers/tree_controller_spec.rb @@ -19,8 +19,10 @@ describe Projects::TreeController do render_views before do - get(:show, namespace_id: project.namespace.to_param, - project_id: project.to_param, id: id) + get(:show, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + id: id) end context "valid branch, no path" do @@ -48,8 +50,10 @@ describe Projects::TreeController do render_views before do - get(:show, namespace_id: project.namespace.to_param, - project_id: project.to_param, id: id) + get(:show, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + id: id) end context 'redirect to blob' do diff --git a/spec/features/atom/users_spec.rb b/spec/features/atom/users_spec.rb index 770ac04c2c5..dc41be8246f 100644 --- a/spec/features/atom/users_spec.rb +++ b/spec/features/atom/users_spec.rb @@ -14,17 +14,24 @@ describe "User Feed", feature: true do context 'feed content' do let(:project) { create(:project) } let(:issue) do - create(:issue, project: project, - author: user, description: "Houston, we have a bug!\n\n***\n\nI guess.") + create(:issue, + project: project, + author: user, + description: "Houston, we have a bug!\n\n***\n\nI guess.") end let(:note) do - create(:note, noteable: issue, author: user, - note: 'Bug confirmed :+1:', project: project) + create(:note, + noteable: issue, + author: user, + note: 'Bug confirmed :+1:', + project: project) end let(:merge_request) do create(:merge_request, - title: 'Fix bug', author: user, - source_project: project, target_project: project, + title: 'Fix bug', + author: user, + source_project: project, + target_project: project, description: "Here is the fix: ![an image](image.png)") end diff --git a/spec/lib/gitlab/asciidoc_spec.rb b/spec/lib/gitlab/asciidoc_spec.rb index 3fd0267bb76..03e36fd3552 100644 --- a/spec/lib/gitlab/asciidoc_spec.rb +++ b/spec/lib/gitlab/asciidoc_spec.rb @@ -11,8 +11,11 @@ module Gitlab context "without project" do it "should convert the input using Asciidoctor and default options" do - expected_asciidoc_opts = { safe: :secure, backend: :html5, - attributes: described_class::DEFAULT_ADOC_ATTRS } + expected_asciidoc_opts = { + safe: :secure, + backend: :html5, + attributes: described_class::DEFAULT_ADOC_ATTRS + } expect(Asciidoctor).to receive(:convert) .with(input, expected_asciidoc_opts).and_return(html) @@ -25,8 +28,11 @@ module Gitlab let(:asciidoc_opts) { { safe: :safe, attributes: ['foo'] } } it "should merge the options with default ones" do - expected_asciidoc_opts = { safe: :safe, backend: :html5, - attributes: described_class::DEFAULT_ADOC_ATTRS + ['foo'] } + expected_asciidoc_opts = { + safe: :safe, + backend: :html5, + attributes: described_class::DEFAULT_ADOC_ATTRS + ['foo'] + } expect(Asciidoctor).to receive(:convert) .with(input, expected_asciidoc_opts).and_return(html) diff --git a/spec/lib/votes_spec.rb b/spec/lib/votes_spec.rb index df243a26008..39e5d054e62 100644 --- a/spec/lib/votes_spec.rb +++ b/spec/lib/votes_spec.rb @@ -179,7 +179,10 @@ describe Issue, 'Votes' do def add_note(text, author = issue.author) created_at = Time.now - 1.hour + Note.count.seconds - issue.notes << create(:note, note: text, project: issue.project, - author_id: author.id, created_at: created_at) + issue.notes << create(:note, + note: text, + project: issue.project, + author_id: author.id, + created_at: created_at) end end diff --git a/spec/requests/api/project_members_spec.rb b/spec/requests/api/project_members_spec.rb index d2c1dd6264b..6358f6a2a4a 100644 --- a/spec/requests/api/project_members_spec.rb +++ b/spec/requests/api/project_members_spec.rb @@ -63,8 +63,9 @@ describe API::API, api: true do end it "should return a 201 status if user is already project member" do - post api("/projects/#{project.id}/members", user), user_id: user2.id, - access_level: ProjectMember::DEVELOPER + post api("/projects/#{project.id}/members", user), + user_id: user2.id, + access_level: ProjectMember::DEVELOPER expect do post api("/projects/#{project.id}/members", user), user_id: user2.id, access_level: ProjectMember::DEVELOPER end.not_to change { ProjectMember.count } diff --git a/spec/services/merge_requests/refresh_service_spec.rb b/spec/services/merge_requests/refresh_service_spec.rb index 0f9b65678df..9516e7936d8 100644 --- a/spec/services/merge_requests/refresh_service_spec.rb +++ b/spec/services/merge_requests/refresh_service_spec.rb @@ -13,12 +13,14 @@ describe MergeRequests::RefreshService do @project = create(:project, namespace: group) @fork_project = Projects::ForkService.new(@project, @user).execute - @merge_request = create(:merge_request, source_project: @project, + @merge_request = create(:merge_request, + source_project: @project, source_branch: 'master', target_branch: 'feature', target_project: @project) - @fork_merge_request = create(:merge_request, source_project: @fork_project, + @fork_merge_request = create(:merge_request, + source_project: @fork_project, source_branch: 'master', target_branch: 'feature', target_project: @project) diff --git a/spec/services/projects/fork_service_spec.rb b/spec/services/projects/fork_service_spec.rb index f158ac87e2b..439a492cea9 100644 --- a/spec/services/projects/fork_service_spec.rb +++ b/spec/services/projects/fork_service_spec.rb @@ -5,8 +5,10 @@ describe Projects::ForkService do before do @from_namespace = create(:namespace) @from_user = create(:user, namespace: @from_namespace ) - @from_project = create(:project, creator_id: @from_user.id, - namespace: @from_namespace, star_count: 107, + @from_project = create(:project, + creator_id: @from_user.id, + namespace: @from_namespace, + star_count: 107, description: 'wow such project') @to_namespace = create(:namespace) @to_user = create(:user, namespace: @to_namespace) |