Skip to content

Commit

Permalink
Updated dependencies and applied new rubocop rules.
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsteneckel committed Jan 15, 2016
1 parent 29b4112 commit d7995bc
Show file tree
Hide file tree
Showing 88 changed files with 771 additions and 802 deletions.
19 changes: 10 additions & 9 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
# https://github.com/bbatsov/rubocop/blob/master/config/enabled.yml

AllCops:
RunRailsCops: true
Exclude:
- 'bin/rails'
- 'bin/rake'
- 'bin/spring'
- 'db/schema.rb'

Rails:
Enabled: true

# Zammad StyleGuide

Metrics/LineLength:
Expand All @@ -30,8 +32,13 @@ Style/IfUnlessModifier:
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier'
Enabled: false

Style/TrailingComma:
Description: 'Checks for trailing comma in parameter lists and literals.'
Style/TrailingCommaInLiteral:
Description: 'Checks for trailing comma in array and hash literals.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
Enabled: false

Style/TrailingCommaInArguments:
Description: 'Checks for trailing comma in argument lists.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
Enabled: false

Expand All @@ -47,12 +54,6 @@ Style/SpaceAfterMethodName:
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-no-spaces'
Enabled: false

Style/SingleSpaceBeforeFirstArg:
Description: >-
Checks that exactly one space is used between a method name
and the first argument for method calls without parentheses.
Enabled: false

