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
|
|
@ -20,7 +20,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|||
rdoc.rdoc_files.include('lib/**/*.rb')
|
||||
end
|
||||
|
||||
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
||||
APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__)
|
||||
load 'rails/tasks/engine.rake'
|
||||
|
||||
Bundler::GemHelper.install_tasks
|
||||
|
|
@ -34,4 +34,4 @@ Rake::TestTask.new(:test) do |t|
|
|||
t.verbose = false
|
||||
end
|
||||
|
||||
task :default => :test
|
||||
task default: :test
|
||||
|
|
|
|||
|
|
@ -4,16 +4,16 @@ class DocumentsController < ApplicationController
|
|||
before_action -> { require_plugin_enabled FoodsoftDocuments }
|
||||
|
||||
def index
|
||||
if params["sort"]
|
||||
sort = case params["sort"]
|
||||
when "name" then "data IS NULL DESC, name"
|
||||
when "created_at" then "created_at"
|
||||
when "name_reverse" then "data IS NULL, name DESC"
|
||||
when "created_at_reverse" then "created_at DESC"
|
||||
sort = if params['sort']
|
||||
case params['sort']
|
||||
when 'name' then 'data IS NULL DESC, name'
|
||||
when 'created_at' then 'created_at'
|
||||
when 'name_reverse' then 'data IS NULL, name DESC'
|
||||
when 'created_at_reverse' then 'created_at DESC'
|
||||
end
|
||||
else
|
||||
sort = "data IS NULL DESC, name"
|
||||
end
|
||||
else
|
||||
'data IS NULL DESC, name'
|
||||
end
|
||||
|
||||
@documents = Document.where(parent: @document).page(params[:page]).per(@per_page).order(sort)
|
||||
end
|
||||
|
|
@ -34,22 +34,22 @@ class DocumentsController < ApplicationController
|
|||
|
||||
if @document.name.empty?
|
||||
name = File.basename(data.original_filename)
|
||||
@document.name = name.gsub(/[^\w\.\-]/, '_')
|
||||
@document.name = name.gsub(/[^\w.-]/, '_')
|
||||
end
|
||||
end
|
||||
@document.created_by = current_user
|
||||
@document.save!
|
||||
redirect_to @document.parent || documents_path, notice: t('.notice')
|
||||
rescue => error
|
||||
redirect_to @document.parent || documents_path, alert: t('.error', error: error.message)
|
||||
rescue StandardError => e
|
||||
redirect_to @document.parent || documents_path, alert: t('.error', error: e.message)
|
||||
end
|
||||
|
||||
def update
|
||||
@document = Document.find(params[:id])
|
||||
@document.update_attribute(:parent_id, params[:parent_id])
|
||||
redirect_to @document.parent || documents_path, notice: t('.notice')
|
||||
rescue => error
|
||||
redirect_to @document.parent || documents_path, alert: t('errors.general_msg', msg: error.message)
|
||||
rescue StandardError => e
|
||||
redirect_to @document.parent || documents_path, alert: t('errors.general_msg', msg: e.message)
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
|
@ -60,8 +60,8 @@ class DocumentsController < ApplicationController
|
|||
else
|
||||
redirect_to documents_path, alert: t('.no_right')
|
||||
end
|
||||
rescue => error
|
||||
redirect_to documents_path, alert: t('.error', error: error.message)
|
||||
rescue StandardError => e
|
||||
redirect_to documents_path, alert: t('.error', error: e.message)
|
||||
end
|
||||
|
||||
def show
|
||||
|
|
|
|||
|
|
@ -1,21 +1,22 @@
|
|||
$:.push File.expand_path("../lib", __FILE__)
|
||||
$:.push File.expand_path('lib', __dir__)
|
||||
|
||||
# Maintain your gem's version:
|
||||
require "foodsoft_documents/version"
|
||||
require 'foodsoft_documents/version'
|
||||
|
||||
# Describe your gem and declare its dependencies:
|
||||
Gem::Specification.new do |s|
|
||||
s.name = "foodsoft_documents"
|
||||
s.name = 'foodsoft_documents'
|
||||
s.version = FoodsoftDocuments::VERSION
|
||||
s.authors = ["paroga"]
|
||||
s.email = ["paroga@paroga.com"]
|
||||
s.homepage = "https://github.com/foodcoops/foodsoft"
|
||||
s.summary = "Documents plugin for foodsoft."
|
||||
s.description = "Adds simple document management to foodsoft."
|
||||
s.authors = ['paroga']
|
||||
s.email = ['paroga@paroga.com']
|
||||
s.homepage = 'https://github.com/foodcoops/foodsoft'
|
||||
s.summary = 'Documents plugin for foodsoft.'
|
||||
s.description = 'Adds simple document management to foodsoft.'
|
||||
|
||||
s.files = Dir["{app,config,db,lib}/**/*"] + ["Rakefile", "README.md"]
|
||||
s.files = Dir['{app,config,db,lib}/**/*'] + ['Rakefile', 'README.md']
|
||||
|
||||
s.add_dependency "rails"
|
||||
s.add_dependency "deface", "~> 1.0"
|
||||
s.add_dependency "ruby-filemagic"
|
||||
s.add_dependency 'rails'
|
||||
s.add_dependency 'deface', '~> 1.0'
|
||||
s.add_dependency 'ruby-filemagic'
|
||||
s.metadata['rubygems_mfa_required'] = 'true'
|
||||
end
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ module FoodsoftDocuments
|
|||
sub_nav.items <<
|
||||
SimpleNavigation::Item.new(primary, :documents, I18n.t('navigation.documents'), context.documents_path)
|
||||
# move to right before tasks item
|
||||
if i = sub_nav.items.index(sub_nav[:tasks])
|
||||
sub_nav.items.insert(i, sub_nav.items.delete_at(-1))
|
||||
end
|
||||
return unless i = sub_nav.items.index(sub_nav[:tasks])
|
||||
|
||||
sub_nav.items.insert(i, sub_nav.items.delete_at(-1))
|
||||
end
|
||||
|
||||
def default_foodsoft_config(cfg)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
module FoodsoftDocuments
|
||||
VERSION = "0.0.1"
|
||||
VERSION = '0.0.1'
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue