GitLab steht wegen Wartungsarbeiten am Montag, den 10. Mai, zwischen 17:00 und 19:00 Uhr nicht zur Verfügung.

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 @@ def public_merge_request
@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 @@
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 @@
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 "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 "#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 @@
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 @@
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 @@
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 @@
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 "#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 "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 @@
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 @@
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 @@
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 "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 "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 "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 @@ def go(params: {}, format: :js)
context 'on invalid dashboard setting' do
it 'sets the flash' do
prefs = {dashboard: 'invalid'}
prefs = { dashboard: 'invalid' }
go params: prefs
......
......@@ -12,8 +12,11 @@
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 "#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 @@
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 @@
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 @@