chore: rubocop
chore: fix api test conventions chore: rubocop -A spec/ chore: more rubocop -A fix failing test rubocop fixes removes helper methods that are in my opinion dead code more rubocop fixes rubocop -a --auto-gen-config
This commit is contained in:
parent
f6fb804bbe
commit
fb2b4d8a8a
331 changed files with 4263 additions and 4507 deletions
|
|
@ -4,12 +4,14 @@ module ApiHelper
|
|||
included do
|
||||
let(:user) { create(:user) }
|
||||
let(:api_scopes) { [] } # empty scopes for stricter testing (in reality this would be default_scopes)
|
||||
let(:api_access_token) { create(:oauth2_access_token, resource_owner_id: user.id, scopes: api_scopes&.join(' ')).token }
|
||||
let(:Authorization) { "Bearer #{api_access_token}" }
|
||||
let(:api_access_token) do
|
||||
create(:oauth2_access_token, resource_owner_id: user.id, scopes: api_scopes&.join(' ')).token
|
||||
end
|
||||
let(:Authorization) { "Bearer #{api_access_token}" } # rubocop:disable RSpec/VariableName
|
||||
|
||||
def self.it_handles_invalid_token
|
||||
context 'with invalid access token' do
|
||||
let(:Authorization) { 'abc' }
|
||||
let(:Authorization) { 'abc' } # rubocop:disable RSpec/VariableName
|
||||
|
||||
response 401, 'not logged-in' do
|
||||
schema '$ref' => '#/components/schemas/Error401'
|
||||
|
|
@ -20,7 +22,7 @@ module ApiHelper
|
|||
|
||||
def self.it_handles_invalid_token_with_id
|
||||
context 'with invalid access token' do
|
||||
let(:Authorization) { 'abc' }
|
||||
let(:Authorization) { 'abc' } # rubocop:disable RSpec/VariableName
|
||||
let(:id) { 42 } # id doesn't matter here
|
||||
|
||||
response 401, 'not logged-in' do
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ module ApiOAuth
|
|||
included do
|
||||
let(:user) { build(:user) }
|
||||
let(:api_scopes) { [] } # empty scopes for stricter testing (in reality this would be default_scopes)
|
||||
let(:api_access_token) { double(:acceptable? => true, :accessible? => true, scopes: api_scopes) }
|
||||
let(:api_access_token) { double(acceptable?: true, accessible?: true, scopes: api_scopes) }
|
||||
before { allow(controller).to receive(:doorkeeper_token) { api_access_token } }
|
||||
|
||||
before { allow(controller).to receive(:current_user) { user } }
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ if ENV['COVERAGE'] or ENV['COVERALLS']
|
|||
|
||||
# slightly tweaked coverage reporting
|
||||
def cov_no_plugins(source_file, path)
|
||||
source_file.filename =~ /#{path}/ and not source_file.filename =~ /\/lib\/foodsoft_.*\//
|
||||
source_file.filename =~ /#{path}/ and !(source_file.filename =~ %r{/lib/foodsoft_.*/})
|
||||
end
|
||||
SimpleCov.start do
|
||||
add_filter '/spec/'
|
||||
|
|
@ -21,6 +21,6 @@ if ENV['COVERAGE'] or ENV['COVERALLS']
|
|||
add_group 'Helpers' do |s| cov_no_plugins s, '/app/helpers/' end
|
||||
add_group 'Documents' do |s| cov_no_plugins s, '/app/documents/' end
|
||||
add_group 'Libraries' do |s| cov_no_plugins s, '/lib/' end
|
||||
add_group 'Plugins' do |s| s.filename =~ /\/lib\/foodsoft_.*\// end
|
||||
add_group 'Plugins' do |s| s.filename =~ %r{/lib/foodsoft_.*/} end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ module Faker
|
|||
class Unit
|
||||
class << self
|
||||
def unit
|
||||
['kg', '1L', '100ml', 'piece', 'bunch', '500g'].sample
|
||||
%w[kg 1L 100ml piece bunch 500g].sample
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# @see http://stackoverflow.com/a/11048669/2866660
|
||||
def scrolldown
|
||||
page.execute_script "window.scrollBy(0,10000)"
|
||||
page.execute_script 'window.scrollBy(0,10000)'
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,14 +1,15 @@
|
|||
module SessionHelper
|
||||
def login(user = nil, password = nil)
|
||||
visit login_path
|
||||
user = FactoryBot.create :user if user.nil?
|
||||
user = FactoryBot.create(:user) if user.nil?
|
||||
if user.instance_of? ::User
|
||||
nick, password = user.nick, user.password
|
||||
nick = user.nick
|
||||
password = user.password
|
||||
else
|
||||
nick = user
|
||||
end
|
||||
fill_in 'nick', :with => nick
|
||||
fill_in 'password', :with => password
|
||||
fill_in 'nick', with: nick
|
||||
fill_in 'password', with: password
|
||||
find('input[type=submit]').click
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ ActiveSupport.on_load(:after_initialize) do
|
|||
# But take care when designing tests using the shared database.
|
||||
SharedSupplier.establish_connection Rails.env.to_sym
|
||||
SharedArticle.establish_connection Rails.env.to_sym
|
||||
# hack for different structure of shared database
|
||||
# HACK: for different structure of shared database
|
||||
SharedArticle.class_eval do
|
||||
belongs_to :supplier, class_name: 'SharedSupplier'
|
||||
alias_attribute :number, :order_number
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue