Commit 88343897 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'rubocop-for-tests' into 'master'

Enable rubocop for tests too

cc @DouweM @rspeicher
Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>

See merge request !862
parents a8e4e6aa 779646ef
...@@ -993,8 +993,6 @@ Rails/Validation: ...@@ -993,8 +993,6 @@ Rails/Validation:
AllCops: AllCops:
RunRailsCops: true RunRailsCops: true
Exclude: Exclude:
- 'spec/**/*'
- 'features/**/*'
- 'vendor/**/*' - 'vendor/**/*'
- 'db/**/*' - 'db/**/*'
- 'tmp/**/*' - 'tmp/**/*'
......
...@@ -28,7 +28,7 @@ class Spinach::Features::Dashboard < Spinach::FeatureSteps ...@@ -28,7 +28,7 @@ class Spinach::Features::Dashboard < Spinach::FeatureSteps
end end
step 'user with name "John Doe" joined project "Shop"' do step 'user with name "John Doe" joined project "Shop"' do
user = create(:user, {name: "John Doe"}) user = create(:user, { name: "John Doe" })
project.team << [user, :master] project.team << [user, :master]
Event.create( Event.create(
project: project, project: project,
......
...@@ -52,7 +52,7 @@ class Spinach::Features::EventFilters < Spinach::FeatureSteps ...@@ -52,7 +52,7 @@ class Spinach::Features::EventFilters < Spinach::FeatureSteps
end end
step 'this project has new member event' do step 'this project has new member event' do
user = create(:user, {name: "John Doe"}) user = create(:user, { name: "John Doe" })
Event.create( Event.create(
project: @project, project: @project,
author_id: user.id, author_id: user.id,
......
...@@ -145,4 +145,3 @@ class Spinach::Features::ExploreProjects < Spinach::FeatureSteps ...@@ -145,4 +145,3 @@ class Spinach::Features::ExploreProjects < Spinach::FeatureSteps
@public_merge_request ||= MergeRequest.find_by!(title: 'Bug fix for public project') @public_merge_request ||= MergeRequest.find_by!(title: 'Bug fix for public project')
end end
end end
...@@ -52,8 +52,8 @@ class Spinach::Features::ProjectSnippets < Spinach::FeatureSteps ...@@ -52,8 +52,8 @@ class Spinach::Features::ProjectSnippets < Spinach::FeatureSteps
end end
step 'I submit new snippet "Snippet three"' do step 'I submit new snippet "Snippet three"' do
fill_in "project_snippet_title", :with => "Snippet three" fill_in "project_snippet_title", with: "Snippet three"
fill_in "project_snippet_file_name", :with => "my_snippet.rb" fill_in "project_snippet_file_name", with: "my_snippet.rb"
page.within('.file-editor') do page.within('.file-editor') do
find(:xpath, "//input[@id='project_snippet_content']").set 'Content of snippet three' find(:xpath, "//input[@id='project_snippet_content']").set 'Content of snippet three'
end end
...@@ -66,7 +66,7 @@ class Spinach::Features::ProjectSnippets < Spinach::FeatureSteps ...@@ -66,7 +66,7 @@ class Spinach::Features::ProjectSnippets < Spinach::FeatureSteps
end end
step 'I submit new title "Snippet new title"' do step 'I submit new title "Snippet new title"' do
fill_in "project_snippet_title", :with => "Snippet new title" fill_in "project_snippet_title", with: "Snippet new title"
click_button "Save" click_button "Save"
end end
......
...@@ -9,4 +9,3 @@ module SharedAdmin ...@@ -9,4 +9,3 @@ module SharedAdmin
2.times { create(:user) } 2.times { create(:user) }
end end
end end
...@@ -2,7 +2,7 @@ module SharedIssuable ...@@ -2,7 +2,7 @@ module SharedIssuable
include Spinach::DSL include Spinach::DSL
def edit_issuable def edit_issuable
find(:css, '.issuable-edit').click find(:css, '.issuable-edit').click
end end
step 'I click link "Edit" for the merge request' do step 'I click link "Edit" for the merge request' do
......
...@@ -20,43 +20,43 @@ module SharedPaths ...@@ -20,43 +20,43 @@ module SharedPaths
# ---------------------------------------- # ----------------------------------------
step 'I visit group "Owned" page' do step 'I visit group "Owned" page' do
visit group_path(Group.find_by(name:"Owned")) visit group_path(Group.find_by(name: "Owned"))
end end
step 'I visit group "Owned" issues page' do step 'I visit group "Owned" issues page' do
visit issues_group_path(Group.find_by(name:"Owned")) visit issues_group_path(Group.find_by(name: "Owned"))
end end
step 'I visit group "Owned" merge requests page' do step 'I visit group "Owned" merge requests page' do
visit merge_requests_group_path(Group.find_by(name:"Owned")) visit merge_requests_group_path(Group.find_by(name: "Owned"))
end end
step 'I visit group "Owned" members page' do step 'I visit group "Owned" members page' do
visit group_group_members_path(Group.find_by(name:"Owned")) visit group_group_members_path(Group.find_by(name: "Owned"))
end end
step 'I visit group "Owned" settings page' do step 'I visit group "Owned" settings page' do
visit edit_group_path(Group.find_by(name:"Owned")) visit edit_group_path(Group.find_by(name: "Owned"))
end end
step 'I visit group "Guest" page' do step 'I visit group "Guest" page' do
visit group_path(Group.find_by(name:"Guest")) visit group_path(Group.find_by(name: "Guest"))
end end
step 'I visit group "Guest" issues page' do step 'I visit group "Guest" issues page' do
visit issues_group_path(Group.find_by(name:"Guest")) visit issues_group_path(Group.find_by(name: "Guest"))
end end
step 'I visit group "Guest" merge requests page' do step 'I visit group "Guest" merge requests page' do
visit merge_requests_group_path(Group.find_by(name:"Guest")) visit merge_requests_group_path(Group.find_by(name: "Guest"))
end end
step 'I visit group "Guest" members page' do step 'I visit group "Guest" members page' do
visit group_group_members_path(Group.find_by(name:"Guest")) visit group_group_members_path(Group.find_by(name: "Guest"))
end end
step 'I visit group "Guest" settings page' do step 'I visit group "Guest" settings page' do
visit edit_group_path(Group.find_by(name:"Guest")) visit edit_group_path(Group.find_by(name: "Guest"))
end end
# ---------------------------------------- # ----------------------------------------
...@@ -201,11 +201,11 @@ module SharedPaths ...@@ -201,11 +201,11 @@ module SharedPaths
end end
step "I visit my project's commits page" do step "I visit my project's commits page" do
visit namespace_project_commits_path(@project.namespace, @project, root_ref, {limit: 5}) visit namespace_project_commits_path(@project.namespace, @project, root_ref, { limit: 5 })
end end
step "I visit my project's commits page for a specific path" do step "I visit my project's commits page for a specific path" do
visit namespace_project_commits_path(@project.namespace, @project, root_ref + "/app/models/project.rb", {limit: 5}) visit namespace_project_commits_path(@project.namespace, @project, root_ref + "/app/models/project.rb", { limit: 5 })
end end
step 'I visit my project\'s commits stats page' do step 'I visit my project\'s commits stats page' do
...@@ -272,11 +272,11 @@ module SharedPaths ...@@ -272,11 +272,11 @@ module SharedPaths
end end
step 'I visit project commits page' do step 'I visit project commits page' do
visit namespace_project_commits_path(@project.namespace, @project, root_ref, {limit: 5}) visit namespace_project_commits_path(@project.namespace, @project, root_ref, { limit: 5 })
end end
step 'I visit project commits page for stable branch' do step 'I visit project commits page for stable branch' do
visit namespace_project_commits_path(@project.namespace, @project, 'stable', {limit: 5}) visit namespace_project_commits_path(@project.namespace, @project, 'stable', { limit: 5 })
end end
step 'I visit project source page' do step 'I visit project source page' do
...@@ -418,13 +418,13 @@ module SharedPaths ...@@ -418,13 +418,13 @@ module SharedPaths
visit explore_projects_path visit explore_projects_path
end end
step 'I visit the explore trending projects' do step 'I visit the explore trending projects' do
visit trending_explore_projects_path visit trending_explore_projects_path
end end
step 'I visit the explore starred projects' do step 'I visit the explore starred projects' do
visit starred_explore_projects_path visit starred_explore_projects_path
end end
step 'I visit the public groups area' do step 'I visit the public groups area' do
visit explore_groups_path visit explore_groups_path
......
...@@ -2,16 +2,16 @@ module SharedUser ...@@ -2,16 +2,16 @@ module SharedUser
include Spinach::DSL include Spinach::DSL
step 'User "John Doe" exists' do step 'User "John Doe" exists' do
user_exists("John Doe", {username: "john_doe"}) user_exists("John Doe", { username: "john_doe" })
end end
step 'User "Mary Jane" exists' do step 'User "Mary Jane" exists' do
user_exists("Mary Jane", {username: "mary_jane"}) user_exists("Mary Jane", { username: "mary_jane" })
end end
protected protected
def user_exists(name, options = {}) def user_exists(name, options = {})
User.find_by(name: name) || create(:user, {name: name, admin: false}.merge(options)) User.find_by(name: name) || create(:user, { name: name, admin: false }.merge(options))
end end
end end
...@@ -23,8 +23,8 @@ class Spinach::Features::Snippets < Spinach::FeatureSteps ...@@ -23,8 +23,8 @@ class Spinach::Features::Snippets < Spinach::FeatureSteps
end end
step 'I submit new snippet "Personal snippet three"' do step 'I submit new snippet "Personal snippet three"' do
fill_in "personal_snippet_title", :with => "Personal snippet three" fill_in "personal_snippet_title", with: "Personal snippet three"
fill_in "personal_snippet_file_name", :with => "my_snippet.rb" fill_in "personal_snippet_file_name", with: "my_snippet.rb"
page.within('.file-editor') do page.within('.file-editor') do
find(:xpath, "//input[@id='personal_snippet_content']").set 'Content of snippet three' find(:xpath, "//input[@id='personal_snippet_content']").set 'Content of snippet three'
end end
...@@ -32,12 +32,12 @@ class Spinach::Features::Snippets < Spinach::FeatureSteps ...@@ -32,12 +32,12 @@ class Spinach::Features::Snippets < Spinach::FeatureSteps
end end
step 'I submit new internal snippet' do step 'I submit new internal snippet' do
fill_in "personal_snippet_title", :with => "Internal personal snippet one" fill_in "personal_snippet_title", with: "Internal personal snippet one"
fill_in "personal_snippet_file_name", :with => "my_snippet.rb" fill_in "personal_snippet_file_name", with: "my_snippet.rb"
choose 'personal_snippet_visibility_level_10' choose 'personal_snippet_visibility_level_10'
page.within('.file-editor') do page.within('.file-editor') do
find(:xpath, "//input[@id='personal_snippet_content']").set 'Content of internal snippet' find(:xpath, "//input[@id='personal_snippet_content']").set 'Content of internal snippet'
end end
click_button "Create snippet" click_button "Create snippet"
...@@ -49,7 +49,7 @@ class Spinach::Features::Snippets < Spinach::FeatureSteps ...@@ -49,7 +49,7 @@ class Spinach::Features::Snippets < Spinach::FeatureSteps
end end
step 'I submit new title "Personal snippet new title"' do step 'I submit new title "Personal snippet new title"' do
fill_in "personal_snippet_title", :with => "Personal snippet new title" fill_in "personal_snippet_title", with: "Personal snippet new title"
click_button "Save" click_button "Save"
end end
......
...@@ -18,8 +18,10 @@ describe Projects::BlobController do ...@@ -18,8 +18,10 @@ describe Projects::BlobController do
render_views render_views
before do before do
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: id) namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: id)
end end
context "valid branch, valid file" do context "valid branch, valid file" do
...@@ -42,8 +44,10 @@ describe Projects::BlobController do ...@@ -42,8 +44,10 @@ describe Projects::BlobController do
render_views render_views
before do before do
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: id) namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: id)
controller.instance_variable_set(:@blob, nil) controller.instance_variable_set(:@blob, nil)
end end
......
...@@ -17,13 +17,13 @@ describe Projects::BranchesController do ...@@ -17,13 +17,13 @@ describe Projects::BranchesController do
describe "POST create" do describe "POST create" do
render_views render_views
before { before do
post :create, post :create,
namespace_id: project.namespace.to_param, namespace_id: project.namespace.to_param,
project_id: project.to_param, project_id: project.to_param,
branch_name: branch, branch_name: branch,
ref: ref ref: ref
} end
context "valid branch name, valid source" do context "valid branch name, valid source" do
let(:branch) { "merge_branch" } let(:branch) { "merge_branch" }
......
...@@ -13,8 +13,11 @@ describe Projects::CommitController do ...@@ -13,8 +13,11 @@ describe Projects::CommitController do
describe "#show" do describe "#show" do
shared_examples "export as" do |format| shared_examples "export as" do |format|
it "should generally work" do it "should generally work" do
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: commit.id, format: format) namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: commit.id,
format: format)
expect(response).to be_success expect(response).to be_success
end end
...@@ -22,13 +25,17 @@ describe Projects::CommitController do ...@@ -22,13 +25,17 @@ describe Projects::CommitController do
it "should generate it" do it "should generate it" do
expect_any_instance_of(Commit).to receive(:"to_#{format}") expect_any_instance_of(Commit).to receive(:"to_#{format}")
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: commit.id, format: format) namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: commit.id, format: format)
end end
it "should render it" do it "should render it" do
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: commit.id, format: format) 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}")) expect(response.body).to eq(commit.send(:"to_#{format}"))
end end
...@@ -37,8 +44,10 @@ describe Projects::CommitController do ...@@ -37,8 +44,10 @@ describe Projects::CommitController do
allow_any_instance_of(Commit).to receive(:"to_#{format}"). allow_any_instance_of(Commit).to receive(:"to_#{format}").
and_return('HTML entities &<>" ') and_return('HTML entities &<>" ')
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: commit.id, format: format) namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: commit.id, format: format)
expect(response.body).not_to include('&amp;') expect(response.body).not_to include('&amp;')
expect(response.body).not_to include('&gt;') expect(response.body).not_to include('&gt;')
...@@ -52,8 +61,11 @@ describe Projects::CommitController do ...@@ -52,8 +61,11 @@ describe Projects::CommitController do
let(:format) { :diff } let(:format) { :diff }
it "should really only be a git diff" do it "should really only be a git diff" do
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: commit.id, format: format) namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: commit.id,
format: format)
expect(response.body).to start_with("diff --git") expect(response.body).to start_with("diff --git")
end end
...@@ -64,15 +76,21 @@ describe Projects::CommitController do ...@@ -64,15 +76,21 @@ describe Projects::CommitController do
let(:format) { :patch } let(:format) { :patch }
it "should really be a git email patch" do it "should really be a git email patch" do
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: commit.id, format: format) 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}") expect(response.body).to start_with("From #{commit.id}")
end end
it "should contain a git diff" do it "should contain a git diff" do
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: commit.id, format: format) namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: commit.id,
format: format)
expect(response.body).to match(/^diff --git/) expect(response.body).to match(/^diff --git/)
end end
...@@ -81,8 +99,10 @@ describe Projects::CommitController do ...@@ -81,8 +99,10 @@ describe Projects::CommitController do
describe "#branches" do describe "#branches" do
it "contains branch and tags information" do it "contains branch and tags information" do
get(:branches, namespace_id: project.namespace.to_param, get(:branches,
project_id: project.to_param, id: commit.id) namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: commit.id)
expect(assigns(:branches)).to include("master", "feature_conflict") expect(assigns(:branches)).to include("master", "feature_conflict")
expect(assigns(:tags)).to include("v1.1.0") expect(assigns(:tags)).to include("v1.1.0")
......
...@@ -12,8 +12,11 @@ describe Projects::CommitsController do ...@@ -12,8 +12,11 @@ describe Projects::CommitsController do
describe "GET show" do describe "GET show" do
context "as atom feed" do context "as atom feed" do
it "should render as atom" do it "should render as atom" do
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: "master", format: "atom") namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: "master",
format: "atom")
expect(response).to be_success expect(response).to be_success
expect(response.content_type).to eq('application/atom+xml') expect(response.content_type).to eq('application/atom+xml')
end end
......
...@@ -35,8 +35,10 @@ describe HelpController do ...@@ -35,8 +35,10 @@ describe HelpController do
context 'for image formats' do context 'for image formats' do
context 'when requested file exists' do context 'when requested file exists' do
it 'renders the raw file' do it 'renders the raw file' do
get :show, category: 'workflow/protected_branches', get :show,
file: 'protected_branches1', format: :png category: 'workflow/protected_branches',
file: 'protected_branches1',
format: :png
expect(response).to be_success expect(response).to be_success
expect(response.content_type).to eq 'image/png' expect(response.content_type).to eq 'image/png'
expect(response.headers['Content-Disposition']).to match(/^inline;/) expect(response.headers['Content-Disposition']).to match(/^inline;/)
...@@ -45,7 +47,10 @@ describe HelpController do ...@@ -45,7 +47,10 @@ describe HelpController do
context 'when requested file is missing' do context 'when requested file is missing' do
it 'renders not found' 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 expect(response).to be_not_found
end end
end end
...@@ -53,7 +58,10 @@ describe HelpController do ...@@ -53,7 +58,10 @@ describe HelpController do
context 'for other formats' do context 'for other formats' do
it 'always renders not found' 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 expect(response).to be_not_found
end end
end end
......
...@@ -61,20 +61,13 @@ describe Import::BitbucketController do ...@@ -61,20 +61,13 @@ describe Import::BitbucketController do
describe "POST create" do describe "POST create" do
let(:bitbucket_username) { user.username } let(:bitbucket_username) { user.username }
let(:bitbucket_user) { let(:bitbucket_user) do
{ { user: { username: bitbucket_username } }.with_indifferent_access
user: { end
username: bitbucket_username
} let(:bitbucket_repo) do
}.with_indifferent_access { slug: "vim", owner: bitbucket_username }.with_indifferent_access
} end
let(:bitbucket_repo) {
{
slug: "vim",
owner: bitbucket_username
}.with_indifferent_access
}
before do before do
allow(Gitlab::BitbucketImport::KeyAdder). allow(Gitlab::BitbucketImport::KeyAdder).
......
...@@ -55,14 +55,14 @@ describe Import::GithubController do ...@@ -55,14 +55,14 @@ describe Import::GithubController do
describe "POST create" do describe "POST create" do
let(:github_username) { user.username } let(:github_username) { user.username }
let(:github_user) { OpenStruct.new(login: github_username) }
let(:github_user) { let(:github_repo) do
OpenStruct.new(login: github_username) OpenStruct.new(
} name: 'vim',
full_name: "#{github_username}/vim",
let(:github_repo) { owner: OpenStruct.new(login: github_username)
OpenStruct.new(name: 'vim', full_name: "#{github_username}/vim", owner: OpenStruct.new(login: github_username)) )
} end
before do before do
stub_client(user: github_user, repo: github_repo) stub_client(user: github_user, repo: github_repo)
......
...@@ -53,21 +53,17 @@ describe Import::GitlabController do ...@@ -53,21 +53,17 @@ describe Import::GitlabController do
describe "POST create" do describe "POST create" do
let(:gitlab_username) { user.username } let(:gitlab_username) { user.username }
let(:gitlab_user) do
let(:gitlab_user) { { username: gitlab_username }.with_indifferent_access
{ end
username: gitlab_username let(:gitlab_repo) do
}.with_indifferent_access
}
let(:gitlab_repo) {
{ {
path: 'vim', path: 'vim',
path_with_namespace: "#{gitlab_username}/vim", path_with_namespace: "#{gitlab_username}/vim",
owner: { name: gitlab_username }, owner: { name: gitlab_username },
namespace: { path: gitlab_username } namespace: { path: gitlab_username }
}.with_indifferent_access }.with_indifferent_access
} end
before do before do
stub_client(user: gitlab_user, project: gitlab_repo) stub_client(user: gitlab_user, project: gitlab_repo)
......
...@@ -63,7 +63,7 @@ describe Profiles::PreferencesController do ...@@ -63,7 +63,7 @@ describe Profiles::PreferencesController do
context 'on invalid dashboard setting' do context 'on invalid dashboard setting' do
it 'sets the flash' do it 'sets the flash' do
prefs = {dashboard: 'invalid'} prefs = { dashboard: 'invalid' }
go params: prefs go params: prefs
......
...@@ -12,8 +12,11 @@ describe Projects::CompareController do ...@@ -12,8 +12,11 @@ describe Projects::CompareController do
end end
it 'compare should show some diffs' do it 'compare should show some diffs' do
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, from: ref_from, to: ref_to) namespace_id: project.namespace.to_param,
project_id: project.to_param,
from: ref_from,
to: ref_to)
expect(response).to be_success expect(response).to be_success
expect(assigns(:diffs).length).to be >= 1 expect(assigns(:diffs).length).to be >= 1
......
...@@ -13,8 +13,11 @@ describe Projects::MergeRequestsController do ...@@ -13,8 +13,11 @@ describe Projects::MergeRequestsController do
describe "#show" do describe "#show" do
shared_examples "export merge as" do |format| shared_examples "export merge as" do |format|
it "should generally work" do it "should generally work" do
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: merge_request.iid, format: format) namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: merge_request.iid,
format: format)
expect(response).to be_success expect(response).to be_success
end end
...@@ -22,13 +25,19 @@ describe Projects::MergeRequestsController do ...@@ -22,13 +25,19 @@ describe Projects::MergeRequestsController do
it "should generate it" do it "should generate it" do
expect_any_instance_of(MergeRequest).to receive(:"to_#{format}") expect_any_instance_of(MergeRequest).to receive(:"to_#{format}")
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: merge_request.iid, format: format) namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: merge_request.iid,
format: format)
end end
it "should render it" do it "should render it" do
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: merge_request.iid, format: format) 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) expect(response.body).to eq((merge_request.send(:"to_#{format}",user)).to_s)
end end
...@@ -37,8 +46,11 @@ describe Projects::MergeRequestsController do ...@@ -37,8 +46,11 @@ describe Projects::MergeRequestsController do
allow_any_instance_of(MergeRequest).to receive(:"to_#{format}"). allow_any_instance_of(MergeRequest).to receive(:"to_#{format}").
and_return('HTML entities &<>" ') and_return('HTML entities &<>" ')
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: merge_request.iid, format: format) namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: merge_request.iid,
format: format)
expect(response.body).not_to include('&amp;') expect(response.body).not_to include('&amp;')
expect(response.body).not_to include('&gt;') expect(response.body).not_to include('&gt;')
...@@ -52,8 +64,11 @@ describe Projects::MergeRequestsController do ...@@ -52,8 +64,11 @@ describe Projects::MergeRequestsController do
let(:format) { :diff } let(:format) { :diff }
it "should really only be a git diff" do it "should really only be a git diff" do
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: merge_request.iid, format: format) 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") expect(response.body).to start_with("diff --git")
end end
...@@ -64,15 +79,20 @@ describe Projects::MergeRequestsController do ...@@ -64,15 +79,20 @@ describe Projects::MergeRequestsController do
let(:format) { :patch } let(:format) { :patch }
it "should really be a git email patch with commit" do it "should really be a git email patch with commit" do
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: merge_request.iid, format: format) 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}") expect(response.body[0..100]).to start_with("From #{merge_request.commits.last.id}")
end end
it "should contain git diffs" do it "should contain git diffs" do
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: merge_request.iid, format: format) namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: merge_request.iid,
format: format)
expect(response.body).to match(/^diff --git/) expect(response.body).to match(/^diff --git/)
end end
...@@ -81,8 +101,11 @@ describe Projects::MergeRequestsController do ...@@ -81,8 +101,11 @@ describe Projects::MergeRequestsController do
describe 'GET diffs' do describe 'GET diffs' do
def go(format: 'html') def go(format: 'html')
get :diffs, namespace_id: project.namespace.to_param, get :diffs,
project_id: project.to_param, id: merge_request.iid, format: format namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: merge_request.iid,
format: format
end end
context 'as html' do context 'as html' do
...@@ -126,8 +149,11 @@ describe Projects::MergeRequestsController do ...@@ -126,8 +149,11 @@ describe Projects::MergeRequestsController do
describe 'GET commits' do describe 'GET commits' do
def go(format: 'html') def go(format: 'html')
get :commits, namespace_id: project.namespace.to_param, get :commits,
project_id: project.to_param, id: merge_request.iid, format: format namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: merge_request.iid,
format: format
end end
context 'as html' do context 'as html' do
......
...@@ -11,15 +11,20 @@ describe Projects::RefsController do ...@@ -11,15 +11,20 @@ describe Projects::RefsController do
describe 'GET #logs_tree' do describe 'GET #logs_tree' do
def default_get(format = :html) def default_get(format = :html)
get :logs_tree, namespace_id: project.namespace.to_param, get :logs_tree,
project_id: project.to_param, id: 'master', namespace_id: project.namespace.to_param,
path: 'foo/bar/baz.html', format: format project_id: project.to_param,
id: 'master',
path: 'foo/bar/baz.html',
format: format
end end
def xhr_get(format = :html) def xhr_get(format = :html)
xhr :get, :logs_tree, namespace_id: project.namespace.to_param, xhr :get,
project_id: project.to_param, id: 'master', :logs_tree,
path: 'foo/bar/baz.html', format: format namespace_id: project.namespace.to_param,
project_id: project.to_param, id: 'master',
path: 'foo/bar/baz.html', format: format
end end
it 'never throws MissingTemplate' do it 'never throws MissingTemplate' do
......
...@@ -16,30 +16,34 @@ describe ProjectsController do ...@@ -16,30 +16,34 @@ describe ProjectsController do
get :show, "go-get" => "1", namespace_id: "bogus_namespace", id: "bogus_project" get :show, "go-get" => "1", namespace_id: "bogus_namespace", id: "bogus_project"
expect(response.body).to include("name='go-import'") expect(response.body).to include("name='go-import'")
content = "localhost/bogus_namespace/bogus_project git http://localhost/bogus_namespace/bogus_project.git" content = "localhost/bogus_namespace/bogus_project git http://localhost/bogus_namespace/bogus_project.git"
expect(response.body).to include("content='#{content}'") expect(response.body).to include("content='#{content}'")
end end
end end
end end
describe "POST #toggle_star" do describe "POST #toggle_star" do
it "toggles star if user is signed in" do it "toggles star if user is signed in" do
sign_in(user) sign_in(user)
expect(user.starred?(public_project)).to be_falsey 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) id: public_project.to_param)
expect(user.starred?(public_project)).to be_truthy 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) id: public_project.to_param)
expect(user.starred?(public_project)).to be_falsey expect(user.starred?(public_project)).to be_falsey
end end
it "does nothing if user is not signed in" do 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) id: public_project.to_param)
expect(user.starred?(public_project)).to be_falsey 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) id: public_project.to_param)
expect(user.starred?(public_project)).to be_falsey expect(user.starred?(public_project)).to be_falsey
end end
......
...@@ -19,8 +19,10 @@ describe Projects::TreeController do ...@@ -19,8 +19,10 @@ describe Projects::TreeController do
render_views render_views
before do before do
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: id) namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: id)
end end
context "valid branch, no path" do context "valid branch, no path" do
...@@ -48,8 +50,10 @@ describe Projects::TreeController do ...@@ -48,8 +50,10 @@ describe Projects::TreeController do
render_views render_views
before do before do
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: id) namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: id)
end end
context 'redirect to blob' do context 'redirect to blob' do
......
...@@ -28,7 +28,7 @@ FactoryGirl.define do ...@@ -28,7 +28,7 @@ FactoryGirl.define do
source_project factory: :project source_project factory: :project
target_project { source_project } target_project { source_project }
# git log --pretty=oneline feature..master # $ git log --pretty=oneline feature..master
# 5937ac0a7beb003549fc5fd26fc247adbce4a52e Add submodule from gitlab.com # 5937ac0a7beb003549fc5fd26fc247adbce4a52e Add submodule from gitlab.com
# 570e7b2abdd848b95f2f578043fc23bd6f6fd24d Change some files # 570e7b2abdd848b95f2f578043fc23bd6f6fd24d Change some files
# 6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9 More submodules # 6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9 More submodules
......
...@@ -14,17 +14,24 @@ describe "User Feed", feature: true do ...@@ -14,17 +14,24 @@ describe "User Feed", feature: true do
context 'feed content' do context 'feed content' do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:issue) do let(:issue) do
create(:issue, project: project, create(:issue,
author: user, description: "Houston, we have a bug!\n\n***\n\nI guess.") project: project,
author: user,
description: "Houston, we have a bug!\n\n***\n\nI guess.")
end end
let(:note) do let(:note) do
create(:note, noteable: issue, author: user, create(:note,
note: 'Bug confirmed :+1:', project: project) noteable: issue,
author: user,
note: 'Bug confirmed :+1:',
project: project)
end end
let(:merge_request) do let(:merge_request) do
create(:merge_request, create(:merge_request,
title: 'Fix bug', author: user, title: 'Fix bug',
source_project: project, target_project: project, author: user,
source_project: project,
target_project: project,
description: "Here is the fix: ![an image](image.png)") description: "Here is the fix: ![an image](image.png)")
end end
......
...@@ -36,9 +36,7 @@ describe 'Issues', feature: true do ...@@ -36,9 +36,7 @@ describe 'Issues', feature: true do
end end
it 'does not change issue count' do it 'does not change issue count' do
expect { expect { click_button 'Save changes' }.to_not change { Issue.count }
click_button 'Save changes'
}.not_to change { Issue.count }
end end
it 'should update issue fields' do it 'should update issue fields' do
...@@ -295,7 +293,7 @@ describe 'Issues', feature: true do ...@@ -295,7 +293,7 @@ describe 'Issues', feature: true do
issue.save issue.save
end end
it 'allows user to remove assignee', :js => true do it 'allows user to remove assignee', js: true do
visit namespace_project_issue_path(project.namespace, project, issue) visit namespace_project_issue_path(project.namespace, project, issue)
expect(page).to have_content "Assignee: #{user2.name}" expect(page).to have_content "Assignee: #{user2.name}"
......
...@@ -86,13 +86,13 @@ describe 'Comments' do ...@@ -86,13 +86,13 @@ describe 'Comments' do
end end
# TODO: fix after 7.7 release # TODO: fix after 7.7 release
#it "should reset the edit note form textarea with the original content of the note if cancelled" do # it "should reset the edit note form textarea with the original content of the note if cancelled" do
#within(".current-note-edit-form") do # within(".current-note-edit-form") do
#fill_in "note[note]", with: "Some new content" # fill_in "note[note]", with: "Some new content"
#find(".btn-cancel").click # find(".btn-cancel").click
#expect(find(".js-note-text", visible: false).text).to eq note.note # expect(find(".js-note-text", visible: false).text).to eq note.note
#end # end
#end # end
it 'appends the edited at time to the note' do it 'appends the edited at time to the note' do
page.within('.current-note-edit-form') do page.within('.current-note-edit-form') do
......
...@@ -17,4 +17,3 @@ describe "Search", feature: true do ...@@ -17,4 +17,3 @@ describe "Search", feature: true do
expect(page).to have_content @project.name expect(page).to have_content @project.name
end end
end end
...@@ -17,4 +17,4 @@ describe OauthHelper do ...@@ -17,4 +17,4 @@ describe OauthHelper do
expect(helper.additional_providers).to eq([]) expect(helper.additional_providers).to eq([])
end end
end end
end end
\ No newline at end of file
...@@ -61,7 +61,7 @@ describe PreferencesHelper do ...@@ -61,7 +61,7 @@ describe PreferencesHelper do
(1..5).each do |color_scheme_id| (1..5).each do |color_scheme_id|
context "with color_scheme_id == #{color_scheme_id}" do context "with color_scheme_id == #{color_scheme_id}" do
it 'should return a string' do it 'should return a string' do
current_user = double(:color_scheme_id => color_scheme_id) current_user = double(color_scheme_id: color_scheme_id)
allow(self).to receive(:current_user).and_return(current_user) allow(self).to receive(:current_user).and_return(current_user)
expect(user_color_scheme_class).to be_kind_of(String) expect(user_color_scheme_class).to be_kind_of(String)
end end
......
...@@ -37,8 +37,8 @@ describe TabHelper do ...@@ -37,8 +37,8 @@ describe TabHelper do
end end
it "passes extra html options to the list element" do it "passes extra html options to the list element" do
expect(nav_link(action: :foo, html_options: {class: 'home'})).to match(/<li class="home active">/) expect(nav_link(action: :foo, html_options: { class: 'home' })).to match(/<li class="home active">/)
expect(nav_link(html_options: {class: 'active'})).to match(/<li class="active">/) expect(nav_link(html_options: { class: 'active' })).to match(/<li class="active">/)
end end
end end
end end
...@@ -4,10 +4,10 @@ describe TreeHelper do ...@@ -4,10 +4,10 @@ describe TreeHelper do
describe 'flatten_tree' do describe 'flatten_tree' do
let(:project) { create(:project) } let(:project) { create(:project) }
before { before do
@repository = project.repository @repository = project.repository
@commit = project.commit("e56497bb") @commit = project.commit("e56497bb")
} end
context "on a directory containing more than one file/directory" do context "on a directory containing more than one file/directory" do
let(:tree_item) { double(name: "files", path: "files") } let(:tree_item) { double(name: "files", path: "files") }
......
...@@ -7,9 +7,7 @@ describe DisableEmailInterceptor do ...@@ -7,9 +7,7 @@ describe DisableEmailInterceptor do
it 'should not send emails' do it 'should not send emails' do
allow(Gitlab.config.gitlab).to receive(:email_enabled).and_return(false) allow(Gitlab.config.gitlab).to receive(:email_enabled).and_return(false)
expect { expect { deliver_mail }.not_to change(ActionMailer::Base.deliveries, :count)
deliver_mail
}.not_to change(ActionMailer::Base.deliveries, :count)
end end
after do after do
......
...@@ -18,7 +18,7 @@ describe ExtractsPath do ...@@ -18,7 +18,7 @@ describe ExtractsPath do
describe '#assign_ref' do describe '#assign_ref' do
let(:ref) { sample_commit[:id] } let(:ref) { sample_commit[:id] }
let(:params) { {path: sample_commit[:line_code_path], ref: ref} } let(:params) { { path: sample_commit[:line_code_path], ref: ref } }
before do before do
@project = create(:project) @project = create(:project)
......
...@@ -9,9 +9,9 @@ describe 'Gitlab::FileSizeValidatorSpec' do ...@@ -9,9 +9,9 @@ describe 'Gitlab::FileSizeValidatorSpec' do
let(:options) { { maximum: 10, attributes: { attachment: attachment } } } let(:options) { { maximum: 10, attributes: { attachment: attachment } } }
it 'attachment exceeds maximum limit' do it 'attachment exceeds maximum limit' do
allow(attachment).to receive(:size) { 100 } allow(attachment).to receive(:size) { 100 }
validator.validate_each(note, :attachment, attachment) validator.validate_each(note, :attachment, attachment)
expect(note.errors).to have_key(:attachment) expect(note.errors).to have_key(:attachment)
end end
it 'attachment under maximum limit' do it 'attachment under maximum limit' do
...@@ -22,8 +22,13 @@ describe 'Gitlab::FileSizeValidatorSpec' do ...@@ -22,8 +22,13 @@ describe 'Gitlab::FileSizeValidatorSpec' do
end end
describe 'options uses a symbol' do describe 'options uses a symbol' do
let(:options) { { maximum: :test, let(:options) do
attributes: { attachment: attachment } } } {
maximum: :test,
attributes: { attachment: attachment }
}
end
before do before do
allow(note).to receive(:test) { 10 } allow(note).to receive(:test) { 10 }
end end
......
...@@ -11,8 +11,11 @@ module Gitlab ...@@ -11,8 +11,11 @@ module Gitlab
context "without project" do context "without project" do
it "should convert the input using Asciidoctor and default options" do it "should convert the input using Asciidoctor and default options" do
expected_asciidoc_opts = { safe: :secure, backend: :html5, expected_asciidoc_opts = {
attributes: described_class::DEFAULT_ADOC_ATTRS } safe: :secure,
backend: :html5,
attributes: described_class::DEFAULT_ADOC_ATTRS
}
expect(Asciidoctor).to receive(:convert) expect(Asciidoctor).to receive(:convert)
.with(input, expected_asciidoc_opts).and_return(html) .with(input, expected_asciidoc_opts).and_return(html)
...@@ -22,11 +25,14 @@ module Gitlab ...@@ -22,11 +25,14 @@ module Gitlab
context "with asciidoc_opts" do context "with asciidoc_opts" do
let(:asciidoc_opts) { {safe: :safe, attributes: ['foo']} } let(:asciidoc_opts) { { safe: :safe, attributes: ['foo'] } }
it "should merge the options with default ones" do it "should merge the options with default ones" do
expected_asciidoc_opts = { safe: :safe, backend: :html5, expected_asciidoc_opts = {
attributes: described_class::DEFAULT_ADOC_ATTRS + ['foo'] } safe: :safe,
backend: :html5,
attributes: described_class::DEFAULT_ADOC_ATTRS + ['foo']
}
expect(Asciidoctor).to receive(:convert) expect(Asciidoctor).to receive(:convert)
.with(input, expected_asciidoc_opts).and_return(html) .with(input, expected_asciidoc_opts).and_return(html)
...@@ -38,7 +44,7 @@ module Gitlab ...@@ -38,7 +44,7 @@ module Gitlab
context "with project in context" do context "with project in context" do
let(:context) { {project: create(:project)} } let(:context) { { project: create(:project) } }
it "should filter converted input via HTML pipeline and return result" do it "should filter converted input via HTML pipeline and return result" do
filtered_html = '<b>ASCII</b>' filtered_html = '<b>ASCII</b>'
......
...@@ -6,13 +6,13 @@ describe Grack::Auth do ...@@ -6,13 +6,13 @@ describe Grack::Auth do
let(:app) { lambda { |env| [200, {}, "Success!"] } } let(:app) { lambda { |env| [200, {}, "Success!"] } }
let!(:auth) { Grack::Auth.new(app) } let!(:auth) { Grack::Auth.new(app) }
let(:env) { let(:env) do
{ {
"rack.input" => "", 'rack.input' => '',
"REQUEST_METHOD" => "GET", 'REQUEST_METHOD' => 'GET',
"QUERY_STRING" => "service=git-upload-pack" 'QUERY_STRING' => 'service=git-upload-pack'
} }
} end
let(:status) { auth.call(env).first } let(:status) { auth.call(env).first }
describe "#call" do describe "#call" do
...@@ -121,7 +121,7 @@ describe Grack::Auth do ...@@ -121,7 +121,7 @@ describe Grack::Auth do
context "when the user isn't blocked" do context "when the user isn't blocked" do
before do before do
expect(Rack::Attack::Allow2Ban).to receive(:reset) expect(Rack::Attack::Allow2Ban).to receive(:reset)
end end
it "responds with status 200" do it "responds with status 200" do
......
...@@ -2,24 +2,26 @@ require 'spec_helper' ...@@ -2,24 +2,26 @@ require 'spec_helper'
describe Gitlab::BitbucketImport::ProjectCreator do describe Gitlab::BitbucketImport::ProjectCreator do
let(:user) { create(:user, bitbucket_access_token: "asdffg", bitbucket_access_token_secret: "sekret") } let(:user) { create(:user, bitbucket_access_token: "asdffg", bitbucket_access_token_secret: "sekret") }
let(:repo) { { let(:repo) do
name: 'Vim', {
slug: 'vim', name: 'Vim',
is_private: true, slug: 'vim',
owner: "asd"}.with_indifferent_access is_private: true,
} owner: "asd"
}.with_indifferent_access
end
let(:namespace){ create(:group, owner: user) } let(:namespace){ create(:group, owner: user) }
before do before do
namespace.add_owner(user) namespace.add_owner(user)
end end
it 'creates project' do it 'creates project' do
allow_any_instance_of(Project).to receive(:add_import_job) allow_any_instance_of(Project).to receive(:add_import_job)
project_creator = Gitlab::BitbucketImport::ProjectCreator.new(repo, namespace, user) project_creator = Gitlab::BitbucketImport::ProjectCreator.new(repo, namespace, user)
project = project_creator.execute project = project_creator.execute
expect(project.import_url).to eq("ssh://git@bitbucket.org/asd/vim.git") expect(project.import_url).to eq("ssh://git@bitbucket.org/asd/vim.git")
expect(project.visibility_level).to eq(Gitlab::VisibilityLevel::PRIVATE) expect(project.visibility_level).to eq(Gitlab::VisibilityLevel::PRIVATE)
end end
......
...@@ -2,14 +2,16 @@ require 'spec_helper' ...@@ -2,14 +2,16 @@ require 'spec_helper'
describe Gitlab::GithubImport::ProjectCreator do describe Gitlab::GithubImport::ProjectCreator do
let(:user) { create(:user, github_access_token: "asdffg") } let(:user) { create(:user, github_access_token: "asdffg") }
let(:repo) { OpenStruct.new( let(:repo) do
login: 'vim', OpenStruct.new(
name: 'vim', login: 'vim',
private: true, name: 'vim',
full_name: 'asd/vim', private: true,
clone_url: "https://gitlab.com/asd/vim.git", full_name: 'asd/vim',
owner: OpenStruct.new(login: "john")) clone_url: "https://gitlab.com/asd/vim.git",
} owner: OpenStruct.new(login: "john")
)
end
let(:namespace){ create(:group, owner: user) } let(:namespace){ create(:group, owner: user) }
before do before do
...@@ -18,10 +20,10 @@ describe Gitlab::GithubImport::ProjectCreator do ...@@ -18,10 +20,10 @@ describe Gitlab::GithubImport::ProjectCreator do
it 'creates project' do it 'creates project' do
allow_any_instance_of(Project).to receive(:add_import_job) allow_any_instance_of(Project).to receive(:add_import_job)
project_creator = Gitlab::GithubImport::ProjectCreator.new(repo, namespace, user) project_creator = Gitlab::GithubImport::ProjectCreator.new(repo, namespace, user)
project = project_creator.execute project = project_creator.execute
expect(project.import_url).to eq("https://asdffg@gitlab.com/asd/vim.git") expect(project.import_url).to eq("https://asdffg@gitlab.com/asd/vim.git")
expect(project.visibility_level).to eq(Gitlab::VisibilityLevel::PRIVATE) expect(project.visibility_level).to eq(Gitlab::VisibilityLevel::PRIVATE)
end end
......
...@@ -2,14 +2,16 @@ require 'spec_helper' ...@@ -2,14 +2,16 @@ require 'spec_helper'
describe Gitlab::GitlabImport::ProjectCreator do describe Gitlab::GitlabImport::ProjectCreator do
let(:user) { create(:user, gitlab_access_token: "asdffg") } let(:user) { create(:user, gitlab_access_token: "asdffg") }
let(:repo) { { let(:repo) do
name: 'vim', {
path: 'vim', name: 'vim',
visibility_level: Gitlab::VisibilityLevel::PRIVATE, path: 'vim',
path_with_namespace: 'asd/vim', visibility_level: Gitlab::VisibilityLevel::PRIVATE,
http_url_to_repo: "https://gitlab.com/asd/vim.git", path_with_namespace: 'asd/vim',
owner: {name: "john"}}.with_indifferent_access http_url_to_repo: "https://gitlab.com/asd/vim.git",
} owner: { name: "john" }
}.with_indifferent_access
end
let(:namespace){ create(:group, owner: user) } let(:namespace){ create(:group, owner: user) }
before do before do
...@@ -18,10 +20,10 @@ describe Gitlab::GitlabImport::ProjectCreator do ...@@ -18,10 +20,10 @@ describe Gitlab::GitlabImport::ProjectCreator do
it 'creates project' do it 'creates project' do
allow_any_instance_of(Project).to receive(:add_import_job) allow_any_instance_of(Project).to receive(:add_import_job)
project_creator = Gitlab::GitlabImport::ProjectCreator.new(repo, namespace, user) project_creator = Gitlab::GitlabImport::ProjectCreator.new(repo, namespace, user)
project = project_creator.execute project = project_creator.execute
expect(project.import_url).to eq("https://oauth2:asdffg@gitlab.com/asd/vim.git") expect(project.import_url).to eq("https://oauth2:asdffg@gitlab.com/asd/vim.git")
expect(project.visibility_level).to eq(Gitlab::VisibilityLevel::PRIVATE) expect(project.visibility_level).to eq(Gitlab::VisibilityLevel::PRIVATE)
end end
......
...@@ -4,16 +4,15 @@ describe Gitlab::GoogleCodeImport::Importer do ...@@ -4,16 +4,15 @@ describe Gitlab::GoogleCodeImport::Importer do
let(:mapped_user) { create(:user, username: "thilo123") } let(:mapped_user) { create(:user, username: "thilo123") }
let(:raw_data) { JSON.parse(File.read(Rails.root.join("spec/fixtures/GoogleCodeProjectHosting.json"))) } let(:raw_data) { JSON.parse(File.read(Rails.root.join("spec/fixtures/GoogleCodeProjectHosting.json"))) }
let(:client) { Gitlab::GoogleCodeImport::Client.new(raw_data) } let(:client) { Gitlab::GoogleCodeImport::Client.new(raw_data) }
let(:import_data) { let(:import_data) do
{ {
"repo" => client.repo("tint2").raw_data, 'repo' => client.repo('tint2').raw_data,
"user_map" => { 'user_map' => { 'thilo...' => "@#{mapped_user.username}" }
"thilo..." => "@#{mapped_user.username}" }
} end
}
}
let(:project) { create(:project) } let(:project) { create(:project) }
subject { described_class.new(project) }
subject { described_class.new(project) }
before do before do
project.create_import_data(data: import_data) project.create_import_data(data: import_data)
......
...@@ -2,13 +2,13 @@ require 'spec_helper' ...@@ -2,13 +2,13 @@ require 'spec_helper'
describe Gitlab::GoogleCodeImport::ProjectCreator do describe Gitlab::GoogleCodeImport::ProjectCreator do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:repo) { let(:repo) do
Gitlab::GoogleCodeImport::Repository.new( Gitlab::GoogleCodeImport::Repository.new(
"name" => 'vim', "name" => 'vim',
"summary" => 'VI Improved', "summary" => 'VI Improved',
"repositoryUrls" => [ "https://vim.googlecode.com/git/" ] "repositoryUrls" => ["https://vim.googlecode.com/git/"]
) )
} end
let(:namespace){ create(:group, owner: user) } let(:namespace){ create(:group, owner: user) }
before do before do
...@@ -20,7 +20,7 @@ describe Gitlab::GoogleCodeImport::ProjectCreator do ...@@ -20,7 +20,7 @@ describe Gitlab::GoogleCodeImport::ProjectCreator do
project_creator = Gitlab::GoogleCodeImport::ProjectCreator.new(repo, namespace, user) project_creator = Gitlab::GoogleCodeImport::ProjectCreator.new(repo, namespace, user)
project = project_creator.execute project = project_creator.execute
expect(project.import_url).to eq("https://vim.googlecode.com/git/") expect(project.import_url).to eq("https://vim.googlecode.com/git/")
expect(project.visibility_level).to eq(Gitlab::VisibilityLevel::PUBLIC) expect(project.visibility_level).to eq(Gitlab::VisibilityLevel::PUBLIC)
end end
......
...@@ -48,7 +48,7 @@ module Gitlab::Markdown ...@@ -48,7 +48,7 @@ module Gitlab::Markdown
end end
it 'accepts link_attr options' do it 'accepts link_attr options' do
doc = filter("See #{link}", link_attr: {class: 'custom'}) doc = filter("See #{link}", link_attr: { class: 'custom' })
expect(doc.at_css('a')['class']).to eq 'custom' expect(doc.at_css('a')['class']).to eq 'custom'
end end
...@@ -89,7 +89,7 @@ module Gitlab::Markdown ...@@ -89,7 +89,7 @@ module Gitlab::Markdown
end end
it 'accepts link_attr options' do it 'accepts link_attr options' do
doc = filter("See #{link}", link_attr: {class: 'custom'}) doc = filter("See #{link}", link_attr: { class: 'custom' })
expect(doc.at_css('a')['class']).to eq 'custom' expect(doc.at_css('a')['class']).to eq 'custom'
end end
......
...@@ -127,7 +127,7 @@ module Gitlab::Markdown ...@@ -127,7 +127,7 @@ module Gitlab::Markdown
it 'gracefully handles non-references matching the pattern' do it 'gracefully handles non-references matching the pattern' do
exp = act = '(format nil "~0f" 3.0) ; 3.0' exp = act = '(format nil "~0f" 3.0) ; 3.0'
expect(filter(act).to_html).to eq exp expect(filter(act).to_html).to eq exp
end end
end end
end end
end end
...@@ -11,9 +11,9 @@ describe Gitlab::OAuth::AuthHash do ...@@ -11,9 +11,9 @@ describe Gitlab::OAuth::AuthHash do
) )
end end
let(:uid_raw) { let(:uid_raw) do
"CN=Onur K\xC3\xBC\xC3\xA7\xC3\xBCk,OU=Test,DC=example,DC=net" "CN=Onur K\xC3\xBC\xC3\xA7\xC3\xBCk,OU=Test,DC=example,DC=net"
} end
let(:email_raw) { "onur.k\xC3\xBC\xC3\xA7\xC3\xBCk@example.net" } let(:email_raw) { "onur.k\xC3\xBC\xC3\xA7\xC3\xBCk@example.net" }
let(:nickname_raw) { "ok\xC3\xBC\xC3\xA7\xC3\xBCk" } let(:nickname_raw) { "ok\xC3\xBC\xC3\xA7\xC3\xBCk" }
let(:first_name_raw) { 'Onur' } let(:first_name_raw) { 'Onur' }
...@@ -34,16 +34,16 @@ describe Gitlab::OAuth::AuthHash do ...@@ -34,16 +34,16 @@ describe Gitlab::OAuth::AuthHash do
let(:nickname_utf8) { nickname_ascii.force_encoding(Encoding::UTF_8) } let(:nickname_utf8) { nickname_ascii.force_encoding(Encoding::UTF_8) }
let(:name_utf8) { name_ascii.force_encoding(Encoding::UTF_8) } let(:name_utf8) { name_ascii.force_encoding(Encoding::UTF_8) }
let(:info_hash) { let(:info_hash) do
{ {
email: email_ascii, email: email_ascii,
first_name: first_name_ascii, first_name: first_name_ascii,
last_name: last_name_ascii, last_name: last_name_ascii,
name: name_ascii, name: name_ascii,
nickname: nickname_ascii, nickname: nickname_ascii,
uid: uid_ascii uid: uid_ascii
} }
} end
context 'defaults' do context 'defaults' do
it { expect(auth_hash.provider).to eql provider_utf8 } it { expect(auth_hash.provider).to eql provider_utf8 }
......
require 'spec_helper' require 'spec_helper'
describe 'Gitlab::Popen', no_db: true do describe 'Gitlab::Popen', no_db: true do
let (:path) { Rails.root.join('tmp').to_s } let(:path) { Rails.root.join('tmp').to_s }
before do before do
@klass = Class.new(Object) @klass = Class.new(Object)
...@@ -40,6 +40,4 @@ describe 'Gitlab::Popen', no_db: true do ...@@ -40,6 +40,4 @@ describe 'Gitlab::Popen', no_db: true do
it { expect(@status).to be_zero } it { expect(@status).to be_zero }
it { expect(@output).to include('spec') } it { expect(@output).to include('spec') }
end end
end end
...@@ -17,15 +17,13 @@ describe 'Gitlab::Satellite::Action' do ...@@ -17,15 +17,13 @@ describe 'Gitlab::Satellite::Action' do
starting_remote_count = repo.git.list_remotes.size starting_remote_count = repo.git.list_remotes.size
expect(starting_remote_count).to be >= 1 expect(starting_remote_count).to be >= 1
#kind of hookey way to add a second remote #kind of hookey way to add a second remote
origin_uri = repo.git.remote({v: true}).split(" ")[1] origin_uri = repo.git.remote({ v: true }).split(" ")[1]
begin
repo.git.remote({raise: true}, 'add', 'another-remote', origin_uri) repo.git.remote({ raise: true }, 'add', 'another-remote', origin_uri)
repo.git.branch({raise: true}, 'a-new-branch') repo.git.branch({ raise: true }, 'a-new-branch')
expect(repo.heads.size).to be > (starting_remote_count) expect(repo.heads.size).to be > (starting_remote_count)
expect(repo.git.remote().split(" ").size).to be > (starting_remote_count) expect(repo.git.remote().split(" ").size).to be > (starting_remote_count)
rescue
end
repo.git.config({}, "user.name", "#{user.name} -- foo") repo.git.config({}, "user.name", "#{user.name} -- foo")
repo.git.config({}, "user.email", "#{user.email} -- foo") repo.git.config({}, "user.email", "#{user.email} -- foo")
...@@ -35,10 +33,10 @@ describe 'Gitlab::Satellite::Action' do ...@@ -35,10 +33,10 @@ describe 'Gitlab::Satellite::Action' do
#These must happen in the context of the satellite directory... #These must happen in the context of the satellite directory...
satellite_action = Gitlab::Satellite::Action.new(user, project) satellite_action = Gitlab::Satellite::Action.new(user, project)
project.satellite.lock { project.satellite.lock do
#Now clean it up, use send to get around prepare_satellite! being protected #Now clean it up, use send to get around prepare_satellite! being protected
satellite_action.send(:prepare_satellite!, repo) satellite_action.send(:prepare_satellite!, repo)
} end
#verify it's clean #verify it's clean
heads = repo.heads.map(&:name) heads = repo.heads.map(&:name)
...@@ -100,16 +98,16 @@ describe 'Gitlab::Satellite::Action' do ...@@ -100,16 +98,16 @@ describe 'Gitlab::Satellite::Action' do
def flocked?(&block) def flocked?(&block)
status = flock LOCK_EX|LOCK_NB status = flock LOCK_EX|LOCK_NB
case status case status
when false when false
return true return true
when 0 when 0
begin begin
block ? block.call : false block ? block.call : false
ensure ensure
flock LOCK_UN flock LOCK_UN
end end
else else
raise SystemCallError, status raise SystemCallError, status
end end
end end
end end
......
...@@ -82,23 +82,23 @@ describe 'Gitlab::Satellite::MergeAction' do ...@@ -82,23 +82,23 @@ describe 'Gitlab::Satellite::MergeAction' do
describe '#can_be_merged?' do describe '#can_be_merged?' do
context 'on fork' do context 'on fork' do
it { expect(Gitlab::Satellite::MergeAction.new( it do
merge_request_fork.author, expect(Gitlab::Satellite::MergeAction.new(merge_request_fork.author, merge_request_fork).can_be_merged?).to be_truthy
merge_request_fork).can_be_merged?).to be_truthy } end
it { expect(Gitlab::Satellite::MergeAction.new( it do
merge_request_fork_with_conflict.author, expect(Gitlab::Satellite::MergeAction.new(merge_request_fork_with_conflict.author, merge_request_fork_with_conflict).can_be_merged?).to be_falsey
merge_request_fork_with_conflict).can_be_merged?).to be_falsey } end
end end
context 'between branches' do context 'between branches' do
it { expect(Gitlab::Satellite::MergeAction.new( it do
merge_request.author, expect(Gitlab::Satellite::MergeAction.new(merge_request.author, merge_request).can_be_merged?).to be_truthy
merge_request).can_be_merged?).to be_truthy } end
it { expect(Gitlab::Satellite::MergeAction.new( it do
merge_request_with_conflict.author, expect(Gitlab::Satellite::MergeAction.new(merge_request_with_conflict.author, merge_request_with_conflict).can_be_merged?).to be_falsey
merge_request_with_conflict).can_be_merged?).to be_falsey } end
end end
end end
end end
...@@ -66,4 +66,3 @@ describe 'Gitlab::VersionInfo', no_db: true do ...@@ -66,4 +66,3 @@ describe 'Gitlab::VersionInfo', no_db: true do
it { expect(@unknown.to_s).to eq("Unknown") } it { expect(@unknown.to_s).to eq("Unknown") }
end end
end end
...@@ -179,7 +179,10 @@ describe Issue, 'Votes' do ...@@ -179,7 +179,10 @@ describe Issue, 'Votes' do
def add_note(text, author = issue.author) def add_note(text, author = issue.author)
created_at = Time.now - 1.hour + Note.count.seconds created_at = Time.now - 1.hour + Note.count.seconds
issue.notes << create(:note, note: text, project: issue.project, issue.notes << create(:note,
author_id: author.id, created_at: created_at) note: text,
project: issue.project,
author_id: author.id,
created_at: created_at)
end end
end end
...@@ -419,9 +419,7 @@ describe Notify do ...@@ -419,9 +419,7 @@ describe Notify do
describe 'project access changed' do describe 'project access changed' do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project_member) { create(:project_member, let(:project_member) { create(:project_member, project: project, user: user) }
project: project,
user: user) }
subject { Notify.project_access_granted_email(project_member.id) } subject { Notify.project_access_granted_email(project_member.id) }
it_behaves_like 'an email sent from GitLab' it_behaves_like 'an email sent from GitLab'
......
...@@ -60,11 +60,11 @@ describe CommitRange do ...@@ -60,11 +60,11 @@ describe CommitRange do
end end
it 'includes the correct values for a three-dot range' do it 'includes the correct values for a three-dot range' do
expect(range.to_param).to eq({from: sha_from, to: sha_to}) expect(range.to_param).to eq({ from: sha_from, to: sha_to })
end end
it 'includes the correct values for a two-dot range' do it 'includes the correct values for a two-dot range' do
expect(range2.to_param).to eq({from: sha_from + '^', to: sha_to}) expect(range2.to_param).to eq({ from: sha_from + '^', to: sha_to })
end end
end end
......
...@@ -44,9 +44,7 @@ describe DeployKeysProject do ...@@ -44,9 +44,7 @@ describe DeployKeysProject do
it "destroys the deploy key" do it "destroys the deploy key" do
subject.destroy subject.destroy
expect { expect { deploy_key.reload }.to raise_error(ActiveRecord::RecordNotFound)
deploy_key.reload
}.to raise_error(ActiveRecord::RecordNotFound)
end end
end end
end end
......
...@@ -26,7 +26,7 @@ describe ServiceHook do ...@@ -26,7 +26,7 @@ describe ServiceHook do
describe "execute" do describe "execute" do
before(:each) do before(:each) do
@service_hook = create(:service_hook) @service_hook = create(:service_hook)
@data = { project_id: 1, data: {}} @data = { project_id: 1, data: {} }
WebMock.stub_request(:post, @service_hook.url) WebMock.stub_request(:post, @service_hook.url)
end end
...@@ -34,7 +34,7 @@ describe ServiceHook do ...@@ -34,7 +34,7 @@ describe ServiceHook do
it "POSTs to the web hook URL" do it "POSTs to the web hook URL" do
@service_hook.execute(@data) @service_hook.execute(@data)
expect(WebMock).to have_requested(:post, @service_hook.url).with( expect(WebMock).to have_requested(:post, @service_hook.url).with(
headers: {'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'Service Hook'} headers: { 'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'Service Hook' }
).once ).once
end end
...@@ -43,16 +43,14 @@ describe ServiceHook do ...@@ -43,16 +43,14 @@ describe ServiceHook do
@service_hook.execute(@data) @service_hook.execute(@data)
expect(WebMock).to have_requested(:post, @service_hook.url).with( expect(WebMock).to have_requested(:post, @service_hook.url).with(
headers: {'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'Service Hook'} headers: { 'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'Service Hook' }
).once ).once
end end
it "catches exceptions" do it "catches exceptions" do
expect(WebHook).to receive(:post).and_raise("Some HTTP Post error") expect(WebHook).to receive(:post).and_raise("Some HTTP Post error")
expect { expect { @service_hook.execute(@data) }.to raise_error(RuntimeError)
@service_hook.execute(@data)
}.to raise_error(RuntimeError)
end end
end end
end end
...@@ -29,7 +29,7 @@ describe SystemHook do ...@@ -29,7 +29,7 @@ describe SystemHook do
Projects::CreateService.new(create(:user), name: 'empty').execute Projects::CreateService.new(create(:user), name: 'empty').execute
expect(WebMock).to have_requested(:post, @system_hook.url).with( expect(WebMock).to have_requested(:post, @system_hook.url).with(
body: /project_create/, body: /project_create/,
headers: {'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'System Hook'} headers: { 'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'System Hook' }
).once ).once
end end
...@@ -39,7 +39,7 @@ describe SystemHook do ...@@ -39,7 +39,7 @@ describe SystemHook do
Projects::DestroyService.new(project, user, {}).execute Projects::DestroyService.new(project, user, {}).execute
expect(WebMock).to have_requested(:post, @system_hook.url).with( expect(WebMock).to have_requested(:post, @system_hook.url).with(
body: /project_destroy/, body: /project_destroy/,
headers: {'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'System Hook'} headers: { 'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'System Hook' }
).once ).once
end end
...@@ -47,7 +47,7 @@ describe SystemHook do ...@@ -47,7 +47,7 @@ describe SystemHook do
create(:user) create(:user)
expect(WebMock).to have_requested(:post, @system_hook.url).with( expect(WebMock).to have_requested(:post, @system_hook.url).with(
body: /user_create/, body: /user_create/,
headers: {'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'System Hook'} headers: { 'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'System Hook' }
).once ).once
end end
...@@ -56,7 +56,7 @@ describe SystemHook do ...@@ -56,7 +56,7 @@ describe SystemHook do
user.destroy user.destroy
expect(WebMock).to have_requested(:post, @system_hook.url).with( expect(WebMock).to have_requested(:post, @system_hook.url).with(
body: /user_destroy/, body: /user_destroy/,
headers: {'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'System Hook'} headers: { 'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'System Hook' }
).once ).once
end end
...@@ -66,7 +66,7 @@ describe SystemHook do ...@@ -66,7 +66,7 @@ describe SystemHook do
project.team << [user, :master] project.team << [user, :master]
expect(WebMock).to have_requested(:post, @system_hook.url).with( expect(WebMock).to have_requested(:post, @system_hook.url).with(
body: /user_add_to_team/, body: /user_add_to_team/,
headers: {'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'System Hook'} headers: { 'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'System Hook' }
).once ).once
end end
...@@ -77,7 +77,7 @@ describe SystemHook do ...@@ -77,7 +77,7 @@ describe SystemHook do
project.project_members.destroy_all project.project_members.destroy_all
expect(WebMock).to have_requested(:post, @system_hook.url).with( expect(WebMock).to have_requested(:post, @system_hook.url).with(
body: /user_remove_from_team/, body: /user_remove_from_team/,
headers: {'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'System Hook'} headers: { 'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'System Hook' }
).once ).once
end end
...@@ -85,7 +85,7 @@ describe SystemHook do ...@@ -85,7 +85,7 @@ describe SystemHook do
create(:group) create(:group)
expect(WebMock).to have_requested(:post, @system_hook.url).with( expect(WebMock).to have_requested(:post, @system_hook.url).with(
body: /group_create/, body: /group_create/,
headers: {'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'System Hook'} headers: { 'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'System Hook' }
).once ).once
end end
...@@ -94,7 +94,7 @@ describe SystemHook do ...@@ -94,7 +94,7 @@ describe SystemHook do
group.destroy group.destroy
expect(WebMock).to have_requested(:post, @system_hook.url).with( expect(WebMock).to have_requested(:post, @system_hook.url).with(
body: /group_destroy/, body: /group_destroy/,
headers: {'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'System Hook'} headers: { 'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'System Hook' }
).once ).once
end end
...@@ -104,7 +104,7 @@ describe SystemHook do ...@@ -104,7 +104,7 @@ describe SystemHook do
group.add_user(user, Gitlab::Access::MASTER) group.add_user(user, Gitlab::Access::MASTER)
expect(WebMock).to have_requested(:post, @system_hook.url).with( expect(WebMock).to have_requested(:post, @system_hook.url).with(
body: /user_add_to_group/, body: /user_add_to_group/,
headers: {'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'System Hook'} headers: { 'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'System Hook' }
).once ).once
end end
...@@ -115,7 +115,7 @@ describe SystemHook do ...@@ -115,7 +115,7 @@ describe SystemHook do
group.group_members.destroy_all group.group_members.destroy_all
expect(WebMock).to have_requested(:post, @system_hook.url).with( expect(WebMock).to have_requested(:post, @system_hook.url).with(
body: /user_remove_from_group/, body: /user_remove_from_group/,
headers: {'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'System Hook'} headers: { 'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'System Hook' }
).once ).once
end end
......
...@@ -47,7 +47,7 @@ describe ProjectHook do ...@@ -47,7 +47,7 @@ describe ProjectHook do
@project_hook = create(:project_hook) @project_hook = create(:project_hook)
@project = create(:project) @project = create(:project)
@project.hooks << [@project_hook] @project.hooks << [@project_hook]
@data = { before: 'oldrev', after: 'newrev', ref: 'ref'} @data = { before: 'oldrev', after: 'newrev', ref: 'ref' }
WebMock.stub_request(:post, @project_hook.url) WebMock.stub_request(:post, @project_hook.url)
end end
...@@ -55,7 +55,7 @@ describe ProjectHook do ...@@ -55,7 +55,7 @@ describe ProjectHook do
it "POSTs to the web hook URL" do it "POSTs to the web hook URL" do
@project_hook.execute(@data, 'push_hooks') @project_hook.execute(@data, 'push_hooks')
expect(WebMock).to have_requested(:post, @project_hook.url).with( expect(WebMock).to have_requested(:post, @project_hook.url).with(
headers: {'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'Push Hook'} headers: { 'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'Push Hook' }
).once ).once
end end
...@@ -64,16 +64,14 @@ describe ProjectHook do ...@@ -64,16 +64,14 @@ describe ProjectHook do
@project_hook.execute(@data, 'push_hooks') @project_hook.execute(@data, 'push_hooks')
expect(WebMock).to have_requested(:post, @project_hook.url).with( expect(WebMock).to have_requested(:post, @project_hook.url).with(
headers: {'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'Push Hook'} headers: { 'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'Push Hook' }
).once ).once
end end
it "catches exceptions" do it "catches exceptions" do
expect(WebHook).to receive(:post).and_raise("Some HTTP Post error") expect(WebHook).to receive(:post).and_raise("Some HTTP Post error")
expect { expect { @project_hook.execute(@data, 'push_hooks') }.to raise_error(RuntimeError)
@project_hook.execute(@data, 'push_hooks')
}.to raise_error(RuntimeError)
end end
end end
end end
...@@ -110,17 +110,3 @@ describe Project do ...@@ -110,17 +110,3 @@ describe Project do
end end
end end
end end
# == Schema Information
#
# Table name: projects
#
# id :integer not null, primary key
# name :string(255)
# path :string(255)
# description :text
# created_at :datetime
# updated_at :datetime
# private_flag :boolean default(TRUE), not null
# code :string(255)
#
...@@ -241,17 +241,17 @@ describe HipchatService do ...@@ -241,17 +241,17 @@ describe HipchatService do
context "#message_options" do context "#message_options" do
it "should be set to the defaults" do it "should be set to the defaults" do
expect(hipchat.send(:message_options)).to eq({notify: false, color: 'yellow'}) expect(hipchat.send(:message_options)).to eq({ notify: false, color: 'yellow' })
end end
it "should set notfiy to true" do it "should set notfiy to true" do
allow(hipchat).to receive(:notify).and_return('1') allow(hipchat).to receive(:notify).and_return('1')
expect(hipchat.send(:message_options)).to eq({notify: true, color: 'yellow'}) expect(hipchat.send(:message_options)).to eq({ notify: true, color: 'yellow' })
end end
it "should set the color" do it "should set the color" do
allow(hipchat).to receive(:color).and_return('red') allow(hipchat).to receive(:color).and_return('red')
expect(hipchat.send(:message_options)).to eq({notify: false, color: 'red'}) expect(hipchat.send(:message_options)).to eq({ notify: false, color: 'red' })
end end
end end
end end
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe SlackService::IssueMessage do describe SlackService::IssueMessage do
subject { SlackService::IssueMessage.new(args) } subject { SlackService::IssueMessage.new(args) }
let(:args) { let(:args) do
{ {
user: { user: {
name: 'Test User', name: 'Test User',
...@@ -23,7 +23,7 @@ describe SlackService::IssueMessage do ...@@ -23,7 +23,7 @@ describe SlackService::IssueMessage do
description: 'issue description' description: 'issue description'
} }
} }
} end
let(:color) { '#345' } let(:color) { '#345' }
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe SlackService::MergeMessage do describe SlackService::MergeMessage do
subject { SlackService::MergeMessage.new(args) } subject { SlackService::MergeMessage.new(args) }
let(:args) { let(:args) do
{ {
user: { user: {
name: 'Test User', name: 'Test User',
...@@ -24,7 +24,7 @@ describe SlackService::MergeMessage do ...@@ -24,7 +24,7 @@ describe SlackService::MergeMessage do
target_branch: 'target_branch', target_branch: 'target_branch',
} }
} }
} end
let(:color) { '#345' } let(:color) { '#345' }
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe SlackService::PushMessage do describe SlackService::PushMessage do
subject { SlackService::PushMessage.new(args) } subject { SlackService::PushMessage.new(args) }
let(:args) { let(:args) do
{ {
after: 'after', after: 'after',
before: 'before', before: 'before',
...@@ -12,7 +12,7 @@ describe SlackService::PushMessage do ...@@ -12,7 +12,7 @@ describe SlackService::PushMessage do
user_name: 'user_name', user_name: 'user_name',
project_url: 'url' project_url: 'url'
} }
} end
let(:color) { '#345' } let(:color) { '#345' }
...@@ -40,16 +40,16 @@ describe SlackService::PushMessage do ...@@ -40,16 +40,16 @@ describe SlackService::PushMessage do
end end
context 'tag push' do context 'tag push' do
let(:args) { let(:args) do
{ {
after: 'after', after: 'after',
before: Gitlab::Git::BLANK_SHA, before: Gitlab::Git::BLANK_SHA,
project_name: 'project_name', project_name: 'project_name',
ref: 'refs/tags/new_tag', ref: 'refs/tags/new_tag',
user_name: 'user_name', user_name: 'user_name',
project_url: 'url' project_url: 'url'
} }
} end
it 'returns a message regarding pushes' do it 'returns a message regarding pushes' do
expect(subject.pretext).to eq('user_name pushed new tag ' \ expect(subject.pretext).to eq('user_name pushed new tag ' \
......
...@@ -67,4 +67,3 @@ describe ProjectTeam do ...@@ -67,4 +67,3 @@ describe ProjectTeam do
end end
end end
end end
...@@ -231,7 +231,7 @@ describe ProjectWiki do ...@@ -231,7 +231,7 @@ describe ProjectWiki do
end end
def commit_details def commit_details
commit = {name: user.name, email: user.email, message: "test commit"} commit = { name: user.name, email: user.email, message: "test commit" }
end end
def create_page(name, content) def create_page(name, content)
......
...@@ -36,7 +36,7 @@ describe Service do ...@@ -36,7 +36,7 @@ describe Service do
end end
describe "Testable" do describe "Testable" do
let (:project) { create :project } let(:project) { create :project }
before do before do
allow(@service).to receive(:project).and_return(project) allow(@service).to receive(:project).and_return(project)
...@@ -49,7 +49,7 @@ describe Service do ...@@ -49,7 +49,7 @@ describe Service do
end end
describe "With commits" do describe "With commits" do
let (:project) { create :project } let(:project) { create :project }
before do before do
allow(@service).to receive(:project).and_return(project) allow(@service).to receive(:project).and_return(project)
...@@ -64,9 +64,16 @@ describe Service do ...@@ -64,9 +64,16 @@ describe Service do
describe "Template" do describe "Template" do
describe "for pushover service" do describe "for pushover service" do
let(:service_template) { let(:service_template) do
PushoverService.create(template: true, properties: {device: 'MyDevice', sound: 'mic', priority: 4, api_key: '123456789'}) PushoverService.create(
} template: true,
properties: {
device: 'MyDevice',
sound: 'mic',
priority: 4,
api_key: '123456789'
})
end
let(:project) { create(:project) } let(:project) { create(:project) }
describe 'should be prefilled for projects pushover service' do describe 'should be prefilled for projects pushover service' do
......
...@@ -43,7 +43,7 @@ describe WikiPage do ...@@ -43,7 +43,7 @@ describe WikiPage do
describe "validations" do describe "validations" do
before do before do
subject.attributes = {title: 'title', content: 'content'} subject.attributes = { title: 'title', content: 'content' }
end end
it "validates presence of title" do it "validates presence of title" do
...@@ -58,7 +58,7 @@ describe WikiPage do ...@@ -58,7 +58,7 @@ describe WikiPage do
end end
before do before do
@wiki_attr = {title: "Index", content: "Home Page", format: "markdown"} @wiki_attr = { title: "Index", content: "Home Page", format: "markdown" }
end end
describe "#create" do describe "#create" do
...@@ -82,7 +82,7 @@ describe WikiPage do ...@@ -82,7 +82,7 @@ describe WikiPage do
let(:title) { 'Index v1.2.3' } let(:title) { 'Index v1.2.3' }
before do before do
@wiki_attr = {title: title, content: "Home Page", format: "markdown"} @wiki_attr = { title: title, content: "Home Page", format: "markdown" }
end end
describe "#create" do describe "#create" do
...@@ -196,7 +196,7 @@ describe WikiPage do ...@@ -196,7 +196,7 @@ describe WikiPage do
end end
def commit_details def commit_details
commit = {name: user.name, email: user.email, message: "test commit"} commit = { name: user.name, email: user.email, message: "test commit" }
end end
def create_page(name, content) def create_page(name, content)
......
...@@ -4,20 +4,20 @@ describe API::API, api: true do ...@@ -4,20 +4,20 @@ describe API::API, api: true do
include ApiHelpers include ApiHelpers
let!(:user) { create(:user) } let!(:user) { create(:user) }
let!(:application) { Doorkeeper::Application.create!(:name => "MyApp", :redirect_uri => "https://app.com", :owner => user) } let!(:application) { Doorkeeper::Application.create!(name: "MyApp", redirect_uri: "https://app.com", owner: user) }
let!(:token) { Doorkeeper::AccessToken.create! :application_id => application.id, :resource_owner_id => user.id } let!(:token) { Doorkeeper::AccessToken.create! application_id: application.id, resource_owner_id: user.id }
describe "when unauthenticated" do describe "when unauthenticated" do
it "returns authentication success" do it "returns authentication success" do
get api("/user"), :access_token => token.token get api("/user"), access_token: token.token
expect(response.status).to eq(200) expect(response.status).to eq(200)
end end
end end
describe "when token invalid" do describe "when token invalid" do
it "returns authentication error" do it "returns authentication error" do
get api("/user"), :access_token => "123a" get api("/user"), access_token: "123a"
expect(response.status).to eq(401) expect(response.status).to eq(401)
end end
end end
......
...@@ -39,14 +39,14 @@ describe API::API, api: true do ...@@ -39,14 +39,14 @@ describe API::API, api: true do
end end
describe "POST /projects/:id/repository/files" do describe "POST /projects/:id/repository/files" do
let(:valid_params) { let(:valid_params) do
{ {
file_path: 'newfile.rb', file_path: 'newfile.rb',
branch_name: 'master', branch_name: 'master',
content: 'puts 8', content: 'puts 8',
commit_message: 'Added newfile' commit_message: 'Added newfile'
} }
} end
it "should create a new file in project repo" do it "should create a new file in project repo" do
post api("/projects/#{project.id}/repository/files", user), valid_params post api("/projects/#{project.id}/repository/files", user), valid_params
...@@ -69,14 +69,14 @@ describe API::API, api: true do ...@@ -69,14 +69,14 @@ describe API::API, api: true do
end end
describe "PUT /projects/:id/repository/files" do describe "PUT /projects/:id/repository/files" do
let(:valid_params) { let(:valid_params) do
{ {
file_path: file_path, file_path: file_path,
branch_name: 'master', branch_name: 'master',
content: 'puts 8', content: 'puts 8',
commit_message: 'Changed file' commit_message: 'Changed file'
} }
} end
it "should update existing file in project repo" do it "should update existing file in project repo" do
put api("/projects/#{project.id}/repository/files", user), valid_params put api("/projects/#{project.id}/repository/files", user), valid_params
...@@ -91,13 +91,13 @@ describe API::API, api: true do ...@@ -91,13 +91,13 @@ describe API::API, api: true do
end end
describe "DELETE /projects/:id/repository/files" do describe "DELETE /projects/:id/repository/files" do
let(:valid_params) { let(:valid_params) do
{ {
file_path: file_path, file_path: file_path,
branch_name: 'master', branch_name: 'master',
commit_message: 'Changed file' commit_message: 'Changed file'
} }
} end
it "should delete existing file in project repo" do it "should delete existing file in project repo" do
delete api("/projects/#{project.id}/repository/files", user), valid_params delete api("/projects/#{project.id}/repository/files", user), valid_params
......
...@@ -6,15 +6,14 @@ describe API::API, api: true do ...@@ -6,15 +6,14 @@ describe API::API, api: true do
let(:user2) { create(:user) } let(:user2) { create(:user) }
let(:user3) { create(:user) } let(:user3) { create(:user) }
let(:admin) { create(:admin) } let(:admin) { create(:admin) }
let(:project) {
create(:project, creator_id: user.id, let(:project) do
namespace: user.namespace) create(:project, creator_id: user.id, namespace: user.namespace)
} end
let(:project_user2) {
create(:project_member, user: user2, let(:project_user2) do
project: project, create(:project_member, user: user2, project: project, access_level: ProjectMember::GUEST)
access_level: ProjectMember::GUEST) end
}
describe 'POST /projects/fork/:id' do describe 'POST /projects/fork/:id' do
before { project_user2 } before { project_user2 }
......
...@@ -61,10 +61,9 @@ describe API::API, api: true do ...@@ -61,10 +61,9 @@ describe API::API, api: true do
it "should return ok and add new member" do it "should return ok and add new member" do
new_user = create(:user) new_user = create(:user)
expect { expect do
post api("/groups/#{group_no_members.id}/members", owner), post api("/groups/#{group_no_members.id}/members", owner), user_id: new_user.id, access_level: GroupMember::MASTER
user_id: new_user.id, access_level: GroupMember::MASTER end.to change { group_no_members.members.count }.by(1)
}.to change { group_no_members.members.count }.by(1)
expect(response.status).to eq(201) expect(response.status).to eq(201)
expect(json_response['name']).to eq(new_user.name) expect(json_response['name']).to eq(new_user.name)
...@@ -74,10 +73,9 @@ describe API::API, api: true do ...@@ -74,10 +73,9 @@ describe API::API, api: true do
it "should not allow guest to modify group members" do it "should not allow guest to modify group members" do
new_user = create(:user) new_user = create(:user)
expect { expect do
post api("/groups/#{group_with_members.id}/members", guest), post api("/groups/#{group_with_members.id}/members", guest), user_id: new_user.id, access_level: GroupMember::MASTER
user_id: new_user.id, access_level: GroupMember::MASTER end.not_to change { group_with_members.members.count }
}.not_to change { group_with_members.members.count }
expect(response.status).to eq(403) expect(response.status).to eq(403)
end end
...@@ -178,9 +176,9 @@ describe API::API, api: true do ...@@ -178,9 +176,9 @@ describe API::API, api: true do
context "when a member of the group" do context "when a member of the group" do
it "should delete guest's membership of group" do it "should delete guest's membership of group" do
expect { expect do
delete api("/groups/#{group_with_members.id}/members/#{guest.id}", owner) delete api("/groups/#{group_with_members.id}/members/#{guest.id}", owner)
}.to change { group_with_members.members.count }.by(-1) end.to change { group_with_members.members.count }.by(-1)
expect(response.status).to eq(200) expect(response.status).to eq(200)
end end
......
...@@ -109,18 +109,18 @@ describe API::API, api: true do ...@@ -109,18 +109,18 @@ describe API::API, api: true do
end end
it "should not create group, duplicate" do it "should not create group, duplicate" do
post api("/groups", user3), {name: 'Duplicate Test', path: group2.path} post api("/groups", user3), { name: 'Duplicate Test', path: group2.path }
expect(response.status).to eq(400) expect(response.status).to eq(400)
expect(response.message).to eq("Bad Request") expect(response.message).to eq("Bad Request")
end end
it "should return 400 bad request error if name not given" do it "should return 400 bad request error if name not given" do
post api("/groups", user3), {path: group2.path} post api("/groups", user3), { path: group2.path }
expect(response.status).to eq(400) expect(response.status).to eq(400)
end end
it "should return 400 bad request error if path not given" do it "should return 400 bad request error if path not given" do
post api("/groups", user3), {name: 'test'} post api("/groups", user3), { name: 'test' }
expect(response.status).to eq(400) expect(response.status).to eq(400)
end end
end end
......
...@@ -8,9 +8,10 @@ describe API::API, api: true do ...@@ -8,9 +8,10 @@ describe API::API, api: true do
let!(:merge_request_closed) { create(:merge_request, state: "closed", author: user, assignee: user, source_project: project, target_project: project, title: "Closed test") } let!(:merge_request_closed) { create(:merge_request, state: "closed", author: user, assignee: user, source_project: project, target_project: project, title: "Closed test") }
let!(:merge_request_merged) { create(:merge_request, state: "merged", author: user, assignee: user, source_project: project, target_project: project, title: "Merged test") } let!(:merge_request_merged) { create(:merge_request, state: "merged", author: user, assignee: user, source_project: project, target_project: project, title: "Merged test") }
let!(:note) { create(:note_on_merge_request, author: user, project: project, noteable: merge_request, note: "a comment on a MR") } let!(:note) { create(:note_on_merge_request, author: user, project: project, noteable: merge_request, note: "a comment on a MR") }
before {
before do
project.team << [user, :reporters] project.team << [user, :reporters]
} end
describe "GET /projects/:id/merge_requests" do describe "GET /projects/:id/merge_requests" do
context "when unauthenticated" do context "when unauthenticated" do
......
...@@ -61,10 +61,9 @@ describe API::API, 'ProjectHooks', api: true do ...@@ -61,10 +61,9 @@ describe API::API, 'ProjectHooks', api: true do
describe "POST /projects/:id/hooks" do describe "POST /projects/:id/hooks" do
it "should add hook to project" do it "should add hook to project" do
expect { expect do
post api("/projects/#{project.id}/hooks", user), post api("/projects/#{project.id}/hooks", user), url: "http://example.com", issues_events: true
url: "http://example.com", issues_events: true end.to change {project.hooks.count}.by(1)
}.to change {project.hooks.count}.by(1)
expect(response.status).to eq(201) expect(response.status).to eq(201)
end end
...@@ -105,9 +104,9 @@ describe API::API, 'ProjectHooks', api: true do ...@@ -105,9 +104,9 @@ describe API::API, 'ProjectHooks', api: true do
describe "DELETE /projects/:id/hooks/:hook_id" do describe "DELETE /projects/:id/hooks/:hook_id" do
it "should delete hook from project" do it "should delete hook from project" do
expect { expect do
delete api("/projects/#{project.id}/hooks/#{hook.id}", user) delete api("/projects/#{project.id}/hooks/#{hook.id}", user)
}.to change {project.hooks.count}.by(-1) end.to change {project.hooks.count}.by(-1)
expect(response.status).to eq(200) expect(response.status).to eq(200)
end end
......
...@@ -53,10 +53,9 @@ describe API::API, api: true do ...@@ -53,10 +53,9 @@ describe API::API, api: true do
describe "POST /projects/:id/members" do describe "POST /projects/:id/members" do
it "should add user to project team" do it "should add user to project team" do
expect { expect do
post api("/projects/#{project.id}/members", user), user_id: user2.id, post api("/projects/#{project.id}/members", user), user_id: user2.id, access_level: ProjectMember::DEVELOPER
access_level: ProjectMember::DEVELOPER end.to change { ProjectMember.count }.by(1)
}.to change { ProjectMember.count }.by(1)
expect(response.status).to eq(201) expect(response.status).to eq(201)
expect(json_response['username']).to eq(user2.username) expect(json_response['username']).to eq(user2.username)
...@@ -64,12 +63,12 @@ describe API::API, api: true do ...@@ -64,12 +63,12 @@ describe API::API, api: true do
end end
it "should return a 201 status if user is already project member" do it "should return a 201 status if user is already project member" do
post api("/projects/#{project.id}/members", user), user_id: user2.id, post api("/projects/#{project.id}/members", user),
access_level: ProjectMember::DEVELOPER user_id: user2.id,
expect { access_level: ProjectMember::DEVELOPER
post api("/projects/#{project.id}/members", user), user_id: user2.id, expect do
access_level: ProjectMember::DEVELOPER post api("/projects/#{project.id}/members", user), user_id: user2.id, access_level: ProjectMember::DEVELOPER
}.not_to change { ProjectMember.count } end.not_to change { ProjectMember.count }
expect(response.status).to eq(201) expect(response.status).to eq(201)
expect(json_response['username']).to eq(user2.username) expect(json_response['username']).to eq(user2.username)
...@@ -123,16 +122,16 @@ describe API::API, api: true do ...@@ -123,16 +122,16 @@ describe API::API, api: true do
before { project_member2 } before { project_member2 }
it "should remove user from project team" do it "should remove user from project team" do
expect { expect do
delete api("/projects/#{project.id}/members/#{user3.id}", user) delete api("/projects/#{project.id}/members/#{user3.id}", user)
}.to change { ProjectMember.count }.by(-1) end.to change { ProjectMember.count }.by(-1)
end end
it "should return 200 if team member is not part of a project" do it "should return 200 if team member is not part of a project" do
delete api("/projects/#{project.id}/members/#{user3.id}", user) delete api("/projects/#{project.id}/members/#{user3.id}", user)
expect { expect do
delete api("/projects/#{project.id}/members/#{user3.id}", user) delete api("/projects/#{project.id}/members/#{user3.id}", user)
}.not_to change { ProjectMember.count } end.to_not change { ProjectMember.count }
end end
it "should return 200 if team member already removed" do it "should return 200 if team member already removed" do
...@@ -142,9 +141,9 @@ describe API::API, api: true do ...@@ -142,9 +141,9 @@ describe API::API, api: true do
end end
it "should return 200 OK when the user was not member" do it "should return 200 OK when the user was not member" do
expect { expect do
delete api("/projects/#{project.id}/members/1000000", user) delete api("/projects/#{project.id}/members/1000000", user)
}.to change { ProjectMember.count }.by(0) end.to change { ProjectMember.count }.by(0)
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect(json_response['message']).to eq("Access revoked") expect(json_response['message']).to eq("Access revoked")
expect(json_response['id']).to eq(1000000) expect(json_response['id']).to eq(1000000)
......
...@@ -81,7 +81,7 @@ describe API::API, api: true do ...@@ -81,7 +81,7 @@ describe API::API, api: true do
end end
it 'should return the correct order when sorted by id' do it 'should return the correct order when sorted by id' do
get api('/projects', user), { order_by: 'id', sort: 'desc'} get api('/projects', user), { order_by: 'id', sort: 'desc' }
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.first['id']).to eq(project3.id) expect(json_response.first['id']).to eq(project3.id)
...@@ -90,7 +90,7 @@ describe API::API, api: true do ...@@ -90,7 +90,7 @@ describe API::API, api: true do
it 'returns projects in the correct order when ci_enabled_first parameter is passed' do it 'returns projects in the correct order when ci_enabled_first parameter is passed' do
[project, project2, project3].each{ |project| project.build_missing_services } [project, project2, project3].each{ |project| project.build_missing_services }
project2.gitlab_ci_service.update(active: true, token: "token", project_url: "url") project2.gitlab_ci_service.update(active: true, token: "token", project_url: "url")
get api('/projects', user), { ci_enabled_first: 'true'} get api('/projects', user), { ci_enabled_first: 'true' }
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.first['id']).to eq(project2.id) expect(json_response.first['id']).to eq(project2.id)
...@@ -125,7 +125,7 @@ describe API::API, api: true do ...@@ -125,7 +125,7 @@ describe API::API, api: true do
expect(json_response).to satisfy do |response| expect(json_response).to satisfy do |response|
response.one? do |entry| response.one? do |entry|
entry['name'] == project.name && entry['name'] == project.name &&
entry['owner']['username'] == user.username entry['owner']['username'] == user.username
end end
end end
end end
...@@ -471,9 +471,9 @@ describe API::API, api: true do ...@@ -471,9 +471,9 @@ describe API::API, api: true do
before { snippet } before { snippet }
it 'should delete existing project snippet' do it 'should delete existing project snippet' do
expect { expect do
delete api("/projects/#{project.id}/snippets/#{snippet.id}", user) delete api("/projects/#{project.id}/snippets/#{snippet.id}", user)
}.to change { Snippet.count }.by(-1) end.to change { Snippet.count }.by(-1)
expect(response.status).to eq(200) expect(response.status).to eq(200)
end end
...@@ -545,9 +545,9 @@ describe API::API, api: true do ...@@ -545,9 +545,9 @@ describe API::API, api: true do
it 'should create new ssh key' do it 'should create new ssh key' do
key_attrs = attributes_for :key key_attrs = attributes_for :key
expect { expect do
post api("/projects/#{project.id}/keys", user), key_attrs post api("/projects/#{project.id}/keys", user), key_attrs
}.to change{ project.deploy_keys.count }.by(1) end.to change{ project.deploy_keys.count }.by(1)
end end
end end
...@@ -555,9 +555,9 @@ describe API::API, api: true do ...@@ -555,9 +555,9 @@ describe API::API, api: true do
before { deploy_key } before { deploy_key }
it 'should delete existing key' do it 'should delete existing key' do
expect { expect do
delete api("/projects/#{project.id}/keys/#{deploy_key.id}", user) delete api("/projects/#{project.id}/keys/#{deploy_key.id}", user)
}.to change{ project.deploy_keys.count }.by(-1) end.to change{ project.deploy_keys.count }.by(-1)
end end
it 'should return 404 Not Found with invalid ID' do it 'should return 404 Not Found with invalid ID' do
......
...@@ -36,9 +36,9 @@ describe API::API, api: true do ...@@ -36,9 +36,9 @@ describe API::API, api: true do
describe "POST /hooks" do describe "POST /hooks" do
it "should create new hook" do it "should create new hook" do
expect { expect do
post api("/hooks", admin), url: 'http://example.com' post api("/hooks", admin), url: 'http://example.com'
}.to change { SystemHook.count }.by(1) end.to change { SystemHook.count }.by(1)
end end
it "should respond with 400 if url not given" do it "should respond with 400 if url not given" do
...@@ -47,9 +47,9 @@ describe API::API, api: true do ...@@ -47,9 +47,9 @@ describe API::API, api: true do
end end
it "should not create new hook without url" do it "should not create new hook without url" do
expect { expect do
post api("/hooks", admin) post api("/hooks", admin)
}.not_to change { SystemHook.count } end.to_not change { SystemHook.count }
end end
end end
...@@ -68,9 +68,9 @@ describe API::API, api: true do ...@@ -68,9 +68,9 @@ describe API::API, api: true do
describe "DELETE /hooks/:id" do describe "DELETE /hooks/:id" do
it "should delete a hook" do it "should delete a hook" do
expect { expect do
delete api("/hooks/#{hook.id}", admin) delete api("/hooks/#{hook.id}", admin)
}.to change { SystemHook.count }.by(-1) end.to change { SystemHook.count }.by(-1)
end end
it "should return success if hook id not found" do it "should return success if hook id not found" do
......
...@@ -21,9 +21,9 @@ describe API::API, api: true do ...@@ -21,9 +21,9 @@ describe API::API, api: true do
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
username = user.username username = user.username
expect(json_response.detect { expect(json_response.detect do |user|
|user| user['username'] == username user['username'] == username
}['username']).to eq(username) end['username']).to eq(username)
end end
end end
...@@ -62,9 +62,9 @@ describe API::API, api: true do ...@@ -62,9 +62,9 @@ describe API::API, api: true do
before{ admin } before{ admin }
it "should create user" do it "should create user" do
expect { expect do
post api("/users", admin), attributes_for(:user, projects_limit: 3) post api("/users", admin), attributes_for(:user, projects_limit: 3)
}.to change { User.count }.by(1) end.to change { User.count }.by(1)
end end
it "should create user with correct attributes" do it "should create user with correct attributes" do
...@@ -103,9 +103,9 @@ describe API::API, api: true do ...@@ -103,9 +103,9 @@ describe API::API, api: true do
it "should not create user with invalid email" do it "should not create user with invalid email" do
post api('/users', admin), post api('/users', admin),
email: 'invalid email', email: 'invalid email',
password: 'password', password: 'password',
name: 'test' name: 'test'
expect(response.status).to eq(400) expect(response.status).to eq(400)
end end
...@@ -131,21 +131,21 @@ describe API::API, api: true do ...@@ -131,21 +131,21 @@ describe API::API, api: true do
it 'should return 400 error if user does not validate' do it 'should return 400 error if user does not validate' do
post api('/users', admin), post api('/users', admin),
password: 'pass', password: 'pass',
email: 'test@example.com', email: 'test@example.com',
username: 'test!', username: 'test!',
name: 'test', name: 'test',
bio: 'g' * 256, bio: 'g' * 256,
projects_limit: -1 projects_limit: -1
expect(response.status).to eq(400) expect(response.status).to eq(400)
expect(json_response['message']['password']). expect(json_response['message']['password']).
to eq(['is too short (minimum is 8 characters)']) to eq(['is too short (minimum is 8 characters)'])
expect(json_response['message']['bio']). expect(json_response['message']['bio']).
to eq(['is too long (maximum is 255 characters)']) to eq(['is too long (maximum is 255 characters)'])
expect(json_response['message']['projects_limit']). expect(json_response['message']['projects_limit']).
to eq(['must be greater than or equal to 0']) to eq(['must be greater than or equal to 0'])
expect(json_response['message']['username']). expect(json_response['message']['username']).
to eq([Gitlab::Regex.send(:namespace_regex_message)]) to eq([Gitlab::Regex.send(:namespace_regex_message)])
end end
it "shouldn't available for non admin users" do it "shouldn't available for non admin users" do
...@@ -156,20 +156,20 @@ describe API::API, api: true do ...@@ -156,20 +156,20 @@ describe API::API, api: true do
context 'with existing user' do context 'with existing user' do
before do before do
post api('/users', admin), post api('/users', admin),
email: 'test@example.com', email: 'test@example.com',
password: 'password', password: 'password',
username: 'test', username: 'test',
name: 'foo' name: 'foo'
end end
it 'should return 409 conflict error if user with same email exists' do it 'should return 409 conflict error if user with same email exists' do
expect { expect do
post api('/users', admin), post api('/users', admin),
name: 'foo', name: 'foo',
email: 'test@example.com', email: 'test@example.com',
password: 'password', password: 'password',
username: 'foo' username: 'foo'
}.to change { User.count }.by(0) end.to change { User.count }.by(0)
expect(response.status).to eq(409) expect(response.status).to eq(409)
expect(json_response['message']).to eq('Email has already been taken') expect(json_response['message']).to eq('Email has already been taken')
end end
...@@ -177,10 +177,10 @@ describe API::API, api: true do ...@@ -177,10 +177,10 @@ describe API::API, api: true do
it 'should return 409 conflict error if same username exists' do it 'should return 409 conflict error if same username exists' do
expect do expect do
post api('/users', admin), post api('/users', admin),
name: 'foo', name: 'foo',
email: 'foo@example.com', email: 'foo@example.com',
password: 'password', password: 'password',
username: 'test' username: 'test'
end.to change { User.count }.by(0) end.to change { User.count }.by(0)
expect(response.status).to eq(409) expect(response.status).to eq(409)
expect(json_response['message']).to eq('Username has already been taken') expect(json_response['message']).to eq('Username has already been taken')
...@@ -203,7 +203,7 @@ describe API::API, api: true do ...@@ -203,7 +203,7 @@ describe API::API, api: true do
before { admin } before { admin }
it "should update user with new bio" do it "should update user with new bio" do
put api("/users/#{user.id}", admin), {bio: 'new test bio'} put api("/users/#{user.id}", admin), { bio: 'new test bio' }
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect(json_response['bio']).to eq('new test bio') expect(json_response['bio']).to eq('new test bio')
expect(user.reload.bio).to eq('new test bio') expect(user.reload.bio).to eq('new test bio')
...@@ -224,14 +224,14 @@ describe API::API, api: true do ...@@ -224,14 +224,14 @@ describe API::API, api: true do
end end
it "should update admin status" do it "should update admin status" do
put api("/users/#{user.id}", admin), {admin: true} put api("/users/#{user.id}", admin), { admin: true }
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect(json_response['is_admin']).to eq(true) expect(json_response['is_admin']).to eq(true)
expect(user.reload.admin).to eq(true) expect(user.reload.admin).to eq(true)
end end
it "should not update admin status" do it "should not update admin status" do
put api("/users/#{admin_user.id}", admin), {can_create_group: false} put api("/users/#{admin_user.id}", admin), { can_create_group: false }
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect(json_response['is_admin']).to eq(true) expect(json_response['is_admin']).to eq(true)
expect(admin_user.reload.admin).to eq(true) expect(admin_user.reload.admin).to eq(true)
...@@ -239,7 +239,7 @@ describe API::API, api: true do ...@@ -239,7 +239,7 @@ describe API::API, api: true do
end end
it "should not allow invalid update" do it "should not allow invalid update" do
put api("/users/#{user.id}", admin), {email: 'invalid email'} put api("/users/#{user.id}", admin), { email: 'invalid email' }
expect(response.status).to eq(400) expect(response.status).to eq(400)
expect(user.reload.email).not_to eq('invalid email') expect(user.reload.email).not_to eq('invalid email')
end end
...@@ -250,36 +250,36 @@ describe API::API, api: true do ...@@ -250,36 +250,36 @@ describe API::API, api: true do
end end
it "should return 404 for non-existing user" do it "should return 404 for non-existing user" do
put api("/users/999999", admin), {bio: 'update should fail'} put api("/users/999999", admin), { bio: 'update should fail' }
expect(response.status).to eq(404) expect(response.status).to eq(404)
expect(json_response['message']).to eq('404 Not found') expect(json_response['message']).to eq('404 Not found')
end end
it 'should return 400 error if user does not validate' do it 'should return 400 error if user does not validate' do
put api("/users/#{user.id}", admin), put api("/users/#{user.id}", admin),
password: 'pass', password: 'pass',
email: 'test@example.com', email: 'test@example.com',
username: 'test!', username: 'test!',
name: 'test', name: 'test',
bio: 'g' * 256, bio: 'g' * 256,
projects_limit: -1 projects_limit: -1
expect(response.status).to eq(400) expect(response.status).to eq(400)
expect(json_response['message']['password']). expect(json_response['message']['password']).
to eq(['is too short (minimum is 8 characters)']) to eq(['is too short (minimum is 8 characters)'])
expect(json_response['message']['bio']). expect(json_response['message']['bio']).
to eq(['is too long (maximum is 255 characters)']) to eq(['is too long (maximum is 255 characters)'])
expect(json_response['message']['projects_limit']). expect(json_response['message']['projects_limit']).
to eq(['must be greater than or equal to 0']) to eq(['must be greater than or equal to 0'])
expect(json_response['message']['username']). expect(json_response['message']['username']).
to eq([Gitlab::Regex.send(:namespace_regex_message)]) to eq([Gitlab::Regex.send(:namespace_regex_message)])
end end
context "with existing user" do context "with existing user" do
before { before do
post api("/users", admin), { email: 'test@example.com', password: 'password', username: 'test', name: 'test' } post api("/users", admin), { email: 'test@example.com', password: 'password', username: 'test', name: 'test' }
post api("/users", admin), { email: 'foo@bar.com', password: 'password', username: 'john', name: 'john' } post api("/users", admin), { email: 'foo@bar.com', password: 'password', username: 'john', name: 'john' }
@user = User.all.last @user = User.all.last
} end
it 'should return 409 conflict error if email address exists' do it 'should return 409 conflict error if email address exists' do
put api("/users/#{@user.id}", admin), email: 'test@example.com' put api("/users/#{@user.id}", admin), email: 'test@example.com'
...@@ -313,9 +313,9 @@ describe API::API, api: true do ...@@ -313,9 +313,9 @@ describe API::API, api: true do
it "should create ssh key" do it "should create ssh key" do
key_attrs = attributes_for :key key_attrs = attributes_for :key
expect { expect do
post api("/users/#{user.id}/keys", admin), key_attrs post api("/users/#{user.id}/keys", admin), key_attrs
}.to change{ user.keys.count }.by(1) end.to change{ user.keys.count }.by(1)
end end
end end
...@@ -361,9 +361,9 @@ describe API::API, api: true do ...@@ -361,9 +361,9 @@ describe API::API, api: true do
it 'should delete existing key' do it 'should delete existing key' do
user.keys << key user.keys << key
user.save user.save
expect { expect do
delete api("/users/#{user.id}/keys/#{key.id}", admin) delete api("/users/#{user.id}/keys/#{key.id}", admin)
}.to change { user.keys.count }.by(-1) end.to change { user.keys.count }.by(-1)
expect(response.status).to eq(200) expect(response.status).to eq(200)
end end
...@@ -475,9 +475,9 @@ describe API::API, api: true do ...@@ -475,9 +475,9 @@ describe API::API, api: true do
describe "POST /user/keys" do describe "POST /user/keys" do
it "should create ssh key" do it "should create ssh key" do
key_attrs = attributes_for :key key_attrs = attributes_for :key
expect { expect do
post api("/user/keys", user), key_attrs post api("/user/keys", user), key_attrs
}.to change{ user.keys.count }.by(1) end.to change{ user.keys.count }.by(1)
expect(response.status).to eq(201) expect(response.status).to eq(201)
end end
...@@ -508,9 +508,9 @@ describe API::API, api: true do ...@@ -508,9 +508,9 @@ describe API::API, api: true do
it "should delete existed key" do it "should delete existed key" do
user.keys << key user.keys << key
user.save user.save
expect { expect do
delete api("/user/keys/#{key.id}", user) delete api("/user/keys/#{key.id}", user)
}.to change{user.keys.count}.by(-1) end.to change{user.keys.count}.by(-1)
expect(response.status).to eq(200) expect(response.status).to eq(200)
end end
......
...@@ -118,4 +118,3 @@ describe Admin::DashboardController, "routing" do ...@@ -118,4 +118,3 @@ describe Admin::DashboardController, "routing" do
expect(get("/admin")).to route_to('admin/dashboard#index') expect(get("/admin")).to route_to('admin/dashboard#index')
end end
end end
...@@ -248,4 +248,3 @@ describe "Groups", "routing" do ...@@ -248,4 +248,3 @@ describe "Groups", "routing" do
expect(get('/1')).to route_to('namespaces#show', id: '1') expect(get('/1')).to route_to('namespaces#show', id: '1')
end end
end end
...@@ -17,9 +17,7 @@ describe ArchiveRepositoryService do ...@@ -17,9 +17,7 @@ describe ArchiveRepositoryService do
end end
it "raises an error" do it "raises an error" do
expect { expect { subject.execute(timeout: 0.0) }.to raise_error(RuntimeError)
subject.execute(timeout: 0.0)
}.to raise_error(RuntimeError)
end end
end end
...@@ -90,4 +88,3 @@ describe ArchiveRepositoryService do ...@@ -90,4 +88,3 @@ describe ArchiveRepositoryService do
end end
end end
end end
...@@ -3,9 +3,9 @@ require 'spec_helper' ...@@ -3,9 +3,9 @@ require 'spec_helper'
describe GitPushService do describe GitPushService do
include RepoHelpers include RepoHelpers
let (:user) { create :user } let(:user) { create :user }
let (:project) { create :project } let(:project) { create :project }
let (:service) { GitPushService.new } let(:service) { GitPushService.new }
before do before do
@blankrev = Gitlab::Git::BLANK_SHA @blankrev = Gitlab::Git::BLANK_SHA
...@@ -226,18 +226,18 @@ describe GitPushService do ...@@ -226,18 +226,18 @@ describe GitPushService do
end end
it "doesn't create cross-reference notes for a closing reference" do it "doesn't create cross-reference notes for a closing reference" do
expect { expect do
service.execute(project, user, @oldrev, @newrev, @ref) service.execute(project, user, @oldrev, @newrev, @ref)
}.not_to change { Note.where(project_id: project.id, system: true, commit_id: closing_commit.id).count } end.not_to change { Note.where(project_id: project.id, system: true, commit_id: closing_commit.id).count }
end end
it "doesn't close issues when pushed to non-default branches" do it "doesn't close issues when pushed to non-default branches" do
allow(project).to receive(:default_branch).and_return('durf') allow(project).to receive(:default_branch).and_return('durf')
# The push still shouldn't create cross-reference notes. # The push still shouldn't create cross-reference notes.
expect { expect do
service.execute(project, user, @oldrev, @newrev, 'refs/heads/hurf') service.execute(project, user, @oldrev, @newrev, 'refs/heads/hurf')
}.not_to change { Note.where(project_id: project.id, system: true).count } end.not_to change { Note.where(project_id: project.id, system: true).count }
expect(Issue.find(issue.id)).to be_opened expect(Issue.find(issue.id)).to be_opened
end end
...@@ -246,9 +246,9 @@ describe GitPushService do ...@@ -246,9 +246,9 @@ describe GitPushService do
allow(project).to receive(:default_issues_tracker?).and_return(false) allow(project).to receive(:default_issues_tracker?).and_return(false)
# The push still shouldn't create cross-reference notes. # The push still shouldn't create cross-reference notes.
expect { expect do
service.execute(project, user, @oldrev, @newrev, 'refs/heads/hurf') service.execute(project, user, @oldrev, @newrev, 'refs/heads/hurf')
}.not_to change { Note.where(project_id: project.id, system: true).count } end.not_to change { Note.where(project_id: project.id, system: true).count }
end end
end end
......
...@@ -3,9 +3,9 @@ require 'spec_helper' ...@@ -3,9 +3,9 @@ require 'spec_helper'
describe GitTagPushService do describe GitTagPushService do
include RepoHelpers include RepoHelpers
let (:user) { create :user } let(:user) { create :user }
let (:project) { create :project } let(:project) { create :project }
let (:service) { GitTagPushService.new } let(:service) { GitTagPushService.new }
before do before do
@oldrev = Gitlab::Git::BLANK_SHA @oldrev = Gitlab::Git::BLANK_SHA
......
require 'spec_helper' require 'spec_helper'
describe Issues::BulkUpdateService do describe Issues::BulkUpdateService do
let(:issue) { let(:issue) { create(:issue, project: @project) }
create(:issue, project: @project)
}
before do before do
@user = create :user @user = create :user
...@@ -26,14 +24,14 @@ describe Issues::BulkUpdateService do ...@@ -26,14 +24,14 @@ describe Issues::BulkUpdateService do
} }
end end
it { it do
result = Issues::BulkUpdateService.new(@project, @user, @params).execute result = Issues::BulkUpdateService.new(@project, @user, @params).execute
expect(result[:success]).to be_truthy expect(result[:success]).to be_truthy
expect(result[:count]).to eq(@issues.count) expect(result[:count]).to eq(@issues.count)
expect(@project.issues.opened).to be_empty expect(@project.issues.opened).to be_empty
expect(@project.issues.closed).not_to be_empty expect(@project.issues.closed).not_to be_empty
} end
end end
...@@ -49,14 +47,14 @@ describe Issues::BulkUpdateService do ...@@ -49,14 +47,14 @@ describe Issues::BulkUpdateService do
} }
end end
it { it do
result = Issues::BulkUpdateService.new(@project, @user, @params).execute result = Issues::BulkUpdateService.new(@project, @user, @params).execute
expect(result[:success]).to be_truthy expect(result[:success]).to be_truthy
expect(result[:count]).to eq(@issues.count) expect(result[:count]).to eq(@issues.count)
expect(@project.issues.closed).to be_empty expect(@project.issues.closed).to be_empty
expect(@project.issues.opened).not_to be_empty expect(@project.issues.opened).not_to be_empty
} end
end end
...@@ -70,13 +68,13 @@ describe Issues::BulkUpdateService do ...@@ -70,13 +68,13 @@ describe Issues::BulkUpdateService do
} }
end end
it { it do
result = Issues::BulkUpdateService.new(@project, @user, @params).execute result = Issues::BulkUpdateService.new(@project, @user, @params).execute
expect(result[:success]).to be_truthy expect(result[:success]).to be_truthy
expect(result[:count]).to eq(1) expect(result[:count]).to eq(1)
expect(@project.issues.first.assignee).to eq(@new_assignee) expect(@project.issues.first.assignee).to eq(@new_assignee)
} end
it 'allows mass-unassigning' do it 'allows mass-unassigning' do
@project.issues.first.update_attribute(:assignee, @new_assignee) @project.issues.first.update_attribute(:assignee, @new_assignee)
...@@ -109,13 +107,13 @@ describe Issues::BulkUpdateService do ...@@ -109,13 +107,13 @@ describe Issues::BulkUpdateService do
} }
end end
it { it do
result = Issues::BulkUpdateService.new(@project, @user, @params).execute result = Issues::BulkUpdateService.new(@project, @user, @params).execute
expect(result[:success]).to be_truthy expect(result[:success]).to be_truthy
expect(result[:count]).to eq(1) expect(result[:count]).to eq(1)
expect(@project.issues.first.milestone).to eq(@milestone) expect(@project.issues.first.milestone).to eq(@milestone)
} end
end end
end end
...@@ -13,12 +13,14 @@ describe MergeRequests::RefreshService do ...@@ -13,12 +13,14 @@ describe MergeRequests::RefreshService do
@project = create(:project, namespace: group) @project = create(:project, namespace: group)
@fork_project = Projects::ForkService.new(@project, @user).execute @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', source_branch: 'master',
target_branch: 'feature', target_branch: 'feature',
target_project: @project) 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', source_branch: 'master',
target_branch: 'feature', target_branch: 'feature',
target_project: @project) target_project: @project)
......
...@@ -25,4 +25,3 @@ describe Notes::CreateService do ...@@ -25,4 +25,3 @@ describe Notes::CreateService do
end end
end end
end end
...@@ -5,8 +5,10 @@ describe Projects::ForkService do ...@@ -5,8 +5,10 @@ describe Projects::ForkService do
before do before do
@from_namespace = create(:namespace) @from_namespace = create(:namespace)
@from_user = create(:user, namespace: @from_namespace ) @from_user = create(:user, namespace: @from_namespace )
@from_project = create(:project, creator_id: @from_user.id, @from_project = create(:project,
namespace: @from_namespace, star_count: 107, creator_id: @from_user.id,
namespace: @from_namespace,
star_count: 107,
description: 'wow such project') description: 'wow such project')
@to_namespace = create(:namespace) @to_namespace = create(:namespace)
@to_user = create(:user, namespace: @to_namespace) @to_user = create(:user, namespace: @to_namespace)
......
...@@ -11,7 +11,7 @@ describe Projects::UpdateService do ...@@ -11,7 +11,7 @@ describe Projects::UpdateService do
context 'should be private when updated to private' do context 'should be private when updated to private' do
before do before do
@created_private = @project.private? @created_private = @project.private?
@opts.merge!(visibility_level: Gitlab::VisibilityLevel::PRIVATE) @opts.merge!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
update_project(@project, @user, @opts) update_project(@project, @user, @opts)
......
...@@ -22,7 +22,7 @@ describe Projects::UploadService do ...@@ -22,7 +22,7 @@ describe Projects::UploadService do
it { expect(@link_to_file['url']).to match('banana_sample.gif') } it { expect(@link_to_file['url']).to match('banana_sample.gif') }
end end
context 'for valid png file' do context 'for valid png file' do
before do before do
png = fixture_file_upload(Rails.root + 'spec/fixtures/dk.png', png = fixture_file_upload(Rails.root + 'spec/fixtures/dk.png',
'image/png') 'image/png')
...@@ -38,7 +38,7 @@ describe Projects::UploadService do ...@@ -38,7 +38,7 @@ describe Projects::UploadService do
it { expect(@link_to_file['url']).to match('dk.png') } it { expect(@link_to_file['url']).to match('dk.png') }
end end
context 'for valid jpg file' do context 'for valid jpg file' do
before do before do
jpg = fixture_file_upload(Rails.root + 'spec/fixtures/rails_sample.jpg', 'image/jpg') jpg = fixture_file_upload(Rails.root + 'spec/fixtures/rails_sample.jpg', 'image/jpg')
@link_to_file = upload_file(@project.repository, jpg) @link_to_file = upload_file(@project.repository, jpg)
......
require 'spec_helper' require 'spec_helper'
describe SystemHooksService do describe SystemHooksService do
let (:user) { create :user } let(:user) { create :user }
let (:project) { create :project } let(:project) { create :project }
let (:project_member) { create :project_member } let(:project_member) { create :project_member }
let (:key) { create(:key, user: user) } let(:key) { create(:key, user: user) }
let (:group) { create(:group) } let(:group) { create(:group) }
let (:group_member) { create(:group_member) } let(:group_member) { create(:group_member) }
context 'event data' do context 'event data' do
it { expect(event_data(user, :create)).to include(:event_name, :name, :created_at, :email, :user_id) } it { expect(event_data(user, :create)).to include(:event_name, :name, :created_at, :email, :user_id) }
......
require 'spec_helper' require 'spec_helper'
describe TestHookService do describe TestHookService do
let (:user) { create :user } let(:user) { create :user }
let (:project) { create :project } let(:project) { create :project }
let (:hook) { create :project_hook, project: project } let(:hook) { create :project_hook, project: project }
describe :execute do describe :execute do
it "should execute successfully" do it "should execute successfully" do
......
...@@ -7,7 +7,7 @@ RSpec.configure do |config| ...@@ -7,7 +7,7 @@ RSpec.configure do |config|
DatabaseCleaner.strategy = :transaction DatabaseCleaner.strategy = :transaction
end end
config.before(:each, :js => true) do config.before(:each, js: true) do
DatabaseCleaner.strategy = :truncation DatabaseCleaner.strategy = :truncation
end end
......
...@@ -9,11 +9,11 @@ end ...@@ -9,11 +9,11 @@ end
def emulate_user(user) def emulate_user(user)
user = case user user = case user
when :user then create(:user) when :user then create(:user)
when :visitor then nil when :visitor then nil
when :admin then create(:admin) when :admin then create(:admin)
else user else user
end end
login_with(user) if user login_with(user) if user
end end
......
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
module Select2Helper module Select2Helper
def select2(value, options={}) def select2(value, options={})
raise "Must pass a hash containing 'from'" if not options.is_a?(Hash) or not options.has_key?(:from) raise ArgumentError, 'options must be a Hash' unless options.kind_of?(Hash)
selector = options[:from] selector = options.fetch(:from)
if options[:multiple] if options[:multiple]
execute_script("$('#{selector}').select2('val', ['#{value}'], true);") execute_script("$('#{selector}').select2('val', ['#{value}'], true);")
......
...@@ -37,7 +37,7 @@ describe 'gitlab:app namespace rake task' do ...@@ -37,7 +37,7 @@ describe 'gitlab:app namespace rake task' do
it 'should fail on mismatch' do it 'should fail on mismatch' do
allow(YAML).to receive(:load_file). allow(YAML).to receive(:load_file).
and_return({gitlab_version: "not #{gitlab_version}" }) and_return({ gitlab_version: "not #{gitlab_version}" })
expect { run_rake_task('gitlab:backup:restore') }. expect { run_rake_task('gitlab:backup:restore') }.
to raise_error(SystemExit) to raise_error(SystemExit)
...@@ -45,7 +45,7 @@ describe 'gitlab:app namespace rake task' do ...@@ -45,7 +45,7 @@ describe 'gitlab:app namespace rake task' do
it 'should invoke restoration on mach' do it 'should invoke restoration on mach' do
allow(YAML).to receive(:load_file). allow(YAML).to receive(:load_file).
and_return({gitlab_version: gitlab_version}) and_return({ gitlab_version: gitlab_version })
expect(Rake::Task["gitlab:backup:db:restore"]).to receive(:invoke) expect(Rake::Task["gitlab:backup:db:restore"]).to receive(:invoke)
expect(Rake::Task["gitlab:backup:repo:restore"]).to receive(:invoke) expect(Rake::Task["gitlab:backup:repo:restore"]).to receive(:invoke)
expect(Rake::Task["gitlab:shell:setup"]).to receive(:invoke) expect(Rake::Task["gitlab:shell:setup"]).to receive(:invoke)
......
...@@ -77,4 +77,3 @@ describe RepositoryArchiveWorker do ...@@ -77,4 +77,3 @@ describe RepositoryArchiveWorker do
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment