diff --git a/.rubocop.yml b/.rubocop.yml index 6baf51e09f..205a61b966 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,12 @@ inherit_from: .rubocop_todo.yml +AllCops: + TargetRubyVersion: 2.3 + StringLiterals: Enabled: false Metrics/LineLength: Enabled: false + +Style/MutableConstant: + Enabled: false \ No newline at end of file diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 7b462b21b0..a18a90fb0f 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2017-01-10 15:12:25 +1030 using RuboCop version 0.46.0. +# on 2017-01-10 15:41:51 +1030 using RuboCop version 0.46.0. # 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 @@ -67,26 +67,6 @@ Lint/ShadowingOuterLocalVariable: - 'lib/tasks/ffcrm/config.rake' - 'lib/tasks/ffcrm/update_data.rake' -# Offense count: 1 -# Cop supports --auto-correct. -Lint/UnifiedInteger: - Exclude: - - 'lib/fat_free_crm/i18n.rb' - -# Offense count: 4 -# Cop supports --auto-correct. -# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. -Lint/UnusedBlockArgument: - Exclude: - - 'config/unicorn.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods. -Lint/UnusedMethodArgument: - Exclude: - - 'spec/support/auth_macros.rb' - # Offense count: 4 # Configuration parameters: ContextCreatingMethods. Lint/UselessAccessModifier: @@ -142,7 +122,7 @@ Metrics/ClassLength: Metrics/CyclomaticComplexity: Max: 13 -# Offense count: 103 +# Offense count: 104 # Configuration parameters: CountComments. Metrics/MethodLength: Max: 38 @@ -150,35 +130,12 @@ Metrics/MethodLength: # Offense count: 2 # Configuration parameters: CountComments. Metrics/ModuleLength: - Max: 390 + Max: 391 # Offense count: 29 Metrics/PerceivedComplexity: Max: 15 -# Offense count: 1 -# Cop supports --auto-correct. -Performance/Casecmp: - Exclude: - - 'db/migrate/20120224073107_remove_default_value_and_clear_settings.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -Performance/RedundantMatch: - Exclude: - - 'app/helpers/application_helper.rb' - -# Offense count: 9 -# Cop supports --auto-correct. -# Configuration parameters: MaxKeyValuePairs. -Performance/RedundantMerge: - Exclude: - - 'app/helpers/application_helper.rb' - - 'app/inputs/date_pair_input.rb' - - 'app/inputs/date_time_input.rb' - - 'app/models/polymorphic/address.rb' - - 'spec/models/setting_spec.rb' - # Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: AutoCorrect. @@ -186,18 +143,6 @@ Performance/StartWith: Exclude: - 'app/helpers/versions_helper.rb' -# Offense count: 1 -# Cop supports --auto-correct. -Performance/StringReplacement: - Exclude: - - 'app/helpers/campaigns_helper.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -Performance/TimesMap: - Exclude: - - 'lib/fat_free_crm/core_ext/string.rb' - # Offense count: 12 Style/AccessorMethodName: Exclude: @@ -232,14 +177,6 @@ Style/Alias: - 'lib/fat_free_crm/core_ext/string.rb' - 'spec/support/auth_macros.rb' -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles. -# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit -Style/AlignHash: - Exclude: - - 'spec/views/campaigns/show.haml_spec.rb' - # Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. @@ -349,52 +286,12 @@ Style/DoubleNegation: - 'app/models/polymorphic/task.rb' - 'lib/gravatar_image_tag.rb' -# Offense count: 6 -# Cop supports --auto-correct. -Style/EachWithObject: - Exclude: - - 'app/controllers/application_controller.rb' - - 'app/models/polymorphic/task.rb' - - 'lib/fat_free_crm/callback.rb' - - 'lib/fat_free_crm/core_ext/string.rb' - - 'spec/controllers/tasks_controller_spec.rb' - - 'spec/support/macros.rb' - # Offense count: 1 # Cop supports --auto-correct. Style/EmptyCaseCondition: Exclude: - 'app/models/polymorphic/task.rb' -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: empty, nil, both -Style/EmptyElse: - Exclude: - - 'app/models/polymorphic/task.rb' - -# Offense count: 6 -# Cop supports --auto-correct. -# Configuration parameters: AllowAdjacentOneLineDefs. -Style/EmptyLineBetweenDefs: - Exclude: - - 'app/models/entities/contact.rb' - - 'app/models/entities/lead.rb' - - 'app/models/entities/opportunity.rb' - - 'app/models/polymorphic/task.rb' - - 'lib/fat_free_crm/callback.rb' - - 'spec/support/auth_macros.rb' - -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: empty_lines, no_empty_lines -Style/EmptyLinesAroundBlockBody: - Exclude: - - 'config/initializers/views.rb' - - 'db/schema.rb' - # Offense count: 10 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. @@ -409,7 +306,7 @@ Style/EmptyMethod: - 'db/migrate/20120316045804_activities_to_versions.rb' - 'db/migrate/20121221033947_fix_country_mapping.rb' -# Offense count: 109 +# Offense count: 99 # Cop supports --auto-correct. # Configuration parameters: AllowForAlignment, ForceEqualSignAlignment. Style/ExtraSpacing: @@ -446,42 +343,16 @@ Style/GlobalVars: - 'db/migrate/20100928030598_create_sessions.rb' - 'db/migrate/20120510025219_add_not_null_constraints_for_timestamp_columns.rb' -# Offense count: 50 +# Offense count: 44 # Configuration parameters: MinBodyLength. Style/GuardClause: Enabled: false -# Offense count: 11 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. -# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys -Style/HashSyntax: - Exclude: - - 'app/controllers/application_controller.rb' - - 'app/helpers/accounts_helper.rb' - - 'app/helpers/application_helper.rb' - - 'app/helpers/opportunities_helper.rb' - - 'lib/fat_free_crm/engine.rb' - # Offense count: 2 Style/IdenticalConditionalBranches: Exclude: - 'app/helpers/application_helper.rb' -# Offense count: 12 -# Cop supports --auto-correct. -# Configuration parameters: MaxLineLength. -Style/IfUnlessModifier: - Exclude: - - 'app/helpers/application_helper.rb' - - 'app/models/entities/lead.rb' - - 'app/models/entities/opportunity.rb' - - 'app/models/setting.rb' - - 'db/migrate/20100928030620_remove_uuid.rb' - - 'lib/fat_free_crm.rb' - - 'lib/fat_free_crm/mail_processor/base.rb' - - 'lib/tasks/ffcrm/update_data.rake' - # Offense count: 27 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. @@ -501,13 +372,6 @@ Style/Lambda: - 'config/locales/th.rb' - 'lib/tasks/ffcrm/setup.rake' -# Offense count: 4 -# Cop supports --auto-correct. -Style/LeadingCommentSpace: - Exclude: - - 'Gemfile' - - 'spec/support/auth_macros.rb' - # Offense count: 2 Style/MethodMissing: Exclude: @@ -558,21 +422,6 @@ Style/MultilineTernaryOperator: Exclude: - 'app/models/users/authentication.rb' -# Offense count: 16 -# Cop supports --auto-correct. -Style/MutableConstant: - Exclude: - - 'app/models/fields/custom_field.rb' - - 'app/models/polymorphic/task.rb' - - 'app/models/polymorphic/version.rb' - - 'config/locales/th.rb' - - 'lib/development_tasks/license.rake' - - 'lib/fat_free_crm/gem_ext/active_support/buffered_logger.rb' - - 'lib/fat_free_crm/mail_processor/comment_replies.rb' - - 'lib/fat_free_crm/version.rb' - - 'spec/features/support/headless.rb' - - 'spec/lib/mail_processor/sample_emails/dropbox.rb' - # Offense count: 5 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles. @@ -589,7 +438,7 @@ Style/Next: Style/NumericLiterals: MinDigits: 15 -# Offense count: 12 +# Offense count: 10 # Cop supports --auto-correct. # Configuration parameters: AutoCorrect, EnforcedStyle, SupportedStyles. # SupportedStyles: predicate, comparison @@ -602,26 +451,9 @@ Style/NumericPredicate: - 'app/helpers/tasks_helper.rb' - 'app/models/fields/custom_field.rb' - 'app/models/polymorphic/task.rb' - - 'app/models/polymorphic/version.rb' - 'app/models/users/user.rb' - - 'lib/gravatar_image_tag.rb' - 'lib/tasks/ffcrm/demo.rake' -# Offense count: 11 -# Cop supports --auto-correct. -Style/ParallelAssignment: - Exclude: - - 'app/controllers/comments_controller.rb' - - 'app/controllers/entities_controller.rb' - - 'app/helpers/application_helper.rb' - - 'app/helpers/opportunities_helper.rb' - - 'db/migrate/20111201030535_add_field_groups_klass_name.rb' - - 'lib/fat_free_crm/mail_processor/base.rb' - - 'lib/fat_free_crm/mail_processor/comment_replies.rb' - - 'lib/tasks/ffcrm/config.rake' - - 'lib/tasks/ffcrm/setup.rake' - - 'spec/controllers/tasks_controller_spec.rb' - # Offense count: 4 # Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist. # NamePrefix: is_, has_, have_ @@ -635,23 +467,6 @@ Style/PredicateName: - 'lib/fat_free_crm/fields.rb' - 'lib/fat_free_crm/mail_processor/base.rb' -# Offense count: 4 -# Cop supports --auto-correct. -Style/RedundantParentheses: - Exclude: - - 'Gemfile' - - 'app/controllers/passwords_controller.rb' - - 'app/helpers/application_helper.rb' - - 'lib/fat_free_crm/permissions.rb' - -# Offense count: 3 -# Cop supports --auto-correct. -Style/RedundantSelf: - Exclude: - - 'app/models/users/user.rb' - - 'db/migrate/20100928030620_remove_uuid.rb' - - 'lib/fat_free_crm/fields.rb' - # Offense count: 18 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes. @@ -671,13 +486,6 @@ Style/RegexpLiteral: - 'spec/views/contacts/update.js.haml_spec.rb' - 'spec/views/opportunities/update.js.haml_spec.rb' -# Offense count: 2 -# Cop supports --auto-correct. -Style/RescueModifier: - Exclude: - - 'app/models/setting.rb' - - 'lib/fat_free_crm/mail_processor/base.rb' - # Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: ConvertCodeThatCanStartToReturnNil. @@ -700,119 +508,6 @@ Style/Semicolon: - 'spec/models/fields/custom_field_spec.rb' - 'spec/support/macros.rb' -# Offense count: 11 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: only_raise, only_fail, semantic -Style/SignalException: - Exclude: - - 'app/helpers/application_helper.rb' - - 'app/models/fields/field.rb' - - 'db/migrate/20100928030620_remove_uuid.rb' - - 'spec/factories/shared_factories.rb' - - 'spec/factories/user_factories.rb' - -# Offense count: 1 -# Configuration parameters: Methods. -# Methods: {"reduce"=>["acc", "elem"]}, {"inject"=>["acc", "elem"]} -Style/SingleLineBlockParams: - Exclude: - - 'spec/support/macros.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyleInsidePipes, SupportedStyles. -# SupportedStyles: space, no_space -Style/SpaceAroundBlockParameters: - Exclude: - - 'spec/controllers/tasks_controller_spec.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -Style/SpaceAroundKeyword: - Exclude: - - 'lib/fat_free_crm/core_ext/string.rb' - -# Offense count: 15 -# Cop supports --auto-correct. -# Configuration parameters: AllowForAlignment. -Style/SpaceAroundOperators: - Exclude: - - 'app/controllers/entities/contacts_controller.rb' - - 'app/helpers/versions_helper.rb' - - 'app/models/fields/field.rb' - - 'config/environments/test.rb' - - 'spec/models/entities/opportunity_spec.rb' - - 'spec/models/fields/custom_field_pair_spec.rb' - - 'spec/views/tasks/index.haml_spec.rb' - - 'spec/views/tasks/update.js.haml_spec.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: space, no_space -Style/SpaceBeforeBlockBraces: - Exclude: - - 'app/controllers/application_controller.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. -# SupportedStyles: space, no_space -Style/SpaceInsideBlockBraces: - Exclude: - - 'app/controllers/application_controller.rb' - -# Offense count: 6 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles. -# SupportedStyles: space, no_space, compact -Style/SpaceInsideHashLiteralBraces: - Exclude: - - 'app/helpers/application_helper.rb' - - 'spec/support/auth_macros.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -Style/SpaceInsidePercentLiteralDelimiters: - Exclude: - - 'config/initializers/assets.rb' - -# Offense count: 8 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: space, no_space -Style/SpaceInsideStringInterpolation: - Exclude: - - 'app/helpers/application_helper.rb' - - 'app/helpers/tasks_helper.rb' - - 'lib/gravatar_image_tag.rb' - -# Offense count: 7 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, AllowSafeAssignment. -# SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex -Style/TernaryParentheses: - Exclude: - - 'app/controllers/application_controller.rb' - - 'app/controllers/entities_controller.rb' - - 'app/helpers/application_helper.rb' - - 'app/helpers/tasks_helper.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: final_newline, final_blank_line -Style/TrailingBlankLines: - Exclude: - - 'config/initializers/paper_trail.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -Style/TrailingWhitespace: - Exclude: - - 'app/models/users/user.rb' - # Offense count: 2 # Cop supports --auto-correct. # Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, Whitelist. @@ -821,23 +516,6 @@ Style/TrivialAccessors: Exclude: - 'spec/support/auth_macros.rb' -# Offense count: 5 -# Cop supports --auto-correct. -Style/UnlessElse: - Exclude: - - 'app/controllers/comments_controller.rb' - - 'app/controllers/entities/contacts_controller.rb' - - 'app/controllers/entities/opportunities_controller.rb' - - 'app/controllers/users_controller.rb' - - 'spec/views/application/auto_complete.haml_spec.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -Style/UnneededInterpolation: - Exclude: - - 'config/initializers/simple_form.rb' - - 'spec/shared/controllers.rb' - # Offense count: 14 # Configuration parameters: EnforcedStyle, SupportedStyles. # SupportedStyles: snake_case, normalcase, non_integer @@ -858,10 +536,3 @@ Style/WhenThen: Style/WordArray: EnforcedStyle: percent MinSize: 5 - -# Offense count: 2 -# Cop supports --auto-correct. -Style/ZeroLengthPredicate: - Exclude: - - 'app/models/polymorphic/version.rb' - - 'lib/gravatar_image_tag.rb' diff --git a/Gemfile b/Gemfile index 6b6765b44a..fd7f86d4da 100644 --- a/Gemfile +++ b/Gemfile @@ -28,7 +28,7 @@ end # (See https://github.com/carlhuda/bundler/issues/1041) spec = Bundler.load_gemspec(File.expand_path("../fat_free_crm.gemspec", __FILE__)) spec.runtime_dependencies.each do |dep| - gem dep.name, *(dep.requirement.as_list) + gem dep.name, *dep.requirement.as_list end # Remove premailer auto-require @@ -46,8 +46,6 @@ group :development do gem 'capistrano-bundler' gem 'capistrano-rails' gem 'capistrano-rvm' - #~ gem 'capistrano-chruby' - #~ gem 'capistrano-rbenv' gem 'guard' gem 'guard-rspec' gem 'guard-rails' diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7d6f92e5b4..47d166fbac 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -45,7 +45,7 @@ def auto_complete respond_to do |format| format.any(:js, :html) { render partial: 'auto_complete' } format.json do - render json: @auto_complete.inject({}){|h, a| + render json: @auto_complete.each_with_object({}) { |a, h| h[a.id] = a.respond_to?(:full_name) ? h(a.full_name) : h(a.name); h } end @@ -252,7 +252,7 @@ def respond_to_access_denied def redirection_url # Try to redirect somewhere sensible. Note: not all controllers have an index action url = if current_user.present? - (respond_to?(:index) && action_name != 'index') ? { action: 'index' } : root_url + respond_to?(:index) && action_name != 'index' ? { action: 'index' } : root_url else login_url end @@ -272,7 +272,7 @@ def cors_preflight_check headers['Access-Control-Allow-Headers'] = 'X-Requested-With, X-Prototype-Version, Token' headers['Access-Control-Max-Age'] = '1728000' - render :text => '', :content_type => 'text/plain' + render text: '', content_type: 'text/plain' end end end diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index eef85d89de..2044a8682b 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -34,7 +34,8 @@ def index def edit @comment = Comment.find(params[:id]) - model, id = @comment.commentable_type, @comment.commentable_id + model = @comment.commentable_type + id = @comment.commentable_id unless model.constantize.my.find_by_id(id) respond_to_related_not_found(model.downcase) end @@ -49,12 +50,13 @@ def create comment_params.merge(user_id: current_user.id) ) # Make sure commentable object exists and is accessible to the current user. - model, id = @comment.commentable_type, @comment.commentable_id - unless model.constantize.my.find_by_id(id) - respond_to_related_not_found(model.downcase) - else + model = @comment.commentable_type + id = @comment.commentable_id + if model.constantize.my.find_by_id(id) @comment.save respond_with(@comment) + else + respond_to_related_not_found(model.downcase) end end diff --git a/app/controllers/entities/contacts_controller.rb b/app/controllers/entities/contacts_controller.rb index c245334512..cb4d641422 100644 --- a/app/controllers/entities/contacts_controller.rb +++ b/app/controllers/entities/contacts_controller.rb @@ -65,14 +65,14 @@ def create @contact.add_comment_by_user(@comment_body, current_user) @contacts = get_contacts if called_from_index_page? else - unless params[:account][:id].blank? - @account = Account.find(params[:account][:id]) - else + if params[:account][:id].blank? if request.referer =~ /\/accounts\/(\d+)\z/ @account = Account.find(Regexp.last_match[1]) # related account else @account = Account.new(user: current_user) end + else + @account = Account.find(params[:account][:id]) end @opportunity = Opportunity.my.find(params[:opportunity]) unless params[:opportunity].blank? end @@ -153,7 +153,7 @@ def get_accounts def set_options super - @naming = (current_user.pref[:contacts_naming] || Contact.first_name_position) unless params[:cancel].true? + @naming = (current_user.pref[:contacts_naming] || Contact.first_name_position) unless params[:cancel].true? end #---------------------------------------------------------------------------- diff --git a/app/controllers/entities/opportunities_controller.rb b/app/controllers/entities/opportunities_controller.rb index 7bb656b36b..749753b5ba 100644 --- a/app/controllers/entities/opportunities_controller.rb +++ b/app/controllers/entities/opportunities_controller.rb @@ -79,14 +79,14 @@ def create end else @accounts = Account.my.order('name') - unless params[:account][:id].blank? - @account = Account.find(params[:account][:id]) - else + if params[:account][:id].blank? if request.referer =~ /\/accounts\/(\d+)\z/ @account = Account.find(Regexp.last_match[1]) # related account else @account = Account.new(user: current_user) end + else + @account = Account.find(params[:account][:id]) end @contact = Contact.find(params[:contact]) unless params[:contact].blank? @campaign = Campaign.find(params[:campaign]) unless params[:campaign].blank? diff --git a/app/controllers/entities_controller.rb b/app/controllers/entities_controller.rb index 2e43154383..adee46e90d 100755 --- a/app/controllers/entities_controller.rb +++ b/app/controllers/entities_controller.rb @@ -186,7 +186,8 @@ def update_recently_viewed #---------------------------------------------------------------------------- def parse_query_and_tags(search_string) return ['', ''] if search_string.blank? - query, tags = [], [] + query = [] + tags = [] search_string.strip.split(/\s+/).each do |token| if token.starts_with?("#") tags << token[1..-1] @@ -207,7 +208,7 @@ def timeline(asset) def set_view if params['view'] controller = params['controller'] - action = (params['action'] == 'show') ? 'show' : 'index' # create update redraw filter index actions all use index view + action = params['action'] == 'show' ? 'show' : 'index' # create update redraw filter index actions all use index view current_user.pref[:"#{controller}_#{action}_view"] = params['view'] end end diff --git a/app/controllers/passwords_controller.rb b/app/controllers/passwords_controller.rb index 3fb940c26d..ee35efb454 100644 --- a/app/controllers/passwords_controller.rb +++ b/app/controllers/passwords_controller.rb @@ -60,6 +60,6 @@ def load_user_using_perishable_token #---------------------------------------------------------------------------- def empty_password? (params[:user][:password] == params[:user][:password_confirmation]) && - (params[:user][:password].blank?) # " ".blank? == true + params[:user][:password].blank? # " ".blank? == true end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 2bbec1fb44..de24d0c4bd 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -102,13 +102,13 @@ def password #---------------------------------------------------------------------------- def change_password if @user.valid_password?(params[:current_password], true) || @user.password_hash.blank? - unless params[:user][:password].blank? + if params[:user][:password].blank? + flash[:notice] = t(:msg_password_not_changed) + else @user.password = params[:user][:password] @user.password_confirmation = params[:user][:password_confirmation] @user.save flash[:notice] = t(:msg_password_changed) - else - flash[:notice] = t(:msg_password_not_changed) end else @user.errors.add(:current_password, t(:msg_invalid_password)) diff --git a/app/helpers/accounts_helper.rb b/app/helpers/accounts_helper.rb index 619cfb53fc..648fdb17f2 100755 --- a/app/helpers/accounts_helper.rb +++ b/app/helpers/accounts_helper.rb @@ -28,8 +28,8 @@ def account_select(options = {}) options[:selected] = (@account && @account.id) || 0 accounts = ([@account] + Account.my.order(:name).limit(25)).compact.uniq collection_select :account, :id, accounts, :id, :name, options, - :"data-placeholder" => t(:select_an_account), - :"data-url" => auto_complete_accounts_path(format: 'json'), + "data-placeholder": t(:select_an_account), + "data-url": auto_complete_accounts_path(format: 'json'), style: "width:330px; display:none;", class: 'ajax_chosen' end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 41022f18ea..b006c450e4 100755 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -10,14 +10,14 @@ def tabs(tabs = nil) @current_tab ||= tabs.first[:text] # Select first tab by default. tabs.each { |tab| tab[:active] = (@current_tab == tab[:text] || @current_tab == tab[:url][:controller]) } else - fail FatFreeCRM::MissingSettings, "Tab settings are missing, please run rake ffcrm:setup command." + raise FatFreeCRM::MissingSettings, "Tab settings are missing, please run rake ffcrm:setup command." end end #---------------------------------------------------------------------------- def tabless_layout? %w(authentications passwords).include?(controller.controller_name) || - ((controller.controller_name == "users") && (%w(create new).include?(controller.action_name))) + ((controller.controller_name == "users") && %w(create new).include?(controller.action_name)) end # Show existing flash or embed hidden paragraph ready for flash[:notice] @@ -36,7 +36,7 @@ def show_flash(options = { sticky: false }) #---------------------------------------------------------------------------- def subtitle(id, hidden = true, text = id.to_s.split("_").last.capitalize) content_tag("div", - link_to("#{ hidden ? '►' : '▼' } #{sanitize text}".html_safe, + link_to("#{hidden ? '►' : '▼'} #{sanitize text}".html_safe, url_for(controller: :home, action: :toggle, id: id), remote: true, onclick: "crm.flip_subtitle(this)" @@ -244,7 +244,7 @@ def refresh_sidebar(action = nil, shake = nil) #---------------------------------------------------------------------------- def refresh_sidebar_for(view, action = nil, shake = nil) text = "" - text << "$('#sidebar').html('#{ j render(partial: 'layouts/sidebar', locals: { view: view, action: action }) }');" + text << "$('#sidebar').html('#{j render(partial: 'layouts/sidebar', locals: { view: view, action: action })}');" text << "$('##{j shake.to_s}').effect('shake', { duration:200, distance: 3 });" if shake text.html_safe end @@ -258,9 +258,9 @@ def web_presence_icons(person) if site == :skype url = "callto:" << url else - url = "http://" << url unless url.match(/^https?:\/\//) + url = "http://" << url unless url =~ /^https?:\/\// end - link_to(image_tag("#{site}.gif", size: "15x15"), h(url), :"data-popup" => true, title: t(:open_in_window, h(url))) + link_to(image_tag("#{site}.gif", size: "15x15"), h(url), "data-popup": true, title: t(:open_in_window, h(url))) end end.compact.join("\n").html_safe end @@ -269,7 +269,8 @@ def web_presence_icons(person) #---------------------------------------------------------------------------- def redraw(option, value, url = send("redraw_#{controller.controller_name}_path")) if value.is_a?(Array) - param, value = value.first, value.last + param = value.first + value = value.last end %{ if ($('##{option}').html() != '#{value}') { @@ -361,11 +362,11 @@ def shown_on_landing_page? def links_to_export(action = :index) token = current_user.single_access_token url_params = { action: action } - url_params.merge!(id: params[:id]) unless params[:id].blank? - url_params.merge!(query: params[:query]) unless params[:query].blank? - url_params.merge!(q: params[:q]) unless params[:q].blank? - url_params.merge!(view: @view) unless @view.blank? # tasks - url_params.merge!(id: params[:id]) unless params[:id].blank? + url_params[:id] = params[:id] unless params[:id].blank? + url_params[:query] = params[:query] unless params[:query].blank? + url_params[:q] = params[:q] unless params[:q].blank? + url_params[:view] = @view unless @view.blank? # tasks + url_params[:id] = params[:id] unless params[:id].blank? exports = %w(xls csv).map do |format| link_to(format.upcase, url_params.merge(format: format), title: I18n.t(:"to_#{format}")) unless action.to_s == "show" @@ -439,7 +440,7 @@ def col(title, value = nil, last = false, email = false, &_block) def section_title(id, hidden = true, text = nil, info_text = nil) text = id.to_s.split("_").last.capitalize if text.nil? content_tag("div", class: "subtitle show_attributes") do - content = link_to("#{ hidden ? '►' : '▼' } #{sanitize text}".html_safe, + content = link_to("#{hidden ? '►' : '▼'} #{sanitize text}".html_safe, url_for(controller: :home, action: :toggle, id: id), remote: true, onclick: "crm.flip_subtitle(this)" @@ -452,7 +453,7 @@ def section_title(id, hidden = true, text = nil, info_text = nil) # Return name of current view def current_view_name controller = params['controller'] - action = (params['action'] == 'show') ? 'show' : 'index' # create update redraw filter index actions all use index view + action = params['action'] == 'show' ? 'show' : 'index' # create update redraw filter index actions all use index view current_user.pref[:"#{controller}_#{action}_view"] end @@ -460,7 +461,7 @@ def current_view_name # Get template in current context with current view name def template_for_current_view controller = params['controller'] - action = (params['action'] == 'show') ? 'show' : 'index' # create update redraw filter index actions all use index view + action = params['action'] == 'show' ? 'show' : 'index' # create update redraw filter index actions all use index view template = FatFreeCRM::ViewFactory.template_for_current_view(controller: controller, action: action, name: current_view_name) template end @@ -469,7 +470,7 @@ def template_for_current_view # Generate buttons for available views given the current context def view_buttons controller = params['controller'] - action = (params['action'] == 'show') ? 'show' : 'index' # create update redraw filter index actions all use index view + action = params['action'] == 'show' ? 'show' : 'index' # create update redraw filter index actions all use index view views = FatFreeCRM::ViewFactory.views_for(controller: controller, action: action) return nil unless views.size > 1 lis = ''.html_safe @@ -481,8 +482,8 @@ def view_buttons "#{h view.name}-button" end lis << content_tag(:li) do - url = (action == "index") ? send("redraw_#{controller}_path") : send("#{controller.singularize}_path") - link_to('#', title: t(view.name, default: h(view.title)), :"data-view" => h(view.name), :"data-url" => h(url), :"data-context" => action, class: classes) do + url = action == "index" ? send("redraw_#{controller}_path") : send("#{controller.singularize}_path") + link_to('#', title: t(view.name, default: h(view.title)), "data-view": h(view.name), "data-url": h(url), "data-context": action, class: classes) do icon = view.icon || 'fa-bars' content_tag(:i, nil, class: "fa #{h icon}") end @@ -520,7 +521,7 @@ def get_icon(name) # options = { renderer: {...} , params: {...} def paginate(options = {}) collection = options.delete(:collection) - options = { params: { action: 'index'}}.merge(options) if params['action'] == 'filter' + options = { params: { action: 'index' } }.merge(options) if params['action'] == 'filter' options = { renderer: RemoteLinkPaginationHelper::LinkRenderer }.merge(options) will_paginate(collection, options) end diff --git a/app/helpers/campaigns_helper.rb b/app/helpers/campaigns_helper.rb index 0dc7db4dfd..11c4793908 100644 --- a/app/helpers/campaigns_helper.rb +++ b/app/helpers/campaigns_helper.rb @@ -29,6 +29,6 @@ def performance(actual, target) def campaign_summary(campaign) status = render file: "campaigns/_status.html.haml", locals: { campaign: campaign } metrics = render file: "campaigns/_metrics.html.haml", locals: { campaign: campaign } - "#{t(campaign.status)}, " << [status, metrics].map { |str| strip_tags(str) }.join(' ').gsub("\n", '') + "#{t(campaign.status)}, " << [status, metrics].map { |str| strip_tags(str) }.join(' ').delete("\n") end end diff --git a/app/helpers/opportunities_helper.rb b/app/helpers/opportunities_helper.rb index 91a4175e4d..0c0dbaca20 100644 --- a/app/helpers/opportunities_helper.rb +++ b/app/helpers/opportunities_helper.rb @@ -13,7 +13,8 @@ def opportunity_stage_checkbox(stage, count) # Opportunity summary for RSS/ATOM feeds. #---------------------------------------------------------------------------- def opportunity_summary(opportunity) - summary, amount = [], [] + summary = [] + amount = [] summary << (opportunity.stage ? t(opportunity.stage) : t(:other)) summary << number_to_currency(opportunity.weighted_amount, precision: 0) unless %w(won lost).include?(opportunity.stage) @@ -38,8 +39,8 @@ def opportunity_campaign_select(options = {}) selected_campaign = Campaign.find_by_id(options[:selected]) campaigns = ([selected_campaign] + Campaign.my.order(:name).limit(25)).compact.uniq collection_select :opportunity, :campaign_id, campaigns, :id, :name, options, - :"data-placeholder" => t(:select_a_campaign), - :"data-url" => auto_complete_campaigns_path(format: 'json'), + "data-placeholder": t(:select_a_campaign), + "data-url": auto_complete_campaigns_path(format: 'json'), style: "width:330px; display:none;", class: 'ajax_chosen' end diff --git a/app/helpers/tasks_helper.rb b/app/helpers/tasks_helper.rb index 786c0b99e5..629c0af292 100644 --- a/app/helpers/tasks_helper.rb +++ b/app/helpers/tasks_helper.rb @@ -92,23 +92,23 @@ def hide_task_and_possibly_bucket(task, bucket) #---------------------------------------------------------------------------- def replace_content(task, bucket = nil) - partial = (task.assigned_to && task.assigned_to != current_user.id) ? "assigned" : "pending" + partial = task.assigned_to && task.assigned_to != current_user.id ? "assigned" : "pending" html = render(partial: "tasks/#{partial}", collection: [task], locals: { bucket: bucket }) - text = "$('##{dom_id(task)}').html('#{ j html }');\n".html_safe + text = "$('##{dom_id(task)}').html('#{j html}');\n".html_safe end #---------------------------------------------------------------------------- def insert_content(task, bucket, view) text = "$('#list_#{bucket}').show();\n" html = render(partial: view, collection: [task], locals: { bucket: bucket }) - text << "$('##{h bucket.to_s}').prepend('#{ j html }');\n" + text << "$('##{h bucket.to_s}').prepend('#{j html}');\n" text << "$('##{dom_id(task)}').effect('highlight', { duration:1500 });\n" text.html_safe end #---------------------------------------------------------------------------- def tasks_flash(message) - text = "$('#flash').html('#{ sanitize(message) }');\n" + text = "$('#flash').html('#{sanitize(message)}');\n" text << "crm.flash('notice', true)\n" text.html_safe end diff --git a/app/helpers/versions_helper.rb b/app/helpers/versions_helper.rb index d7f9d88154..a783b8c561 100644 --- a/app/helpers/versions_helper.rb +++ b/app/helpers/versions_helper.rb @@ -23,7 +23,7 @@ def parse_version(attr_name, change) first = link_to(h(account.name), account_path(account)) end if second.present? && (account = Account.find_by_id(second)) - second = link_to(h(account.name), account_path(account)) + second = link_to(h(account.name), account_path(account)) end end diff --git a/app/inputs/date_pair_input.rb b/app/inputs/date_pair_input.rb index 7586ac68d7..2c04e5c454 100644 --- a/app/inputs/date_pair_input.rb +++ b/app/inputs/date_pair_input.rb @@ -17,7 +17,7 @@ def input(wrapper_options) label = field == field1 ? I18n.t('pair.start') : I18n.t('pair.end') [:required, :disabled].each { |k| input_html_options.delete(k) } # ensure these come from field not default options input_html_options.merge!(field.input_options) - input_html_options.merge!(value: value(field)) + input_html_options[:value] = value(field) out << "#{label}".html_safe text = @builder.text_field(field.name, merge_wrapper_options(input_html_options, wrapper_options)) out << text << ''.html_safe diff --git a/app/inputs/date_time_input.rb b/app/inputs/date_time_input.rb index 9b87f751fb..b52c0a9d63 100755 --- a/app/inputs/date_time_input.rb +++ b/app/inputs/date_time_input.rb @@ -7,7 +7,7 @@ class DateTimeInput < SimpleForm::Inputs::DateTimeInput def input(wrapper_options) add_autocomplete! input_html_options.merge(input_options) - input_html_options.merge!(value: value) + input_html_options[:value] = value @builder.text_field(attribute_name, merge_wrapper_options(input_html_options, wrapper_options)) end diff --git a/app/models/entities/contact.rb b/app/models/entities/contact.rb index cd22e72aff..6435f16f61 100644 --- a/app/models/entities/contact.rb +++ b/app/models/entities/contact.rb @@ -101,6 +101,7 @@ class Contact < ActiveRecord::Base def self.per_page 20 end + def self.first_name_position "before" end diff --git a/app/models/entities/lead.rb b/app/models/entities/lead.rb index 1968dab4bc..a40aa01a9d 100644 --- a/app/models/entities/lead.rb +++ b/app/models/entities/lead.rb @@ -85,6 +85,7 @@ class Lead < ActiveRecord::Base def self.per_page 20 end + def self.first_name_position "before" end @@ -150,9 +151,7 @@ def reject # Attach a task to the lead if it hasn't been attached already. #---------------------------------------------------------------------------- def attach!(task) - unless task_ids.include?(task.id) - tasks << task - end + tasks << task unless task_ids.include?(task.id) end # Discard a task from the lead. @@ -175,16 +174,12 @@ def full_name(format = nil) #---------------------------------------------------------------------------- def increment_leads_count - if campaign_id - Campaign.increment_counter(:leads_count, campaign_id) - end + Campaign.increment_counter(:leads_count, campaign_id) if campaign_id end #---------------------------------------------------------------------------- def decrement_leads_count - if campaign_id - Campaign.decrement_counter(:leads_count, campaign_id) - end + Campaign.decrement_counter(:leads_count, campaign_id) if campaign_id end # Make sure at least one user has been selected if the lead is being shared. diff --git a/app/models/entities/opportunity.rb b/app/models/entities/opportunity.rb index 8388fdd53c..52641df20c 100644 --- a/app/models/entities/opportunity.rb +++ b/app/models/entities/opportunity.rb @@ -91,6 +91,7 @@ class Opportunity < ActiveRecord::Base def self.per_page 20 end + def self.default_stage Setting[:opportunity_default_stage].try(:to_s) || 'prospecting' end @@ -174,16 +175,12 @@ def users_for_shared_access #---------------------------------------------------------------------------- def increment_opportunities_count - if campaign_id - Campaign.increment_counter(:opportunities_count, campaign_id) - end + Campaign.increment_counter(:opportunities_count, campaign_id) if campaign_id end #---------------------------------------------------------------------------- def decrement_opportunities_count - if campaign_id - Campaign.decrement_counter(:opportunities_count, campaign_id) - end + Campaign.decrement_counter(:opportunities_count, campaign_id) if campaign_id end ActiveSupport.run_load_hooks(:fat_free_crm_opportunity, self) diff --git a/app/models/fields/field.rb b/app/models/fields/field.rb index 4ab45234f2..dedca6758e 100644 --- a/app/models/fields/field.rb +++ b/app/models/fields/field.rb @@ -46,7 +46,7 @@ class Field < ActiveRecord::Base 'url' => { klass: 'CustomField', type: 'string' }, 'tel' => { klass: 'CustomField', type: 'string' }, 'select' => { klass: 'CustomField', type: 'string' }, - 'radio_buttons' => { klass: 'CustomField', type: 'string' }, + 'radio_buttons' => { klass: 'CustomField', type: 'string' }, 'check_boxes' => { klass: 'CustomField', type: 'text' }, 'boolean' => { klass: 'CustomField', type: 'boolean' }, 'date' => { klass: 'CustomField', type: 'date' }, @@ -63,7 +63,7 @@ class Field < ActiveRecord::Base validates_inclusion_of :as, in: proc { field_types.keys }, message: "^Invalid field type.", allow_blank: true def column_type(field_type = as) - (opts = Field.field_types[field_type]) ? opts[:type] : fail("Unknown field_type: #{field_type}") + (opts = Field.field_types[field_type]) ? opts[:type] : raise("Unknown field_type: #{field_type}") end def input_options diff --git a/app/models/polymorphic/address.rb b/app/models/polymorphic/address.rb index 2bdc8e83ae..51ec5887a8 100644 --- a/app/models/polymorphic/address.rb +++ b/app/models/polymorphic/address.rb @@ -51,7 +51,7 @@ def blank? def self.reject_address(attributes) exists = attributes['id'].present? empty = %w(street1 street2 city state zipcode country full_address).map { |name| attributes[name].blank? }.all? - attributes.merge!(_destroy: 1) if exists && empty + attributes[:_destroy] = 1 if exists && empty (!exists && empty) end diff --git a/app/models/polymorphic/comment.rb b/app/models/polymorphic/comment.rb index b5f279d1fd..c3355e848b 100644 --- a/app/models/polymorphic/comment.rb +++ b/app/models/polymorphic/comment.rb @@ -23,7 +23,7 @@ class Comment < ActiveRecord::Base belongs_to :user belongs_to :commentable, polymorphic: true - scope :created_by, lambda { |user| where(user_id: user.id) } + scope :created_by, ->(user) { where(user_id: user.id) } validates_presence_of :user, :commentable, :comment has_paper_trail class_name: 'Version', meta: { related: :commentable }, diff --git a/app/models/polymorphic/task.rb b/app/models/polymorphic/task.rb index 5a3fda7f33..6c53d74a69 100644 --- a/app/models/polymorphic/task.rb +++ b/app/models/polymorphic/task.rb @@ -166,6 +166,7 @@ def computed_bucket "due_later" end end + # Returns list of tasks grouping them by due date as required by tasks/index. #---------------------------------------------------------------------------- def self.find_all_grouped(user, view) @@ -194,7 +195,7 @@ def self.bucket_empty?(bucket, user, view = "pending") def self.totals(user, view = "pending") return {} unless ALLOWED_VIEWS.include?(view) settings = (view == "completed" ? Setting.task_completed : Setting.task_bucket) - settings.inject(HashWithIndifferentAccess[all: 0]) do |hash, key| + settings.each_with_object(HashWithIndifferentAccess[all: 0]) do |key, hash| hash[key] = (view == "assigned" ? assigned_by(user).send(key).pending.count : my(user).send(key).send(view).count) hash[:all] += hash[key] hash @@ -220,8 +221,6 @@ def set_due_date Time.zone.now.midnight + 100.years when "specific_time" calendar ? parse_calendar_date : nil - else # due_later or due_asap - nil end end diff --git a/app/models/polymorphic/version.rb b/app/models/polymorphic/version.rb index 80ef7e799d..d4aa513429 100644 --- a/app/models/polymorphic/version.rb +++ b/app/models/polymorphic/version.rb @@ -13,10 +13,10 @@ class Version < PaperTrail::Version belongs_to :related, polymorphic: true belongs_to :user, foreign_key: :whodunnit - scope :default_order, lambda { order('created_at DESC') } - scope :include_events, lambda { |*events| where(event: events) } - scope :exclude_events, lambda { |*events| where('event NOT IN (?)', events) } - scope :for, lambda { |user| where(whodunnit: user.id.to_s) } + scope :default_order, -> { order('created_at DESC') } + scope :include_events, ->(*events) { where(event: events) } + scope :exclude_events, ->(*events) { where('event NOT IN (?)', events) } + scope :for, ->(user) { where(whodunnit: user.id.to_s) } class << self def recent_for_user(user, limit = 10) @@ -32,7 +32,7 @@ def recent_for_user(user, limit = 10) .offset(offset) .default_order - break if query.size == 0 + break if query.empty? versions += query.select { |v| v.item.present? } versions.uniq! { |v| [v.item_id, v.item_type] } offset += limit * 2 diff --git a/app/models/setting.rb b/app/models/setting.rb index bf9cbab88e..bf36c24201 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -56,15 +56,11 @@ def [](name) # Check database if database_and_table_exists? if setting = find_by_name(name.to_s) - unless setting.value.nil? - return cache[name] = setting.value - end + return cache[name] = setting.value unless setting.value.nil? end end # Check YAML settings - if yaml_settings.key?(name) - return cache[name] = yaml_settings[name] - end + return cache[name] = yaml_settings[name] if yaml_settings.key?(name) end # Set setting value @@ -89,7 +85,10 @@ def database_and_table_exists? # Returns false if table or database is unavailable. # Catches all database-related errors, so that Setting will return nil # instead of crashing the entire application. - table_exists? rescue false + + table_exists? + rescue + false end # Loads settings from YAML files diff --git a/app/models/users/user.rb b/app/models/users/user.rb index 8cf6dff0ef..9e3421f877 100644 --- a/app/models/users/user.rb +++ b/app/models/users/user.rb @@ -105,7 +105,7 @@ def suspended? #---------------------------------------------------------------------------- def awaits_approval? - self.suspended? && login_count == 0 && Setting.user_signup == :needs_approval + suspended? && login_count == 0 && Setting.user_signup == :needs_approval end #---------------------------------------------------------------------------- @@ -161,7 +161,7 @@ def check_if_current_user def has_related_assets? sum = %w(Account Campaign Lead Contact Opportunity Comment Task).detect do |asset| klass = asset.constantize - + asset != "Comment" && klass.assigned_to(self).exists? || klass.created_by(self).exists? end !sum.nil? diff --git a/config/environments/test.rb b/config/environments/test.rb index 8284cbc914..700f655d05 100755 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -28,7 +28,7 @@ config.action_dispatch.show_exceptions = false # Disable request forgery protection in test environment - config.action_controller.allow_forgery_protection = false + config.action_controller.allow_forgery_protection = false # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 5578b2bcda..a9f8a3237e 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -8,7 +8,7 @@ # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. -Rails.application.config.assets.precompile += %w( print.css chosen-sprite.png jquery-ui/* jquery_ui_datepicker/*.js ) +Rails.application.config.assets.precompile += %w(print.css chosen-sprite.png jquery-ui/* jquery_ui_datepicker/*.js) # Don't initialize Rails environment Rails.application.config.assets.initialize_on_precompile = false diff --git a/config/initializers/paper_trail.rb b/config/initializers/paper_trail.rb index 442b5f789c..39a6679176 100644 --- a/config/initializers/paper_trail.rb +++ b/config/initializers/paper_trail.rb @@ -1 +1 @@ -PaperTrail.config.track_associations = false \ No newline at end of file +PaperTrail.config.track_associations = false diff --git a/config/initializers/simple_form.rb b/config/initializers/simple_form.rb index 89046c560d..668960af3a 100644 --- a/config/initializers/simple_form.rb +++ b/config/initializers/simple_form.rb @@ -57,7 +57,7 @@ # config.collection_value_methods = [ :id, :to_s ] # How the label text should be generated altogether with the required text. - config.label_text = lambda { |label, _required, _explicit_label| "#{label}" } + config.label_text = ->(label, _required, _explicit_label) { label.to_s } # You can define the class to use on all labels. Default is nil. # config.label_class = nil diff --git a/config/initializers/views.rb b/config/initializers/views.rb index d347dad2fd..a5310fb89d 100644 --- a/config/initializers/views.rb +++ b/config/initializers/views.rb @@ -43,5 +43,4 @@ controllers: ['campaigns'], actions: ['index'], template: 'campaigns/index_long' }, { name: 'campaigns_show_normal', title: 'Normal format', icon: 'fa-list', controllers: ['campaigns'], actions: ['show'], template: nil }, # default show view - ].each { |view| FatFreeCRM::ViewFactory.new(view) } diff --git a/config/locales/th.rb b/config/locales/th.rb index 7783ec804a..2b8ce32a0b 100644 --- a/config/locales/th.rb +++ b/config/locales/th.rb @@ -41,9 +41,9 @@ module ThaiLocaleI18n date: { formats: { - default: lambda { |date, _opts| "%d-%m-#{date.year + 543}" }, + default: ->(date, _opts) { "%d-%m-#{date.year + 543}" }, short: "%d %b", - long: lambda { |date, _opts| "%d %B #{date.year + 543}" } + long: ->(date, _opts) { "%d %B #{date.year + 543}" } }, day_names: %w(อาทิตย์ จันทร์ อังคาร พุธ พฤหัสบดี ศุกร์ เสาร์), @@ -56,9 +56,9 @@ module ThaiLocaleI18n time: { formats: { - default: lambda { |date, _opts| "%a %d %b #{date.year + 543} %H:%M:%S %z" }, + default: ->(date, _opts) { "%a %d %b #{date.year + 543} %H:%M:%S %z" }, short: "%d %b %H:%M น.", - long: lambda { |date, _opts| "%d %B #{date.year + 543} %H:%M น." } + long: ->(date, _opts) { "%d %B #{date.year + 543} %H:%M น." } }, am: "ก่อนเที่ยง", pm: "หลังเที่ยง" diff --git a/config/unicorn.rb b/config/unicorn.rb index 328265cb21..f680d61f98 100755 --- a/config/unicorn.rb +++ b/config/unicorn.rb @@ -12,7 +12,7 @@ timeout 15 preload_app true -before_fork do |server, worker| +before_fork do |_server, _worker| Signal.trap 'TERM' do puts 'Unicorn master intercepting TERM and sending myself QUIT instead' Process.kill 'QUIT', Process.pid @@ -22,7 +22,7 @@ ActiveRecord::Base.connection.disconnect! end -after_fork do |server, worker| +after_fork do |_server, _worker| Signal.trap 'TERM' do puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT' end diff --git a/db/migrate/20100928030620_remove_uuid.rb b/db/migrate/20100928030620_remove_uuid.rb index e944a04a8f..57ec6f5621 100644 --- a/db/migrate/20100928030620_remove_uuid.rb +++ b/db/migrate/20100928030620_remove_uuid.rb @@ -4,14 +4,12 @@ class RemoveUuid < ActiveRecord::Migration def self.up [:users, :accounts, :campaigns, :leads, :contacts, :opportunities, :tasks].each do |table| remove_column table, :uuid - if self.uuid_configured? - execute("DROP TRIGGER IF EXISTS #{table}_uuid") - end + execute("DROP TRIGGER IF EXISTS #{table}_uuid") if uuid_configured? end end def self.down - fail ActiveRecord::IrreversibleMigration, "Can't recover deleted UUIDs" + raise ActiveRecord::IrreversibleMigration, "Can't recover deleted UUIDs" end private diff --git a/db/migrate/20111201030535_add_field_groups_klass_name.rb b/db/migrate/20111201030535_add_field_groups_klass_name.rb index 9f086c0ca6..5386ed4b19 100644 --- a/db/migrate/20111201030535_add_field_groups_klass_name.rb +++ b/db/migrate/20111201030535_add_field_groups_klass_name.rb @@ -6,7 +6,8 @@ def up %w(Account Campaign Contact Lead Opportunity).each do |entity| klass = entity.classify.constantize field_group = FieldGroup.new - field_group.label, field_group.klass_name = 'Custom Fields', klass.name + field_group.label = 'Custom Fields' + field_group.klass_name = klass.name field_group.save! Field.where(field_group_id: nil, klass_name: klass.name).update_all(field_group_id: field_group.id) end diff --git a/db/migrate/20120224073107_remove_default_value_and_clear_settings.rb b/db/migrate/20120224073107_remove_default_value_and_clear_settings.rb index a3c78a3b43..895bc2674a 100644 --- a/db/migrate/20120224073107_remove_default_value_and_clear_settings.rb +++ b/db/migrate/20120224073107_remove_default_value_and_clear_settings.rb @@ -3,7 +3,7 @@ def up remove_column :settings, :default_value # Truncate settings table - if connection.adapter_name.downcase == "sqlite" + if connection.adapter_name.casecmp("sqlite").zero? execute("DELETE FROM settings") else # mysql and postgres execute("TRUNCATE settings") diff --git a/db/schema.rb b/db/schema.rb index 67d3f1bd33..bd6960f42b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -12,7 +12,6 @@ # It's strongly recommended that you check this file into your version control system. ActiveRecord::Schema.define(version: 20160511053730) do - # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -455,5 +454,4 @@ add_index "versions", ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id", using: :btree add_index "versions", ["transaction_id"], name: "index_versions_on_transaction_id", using: :btree add_index "versions", ["whodunnit"], name: "index_versions_on_whodunnit", using: :btree - end diff --git a/lib/fat_free_crm.rb b/lib/fat_free_crm.rb index e75330c455..3a2b3463c4 100644 --- a/lib/fat_free_crm.rb +++ b/lib/fat_free_crm.rb @@ -26,9 +26,7 @@ def application? end # Load Fat Free CRM as a Rails Engine, unless running as a Rails Application -unless defined?(FatFreeCRM::Application) - require 'fat_free_crm/engine' -end +require 'fat_free_crm/engine' unless defined?(FatFreeCRM::Application) require 'fat_free_crm/load_settings' # register load hook for Setting diff --git a/lib/fat_free_crm/callback.rb b/lib/fat_free_crm/callback.rb index 060a97d1f3..9392a4ca87 100644 --- a/lib/fat_free_crm/callback.rb +++ b/lib/fat_free_crm/callback.rb @@ -43,6 +43,7 @@ def self.hook(method, caller, context = {}) def self.view_responder(method) @@responder[method] ||= @@classes.map(&:instance).select { |instance| instance.class.view_hooks[method] } end + # Invokes the view hook Proc stored under :hook and captures its output. # => Instead of defining methods on the class, view hooks are # stored as Procs in a hash. This allows the same hook to be manipulated in @@ -52,7 +53,7 @@ def self.view_responder(method) # - a hash of arrays containing Procs and positions to insert content. #-------------------------------------------------------------------------- def self.view_hook(hook, caller, context = {}) - view_responder(hook).inject(Hash.new([])) do |response, instance| + view_responder(hook).each_with_object(Hash.new([])) do |instance, response| # Process each operation within each view hook, storing the data in a hash. instance.class.view_hooks[hook].each do |op| response[op[:position]] += [op[:proc].call(caller, context)] diff --git a/lib/fat_free_crm/core_ext/string.rb b/lib/fat_free_crm/core_ext/string.rb index 4b6609c753..98daccd992 100644 --- a/lib/fat_free_crm/core_ext/string.rb +++ b/lib/fat_free_crm/core_ext/string.rb @@ -34,10 +34,10 @@ def false? # A query with 4 words will generate 6 permutations def name_permutations parts = split(" ") - (parts.size - 1).times.map do|i| + Array.new((parts.size - 1)) do |i| # ["A", "B", "C", "D"] => [["A B C", "D"], ["A B", "C D"], ["A", "B C D"]] [parts[(0..i)].join(" "), parts[(i + 1)..-1].join(" ")] - end.inject([]) do |arr, perm| + end.each_with_object([]) do |perm, arr| # Search both [first, last] and [last, first] # e.g. for every ["A B C", "D"], also include ["D", "A B C"] arr << perm diff --git a/lib/fat_free_crm/engine.rb b/lib/fat_free_crm/engine.rb index 31d64a4e41..f71d8a4940 100644 --- a/lib/fat_free_crm/engine.rb +++ b/lib/fat_free_crm/engine.rb @@ -11,7 +11,7 @@ class Engine < ::Rails::Engine config.active_record.observers = [:lead_observer, :opportunity_observer, :task_observer, :entity_observer] - initializer "model_core.factories", :after => "factory_girl.set_factory_paths" do + initializer "model_core.factories", after: "factory_girl.set_factory_paths" do FactoryGirl.definition_file_paths << File.expand_path('../../../spec/factories', __FILE__) if defined?(FactoryGirl) end diff --git a/lib/fat_free_crm/fields.rb b/lib/fat_free_crm/fields.rb index f918f72ebb..a26ddff785 100755 --- a/lib/fat_free_crm/fields.rb +++ b/lib/fat_free_crm/fields.rb @@ -79,7 +79,7 @@ def method_missing(method_id, *args, &block) # Refresh columns and try again. self.class.reset_column_information # If new record, create new object from class, else reload class - object = self.new_record? ? self.class.new : (reload && self) + object = new_record? ? self.class.new : (reload && self) # ensure serialization is setup if needed self.class.serialize_custom_fields! # Try again if object now responds to method, else return nil diff --git a/lib/fat_free_crm/i18n.rb b/lib/fat_free_crm/i18n.rb index 14e0a94f6b..b3ed3cc37d 100644 --- a/lib/fat_free_crm/i18n.rb +++ b/lib/fat_free_crm/i18n.rb @@ -13,7 +13,7 @@ def t(*args) super(args.first, default: args.first.to_s) elsif args.second.is_a?(Hash) super(*args) - elsif args.second.is_a?(Fixnum) + elsif args.second.is_a?(Integer) super(args.first, count: args.second) else super(args.first, value: args.second) diff --git a/lib/fat_free_crm/mail_processor/base.rb b/lib/fat_free_crm/mail_processor/base.rb index 6f47db4880..6712614893 100644 --- a/lib/fat_free_crm/mail_processor/base.rb +++ b/lib/fat_free_crm/mail_processor/base.rb @@ -16,7 +16,9 @@ class Base #-------------------------------------------------------------------------------------- def initialize - @archived, @discarded, @dry_run = 0, 0, false + @archived = 0 + @discarded = 0 + @dry_run = false end # Setup imap folders in settings. @@ -81,7 +83,11 @@ def disconnect! if @imap @imap.logout unless @imap.disconnected? - @imap.disconnect rescue nil + begin + @imap.disconnect + rescue + nil + end end end end diff --git a/lib/fat_free_crm/mail_processor/comment_replies.rb b/lib/fat_free_crm/mail_processor/comment_replies.rb index 62e4fc3640..70a6c9519b 100644 --- a/lib/fat_free_crm/mail_processor/comment_replies.rb +++ b/lib/fat_free_crm/mail_processor/comment_replies.rb @@ -39,7 +39,8 @@ def process(_uid, email) #-------------------------------------------------------------------------------------- def with_subject_line(email) if /\[([^:]*):([^\]]*)\]/ =~ email.subject - entity_name, entity_id = Regexp.last_match[1], Regexp.last_match[2] + entity_name = Regexp.last_match[1] + entity_id = Regexp.last_match[2] # Check that entity is a known model if ENTITY_SHORTCUTS.values.include?(entity_name) yield entity_name, entity_id diff --git a/lib/fat_free_crm/permissions.rb b/lib/fat_free_crm/permissions.rb index c7404a21ad..d91893d312 100644 --- a/lib/fat_free_crm/permissions.rb +++ b/lib/fat_free_crm/permissions.rb @@ -74,7 +74,7 @@ def remove_permissions permissions_to_remove = [] end - permissions_to_remove.each { |p| (permissions.delete(p); p.destroy) } + permissions_to_remove.each { |p| permissions.delete(p); p.destroy } end # Save the model along with its permissions if any. diff --git a/lib/gravatar_image_tag.rb b/lib/gravatar_image_tag.rb index 36bd96e1df..6b844a31b1 100644 --- a/lib/gravatar_image_tag.rb +++ b/lib/gravatar_image_tag.rb @@ -46,11 +46,11 @@ def self.gravatar_url_base(secure = false) end def self.gravatar_id(email, filetype = nil) - "#{ Digest::MD5.hexdigest(email) }#{ ".#{filetype}" unless filetype.nil? }" unless email.nil? + "#{Digest::MD5.hexdigest(email)}#{".#{filetype}" unless filetype.nil?}" unless email.nil? end def self.url_params(gravatar_params) - return nil if gravatar_params.keys.size == 0 + return nil if gravatar_params.keys.empty? "?#{gravatar_params.map { |key, value| "#{key}=#{URI.escape(value.is_a?(String) ? value : value.to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))}" }.join('&')}" end end diff --git a/lib/tasks/ffcrm/config.rake b/lib/tasks/ffcrm/config.rake index 9239bea721..1de7873341 100644 --- a/lib/tasks/ffcrm/config.rake +++ b/lib/tasks/ffcrm/config.rake @@ -9,7 +9,8 @@ namespace :ffcrm do task :copy_database_yml do require 'fileutils' filename = "config/database.#{ENV['DB'] || 'postgres'}.yml" - orig, dest = FatFreeCRM.root.join(filename), Rails.root.join('config/database.yml') + orig = FatFreeCRM.root.join(filename) + dest = Rails.root.join('config/database.yml') unless File.exist?(dest) puts "Copying #{filename} to config/database.yml ..." FileUtils.cp orig, dest diff --git a/lib/tasks/ffcrm/setup.rake b/lib/tasks/ffcrm/setup.rake index cbed0d9c54..73e32235c1 100644 --- a/lib/tasks/ffcrm/setup.rake +++ b/lib/tasks/ffcrm/setup.rake @@ -28,7 +28,9 @@ namespace :ffcrm do namespace :setup do desc "Create admin user" task admin: :environment do - username, password, email = ENV["USERNAME"], ENV["PASSWORD"], ENV["EMAIL"] + username = ENV["USERNAME"] + password = ENV["PASSWORD"] + email = ENV["EMAIL"] unless username && password && email puts "\nTo create the admin user you will be prompted to enter username, password," puts "and email address. You might also specify the username of existing user.\n" @@ -40,7 +42,7 @@ namespace :ffcrm do password ||= "manager" print "Password [#{password}]: " - echo = lambda { |toggle| return if RUBY_PLATFORM =~ /mswin/; system(toggle ? "stty echo && echo" : "stty -echo") } + echo = ->(toggle) { return if RUBY_PLATFORM =~ /mswin/; system(toggle ? "stty echo && echo" : "stty -echo") } begin echo.call(false) reply = STDIN.gets.strip diff --git a/lib/tasks/ffcrm/update_data.rake b/lib/tasks/ffcrm/update_data.rake index 30afe9f159..7dead054a6 100644 --- a/lib/tasks/ffcrm/update_data.rake +++ b/lib/tasks/ffcrm/update_data.rake @@ -217,9 +217,7 @@ in a console and continue. This is strongly discouraged. You have been warned! tmp = Address.where(scope) tmp.map { |t| t.country = ct[2] } - unless tmp.blank? - addresses_to_update << tmp - end + addresses_to_update << tmp unless tmp.blank? end Address.transaction do diff --git a/spec/controllers/tasks_controller_spec.rb b/spec/controllers/tasks_controller_spec.rb index fef1a85345..a2c841e4c9 100644 --- a/spec/controllers/tasks_controller_spec.rb +++ b/spec/controllers/tasks_controller_spec.rb @@ -14,7 +14,7 @@ def update_sidebar def produce_tasks(user, view) settings = (view != "completed" ? Setting.task_bucket : Setting.task_completed) - settings.inject({}) do | hash, due | + settings.each_with_object({}) do |due, hash| hash[due] ||= [] if Date.tomorrow == Date.today.end_of_week && due == :due_tomorrow due = :due_this_week @@ -55,7 +55,8 @@ def produce_tasks(user, view) describe "responding to GET index" do before do update_sidebar - @timezone, Time.zone = Time.zone, 'UTC' + @timezone = Time.zone + Time.zone = 'UTC' end after do diff --git a/spec/factories/shared_factories.rb b/spec/factories/shared_factories.rb index da332167bb..fd52add2bd 100755 --- a/spec/factories/shared_factories.rb +++ b/spec/factories/shared_factories.rb @@ -6,14 +6,14 @@ FactoryGirl.define do factory :version do whodunnit "" - item { fail "Please specify :item for the version" } + item { raise "Please specify :item for the version" } event "create" created_at { FactoryGirl.generate(:time) } end factory :comment do user - commentable { fail "Please specify :commentable for the comment" } + commentable { raise "Please specify :commentable for the comment" } title { FactoryGirl.generate(:title) } private false comment { FFaker::Lorem.paragraph } @@ -25,7 +25,7 @@ factory :email do imap_message_id { "%08x" % rand(0xFFFFFFFF) } user - mediator { fail "Please specify :mediator for the email" } + mediator { raise "Please specify :mediator for the email" } sent_from { FFaker::Internet.email } sent_to { FFaker::Internet.email } cc { FFaker::Internet.email } @@ -42,7 +42,7 @@ end factory :address do - addressable { fail "Please specify :addressable for the address" } + addressable { raise "Please specify :addressable for the address" } street1 { FFaker::Address.street_address } street2 { FFaker::Address.street_address } city { FFaker::Address.city } @@ -58,7 +58,7 @@ factory :avatar do user - entity { fail "Please specify :entity for the avatar" } + entity { raise "Please specify :entity for the avatar" } image { File.new(Rails.root.join('spec', 'fixtures', 'rails.png')) } updated_at { FactoryGirl.generate(:time) } created_at { FactoryGirl.generate(:time) } diff --git a/spec/factories/user_factories.rb b/spec/factories/user_factories.rb index 0bf82f0d5d..7cda3b7c15 100755 --- a/spec/factories/user_factories.rb +++ b/spec/factories/user_factories.rb @@ -43,15 +43,15 @@ factory :permission do user - asset { fail "Please specify :asset for the permission" } + asset { raise "Please specify :asset for the permission" } updated_at { FactoryGirl.generate(:time) } created_at { FactoryGirl.generate(:time) } end factory :preference do user - name { fail "Please specify :name for the preference" } - value { fail "Please specify :value for the preference" } + name { raise "Please specify :name for the preference" } + value { raise "Please specify :value for the preference" } updated_at { FactoryGirl.generate(:time) } created_at { FactoryGirl.generate(:time) } end diff --git a/spec/models/entities/opportunity_spec.rb b/spec/models/entities/opportunity_spec.rb index 7e9ce3663e..7a25373e07 100644 --- a/spec/models/entities/opportunity_spec.rb +++ b/spec/models/entities/opportunity_spec.rb @@ -35,7 +35,7 @@ end it "should be possible to create opportunity with the same name" do - first = FactoryGirl.create(:opportunity, name: "Hello", user: current_user) + first = FactoryGirl.create(:opportunity, name: "Hello", user: current_user) expect { FactoryGirl.create(:opportunity, name: "Hello", user: current_user) }.to_not raise_error end diff --git a/spec/models/fields/custom_field_pair_spec.rb b/spec/models/fields/custom_field_pair_spec.rb index bea114b2e4..0fbe44d7fd 100644 --- a/spec/models/fields/custom_field_pair_spec.rb +++ b/spec/models/fields/custom_field_pair_spec.rb @@ -18,7 +18,7 @@ class CustomFieldFooPair @field = { 'as' => 'foopair', 'field_group_id' => 1, 'label' => 'Event' } @pair1 = { 'name' => 'pair1' } @pair2 = { 'name' => 'pair2' } - @params = { 'field' => @field, 'pair' => { '0' => @pair1, '1' => @pair2 } } + @params = { 'field' => @field, 'pair' => { '0' => @pair1, '1' => @pair2 } } end it "should create the pair" do @@ -38,7 +38,7 @@ class CustomFieldFooPair @field = { 'as' => 'foopair', 'field_group_id' => 1, 'label' => 'Event' } @pair1 = { 'name' => 'pair1' } @pair2 = { 'name' => 'pair2' } - @params = { 'id' => '3', 'field' => @field, 'pair' => { '0' => @pair1, '1' => @pair2 } } + @params = { 'id' => '3', 'field' => @field, 'pair' => { '0' => @pair1, '1' => @pair2 } } end it "should update the pair" do diff --git a/spec/models/setting_spec.rb b/spec/models/setting_spec.rb index 14fb72c71b..8f8d062645 100644 --- a/spec/models/setting_spec.rb +++ b/spec/models/setting_spec.rb @@ -31,7 +31,7 @@ it "should use value from YAML if setting is missing from database" do @setting = FactoryGirl.create(:setting, name: "magoody", value: nil) - Setting.yaml_settings.merge!(magoody: "thingymabob") + Setting.yaml_settings[:magoody] = "thingymabob" expect(Setting[:magoody]).to eq("thingymabob") expect(Setting.magoody).to eq("thingymabob") end diff --git a/spec/shared/controllers.rb b/spec/shared/controllers.rb index 695bd0bbea..69d2ada055 100644 --- a/spec/shared/controllers.rb +++ b/spec/shared/controllers.rb @@ -78,7 +78,7 @@ it "should discard the attachment without deleting it" do xhr :post, :discard, id: @model.id, attachment: @attachment.class.name, attachment_id: @attachment.id expect(assigns[:attachment]).to eq(@attachment.reload) # The attachment should still exist. - expect(@model.reload.send("#{@attachment.class.name.tableize}")).to eq([]) # But no longer associated with the model. + expect(@model.reload.send(@attachment.class.name.tableize.to_s)).to eq([]) # But no longer associated with the model. expect(assigns[:account]).to eq(@model) if @model.is_a?(Account) expect(assigns[:campaign]).to eq(@model) if @model.is_a?(Campaign) diff --git a/spec/support/auth_macros.rb b/spec/support/auth_macros.rb index 47bb5b2931..bd758d94bb 100755 --- a/spec/support/auth_macros.rb +++ b/spec/support/auth_macros.rb @@ -17,21 +17,22 @@ def activate_authlogic #---------------------------------------------------------------------------- def login(user_stubs = {}, session_stubs = {}) User.current_user = @current_user = FactoryGirl.create(:user, user_stubs) - @current_user_session = double(Authentication, {record: current_user}.merge(session_stubs)) + @current_user_session = double(Authentication, { record: current_user }.merge(session_stubs)) allow(Authentication).to receive(:find).and_return(@current_user_session) - #set_timezone + # set_timezone end alias :require_user :login #---------------------------------------------------------------------------- def login_and_assign(user_stubs = {}, session_stubs = {}) User.current_user = @current_user = FactoryGirl.build_stubbed(:user, user_stubs) - @current_user_session = double(Authentication, {record: current_user}.merge(session_stubs)) + @current_user_session = double(Authentication, { record: current_user }.merge(session_stubs)) allow(Authentication).to receive(:find).and_return(@current_user_session) - #set_timezone + # set_timezone assigns[:current_user] = current_user end -def login_and_assign!(user_stubs = {}, session_stubs = {}) + +def login_and_assign!(_user_stubs = {}, _session_stubs = {}) login assigns[:current_user] = current_user end diff --git a/spec/support/macros.rb b/spec/support/macros.rb index eb88a95531..9d6b83ebcb 100755 --- a/spec/support/macros.rb +++ b/spec/support/macros.rb @@ -22,7 +22,7 @@ def stub_task(view) #---------------------------------------------------------------------------- def stub_task_total(view = "pending") settings = (view == "completed" ? Setting.task_completed : Setting.task_bucket) - settings.inject(all: 0) { |hash, key| hash[key] = 1; hash } + settings.each_with_object(all: 0) { |key, hash| hash[key] = 1; hash } end # Get current server timezone and set it (see rake time:zones:local for details). diff --git a/spec/views/application/auto_complete.haml_spec.rb b/spec/views/application/auto_complete.haml_spec.rb index 64c19a9450..fdfd8af2b7 100644 --- a/spec/views/application/auto_complete.haml_spec.rb +++ b/spec/views/application/auto_complete.haml_spec.rb @@ -25,10 +25,10 @@ render expect(rendered).to have_tag("ul", count: 1) do |list| - unless model == :lead - expect(list).to have_tag("li", id: @auto_complete.id.to_s, text: @auto_complete.name) - else + if model == :lead expect(list).to have_tag("li", id: @auto_complete.id.to_s, text: "#{@auto_complete.name} (#{@auto_complete.company})") + else + expect(list).to have_tag("li", id: @auto_complete.id.to_s, text: @auto_complete.name) end end end diff --git a/spec/views/campaigns/show.haml_spec.rb b/spec/views/campaigns/show.haml_spec.rb index 2f048c49ca..e274eb03ea 100644 --- a/spec/views/campaigns/show.haml_spec.rb +++ b/spec/views/campaigns/show.haml_spec.rb @@ -11,8 +11,8 @@ before do login_and_assign @campaign = FactoryGirl.build_stubbed(:campaign, id: 42, - leads: [FactoryGirl.build_stubbed(:lead)], - opportunities: [FactoryGirl.build_stubbed(:opportunity)]) + leads: [FactoryGirl.build_stubbed(:lead)], + opportunities: [FactoryGirl.build_stubbed(:opportunity)]) assign(:campaign, @campaign) assign(:users, [current_user]) assign(:comment, Comment.new) diff --git a/spec/views/tasks/index.haml_spec.rb b/spec/views/tasks/index.haml_spec.rb index c3c93ebc5b..bb16ded194 100644 --- a/spec/views/tasks/index.haml_spec.rb +++ b/spec/views/tasks/index.haml_spec.rb @@ -16,7 +16,7 @@ before do user = FactoryGirl.build_stubbed(:user) account = FactoryGirl.build_stubbed(:account) - @due = FactoryGirl.build_stubbed(:task, asset: account, bucket: "due_asap", assignee: user) + @due = FactoryGirl.build_stubbed(:task, asset: account, bucket: "due_asap", assignee: user) @completed = FactoryGirl.build_stubbed(:task, asset: account, bucket: "completed_today", assignee: user, completed_at: 1.hour.ago, completor: user) end diff --git a/spec/views/tasks/update.js.haml_spec.rb b/spec/views/tasks/update.js.haml_spec.rb index 2f84dc936f..5980ed3a0f 100644 --- a/spec/views/tasks/update.js.haml_spec.rb +++ b/spec/views/tasks/update.js.haml_spec.rb @@ -15,7 +15,7 @@ describe "Changing due date" do before do assign(:task_before_update, FactoryGirl.build_stubbed(:task, bucket: "due_asap")) - assign(:task, @task = FactoryGirl.build_stubbed(:task, bucket: "due_tomorrow")) + assign(:task, @task = FactoryGirl.build_stubbed(:task, bucket: "due_tomorrow")) assign(:view, "pending") assign(:task_total, stub_task_total("pending")) end @@ -64,7 +64,7 @@ it "pending task to somebody from Tasks tab: should remove the task and show flash message (assigned)" do assignee = FactoryGirl.build_stubbed(:user) assign(:task_before_update, FactoryGirl.build_stubbed(:task, assignee: nil)) - assign(:task, @task = FactoryGirl.build_stubbed(:task, assignee: assignee)) + assign(:task, @task = FactoryGirl.build_stubbed(:task, assignee: assignee)) assign(:view, "pending") controller.request.env["HTTP_REFERER"] = "http://localhost/tasks" @@ -78,7 +78,7 @@ it "assigned tasks to me from Tasks tab: should remove the task and show flash message (pending)" do assignee = FactoryGirl.build_stubbed(:user) assign(:task_before_update, FactoryGirl.build_stubbed(:task, assignee: assignee)) - assign(:task, @task = FactoryGirl.build_stubbed(:task, assignee: nil)) + assign(:task, @task = FactoryGirl.build_stubbed(:task, assignee: nil)) assign(:view, "assigned") controller.request.env["HTTP_REFERER"] = "http://localhost/tasks?view=assigned" @@ -91,7 +91,7 @@ it "assigned tasks to somebody else from Tasks tab: should re-render task partial" do assign(:task_before_update, FactoryGirl.build_stubbed(:task, assignee: FactoryGirl.build_stubbed(:user))) - assign(:task, @task = FactoryGirl.build_stubbed(:task, assignee: FactoryGirl.build_stubbed(:user))) + assign(:task, @task = FactoryGirl.build_stubbed(:task, assignee: FactoryGirl.build_stubbed(:user))) assign(:view, "assigned") controller.request.env["HTTP_REFERER"] = "http://localhost/tasks?view=assigned" @@ -101,7 +101,7 @@ it "from Tasks tab: should update tasks sidebar" do assign(:task_before_update, FactoryGirl.build_stubbed(:task, assignee: nil)) - assign(:task, @task = FactoryGirl.build_stubbed(:task, assignee: FactoryGirl.build_stubbed(:user))) + assign(:task, @task = FactoryGirl.build_stubbed(:task, assignee: FactoryGirl.build_stubbed(:user))) assign(:view, "assigned") controller.request.env["HTTP_REFERER"] = "http://localhost/tasks?view=assigned" render @@ -114,7 +114,7 @@ it "from asset page: should should re-render task partial" do assign(:task_before_update, FactoryGirl.build_stubbed(:task, assignee: nil)) - assign(:task, @task = FactoryGirl.build_stubbed(:task, assignee: FactoryGirl.build_stubbed(:user))) + assign(:task, @task = FactoryGirl.build_stubbed(:task, assignee: FactoryGirl.build_stubbed(:user))) render expect(rendered).to include("$('#task_#{@task.id}').html('