Skip to content

Commit

Permalink
rubocop fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sashazykov committed Dec 6, 2020
1 parent ff7ff2e commit 1701f4c
Show file tree
Hide file tree
Showing 15 changed files with 264 additions and 290 deletions.
40 changes: 6 additions & 34 deletions .rubocop_todo.yml
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2020-12-06 17:32:53 UTC using RuboCop version 1.5.2.
# on 2020-12-06 18:08:51 UTC using RuboCop version 1.5.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -11,11 +11,11 @@
Metrics/AbcSize:
Max: 34

# Offense count: 17
# Offense count: 15
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
# IgnoredMethods: refine
Metrics/BlockLength:
Max: 224
Max: 117

# Offense count: 2
# Configuration parameters: CountComments, CountAsOne.
Expand Down Expand Up @@ -47,45 +47,22 @@ Naming/PredicateName:
Exclude:
- 'app/models/project.rb'

# Offense count: 3
# Offense count: 1
# Configuration parameters: Prefixes.
# Prefixes: when, with, without
RSpec/ContextWording:
Exclude:
- 'spec/controllers/projects_controller_spec.rb'

# Offense count: 1
# Configuration parameters: IgnoredMetadata.
RSpec/DescribeClass:
Exclude:
- 'spec/misc_spec.rb'

# Offense count: 13
# Configuration parameters: Max.
RSpec/ExampleLength:
Exclude:
- 'spec/controllers/projects_controller_spec.rb'
- 'spec/controllers/users_controller_spec.rb'
- 'spec/lib/blacklist_spec.rb'
- 'spec/models/deposit_spec.rb'

# Offense count: 25
# Cop supports --auto-correct.
RSpec/ExpectActual:
Exclude:
- 'spec/controllers/deposits_controller_spec.rb'
- 'spec/controllers/home_controller_spec.rb'
- 'spec/controllers/projects_controller_spec.rb'
- 'spec/controllers/tips_controller_spec.rb'
- 'spec/controllers/users_controller_spec.rb'
- 'spec/controllers/withdrawals_controller_spec.rb'

# Offense count: 1
# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
# Include: **/*_spec*rb*, **/spec/**/*
RSpec/FilePath:
Exclude:
- 'spec/models/send_many_spec.rb'
- 'spec/routing/projects_routing_spec.rb'
- 'spec/routing/users_routing_spec.rb'

# Offense count: 2
# Configuration parameters: AssignmentOnly.
Expand Down Expand Up @@ -117,11 +94,6 @@ RSpec/NamedSubject:
RSpec/NestedGroups:
Max: 5

# Offense count: 2
RSpec/RepeatedExample:
Exclude:
- 'spec/controllers/home_controller_spec.rb'

# Offense count: 2
RSpec/RepeatedExampleGroupBody:
Exclude:
Expand Down
9 changes: 0 additions & 9 deletions spec/controllers/deposits_controller_spec.rb
Expand Up @@ -9,13 +9,4 @@
expect(response).to be_successful
end
end

describe 'routing' do
it 'routes GET / to Deposits#index' do
expect({ get: '/deposits' }).to route_to(
controller: 'deposits',
action: 'index'
)
end
end
end
32 changes: 0 additions & 32 deletions spec/controllers/home_controller_spec.rb
Expand Up @@ -14,36 +14,4 @@
expect(subject.status).to eq 200
end
end

describe 'routing' do
it 'routes GET / to Home#index' do
expect({ get: '/' }).to route_to(
controller: 'home',
action: 'index'
)
end

it 'routes GET /home to Home#index' do
expect({ get: '/' }).to route_to(
controller: 'home',
action: 'index'
)
end

it 'routes GET /users/999999/no-such-path to Home#index' do
expect({ get: '/users/999999/no-such-path' }).to route_to(
controller: 'home',
action: 'index',
path: 'users/999999/no-such-path'
)
end

it 'routes GET /any/non-existent/path to Home#index' do
expect({ get: '/any/non-existent/path' }).to route_to(
controller: 'home',
action: 'index',
path: 'any/non-existent/path'
)
end
end
end
125 changes: 2 additions & 123 deletions spec/controllers/projects_controller_spec.rb
Expand Up @@ -71,7 +71,7 @@
shared_context 'accessing_project' do |verb, action|
let(:a_project) { create :project, host: 'github', full_name: 'test/test' }

context 'existing_project' do
context 'with existsing project' do
it 'via project id returns 302 status code' do
case verb
when :get
Expand All @@ -93,7 +93,7 @@
end
end

context 'nonexisting_project' do
context 'with non-existing project' do
it 'via project id returns 302 status code' do
case verb
when :get
Expand Down Expand Up @@ -158,125 +158,4 @@
expect(response).to be_redirect
end
end

describe 'routing' do
it 'routes GET /projects to Project#index' do
expect({ get: '/projects' }).to route_to(
controller: 'projects',
action: 'index'
)
end

it 'routes GET /projects/search?query= to Project#search' do
expect({ get: '/projects/search?query=seldon&order=balance' }).to route_to(
controller: 'projects',
action: 'search',
query: 'seldon',
order: 'balance'
)
end

it 'routes GET /projects/1 to Project#show' do
expect({ get: '/projects/1' }).to route_to(
controller: 'projects',
action: 'show',
id: '1'
)
end

it 'routes GET /projects/1/edit to Project#edit' do
expect({ get: '/projects/1/edit' }).to route_to(
controller: 'projects',
action: 'edit',
id: '1'
)
end

