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
|
||||
|
|
|
|||
|
|
@ -27,9 +27,9 @@ class PollsController < ApplicationController
|
|||
def edit
|
||||
@poll = Poll.find(params[:id])
|
||||
|
||||
if user_has_no_right
|
||||
redirect_to polls_path, alert: t('.no_right')
|
||||
end
|
||||
return unless user_has_no_right
|
||||
|
||||
redirect_to polls_path, alert: t('.no_right')
|
||||
end
|
||||
|
||||
def update
|
||||
|
|
@ -53,8 +53,8 @@ class PollsController < ApplicationController
|
|||
@poll.destroy
|
||||
redirect_to polls_path, notice: t('.notice')
|
||||
end
|
||||
rescue => error
|
||||
redirect_to polls_path, alert: t('.error', error: error.message)
|
||||
rescue StandardError => e
|
||||
redirect_to polls_path, alert: t('.error', error: e.message)
|
||||
end
|
||||
|
||||
def vote
|
||||
|
|
@ -73,25 +73,25 @@ class PollsController < ApplicationController
|
|||
|
||||
@poll_vote = @poll.poll_votes.where(attributes).first_or_initialize
|
||||
|
||||
if request.post?
|
||||
@poll_vote.update!(note: params[:note], user: current_user)
|
||||
return unless request.post?
|
||||
|
||||
if @poll.single_select?
|
||||
choices = {}
|
||||
choice = params[:choice]
|
||||
choices[choice] = '1' if choice
|
||||
else
|
||||
choices = params[:choices].try(:to_h) || {}
|
||||
end
|
||||
@poll_vote.update!(note: params[:note], user: current_user)
|
||||
|
||||
@poll_vote.poll_choices = choices.map do |choice, value|
|
||||
poll_choice = @poll_vote.poll_choices.where(choice: choice).first_or_initialize
|
||||
poll_choice.update!(value: value)
|
||||
poll_choice
|
||||
end
|
||||
|
||||
redirect_to @poll
|
||||
if @poll.single_select?
|
||||
choices = {}
|
||||
choice = params[:choice]
|
||||
choices[choice] = '1' if choice
|
||||
else
|
||||
choices = params[:choices].try(:to_h) || {}
|
||||
end
|
||||
|
||||
@poll_vote.poll_choices = choices.map do |choice, value|
|
||||
poll_choice = @poll_vote.poll_choices.where(choice: choice).first_or_initialize
|
||||
poll_choice.update!(value: value)
|
||||
poll_choice
|
||||
end
|
||||
|
||||
redirect_to @poll
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
|||
|
|
@ -24,14 +24,14 @@ class CreatePolls < ActiveRecord::Migration[4.2]
|
|||
t.references :ordergroup
|
||||
t.text :note
|
||||
t.timestamps
|
||||
t.index [:poll_id, :user_id, :ordergroup_id], unique: true
|
||||
t.index %i[poll_id user_id ordergroup_id], unique: true
|
||||
end
|
||||
|
||||
create_table :poll_choices do |t|
|
||||
t.references :poll_vote, null: false
|
||||
t.integer :choice, null: false
|
||||
t.integer :value, null: false
|
||||
t.index [:poll_vote_id, :choice], unique: true
|
||||
t.index %i[poll_vote_id choice], unique: true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
class IncreaseChoicesSize < ActiveRecord::Migration[4.2]
|
||||
def up
|
||||
change_column :polls, :choices, :text, limit: 65535
|
||||
change_column :polls, :choices, :text, limit: 65_535
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,20 +1,21 @@
|
|||
$:.push File.expand_path("../lib", __FILE__)
|
||||
$:.push File.expand_path('lib', __dir__)
|
||||
|
||||
# Maintain your gem's version:
|
||||
require "foodsoft_polls/version"
|
||||
require 'foodsoft_polls/version'
|
||||
|
||||
# Describe your gem and declare its dependencies:
|
||||
Gem::Specification.new do |s|
|
||||
s.name = "foodsoft_polls"
|
||||
s.name = 'foodsoft_polls'
|
||||
s.version = FoodsoftPolls::VERSION
|
||||
s.authors = ["paroga"]
|
||||
s.email = ["paroga@paroga.com"]
|
||||
s.homepage = "https://github.com/foodcoops/foodsoft"
|
||||
s.summary = "Polls plugin for foodsoft."
|
||||
s.description = "Adds possibility to do polls with foodsoft."
|
||||
s.authors = ['paroga']
|
||||
s.email = ['paroga@paroga.com']
|
||||
s.homepage = 'https://github.com/foodcoops/foodsoft'
|
||||
s.summary = 'Polls plugin for foodsoft.'
|
||||
s.description = 'Adds possibility to do polls with 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 'rails'
|
||||
s.add_dependency 'deface', '~> 1.0'
|
||||
s.metadata['rubygems_mfa_required'] = 'true'
|
||||
end
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ module FoodsoftPolls
|
|||
sub_nav.items <<
|
||||
SimpleNavigation::Item.new(primary, :polls, I18n.t('navigation.polls'), context.polls_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
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
module FoodsoftPolls
|
||||
VERSION = "0.0.1"
|
||||
VERSION = '0.0.1'
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue