Commit e331a8e6 authored by Douwe Maan's avatar Douwe Maan

Enable Style/WordArray

parent 6f2a4269
...@@ -491,7 +491,7 @@ Style/WhileUntilModifier: ...@@ -491,7 +491,7 @@ Style/WhileUntilModifier:
# Use %w or %W for arrays of words. # Use %w or %W for arrays of words.
Style/WordArray: Style/WordArray:
Enabled: false Enabled: true
# Metrics ##################################################################### # Metrics #####################################################################
......
...@@ -99,7 +99,7 @@ class TodosFinder ...@@ -99,7 +99,7 @@ class TodosFinder
end end
def type? def type?
type.present? && ['Issue', 'MergeRequest'].include?(type) type.present? && %w(Issue MergeRequest).include?(type)
end end
def type def type
......
...@@ -22,7 +22,7 @@ module EmailsHelper ...@@ -22,7 +22,7 @@ module EmailsHelper
def action_title(url) def action_title(url)
return unless url return unless url
["merge_requests", "issues", "commit"].each do |action| %w(merge_requests issues commit).each do |action|
if url.split("/").include?(action) if url.split("/").include?(action)
return "View #{action.humanize.singularize}" return "View #{action.humanize.singularize}"
end end
......
...@@ -99,7 +99,7 @@ module TabHelper ...@@ -99,7 +99,7 @@ module TabHelper
return 'active' return 'active'
end end
if ['services', 'hooks', 'deploy_keys', 'protected_branches', 'push_rules'].include? controller.controller_name if %w(services hooks deploy_keys protected_branches push_rules).include? controller.controller_name
"active" "active"
end end
end end
......
...@@ -150,6 +150,6 @@ module TodosHelper ...@@ -150,6 +150,6 @@ module TodosHelper
private private
def show_todo_state?(todo) def show_todo_state?(todo)
(todo.target.is_a?(MergeRequest) || todo.target.is_a?(Issue)) && ['closed', 'merged'].include?(todo.target.state) (todo.target.is_a?(MergeRequest) || todo.target.is_a?(Issue)) && %w(closed merged).include?(todo.target.state)
end end
end end
...@@ -185,7 +185,7 @@ module Issuable ...@@ -185,7 +185,7 @@ module Issuable
def grouping_columns(sort) def grouping_columns(sort)
grouping_columns = [arel_table[:id]] grouping_columns = [arel_table[:id]]
if ["milestone_due_desc", "milestone_due_asc"].include?(sort) if %w(milestone_due_desc milestone_due_asc).include?(sort)
milestone_table = Milestone.arel_table milestone_table = Milestone.arel_table
grouping_columns << milestone_table[:id] grouping_columns << milestone_table[:id]
grouping_columns << milestone_table[:due_date] grouping_columns << milestone_table[:due_date]
......
...@@ -13,7 +13,7 @@ class DiffNote < Note ...@@ -13,7 +13,7 @@ class DiffNote < Note
validates :position, presence: true validates :position, presence: true
validates :diff_line, presence: true validates :diff_line, presence: true
validates :line_code, presence: true, line_code: true validates :line_code, presence: true, line_code: true
validates :noteable_type, inclusion: { in: ['Commit', 'MergeRequest'] } validates :noteable_type, inclusion: { in: %w(Commit MergeRequest) }
validates :resolved_by, presence: true, if: :resolved? validates :resolved_by, presence: true, if: :resolved?
validate :positions_complete validate :positions_complete
validate :verify_supported validate :verify_supported
......
...@@ -52,7 +52,7 @@ class Event < ActiveRecord::Base ...@@ -52,7 +52,7 @@ class Event < ActiveRecord::Base
def contributions def contributions
where("action = ? OR (target_type IN (?) AND action IN (?)) OR (target_type = ? AND action = ?)", where("action = ? OR (target_type IN (?) AND action IN (?)) OR (target_type = ? AND action = ?)",
Event::PUSHED, Event::PUSHED,
["MergeRequest", "Issue"], [Event::CREATED, Event::CLOSED, Event::MERGED], %w(MergeRequest Issue), [Event::CREATED, Event::CLOSED, Event::MERGED],
"Note", Event::COMMENTED) "Note", Event::COMMENTED)
end end
......
...@@ -74,7 +74,7 @@ class Note < ActiveRecord::Base ...@@ -74,7 +74,7 @@ class Note < ActiveRecord::Base
scope :inc_author, ->{ includes(:author) } scope :inc_author, ->{ includes(:author) }
scope :inc_relations_for_view, ->{ includes(:project, :author, :updated_by, :resolved_by, :award_emoji) } scope :inc_relations_for_view, ->{ includes(:project, :author, :updated_by, :resolved_by, :award_emoji) }
scope :diff_notes, ->{ where(type: ['LegacyDiffNote', 'DiffNote']) } scope :diff_notes, ->{ where(type: %w(LegacyDiffNote DiffNote)) }
scope :non_diff_notes, ->{ where(type: ['Note', nil]) } scope :non_diff_notes, ->{ where(type: ['Note', nil]) }
scope :with_associations, -> do scope :with_associations, -> do
......
...@@ -114,7 +114,7 @@ class DroneCiService < CiService ...@@ -114,7 +114,7 @@ class DroneCiService < CiService
end end
def merge_request_valid?(data) def merge_request_valid?(data)
['opened', 'reopened'].include?(data[:object_attributes][:state]) && %w(opened reopened).include?(data[:object_attributes][:state]) &&
data[:object_attributes][:merge_status] == 'unchecked' data[:object_attributes][:merge_status] == 'unchecked'
end end
end end
...@@ -36,7 +36,7 @@ class HipchatService < Service ...@@ -36,7 +36,7 @@ class HipchatService < Service
{ type: 'text', name: 'token', placeholder: 'Room token' }, { type: 'text', name: 'token', placeholder: 'Room token' },
{ type: 'text', name: 'room', placeholder: 'Room name or ID' }, { type: 'text', name: 'room', placeholder: 'Room name or ID' },
{ type: 'checkbox', name: 'notify' }, { type: 'checkbox', name: 'notify' },
{ type: 'select', name: 'color', choices: ['yellow', 'red', 'green', 'purple', 'gray', 'random'] }, { type: 'select', name: 'color', choices: %w(yellow red green purple gray random) },
{ type: 'text', name: 'api_version', { type: 'text', name: 'api_version',
placeholder: 'Leave blank for default (v2)' }, placeholder: 'Leave blank for default (v2)' },
{ type: 'text', name: 'server', { type: 'text', name: 'server',
......
...@@ -34,19 +34,19 @@ class PushoverService < Service ...@@ -34,19 +34,19 @@ class PushoverService < Service
[ [
['Device default sound', nil], ['Device default sound', nil],
['Pushover (default)', 'pushover'], ['Pushover (default)', 'pushover'],
['Bike', 'bike'], %w(Bike bike),
['Bugle', 'bugle'], %w(Bugle bugle),
['Cash Register', 'cashregister'], ['Cash Register', 'cashregister'],
['Classical', 'classical'], %w(Classical classical),
['Cosmic', 'cosmic'], %w(Cosmic cosmic),
['Falling', 'falling'], %w(Falling falling),
['Gamelan', 'gamelan'], %w(Gamelan gamelan),
['Incoming', 'incoming'], %w(Incoming incoming),
['Intermission', 'intermission'], %w(Intermission intermission),
['Magic', 'magic'], %w(Magic magic),
['Mechanical', 'mechanical'], %w(Mechanical mechanical),
['Piano Bar', 'pianobar'], ['Piano Bar', 'pianobar'],
['Siren', 'siren'], %w(Siren siren),
['Space Alarm', 'spacealarm'], ['Space Alarm', 'spacealarm'],
['Tug Boat', 'tugboat'], ['Tug Boat', 'tugboat'],
['Alien Alarm (long)', 'alien'], ['Alien Alarm (long)', 'alien'],
......
...@@ -25,7 +25,7 @@ module Projects ...@@ -25,7 +25,7 @@ module Projects
end end
def http?(url) def http?(url)
url =~ /\A#{URI.regexp(['http', 'https'])}\z/ url =~ /\A#{URI.regexp(%w(http https))}\z/
end end
def valid_domain?(url) def valid_domain?(url)
......
HealthCheck.setup do |config| HealthCheck.setup do |config|
config.standard_checks = ['database', 'migrations', 'cache'] config.standard_checks = %w(database migrations cache)
config.full_checks = ['database', 'migrations', 'cache'] config.full_checks = %w(database migrations cache)
end end
...@@ -20,13 +20,13 @@ def instrument_classes(instrumentation) ...@@ -20,13 +20,13 @@ def instrument_classes(instrumentation)
# Path to search => prefix to strip from constant # Path to search => prefix to strip from constant
paths_to_instrument = { paths_to_instrument = {
['app', 'finders'] => ['app', 'finders'], %w(app finders) => %w(app finders),
['app', 'mailers', 'emails'] => ['app', 'mailers'], %w(app mailers emails) => %w(app mailers),
['app', 'services', '**'] => ['app', 'services'], ['app', 'services', '**'] => %w(app services),
['lib', 'gitlab', 'conflicts'] => ['lib'], %w(lib gitlab conflicts) => ['lib'],
['lib', 'gitlab', 'diff'] => ['lib'], %w(lib gitlab diff) => ['lib'],
['lib', 'gitlab', 'email', 'message'] => ['lib'], %w(lib gitlab email message) => ['lib'],
['lib', 'gitlab', 'checks'] => ['lib'] %w(lib gitlab checks) => ['lib']
} }
paths_to_instrument.each do |(path, prefix)| paths_to_instrument.each do |(path, prefix)|
......
...@@ -12,7 +12,7 @@ class RemoveUnnecessaryIndexes < ActiveRecord::Migration ...@@ -12,7 +12,7 @@ class RemoveUnnecessaryIndexes < ActiveRecord::Migration
remove_index :award_emoji, column: :user_id if index_exists?(:award_emoji, :user_id) remove_index :award_emoji, column: :user_id if index_exists?(:award_emoji, :user_id)
remove_index :ci_builds, column: :commit_id if index_exists?(:ci_builds, :commit_id) remove_index :ci_builds, column: :commit_id if index_exists?(:ci_builds, :commit_id)
remove_index :deployments, column: :project_id if index_exists?(:deployments, :project_id) remove_index :deployments, column: :project_id if index_exists?(:deployments, :project_id)
remove_index :deployments, column: ["project_id", "environment_id"] if index_exists?(:deployments, ["project_id", "environment_id"]) remove_index :deployments, column: %w(project_id environment_id) if index_exists?(:deployments, %w(project_id environment_id))
remove_index :lists, column: :board_id if index_exists?(:lists, :board_id) remove_index :lists, column: :board_id if index_exists?(:lists, :board_id)
remove_index :milestones, column: :project_id if index_exists?(:milestones, :project_id) remove_index :milestones, column: :project_id if index_exists?(:milestones, :project_id)
remove_index :notes, column: :project_id if index_exists?(:notes, :project_id) remove_index :notes, column: :project_id if index_exists?(:notes, :project_id)
...@@ -24,7 +24,7 @@ class RemoveUnnecessaryIndexes < ActiveRecord::Migration ...@@ -24,7 +24,7 @@ class RemoveUnnecessaryIndexes < ActiveRecord::Migration
add_concurrent_index :award_emoji, :user_id add_concurrent_index :award_emoji, :user_id
add_concurrent_index :ci_builds, :commit_id add_concurrent_index :ci_builds, :commit_id
add_concurrent_index :deployments, :project_id add_concurrent_index :deployments, :project_id
add_concurrent_index :deployments, ["project_id", "environment_id"] add_concurrent_index :deployments, %w(project_id environment_id)
add_concurrent_index :lists, :board_id add_concurrent_index :lists, :board_id
add_concurrent_index :milestones, :project_id add_concurrent_index :milestones, :project_id
add_concurrent_index :notes, :project_id add_concurrent_index :notes, :project_id
......
...@@ -76,7 +76,7 @@ class Spinach::Features::ProjectBuildsArtifacts < Spinach::FeatureSteps ...@@ -76,7 +76,7 @@ class Spinach::Features::ProjectBuildsArtifacts < Spinach::FeatureSteps
base64_params = send_data.sub(/\Aartifacts\-entry:/, '') base64_params = send_data.sub(/\Aartifacts\-entry:/, '')
params = JSON.parse(Base64.urlsafe_decode64(base64_params)) params = JSON.parse(Base64.urlsafe_decode64(base64_params))
expect(params.keys).to eq(['Archive', 'Entry']) expect(params.keys).to eq(%w(Archive Entry))
expect(params['Archive']).to end_with('build_artifacts.zip') expect(params['Archive']).to end_with('build_artifacts.zip')
expect(params['Entry']).to eq(Base64.encode64('ci_artifacts.txt')) expect(params['Entry']).to eq(Base64.encode64('ci_artifacts.txt'))
end end
......
...@@ -11,7 +11,7 @@ module API ...@@ -11,7 +11,7 @@ module API
helpers do helpers do
params :optional_scope do params :optional_scope do
optional :scope, types: [String, Array[String]], desc: 'The scope of builds to show', optional :scope, types: [String, Array[String]], desc: 'The scope of builds to show',
values: ['pending', 'running', 'failed', 'success', 'canceled'], values: %w(pending running failed success canceled),
coerce_with: ->(scope) { coerce_with: ->(scope) {
if scope.is_a?(String) if scope.is_a?(String)
[scope] [scope]
......
...@@ -40,7 +40,7 @@ module API ...@@ -40,7 +40,7 @@ module API
requires :id, type: String, desc: 'The ID of a project' requires :id, type: String, desc: 'The ID of a project'
requires :sha, type: String, desc: 'The commit hash' requires :sha, type: String, desc: 'The commit hash'
requires :state, type: String, desc: 'The state of the status', requires :state, type: String, desc: 'The state of the status',
values: ['pending', 'running', 'success', 'failed', 'canceled'] values: %w(pending running success failed canceled)
optional :ref, type: String, desc: 'The ref' optional :ref, type: String, desc: 'The ref'
optional :target_url, type: String, desc: 'The target URL to associate with this status' optional :target_url, type: String, desc: 'The target URL to associate with this status'
optional :description, type: String, desc: 'A short description of the status' optional :description, type: String, desc: 'A short description of the status'
......
...@@ -157,7 +157,7 @@ module API ...@@ -157,7 +157,7 @@ module API
optional :path, type: String, desc: 'The file path' optional :path, type: String, desc: 'The file path'
given :path do given :path do
requires :line, type: Integer, desc: 'The line number' requires :line, type: Integer, desc: 'The line number'
requires :line_type, type: String, values: ['new', 'old'], default: 'new', desc: 'The type of the line' requires :line_type, type: String, values: %w(new old), default: 'new', desc: 'The type of the line'
end end
end end
post ':id/repository/commits/:sha/comments' do post ':id/repository/commits/:sha/comments' do
......
...@@ -14,7 +14,7 @@ module API ...@@ -14,7 +14,7 @@ module API
end end
params do params do
use :pagination use :pagination
optional :scope, type: String, values: ['running', 'branches', 'tags'], optional :scope, type: String, values: %w(running branches tags),
desc: 'Either running, branches, or tags' desc: 'Either running, branches, or tags'
end end
get ':id/pipelines' do get ':id/pipelines' do
......
...@@ -14,7 +14,7 @@ module API ...@@ -14,7 +14,7 @@ module API
use :pagination use :pagination
end end
get do get do
runners = filter_runners(current_user.ci_authorized_runners, params[:scope], without: ['specific', 'shared']) runners = filter_runners(current_user.ci_authorized_runners, params[:scope], without: %w(specific shared))
present paginate(runners), with: Entities::Runner present paginate(runners), with: Entities::Runner
end end
......
...@@ -162,7 +162,7 @@ module API ...@@ -162,7 +162,7 @@ module API
optional :path, type: String, desc: 'The file path' optional :path, type: String, desc: 'The file path'
given :path do given :path do
requires :line, type: Integer, desc: 'The line number' requires :line, type: Integer, desc: 'The line number'
requires :line_type, type: String, values: ['new', 'old'], default: 'new', desc: 'The type of the line' requires :line_type, type: String, values: %w(new old), default: 'new', desc: 'The type of the line'
end end
end end
post ':id/repository/commits/:sha/comments' do post ':id/repository/commits/:sha/comments' do
......
...@@ -73,7 +73,7 @@ module Ci ...@@ -73,7 +73,7 @@ module Ci
def get_runner_version_from_params def get_runner_version_from_params
return unless params["info"].present? return unless params["info"].present?
attributes_for_keys(["name", "version", "revision", "platform", "architecture"], params["info"]) attributes_for_keys(%w(name version revision platform architecture), params["info"])
end end
def max_artifacts_size def max_artifacts_size
......
...@@ -28,7 +28,7 @@ module Gitlab ...@@ -28,7 +28,7 @@ module Gitlab
end end
def dropdown_names(context) def dropdown_names(context)
categories = context == 'autodeploy' ? ['Auto deploy'] : ['General', 'Pages'] categories = context == 'autodeploy' ? ['Auto deploy'] : %w(General Pages)
super().slice(*categories) super().slice(*categories)
end end
end end
......
module Gitlab module Gitlab
class UrlSanitizer class UrlSanitizer
def self.sanitize(content) def self.sanitize(content)
regexp = URI::Parser.new.make_regexp(['http', 'https', 'ssh', 'git']) regexp = URI::Parser.new.make_regexp(%w(http https ssh git))
content.gsub(regexp) { |url| new(url).masked_url } content.gsub(regexp) { |url| new(url).masked_url }
rescue Addressable::URI::InvalidURIError rescue Addressable::URI::InvalidURIError
......
...@@ -32,10 +32,10 @@ describe Profiles::PersonalAccessTokensController do ...@@ -32,10 +32,10 @@ describe Profiles::PersonalAccessTokensController do
context "scopes" do context "scopes" do
it "allows creation of a token with scopes" do it "allows creation of a token with scopes" do
post :create, personal_access_token: { name: FFaker::Product.brand, scopes: ['api', 'read_user'] } post :create, personal_access_token: { name: FFaker::Product.brand, scopes: %w(api read_user) }
expect(created_token).not_to be_nil expect(created_token).not_to be_nil
expect(created_token.scopes).to eq(['api', 'read_user']) expect(created_token.scopes).to eq(%w(api read_user))
end end
it "allows creation of a token with no scopes" do it "allows creation of a token with no scopes" do
......
...@@ -1045,7 +1045,7 @@ describe Projects::MergeRequestsController do ...@@ -1045,7 +1045,7 @@ describe Projects::MergeRequestsController do
section['lines'].each do |line| section['lines'].each do |line|
if section['conflict'] if section['conflict']
expect(line['type']).to be_in(['old', 'new']) expect(line['type']).to be_in(%w(old new))
expect(line.values_at('old_line', 'new_line')).to contain_exactly(nil, a_kind_of(Integer)) expect(line.values_at('old_line', 'new_line')).to contain_exactly(nil, a_kind_of(Integer))
else else
if line['type'].nil? if line['type'].nil?
......
...@@ -55,7 +55,7 @@ feature 'Issues > Labels bulk assignment', feature: true do ...@@ -55,7 +55,7 @@ feature 'Issues > Labels bulk assignment', feature: true do
context 'to all issues' do context 'to all issues' do
before do before do
check 'check_all_issues' check 'check_all_issues'
open_labels_dropdown ['bug', 'feature'] open_labels_dropdown %w(bug feature)
update_issues update_issues
end end
...@@ -70,7 +70,7 @@ feature 'Issues > Labels bulk assignment', feature: true do ...@@ -70,7 +70,7 @@ feature 'Issues > Labels bulk assignment', feature: true do
context 'to a issue' do context 'to a issue' do
before do before do
check "selected_issue_#{issue1.id}" check "selected_issue_#{issue1.id}"
open_labels_dropdown ['bug', 'feature'] open_labels_dropdown %w(bug feature)
update_issues update_issues
end end
...@@ -112,7 +112,7 @@ feature 'Issues > Labels bulk assignment', feature: true do ...@@ -112,7 +112,7 @@ feature 'Issues > Labels bulk assignment', feature: true do
visit namespace_project_issues_path(project.namespace, project) visit namespace_project_issues_path(project.namespace, project)
check 'check_all_issues' check 'check_all_issues'
unmark_labels_in_dropdown ['bug', 'feature'] unmark_labels_in_dropdown %w(bug feature)
update_issues update_issues
end end
......
...@@ -161,7 +161,7 @@ describe 'Issues', feature: true do ...@@ -161,7 +161,7 @@ describe 'Issues', feature: true do
describe 'Filter issue' do describe 'Filter issue' do
before do before do
['foobar', 'barbaz', 'gitlab'].each do |title| %w(foobar barbaz gitlab).each do |title|
create(:issue, create(:issue,
author: @user, author: @user,
assignee: @user, assignee: @user,
......
...@@ -37,7 +37,7 @@ feature 'Issue prioritization', feature: true do ...@@ -37,7 +37,7 @@ feature 'Issue prioritization', feature: true do
page.within('.issues-holder') do page.within('.issues-holder') do
issue_titles = all('.issues-list .issue-title-text').map(&:text) issue_titles = all('.issues-list .issue-title-text').map(&:text)
expect(issue_titles).to eq(['issue_4', 'issue_3', 'issue_5', 'issue_2', 'issue_1']) expect(issue_titles).to eq(%w(issue_4 issue_3 issue_5 issue_2 issue_1))
end end
end end
end end
...@@ -77,7 +77,7 @@ feature 'Issue prioritization', feature: true do ...@@ -77,7 +77,7 @@ feature 'Issue prioritization', feature: true do
expect(issue_titles[0..1]).to contain_exactly('issue_5', 'issue_8') expect(issue_titles[0..1]).to contain_exactly('issue_5', 'issue_8')
expect(issue_titles[2..4]).to contain_exactly('issue_1', 'issue_3', 'issue_7') expect(issue_titles[2..4]).to contain_exactly('issue_1', 'issue_3', 'issue_7')
expect(issue_titles[5..-1]).to eq(['issue_2', 'issue_4', 'issue_6']) expect(issue_titles[5..-1]).to eq(%w(issue_2 issue_4 issue_6))
end end
end end
end end
......
...@@ -55,7 +55,7 @@ describe AuthHelper do ...@@ -55,7 +55,7 @@ describe AuthHelper do
context 'all the button based providers are disabled via application_setting' do context 'all the button based providers are disabled via application_setting' do
it 'returns false' do it 'returns false' do
stub_application_setting( stub_application_setting(
disabled_oauth_sign_in_sources: ['github', 'twitter'] disabled_oauth_sign_in_sources: %w(github twitter)
) )
expect(helper.button_based_providers_enabled?).to be false expect(helper.button_based_providers_enabled?).to be false
......
...@@ -51,7 +51,7 @@ describe IssuablesHelper do ...@@ -51,7 +51,7 @@ describe IssuablesHelper do
utf8: '✓', utf8: '✓',
author_id: '11', author_id: '11',
assignee_id: '18', assignee_id: '18',
label_name: ['bug', 'discussion', 'documentation'], label_name: %w(bug discussion documentation),
milestone_title: 'v4.0', milestone_title: 'v4.0',
sort: 'due_date_asc', sort: 'due_date_asc',
namespace_id: 'gitlab-org', namespace_id: 'gitlab-org',
......
...@@ -113,7 +113,7 @@ describe IssuesHelper do ...@@ -113,7 +113,7 @@ describe IssuesHelper do
describe "awards_sort" do describe "awards_sort" do
it "sorts a hash so thumbsup and thumbsdown are always on top" do it "sorts a hash so thumbsup and thumbsdown are always on top" do
data = { "thumbsdown" => "some value", "lifter" => "some value", "thumbsup" => "some value" } data = { "thumbsdown" => "some value", "lifter" => "some value", "thumbsup" => "some value" }
expect(awards_sort(data).keys).to eq(["thumbsup", "thumbsdown", "lifter"]) expect(awards_sort(data).keys).to eq(%w(thumbsup thumbsdown lifter))
end end
end end
......
...@@ -19,6 +19,6 @@ describe Bitbucket::Collection do ...@@ -19,6 +19,6 @@ describe Bitbucket::Collection do
it "iterates paginator" do it "iterates paginator" do
collection = described_class.new(TestPaginator.new) collection = described_class.new(TestPaginator.new)
expect(collection.to_a).to match(["result_1_page_1", "result_2_page_1", "result_1_page_2", "result_2_page_2"]) expect(collection.to_a).to match(%w(result_1_page_1 result_2_page_1 result_1_page_2 result_2_page_2))
end end
end end
...@@ -29,7 +29,7 @@ describe Bitbucket::Representation::Repo do ...@@ -29,7 +29,7 @@ describe Bitbucket::Representation::Repo do
end end
describe '#owner_and_slug' do describe '#owner_and_slug' do
it { expect(described_class.new({ 'full_name' => 'ben/test' }).owner_and_slug).to eq(['ben', 'test']) } it { expect(described_class.new({ 'full_name' => 'ben/test' }).owner_and_slug).to eq(%w(ben test)) }
end end
describe '#owner' do describe '#owner' do
......
...@@ -96,7 +96,7 @@ module Ci ...@@ -96,7 +96,7 @@ module Ci
it "returns builds if only has a list of branches including specified" do it "returns builds if only has a list of branches including specified" do
config = YAML.dump({ config = YAML.dump({
before_script: ["pwd"], before_script: ["pwd"],
rspec: { script: "rspec", type: type, only: ["master", "deploy"] } rspec: { script: "rspec", type: type, only: %w(master deploy) }
}) })
config_processor = GitlabCiYamlProcessor.new(config, path) config_processor = GitlabCiYamlProcessor.new(config, path)
...@@ -173,8 +173,8 @@ module Ci ...@@ -173,8 +173,8 @@ module Ci
it "returns build only for specified type" do it "returns build only for specified type" do
config = YAML.dump({ config = YAML.dump({
before_script: ["pwd"], before_script: ["pwd"],
rspec: { script: "rspec", type: "test", only: ["master", "deploy"] }, rspec: { script: "rspec", type: "test", only: %w(master deploy) },
staging: { script: "deploy", type: "deploy", only: ["master", "deploy"] }, staging: { script: "deploy", type: "deploy", only: %w(master deploy) },
production: { script: "deploy", type: "deploy", only: ["master@path", "deploy"] }, production: { script: "deploy", type: "deploy", only: ["master@path", "deploy"] },
}) })
...@@ -252,7 +252,7 @@ module Ci ...@@ -252,7 +252,7 @@ module Ci
it "does not return builds if except has a list of branches including specified" do it "does not return builds if except has a list of branches including specified" do
config = YAML.dump({ config = YAML.dump({
before_script: ["pwd"], before_script: ["pwd"],
rspec: { script: "rspec", type: type, except: ["master", "deploy"] } rspec: { script: "rspec", type: type, except: %w(master deploy) }
}) })
config_processor = GitlabCiYamlProcessor.new(config, path) config_processor = GitlabCiYamlProcessor.new(config, path)
...@@ -580,7 +580,7 @@ module Ci ...@@ -580,7 +580,7 @@ module Ci
context 'when syntax is incorrect' do context 'when syntax is incorrect' do
context 'when variables defined but invalid' do context 'when variables defined but invalid' do
let(:variables) do let(:variables) do
['VAR1', 'value1', 'VAR2', 'value2'] %w(VAR1 value1 VAR2 value2)
end end
it 'raises error' do it 'raises error' do
...@@ -909,7 +909,7 @@ module Ci ...@@ -909,7 +909,7 @@ module Ci
end end
context 'dependencies to builds' do context 'dependencies to builds' do
let(:dependencies) { ['build1', 'build2'] } let(:dependencies) { %w(build1 build2) }
it { expect { subject }.not_to raise_error } it { expect { subject }.not_to raise_error }
end end
...@@ -1215,7 +1215,7 @@ EOT ...@@ -1215,7 +1215,7 @@ EOT
end end
it "returns errors if job stage is not a defined stage" do it "returns errors if job stage is not a defined stage" do
config = YAML.dump({ types: ["build", "test"], rspec: { script: "test", type: "acceptance" } }) config = YAML.dump({ types: %w(build test), rspec: { script: "test", type: "acceptance" } })
expect do expect do
GitlabCiYamlProcessor.new(config, path) GitlabCiYamlProcessor.new(config, path)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: stage parameter should be build, test") end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: stage parameter should be build, test")
...@@ -1257,42 +1257,42 @@ EOT ...@@ -1257,42 +1257,42 @@ EOT
end end
it "returns errors if job artifacts:name is not an a string" do it "returns errors if job artifacts:name is not an a string" do
config = YAML.dump({ types: ["build", "test"], rspec: { script: "test", artifacts: { name: 1 } } }) config = YAML.dump({ types: %w(build test), rspec: { script: "test", artifacts: { name: 1 } } })
expect do expect do
GitlabCiYamlProcessor.new(config) GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "jobs:rspec:artifacts name should be a string") end.to raise_error(GitlabCiYamlProcessor::ValidationError, "jobs:rspec:artifacts name should be a string")
end end
it "returns errors if job artifacts:when is not an a predefined value" do it "returns errors if job artifacts:when is not an a predefined value" do
config = YAML.dump({ types: ["build", "test"], rspec: { script: "test", artifacts: { when: 1 } } }) config = YAML.dump({ types: %w(build test), rspec: { script: "test", artifacts: { when: 1 } } })
expect do expect do
GitlabCiYamlProcessor.new(config) GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "jobs:rspec:artifacts when should be on_success, on_failure or always") end.to raise_error(GitlabCiYamlProcessor::ValidationError, "jobs:rspec:artifacts when should be on_success, on_failure or always")
end end
it "returns errors if job artifacts:expire_in is not an a string" do it "returns errors if job artifacts:expire_in is not an a string" do
config = YAML.dump({ types: ["build", "test"], rspec: { script: "test", artifacts: { expire_in: 1 } } }) config = YAML.dump({ types: %w(build test), rspec: { script: "test", artifacts: { expire_in: 1 } } })
expect do expect do
GitlabCiYamlProcessor.new(config) GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "jobs:rspec:artifacts expire in should be a duration") end.to raise_error(GitlabCiYamlProcessor::ValidationError, "jobs:rspec:artifacts expire in should be a duration")
end end
it "returns errors if job artifacts:expire_in is not an a valid duration" do it "returns errors if job artifacts:expire_in is not an a valid duration" do
config = YAML.dump({ types: ["build", "test"], rspec: { script: "test", artifacts: { expire_in: "7 elephants" } } }) config = YAML.dump({ types: %w(build test), rspec: { script: "test", artifacts: { expire_in: "7 elephants" } } })
expect do expect do
GitlabCiYamlProcessor.new(config) GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "jobs:rspec:artifacts expire in should be a duration") end.to raise_error(GitlabCiYamlProcessor::ValidationError, "jobs:rspec:artifacts expire in should be a duration")
end end
it "returns errors if job artifacts:untracked is not an array of strings" do it "returns errors if job artifacts:untracked is not an array of strings" do
config = YAML.dump({ types: ["build", "test"], rspec: { script: "test", artifacts: { untracked: "string" } } }) config = YAML.dump({ types: %w(build test), rspec: { script: "test", artifacts: { untracked: "string" } } })
expect do expect do
GitlabCiYamlProcessor.new(config) GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "jobs:rspec:artifacts untracked should be a boolean value") end.to raise_error(GitlabCiYamlProcessor::ValidationError, "jobs:rspec:artifacts untracked should be a boolean value")
end end
it "returns errors if job artifacts:paths is not an array of strings" do it "returns errors if job artifacts:paths is not an array of strings" do
config = YAML.dump({ types: ["build", "test"], rspec: { script: "test", artifacts: { paths: "string" } } }) config = YAML.dump({ types: %w(build test), rspec: { script: "test", artifacts: { paths: "string" } } })
expect do expect do
GitlabCiYamlProcessor.new(config) GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "jobs:rspec:artifacts paths should be an array of strings") end.to raise_error(GitlabCiYamlProcessor::ValidationError, "jobs:rspec:artifacts paths should be an array of strings")
...@@ -1320,28 +1320,28 @@ EOT ...@@ -1320,28 +1320,28 @@ EOT
end end
it "returns errors if job cache:key is not an a string" do it "returns errors if job cache:key is not an a string" do
config = YAML.dump({ types: ["build", "test"], rspec: { script: "test", cache: { key: 1 } } }) config = YAML.dump({ types: %w(build test), rspec: { script: "test", cache: { key: 1 } } })
expect do expect do
GitlabCiYamlProcessor.new(config) GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "jobs:rspec:cache:key config should be a string or symbol") end.to raise_error(GitlabCiYamlProcessor::ValidationError, "jobs:rspec:cache:key config should be a string or symbol")
end end
it "returns errors if job cache:untracked is not an array of strings" do it "returns errors if job cache:untracked is not an array of strings" do
config = YAML.dump({ types: ["build", "test"], rspec: { script: "test", cache: { untracked: "string" } } }) config = YAML.dump({ types: %w(build test), rspec: { script: "test", cache: { untracked: "string" } } })
expect do expect do
GitlabCiYamlProcessor.new(config) GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "jobs:rspec:cache:untracked config should be a boolean value") end.to raise_error(GitlabCiYamlProcessor::ValidationError, "jobs:rspec:cache:untracked config should be a boolean value")
end end
it "returns errors if job cache:paths is not an array of strings" do it "returns errors if job cache:paths is not an array of strings" do
config = YAML.dump({ types: ["build", "test"], rspec: { script: "test", cache: { paths: "string" } } }) config = YAML.dump({ types: %w(build test), rspec: { script: "test", cache: { paths: "string" } } })
expect do expect do
GitlabCiYamlProcessor.new(config) GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "jobs:rspec:cache:paths config should be an array of strings") end.to raise_error(GitlabCiYamlProcessor::ValidationError, "jobs:rspec:cache:paths config should be an array of strings")
end end
it "returns errors if job dependencies is not an array of strings" do it "returns errors if job dependencies is not an array of strings" do
config = YAML.dump({ types: ["build", "test"], rspec: { script: "test", dependencies: "string" } }) config = YAML.dump({ types: %w(build test), rspec: { script: "test", dependencies: "string" } })
expect do expect do
GitlabCiYamlProcessor.new(config) GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "jobs:rspec dependencies should be an array of strings") end.to raise_error(GitlabCiYamlProcessor::ValidationError, "jobs:rspec dependencies should be an array of strings")
......
...@@ -177,12 +177,12 @@ describe ExtractsPath, lib: true do ...@@ -177,12 +177,12 @@ describe ExtractsPath, lib: true do
it "extracts a valid commit SHA" do it "extracts a valid commit SHA" do
expect(extract_ref('f4b14494ef6abf3d144c28e4af0c20143383e062/CHANGELOG')).to eq( expect(extract_ref('f4b14494ef6abf3d144c28e4af0c20143383e062/CHANGELOG')).to eq(
['f4b14494ef6abf3d144c28e4af0c20143383e062', 'CHANGELOG'] %w(f4b14494ef6abf3d144c28e4af0c20143383e062 CHANGELOG)
) )
end end
it "falls back to a primitive split for an invalid ref" do it "falls back to a primitive split for an invalid ref" do
expect(extract_ref('stable/CHANGELOG')).to eq(['stable', 'CHANGELOG']) expect(extract_ref('stable/CHANGELOG')).to eq(%w(stable CHANGELOG))
end end
end end
end end
......
...@@ -4,7 +4,7 @@ describe Gitlab::Ci::Config::Entry::Commands do ...@@ -4,7 +4,7 @@ describe Gitlab::Ci::Config::Entry::Commands do
let(:entry) { described_class.new(config) } let(:entry) { described_class.new(config) }
context 'when entry config value is an array' do context 'when entry config value is an array' do
let(:config) { ['ls', 'pwd'] } let(:config) { %w(ls pwd) }
describe '#value' do describe '#value' do
it 'returns array of strings' do it 'returns array of strings' do
......
...@@ -8,20 +8,20 @@ describe Gitlab::Ci::Config::Entry::Factory do ...@@ -8,20 +8,20 @@ describe Gitlab::Ci::Config::Entry::Factory do
context 'when setting a concrete value' do context 'when setting a concrete value' do
it 'creates entry with valid value' do it 'creates entry with valid value' do
entry = factory entry = factory
.value(['ls', 'pwd']) .value(%w(ls pwd))
.create! .create!
expect(entry.value).to eq ['ls', 'pwd'] expect(entry.value).to eq %w(ls pwd)
end end
context 'when setting description' do context 'when setting description' do
it 'creates entry with description' do it 'creates entry with description' do
entry = factory entry = factory
.value(['ls', 'pwd']) .value(%w(ls pwd))
.with(description: 'test description') .with(description: 'test description')
.create! .create!
expect(entry.value).to eq ['ls', 'pwd'] expect(entry.value).to eq %w(ls pwd)
expect(entry.description).to eq 'test description' expect(entry.description).to eq 'test description'
end end
end end
...@@ -29,7 +29,7 @@ describe Gitlab::Ci::Config::Entry::Factory do ...@@ -29,7 +29,7 @@ describe Gitlab::Ci::Config::Entry::Factory do
context 'when setting key' do context 'when setting key' do
it 'creates entry with custom key' do it 'creates entry with custom key' do
entry = factory entry = factory
.value(['ls', 'pwd']) .value(%w(ls pwd))
.with(key: 'test key') .with(key: 'test key')
.create! .create!
......
...@@ -21,12 +21,12 @@ describe Gitlab::Ci::Config::Entry::Global do ...@@ -21,12 +21,12 @@ describe Gitlab::Ci::Config::Entry::Global do
context 'when configuration is valid' do context 'when configuration is valid' do
context 'when some entries defined' do context 'when some entries defined' do
let(:hash) do let(:hash) do
{ before_script: ['ls', 'pwd'], { before_script: %w(ls pwd),
image: 'ruby:2.2', image: 'ruby:2.2',
services: ['postgres:9.1', 'mysql:5.5'], services: ['postgres:9.1', 'mysql:5.5'],
variables: { VAR: 'value' }, variables: { VAR: 'value' },
after_script: ['make clean'], after_script: ['make clean'],
stages: ['build', 'pages'], stages: %w(build pages),
cache: { key: 'k', untracked: true, paths: ['public/'] }, cache: { key: 'k', untracked: true, paths: ['public/'] },
rspec: { script: %w[rspec ls] }, rspec: { script: %w[rspec ls] },
spinach: { before_script: [], variables: {}, script: 'spinach' } } spinach: { before_script: [], variables: {}, script: 'spinach' } }
...@@ -89,7 +89,7 @@ describe Gitlab::Ci::Config::Entry::Global do ...@@ -89,7 +89,7 @@ describe Gitlab::Ci::Config::Entry::Global do
describe '#before_script_value' do describe '#before_script_value' do
it 'returns correct script' do it 'returns correct script' do
expect(global.before_script_value).to eq ['ls', 'pwd'] expect(global.before_script_value).to eq %w(ls pwd)
end end
end end
...@@ -126,7 +126,7 @@ describe Gitlab::Ci::Config::Entry::Global do ...@@ -126,7 +126,7 @@ describe Gitlab::Ci::Config::Entry::Global do
context 'when deprecated types key defined' do context 'when deprecated types key defined' do
let(:hash) do let(:hash) do
{ types: ['test', 'deploy'], { types: %w(test deploy),
rspec: { script: 'rspec' } } rspec: { script: 'rspec' } }
end end
...@@ -148,7 +148,7 @@ describe Gitlab::Ci::Config::Entry::Global do ...@@ -148,7 +148,7 @@ describe Gitlab::Ci::Config::Entry::Global do
expect(global.jobs_value).to eq( expect(global.jobs_value).to eq(
rspec: { name: :rspec, rspec: { name: :rspec,
script: %w[rspec ls], script: %w[rspec ls],
before_script: ['ls', 'pwd'], before_script: %w(ls pwd),
commands: "ls\npwd\nrspec\nls", commands: "ls\npwd\nrspec\nls",
image: 'ruby:2.2', image: 'ruby:2.2',
services: ['postgres:9.1', 'mysql:5.5'], services: ['postgres:9.1', 'mysql:5.5'],
......
...@@ -5,7 +5,7 @@ describe Gitlab::Ci::Config::Entry::Script do ...@@ -5,7 +5,7 @@ describe Gitlab::Ci::Config::Entry::Script do
describe 'validations' do describe 'validations' do
context 'when entry config value is correct' do context 'when entry config value is correct' do
let(:config) { ['ls', 'pwd'] } let(:config) { %w(ls pwd) }
describe '#value' do describe '#value' do
it 'returns array of strings' do it 'returns array of strings' do
......
...@@ -44,7 +44,7 @@ describe Gitlab::Conflict::File, lib: true do ...@@ -44,7 +44,7 @@ describe Gitlab::Conflict::File, lib: true do
it 'returns a file containing only the chosen parts of the resolved sections' do it 'returns a file containing only the chosen parts of the resolved sections' do
expect(resolved_lines.chunk { |line| line.type || 'both' }.map(&:first)) expect(resolved_lines.chunk { |line| line.type || 'both' }.map(&:first))
.to eq(['both', 'new', 'both', 'old', 'both', 'new', 'both']) .to eq(%w(both new both old both new both))
end end
end end
...@@ -123,7 +123,7 @@ describe Gitlab::Conflict::File, lib: true do ...@@ -123,7 +123,7 @@ describe Gitlab::Conflict::File, lib: true do
it 'sets conflict to true for sections with only changed lines' do it 'sets conflict to true for sections with only changed lines' do
conflict_file.sections.select { |section| section[:conflict] }.each do |section| conflict_file.sections.select { |section| section[:conflict] }.each do |section|
section[:lines].each do |line| section[:lines].each do |line|
expect(line.type).to be_in(['new', 'old']) expect(line.type).to be_in(%w(new old))
end end
end end
end end
......
...@@ -11,7 +11,7 @@ describe Gitlab::Git::BlobSnippet, seed_helper: true do ...@@ -11,7 +11,7 @@ describe Gitlab::Git::BlobSnippet, seed_helper: true do
end end
context 'present lines' do context 'present lines' do
let(:snippet) { Gitlab::Git::BlobSnippet.new('master', ['wow', 'much'], 1, 'wow.rb') } let(:snippet) { Gitlab::Git::BlobSnippet.new('master', %w(wow much), 1, 'wow.rb') }
it { expect(snippet.data).to eq("wow\nmuch") } it { expect(snippet.data).to eq("wow\nmuch") }
end end
......
...@@ -345,7 +345,7 @@ describe Gitlab::GitAccess, lib: true do ...@@ -345,7 +345,7 @@ describe Gitlab::GitAccess, lib: true do
} }
} }
[['feature', 'exact'], ['feat*', 'wildcard']].each do |protected_branch_name, protected_branch_type| [%w(feature exact), ['feat*', 'wildcard']].each do |protected_branch_name, protected_branch_type|
context do context do
before { create(:protected_branch, :remove_default_access_levels, :masters_can_push, name: protected_branch_name, project: project) } before { create(:protected_branch, :remove_default_access_levels, :masters_can_push, name: protected_branch_name, project: project) }
......
...@@ -17,7 +17,7 @@ describe 'Import/Export attribute configuration', lib: true do ...@@ -17,7 +17,7 @@ describe 'Import/Export attribute configuration', lib: true do
# Remove duplicated or add missing models # Remove duplicated or add missing models
# - project is not part of the tree, so it has to be added manually. # - project is not part of the tree, so it has to be added manually.
# - milestone, labels have both singular and plural versions in the tree, so remove the duplicates. # - milestone, labels have both singular and plural versions in the tree, so remove the duplicates.
names.flatten.uniq - ['milestones', 'labels'] + ['project'] names.flatten.uniq - %w(milestones labels) + ['project']
end end
let(:safe_attributes_file) { 'spec/lib/gitlab/import_export/safe_model_attributes.yml' } let(:safe_attributes_file) { 'spec/lib/gitlab/import_export/safe_model_attributes.yml' }
......
...@@ -14,7 +14,7 @@ describe 'Import/Export model configuration', lib: true do ...@@ -14,7 +14,7 @@ describe 'Import/Export model configuration', lib: true do
# - project is not part of the tree, so it has to be added manually. # - project is not part of the tree, so it has to be added manually.
# - milestone, labels have both singular and plural versions in the tree, so remove the duplicates. # - milestone, labels have both singular and plural versions in the tree, so remove the duplicates.
# - User, Author... Models we do not care about for checking models # - User, Author... Models we do not care about for checking models
names.flatten.uniq - ['milestones', 'labels', 'user', 'author'] + ['project'] names.flatten.uniq - %w(milestones labels user author) + ['project']
end end
let(:all_models_yml) { 'spec/lib/gitlab/import_export/all_models.yml' } let(:all_models_yml) { 'spec/lib/gitlab/import_export/all_models.yml' }
......
...@@ -114,7 +114,7 @@ describe Gitlab::ImportExport::ProjectTreeSaver, services: true do ...@@ -114,7 +114,7 @@ describe Gitlab::ImportExport::ProjectTreeSaver, services: true do
it 'has project and group labels' do it 'has project and group labels' do
label_types = saved_project_json['issues'].first['label_links'].map { |link| link['label']['type'] } label_types = saved_project_json['issues'].first['label_links'].map { |link| link['label']['type'] }
expect(label_types).to match_array(['ProjectLabel', 'GroupLabel']) expect(label_types).to match_array(%w(ProjectLabel GroupLabel))
end end
it 'has priorities associated to labels' do it 'has priorities associated to labels' do
......
...@@ -22,16 +22,15 @@ describe Gitlab::ImportSources do ...@@ -22,16 +22,15 @@ describe Gitlab::ImportSources do
describe '.values' do describe '.values' do
it 'returns an array' do it 'returns an array' do
expected = expected =
[ %w(
'github', github
'bitbucket', bitbucket
'gitlab', gitlab
'google_code', google_code
'fogbugz', fogbugz
'git', git
'gitlab_project', gitlab_project
'gitea' gitea)
]
expect(described_class.values).to eq(expected) expect(described_class.values).to eq(expected)
end end
...@@ -40,15 +39,14 @@ describe Gitlab::ImportSources do ...@@ -40,15 +39,14 @@ describe Gitlab::ImportSources do
describe '.importer_names' do describe '.importer_names' do
it 'returns an array of importer names' do it 'returns an array of importer names' do
expected = expected =
[ %w(
'github', github
'bitbucket', bitbucket
'gitlab', gitlab
'google_code', google_code
'fogbugz', fogbugz
'gitlab_project', gitlab_project
'gitea' gitea)
]
expect(described_class.importer_names).to eq(expected) expect(described_class.importer_names).to eq(expected)
end end
......
...@@ -44,7 +44,7 @@ describe Gitlab::LDAP::AuthHash, lib: true do ...@@ -44,7 +44,7 @@ describe Gitlab::LDAP::AuthHash, lib: true do
context "with overridden attributes" do context "with overridden attributes" do
let(:attributes) do let(:attributes) do
{ {
'username' => ['mail', 'email'], 'username' => %w(mail email),
'name' => 'fullName' 'name' => 'fullName'
} }
end end
......
...@@ -136,9 +136,9 @@ describe ApplicationSetting, models: true do ...@@ -136,9 +136,9 @@ describe ApplicationSetting, models: true do
describe 'inclusion' do describe 'inclusion' do
it { is_expected.to allow_value('custom1').for(:repository_storages) } it { is_expected.to allow_value('custom1').for(:repository_storages) }
it { is_expected.to allow_value(['custom2', 'custom3']).for(:repository_storages) } it { is_expected.to allow_value(%w(custom2 custom3)).for(:repository_storages) }
it { is_expected.not_to allow_value('alternative').for(:repository_storages) } it { is_expected.not_to allow_value('alternative').for(:repository_storages) }
it { is_expected.not_to allow_value(['alternative', 'custom1']).for(:repository_storages) } it { is_expected.not_to allow_value(%w(alternative custom1)).for(:repository_storages) }
end end
describe 'presence' do describe 'presence' do
...@@ -157,7 +157,7 @@ describe ApplicationSetting, models: true do ...@@ -157,7 +157,7 @@ describe ApplicationSetting, models: true do
describe '#repository_storage' do describe '#repository_storage' do
it 'returns the first storage' do it 'returns the first storage' do
setting.repository_storages = ['good', 'bad'] setting.repository_storages = %w(good bad)
expect(setting.repository_storage).to eq('good') expect(setting.repository_storage).to eq('good')
end end
......
...@@ -1420,7 +1420,7 @@ describe Ci::Build, :models do ...@@ -1420,7 +1420,7 @@ describe Ci::Build, :models do
end end
context 'when runner is assigned to build' do context 'when runner is assigned to build' do
let(:runner) { create(:ci_runner, description: 'description', tag_list: ['docker', 'linux']) } let(:runner) { create(:ci_runner, description: 'description', tag_list: %w(docker linux)) }
before do before do
build.update(runner: runner) build.update(runner: runner)
......
...@@ -168,9 +168,9 @@ describe Ci::Pipeline, models: true do ...@@ -168,9 +168,9 @@ describe Ci::Pipeline, models: true do
end end
it 'returns list of stages with correct statuses' do it 'returns list of stages with correct statuses' do
expect(statuses).to eq([['build', 'failed'], expect(statuses).to eq([%w(build failed),
['test', 'success'], %w(test success),
['deploy', 'running']]) %w(deploy running)])
end end
context 'when commit status is retried' do context 'when commit status is retried' do
...@@ -183,9 +183,9 @@ describe Ci::Pipeline, models: true do ...@@ -183,9 +183,9 @@ describe Ci::Pipeline, models: true do
end end
it 'ignores the previous state' do it 'ignores the previous state' do
expect(statuses).to eq([['build', 'success'], expect(statuses).to eq([%w(build success),
['test', 'success'], %w(test success),
['deploy', 'running']]) %w(deploy running)])
end end
end end
end end
...@@ -199,7 +199,7 @@ describe Ci::Pipeline, models: true do ...@@ -199,7 +199,7 @@ describe Ci::Pipeline, models: true do
describe '#stages_name' do describe '#stages_name' do
it 'returns a valid names of stages' do it 'returns a valid names of stages' do
expect(pipeline.stages_name).to eq(['build', 'test', 'deploy']) expect(pipeline.stages_name).to eq(%w(build test deploy))
end end
end end
end end
...@@ -767,7 +767,7 @@ describe Ci::Pipeline, models: true do ...@@ -767,7 +767,7 @@ describe Ci::Pipeline, models: true do
end end
it 'cancels created builds' do it 'cancels created builds' do
expect(latest_status).to eq ['canceled', 'canceled'] expect(latest_status).to eq %w(canceled canceled)
end end
end end
end end
......
...@@ -113,7 +113,7 @@ describe Ci::Runner, models: true do ...@@ -113,7 +113,7 @@ describe Ci::Runner, models: true do
context 'when runner has tags' do context 'when runner has tags' do
before do before do
runner.tag_list = ['bb', 'cc'] runner.tag_list = %w(bb cc)
end end
shared_examples 'tagged build picker' do shared_examples 'tagged build picker' do
...@@ -169,7 +169,7 @@ describe Ci::Runner, models: true do ...@@ -169,7 +169,7 @@ describe Ci::Runner, models: true do
context 'when having runner tags' do context 'when having runner tags' do
before do before do
runner.tag_list = ['bb', 'cc'] runner.tag_list = %w(bb cc)
end end
it 'cannot handle it for builds without matching tags' do it 'cannot handle it for builds without matching tags' do
...@@ -189,7 +189,7 @@ describe Ci::Runner, models: true do ...@@ -189,7 +189,7 @@ describe Ci::Runner, models: true do
context 'when having runner tags' do context 'when having runner tags' do
before do before do
runner.tag_list = ['bb', 'cc'] runner.tag_list = %w(bb cc)
build.tag_list = ['bb'] build.tag_list = ['bb']
end end
...@@ -212,7 +212,7 @@ describe Ci::Runner, models: true do ...@@ -212,7 +212,7 @@ describe Ci::Runner, models: true do
context 'when having runner tags' do context 'when having runner tags' do
before do before do
runner.tag_list = ['bb', 'cc'] runner.tag_list = %w(bb cc)
build.tag_list = ['bb'] build.tag_list = ['bb']
end end
......
...@@ -109,7 +109,7 @@ describe MergeRequestDiff, models: true do ...@@ -109,7 +109,7 @@ describe MergeRequestDiff, models: true do
{ id: 'sha2' } { id: 'sha2' }
] ]
expect(subject.commits_sha).to eq(['sha1', 'sha2']) expect(subject.commits_sha).to eq(%w(sha1 sha2))
end end
end end
......
...@@ -60,7 +60,7 @@ describe IrkerService, models: true do ...@@ -60,7 +60,7 @@ describe IrkerService, models: true do
conn = @irker_server.accept conn = @irker_server.accept
conn.readlines.each do |line| conn.readlines.each do |line|
msg = JSON.parse(line.chomp("\n")) msg = JSON.parse(line.chomp("\n"))
expect(msg.keys).to match_array(['to', 'privmsg']) expect(msg.keys).to match_array(%w(to privmsg))
expect(msg['to']).to match_array(["irc://chat.freenode.net/#commits", expect(msg['to']).to match_array(["irc://chat.freenode.net/#commits",
"irc://test.net/#test"]) "irc://test.net/#test"])
end end
......
...@@ -776,7 +776,7 @@ describe API::Issues, api: true do ...@@ -776,7 +776,7 @@ describe API::Issues, api: true do
expect(response).to have_http_status(201) expect(response).to have_http_status(201)
expect(json_response['title']).to eq('new issue') expect(json_response['title']).to eq('new issue')
expect(json_response['description']).to be_nil expect(json_response['description']).to be_nil
expect(json_response['labels']).to eq(['label', 'label2']) expect(json_response['labels']).to eq(%w(label label2))
expect(json_response['confidential']).to be_falsy expect(json_response['confidential']).to be_falsy
expect(json_response['weight']).to eq(3) expect(json_response['weight']).to eq(3)
end end
......
...@@ -21,11 +21,10 @@ describe API::Labels, api: true do ...@@ -21,11 +21,10 @@ describe API::Labels, api: true do
create(:labeled_issue, project: project, labels: [label1], author: user, state: :closed) create(:labeled_issue, project: project, labels: [label1], author: user, state: :closed)
create(:labeled_merge_request, labels: [priority_label], author: user, source_project: project ) create(:labeled_merge_request, labels: [priority_label], author: user, source_project: project )
expected_keys = [ expected_keys = %w(
'id', 'name', 'color', 'description', id name color description
'open_issues_count', 'closed_issues_count', 'open_merge_requests_count', open_issues_count closed_issues_count open_merge_requests_count
'subscribed', 'priority' subscribed priority)
]
get api("/projects/#{project.id}/labels", user) get api("/projects/#{project.id}/labels", user)
......
...@@ -252,7 +252,7 @@ describe API::MergeRequests, api: true do ...@@ -252,7 +252,7 @@ describe API::MergeRequests, api: true do
expect(response).to have_http_status(201) expect(response).to have_http_status(201)
expect(json_response['title']).to eq('Test merge_request') expect(json_response['title']).to eq('Test merge_request')
expect(json_response['labels']).to eq(['label', 'label2']) expect(json_response['labels']).to eq(%w(label label2))
expect(json_response['milestone']['id']).to eq(milestone.id) expect(json_response['milestone']['id']).to eq(milestone.id)
expect(json_response['force_remove_source_branch']).to be_truthy expect(json_response['force_remove_source_branch']).to be_truthy
expect(json_response['squash']).to be_truthy expect(json_response['squash']).to be_truthy
......
...@@ -121,7 +121,7 @@ describe API::Projects, api: true do ...@@ -121,7 +121,7 @@ describe API::Projects, api: true do
context 'and with simple=true' do context 'and with simple=true' do
it 'returns a simplified version of all the projects' do it 'returns a simplified version of all the projects' do
expected_keys = ["id", "http_url_to_repo", "web_url", "name", "name_with_namespace", "path", "path_with_namespace"] expected_keys = %w(id http_url_to_repo web_url name name_with_namespace path path_with_namespace)
get api('/projects?simple=true', user) get api('/projects?simple=true', user)
......
...@@ -723,7 +723,7 @@ describe API::V3::Issues, api: true do ...@@ -723,7 +723,7 @@ describe API::V3::Issues, api: true do
expect(response).to have_http_status(201) expect(response).to have_http_status(201)
expect(json_response['title']).to eq('new issue') expect(json_response['title']).to eq('new issue')
expect(json_response['description']).to be_nil expect(json_response['description']).to be_nil
expect(json_response['labels']).to eq(['label', 'label2']) expect(json_response['labels']).to eq(%w(label label2))
expect(json_response['confidential']).to be_falsy expect(json_response['confidential']).to be_falsy
expect(json_response['weight']).to eq(3) expect(json_response['weight']).to eq(3)
end end
......
...@@ -21,11 +21,10 @@ describe API::V3::Labels, api: true do ...@@ -21,11 +21,10 @@ describe API::V3::Labels, api: true do
create(:labeled_issue, project: project, labels: [label1], author: user, state: :closed) create(:labeled_issue, project: project, labels: [label1], author: user, state: :closed)
create(:labeled_merge_request, labels: [priority_label], author: user, source_project: project ) create(:labeled_merge_request, labels: [priority_label], author: user, source_project: project )
expected_keys = [ expected_keys = %w(
'id', 'name', 'color', 'description', id name color description
'open_issues_count', 'closed_issues_count', 'open_merge_requests_count', open_issues_count closed_issues_count open_merge_requests_count
'subscribed', 'priority' subscribed priority)
]
get v3_api("/projects/#{project.id}/labels", user) get v3_api("/projects/#{project.id}/labels", user)
......
...@@ -239,7 +239,7 @@ describe API::MergeRequests, api: true do ...@@ -239,7 +239,7 @@ describe API::MergeRequests, api: true do
expect(response).to have_http_status(201) expect(response).to have_http_status(201)
expect(json_response['title']).to eq('Test merge_request') expect(json_response['title']).to eq('Test merge_request')
expect(json_response['labels']).to eq(['label', 'label2']) expect(json_response['labels']).to eq(%w(label label2))
expect(json_response['milestone']['id']).to eq(milestone.id) expect(json_response['milestone']['id']).to eq(milestone.id)
expect(json_response['force_remove_source_branch']).to be_truthy expect(json_response['force_remove_source_branch']).to be_truthy
expect(json_response['squash']).to be_truthy expect(json_response['squash']).to be_truthy
......
...@@ -84,7 +84,7 @@ describe API::V3::Projects, api: true do ...@@ -84,7 +84,7 @@ describe API::V3::Projects, api: true do
context 'GET /projects?simple=true' do context 'GET /projects?simple=true' do
it 'returns a simplified version of all the projects' do it 'returns a simplified version of all the projects' do
expected_keys = ["id", "http_url_to_repo", "web_url", "name", "name_with_namespace", "path", "path_with_namespace"] expected_keys = %w(id http_url_to_repo web_url name name_with_namespace path path_with_namespace)
get v3_api('/projects?simple=true', user) get v3_api('/projects?simple=true', user)
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe Ci::API::Builds do describe Ci::API::Builds do
include ApiHelpers include ApiHelpers
let(:runner) { FactoryGirl.create(:ci_runner, tag_list: ["mysql", "ruby"]) } let(:runner) { FactoryGirl.create(:ci_runner, tag_list: %w(mysql ruby)) }
let(:project) { FactoryGirl.create(:empty_project, shared_runners_enabled: false) } let(:project) { FactoryGirl.create(:empty_project, shared_runners_enabled: false) }
let(:last_update) { nil } let(:last_update) { nil }
......
...@@ -41,7 +41,7 @@ describe Ci::API::Runners do ...@@ -41,7 +41,7 @@ describe Ci::API::Runners do
it 'creates runner' do it 'creates runner' do
expect(response).to have_http_status 201 expect(response).to have_http_status 201
expect(Ci::Runner.first.tag_list.sort).to eq(["tag1", "tag2"]) expect(Ci::Runner.first.tag_list.sort).to eq(%w(tag1 tag2))
end end
end end
......
...@@ -77,7 +77,7 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do ...@@ -77,7 +77,7 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
shared_examples 'a pullable and pushable' do shared_examples 'a pullable and pushable' do
it_behaves_like 'a accessible' do it_behaves_like 'a accessible' do
let(:actions) { ['pull', 'push'] } let(:actions) { %w(pull push) }
end end
end end
......
...@@ -59,8 +59,8 @@ describe MergeRequests::ResolveService do ...@@ -59,8 +59,8 @@ describe MergeRequests::ResolveService do
it 'creates a commit with the correct parents' do it 'creates a commit with the correct parents' do
expect(merge_request.source_branch_head.parents.map(&:id)) expect(merge_request.source_branch_head.parents.map(&:id))
.to eq(['1450cd639e0bc6721eb02800169e464f212cde06', .to eq(%w(1450cd639e0bc6721eb02800169e464f212cde06
'824be604a34828eb682305f0d963056cfac87b2d']) 824be604a34828eb682305f0d963056cfac87b2d))
end end
end end
...@@ -125,8 +125,8 @@ describe MergeRequests::ResolveService do ...@@ -125,8 +125,8 @@ describe MergeRequests::ResolveService do
it 'creates a commit with the correct parents' do it 'creates a commit with the correct parents' do
expect(merge_request.source_branch_head.parents.map(&:id)) expect(merge_request.source_branch_head.parents.map(&:id))
.to eq(['1450cd639e0bc6721eb02800169e464f212cde06', .to eq(%w(1450cd639e0bc6721eb02800169e464f212cde06
'824be604a34828eb682305f0d963056cfac87b2d']) 824be604a34828eb682305f0d963056cfac87b2d))
end end
it 'sets the content to the content given' do it 'sets the content to the content given' do
......
...@@ -638,7 +638,7 @@ describe SystemNoteService, services: true do ...@@ -638,7 +638,7 @@ describe SystemNoteService, services: true do
jira_service_settings jira_service_settings
end end
noteable_types = ["merge_requests", "commit"] noteable_types = %w(merge_requests commit)
noteable_types.each do |type| noteable_types.each do |type|
context "when noteable is a #{type}" do context "when noteable is a #{type}" do
......
...@@ -100,13 +100,12 @@ eos ...@@ -100,13 +100,12 @@ eos
} }
] ]
commits = [ commits = %w(
'5937ac0a7beb003549fc5fd26fc247adbce4a52e', 5937ac0a7beb003549fc5fd26fc247adbce4a52e
'570e7b2abdd848b95f2f578043fc23bd6f6fd24d', 570e7b2abdd848b95f2f578043fc23bd6f6fd24d
'6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9', 6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9
'd14d6c0abdd253381df51a723d58691b2ee1ab08', d14d6c0abdd253381df51a723d58691b2ee1ab08
'c1acaa58bbcbc3eafe538cb8274ba387047b69f8', c1acaa58bbcbc3eafe538cb8274ba387047b69f8).reverse # last commit is recent one
].reverse # last commit is recent one
OpenStruct.new( OpenStruct.new(
source_branch: 'master', source_branch: 'master',
......
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