it 'routes PUT /projects/1 to Project#update' do
expect({ put: '/projects/1' }).to route_to(
controller: 'projects',
action: 'update',
id: '1'
)
end

it 'routes GET /projects/1/decide_tip_amounts to Project#decide_tip_amounts' do
expect({ get: '/projects/1/decide_tip_amounts' }).to route_to(
controller: 'projects',
action: 'decide_tip_amounts',
id: '1'
)
end

it 'routes PATCH /projects/1/decide_tip_amounts to Project#decide_tip_amounts' do
expect({ patch: '/projects/1/decide_tip_amounts' }).to route_to(
controller: 'projects',
action: 'decide_tip_amounts',
id: '1'
)
end

it 'routes GET /projects/1/tips to Tips#index' do
expect({ get: '/projects/1/tips' }).to route_to(
controller: 'tips',
action: 'index',
project_id: '1'
)
end

it 'routes GET /projects/1/deposits to Deposits#index' do
expect({ get: '/projects/1/deposits' }).to route_to(
controller: 'deposits',
action: 'index',
project_id: '1'
)
end
end

describe 'Project pretty url routing' do
it 'routes GET /:provider/:repo to Project#show' do
expect({ get: '/github/test/test' }).to route_to(
controller: 'projects',
action: 'show',
service: 'github',
repo: 'test/test'
)
end

it 'routes GET /:provider/:repo/edit to Project#edit' do
expect({ get: '/github/test/test/edit' }).to route_to(
controller: 'projects',
action: 'edit',
service: 'github',
repo: 'test/test'
)
end

it 'routes GET /:provider/:repo/decide_tip_amounts to Project#decide_tip_amounts' do
expect({ get: '/github/test/test/decide_tip_amounts' }).to route_to(
controller: 'projects',
action: 'decide_tip_amounts',
service: 'github',
repo: 'test/test'
)
end

it 'routes GET /:provider/:repo/tips to Project#tips' do
expect({ get: '/github/test/test/tips' }).to route_to(
controller: 'tips',
action: 'index',
service: 'github',
repo: 'test/test'
)
end

it 'routes GET /:provider/:repo/deposits to Project#deposits' do
expect({ get: '/github/test/test/deposits' }).to route_to(
controller: 'deposits',
action: 'index',
service: 'github',
repo: 'test/test'
)
end
end
end
9 changes: 0 additions & 9 deletions spec/controllers/tips_controller_spec.rb
Expand Up @@ -9,13 +9,4 @@
expect(response).to be_successful
end
end

describe 'routing' do
it 'routes GET / to Tips#index' do
expect({ get: '/tips' }).to route_to(
controller: 'tips',
action: 'index'
)
end
end
end
64 changes: 0 additions & 64 deletions spec/controllers/users_controller_spec.rb
Expand Up @@ -95,68 +95,4 @@
end
end
end

describe 'routing' do
it 'routes GET /users to User#index' do
expect({ get: '/users' }).to route_to(
controller: 'users',
action: 'index'
)
end

it 'routes GET /users/nick-name321 to User#show' do
expect({ get: '/users/nick-name321' }).to route_to(
controller: 'users',
action: 'show',
nickname: 'nick-name321'
)
end

it 'routes GET /users/login to User#login' do
expect({ get: '/users/login' }).to route_to(
controller: 'users',
action: 'login'
)
end

it 'routes GET /users/1/tips to Tips#index' do
expect({ get: '/users/1/tips' }).to route_to(
controller: 'tips',
action: 'index',
user_id: '1'
)
end
end

describe 'pretty url routing' do
let(:user) { create(:user) }

it 'regex rejects reserved user paths' do
# accepted pertty url usernames
should_accept = [' ', 'logi', 'ogin', 's4c2', '42x', 'nick name', 'kd']
# reserved routes (rejected pertty url usernames)
should_reject = ['', '1', '42']

accepted = should_accept.select { |ea| ea =~ /\D+/ }
rejected = should_reject.select { |ea| (ea =~ /\D+/).nil? }
(expect(accepted.size).to eq(should_accept.size)) &&
(expect(rejected.size).to eq(should_reject.size))
end

it 'routes GET /users/:nickname to User#show' do
expect({ get: "/users/#{user.nickname}" }).to route_to(
controller: 'users',
action: 'show',
nickname: 'kd'
)
end

it 'routes GET /users/:nickname/tips to Tips#index' do
expect({ get: "/users/#{user.nickname}/tips" }).to route_to(
controller: 'tips',
action: 'index',
nickname: 'kd'
)
end
end
end
9 changes: 0 additions & 9 deletions spec/controllers/withdrawals_controller_spec.rb
Expand Up @@ -9,13 +9,4 @@
expect(response).to be_successful
end
end

describe 'routing' do
it 'routes GET / to Withdrawals#index' do
expect({ get: '/withdrawals' }).to route_to(
controller: 'withdrawals',
action: 'index'
)
end
end
end
2 changes: 1 addition & 1 deletion spec/misc_spec.rb → spec/features/assets.rb
Expand Up @@ -2,7 +2,7 @@

require 'spec_helper'

describe 'Misc tets' do
describe 'Assets', type: :feature do
let(:locales) { Rails.application.config.available_locales }

it 'has a flag image for each locale' do
Expand Down
9 changes: 0 additions & 9 deletions spec/models/send_many_spec.rb

This file was deleted.

0 comments on commit 1701f4c

Please sign in to comment.