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