Style/LeadingCommentSpace:
Description: 'Comments should start with a space.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#hash-space'
Expand Down
39 changes: 17 additions & 22 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ GEM
addressable (2.4.0)
arel (6.0.3)
ast (2.2.0)
astrolabe (1.3.1)
parser (~> 2.2)
autoprefixer-rails (6.2.3)
autoprefixer-rails (6.3.1)
execjs
json
biz (1.3.3)
Expand All @@ -58,7 +56,7 @@ GEM
browser (1.1.0)
buftok (0.2.0)
builder (3.2.2)
childprocess (0.5.8)
childprocess (0.5.9)
ffi (~> 1.0, >= 1.0.11)
clavius (1.0.1)
memoizable (~> 0.4.0)
Expand Down Expand Up @@ -95,7 +93,7 @@ GEM
http_parser.rb (~> 0.6.0)
equalizer (0.0.10)
erubis (2.7.0)
eventmachine (1.0.8)
eventmachine (1.0.9.1)
execjs (2.6.0)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
Expand Down Expand Up @@ -159,7 +157,7 @@ GEM
mysql2 (0.3.20)
naught (1.1.0)
nenv (0.2.0)
net-ldap (0.12.1)
net-ldap (0.13.0)
nokogiri (1.6.7.1)
mini_portile2 (~> 2.0.0.rc2)
notiffany (0.0.8)
Expand All @@ -177,28 +175,28 @@ GEM
rack (>= 1.0, < 3)
omniauth-facebook (3.0.0)
omniauth-oauth2 (~> 1.2)
omniauth-google-oauth2 (0.2.10)
omniauth-google-oauth2 (0.3.0)
addressable (~> 2.3)
jwt (~> 1.0)
multi_json (~> 1.3)
omniauth (>= 1.1.1)
omniauth-oauth2 (~> 1.3.1)
omniauth-oauth2 (>= 1.3.1)
omniauth-linkedin (0.2.0)
omniauth-oauth (~> 1.0)
omniauth-oauth (1.1.0)
oauth
omniauth (~> 1.0)
omniauth-oauth2 (1.3.1)
omniauth-oauth2 (1.4.0)
oauth2 (~> 1.0)
omniauth (~> 1.2)
omniauth-twitter (1.2.1)
json (~> 1.3)
omniauth-oauth (~> 1.1)
parser (2.2.3.0)
ast (>= 1.1, < 3.0)
parser (2.3.0.1)
ast (~> 2.2)
pluginator (1.3.0)
polyglot (0.3.5)
power_assert (0.2.6)
power_assert (0.2.7)
powerpack (0.1.1)
pre-commit (0.26.0)
pluginator (~> 1.1)
Expand Down Expand Up @@ -239,29 +237,27 @@ GEM
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (2.0.0)
rake (10.4.2)
rake (10.5.0)
rb-fsevent (0.9.7)
rb-inotify (0.9.5)
ffi (>= 0.5.0)
ref (2.0.0)
rubocop (0.35.1)
astrolabe (~> 1.3)
parser (>= 2.2.3.0, < 3.0)
rubocop (0.36.0)
parser (>= 2.3.0.0, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
tins (<= 1.6.0)
ruby-progressbar (1.7.5)
rubyzip (1.1.7)
sass (3.4.20)
sass (3.4.21)
sass-rails (5.0.4)
railties (>= 4.0.0, < 5.0)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
scrub_rb (1.0.1)
selenium-webdriver (2.48.1)
selenium-webdriver (2.49.0)
childprocess (~> 0.5)
multi_json (~> 1.0)
rubyzip (~> 1.0)
Expand All @@ -277,7 +273,7 @@ GEM
simplecov-rcov (0.2.3)
simplecov (>= 0.4.1)
slop (3.6.0)
spring (1.6.1)
spring (1.6.2)
sprockets (3.5.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
Expand All @@ -293,8 +289,7 @@ GEM
ref
thor (0.19.1)
thread_safe (0.3.5)
tilt (2.0.1)
tins (1.6.0)
tilt (2.0.2)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
Expand Down
10 changes: 5 additions & 5 deletions app/controllers/search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ def search_generic

# convert objects string into array of class names
# e.g. user-ticket-another_object = %w( User Ticket AnotherObject )
if !params[:objects]
objects = Setting.get('models_searchable')
else
objects = params[:objects].split('-').map(&:camelize)
end
objects = if !params[:objects]
Setting.get('models_searchable')
else
params[:objects].split('-').map(&:camelize)
end

# get priorities of result
objects_in_order = []
Expand Down
8 changes: 3 additions & 5 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ def create
end

# remember me - set session cookie to expire later
if params[:remember_me]
request.env['rack.session.options'][:expire_after] = 1.year
else
request.env['rack.session.options'][:expire_after] = nil
end
request.env['rack.session.options'][:expire_after] = if params[:remember_me]
1.year
end
# both not needed to set :expire_after works fine
# request.env['rack.session.options'][:renew] = true
# reset_session
Expand Down
12 changes: 6 additions & 6 deletions app/controllers/ticket_articles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def show

# POST /articles
def create
form_id = params[:ticket_article][:form_id]
form_id = params[:ticket_article][:form_id]
params[:ticket_article].delete(:form_id)
@article = Ticket::Article.new( Ticket::Article.param_validation( params[:ticket_article] ) )

Expand Down Expand Up @@ -93,11 +93,11 @@ def ticket_attachment_upload_add
file = params[:File]
content_type = file.content_type
if !content_type || content_type == 'application/octet-stream'
if MIME::Types.type_for(file.original_filename).first
content_type = MIME::Types.type_for(file.original_filename).first.content_type
else
content_type = 'application/octet-stream'
end
content_type = if MIME::Types.type_for(file.original_filename).first
MIME::Types.type_for(file.original_filename).first.content_type
else
'application/octet-stream'
end
end
headers_store = {
'Content-Type' => content_type
Expand Down
24 changes: 12 additions & 12 deletions app/controllers/tickets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ def ticket_related

# open tickets by customer
group_ids = Group.select( 'groups.id' )
.joins(:users)
.where( 'groups_users.user_id = ?', current_user.id )
.where( 'groups.active = ?', true )
.map( &:id )
.joins(:users)
.where( 'groups_users.user_id = ?', current_user.id )
.where( 'groups.active = ?', true )
.map( &:id )

access_condition = [ 'group_id IN (?)', group_ids ]

Expand All @@ -142,7 +142,7 @@ def ticket_related
}

ticket_ids_recent_viewed = []
recent_views = RecentView.list( current_user, 8, 'Ticket' )
recent_views = RecentView.list( current_user, 8, 'Ticket' )
recent_views.each {|recent_view|
next if recent_view['object'] != 'Ticket'
ticket_ids_recent_viewed.push recent_view['o_id']
Expand Down Expand Up @@ -417,15 +417,15 @@ def stats

# created
created = Ticket.where('created_at > ? AND created_at < ?', date_start, date_end )
.where(access_condition)
.where(condition)
.count
.where(access_condition)
.where(condition)
.count

# closed
closed = Ticket.where('close_time > ? AND close_time < ?', date_start, date_end )
.where(access_condition)
.where(condition)
.count
.where(access_condition)
.where(condition)
.count

data = {
month: date_to_check.month,
Expand Down Expand Up @@ -532,7 +532,7 @@ def assets_of_tickets(tickets, assets)
def article_create(ticket, params)

# create article if given
form_id = params[:form_id]
form_id = params[:form_id]
params.delete(:form_id)
article = Ticket::Article.new( Ticket::Article.param_validation( params ) )
article.ticket_id = ticket.id
Expand Down
20 changes: 10 additions & 10 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ class UsersController < ApplicationController
def index

# only allow customer to fetch him self
if role?(Z_ROLENAME_CUSTOMER) && !role?(Z_ROLENAME_ADMIN) && !role?('Agent')
users = User.where( id: current_user.id )
else
users = User.all
end
users = if role?(Z_ROLENAME_CUSTOMER) && !role?(Z_ROLENAME_ADMIN) && !role?('Agent')
User.where( id: current_user.id )
else
User.all
end
users_all = []
users.each {|user|
users_all.push User.lookup( id: user.id ).attributes_with_associations
Expand Down Expand Up @@ -337,11 +337,11 @@ def recent
end

# do query
if params[:role_ids] && !params[:role_ids].empty?
user_all = User.joins(:roles).where( 'roles.id' => params[:role_ids] ).where('users.id != 1').order('users.created_at DESC').limit( params[:limit] || 20 )
else
user_all = User.where('id != 1').order('created_at DESC').limit( params[:limit] || 20 )
end
user_all = if params[:role_ids] && !params[:role_ids].empty?
User.joins(:roles).where( 'roles.id' => params[:role_ids] ).where('users.id != 1').order('users.created_at DESC').limit( params[:limit] || 20 )
else
User.where('id != 1').order('created_at DESC').limit( params[:limit] || 20 )
end

# build result list
if !params[:full]
Expand Down
18 changes: 9 additions & 9 deletions app/models/activity_stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ def self.list(user, limit)
customer_role = Role.lookup( name: 'Customer' )

return [] if role_ids.include?(customer_role.id)
if group_ids.empty?
stream = ActivityStream.where('(role_id IN (?) AND group_id is NULL)', role_ids )
.order( 'created_at DESC, id DESC' )
.limit( limit )
else
stream = ActivityStream.where('(role_id IN (?) AND group_id is NULL) OR ( role_id IN (?) AND group_id IN (?) ) OR ( role_id is NULL AND group_id IN (?) )', role_ids, role_ids, group_ids, group_ids )
.order( 'created_at DESC, id DESC' )
.limit( limit )
end
stream = if group_ids.empty?
ActivityStream.where('(role_id IN (?) AND group_id is NULL)', role_ids )
.order( 'created_at DESC, id DESC' )
.limit( limit )
else
ActivityStream.where('(role_id IN (?) AND group_id is NULL) OR ( role_id IN (?) AND group_id IN (?) ) OR ( role_id is NULL AND group_id IN (?) )', role_ids, role_ids, group_ids, group_ids )
.order( 'created_at DESC, id DESC' )
.limit( limit )
end
list = []
stream.each do |item|
data = item.attributes
Expand Down
Loading

0 comments on commit d7995bc

Please sign in to comment.