From 5dfb04e4b31b4961c02ee7e5aa3fa2110fdc7255 Mon Sep 17 00:00:00 2001 From: Karan Misra Date: Sat, 23 Mar 2013 20:32:59 +0530 Subject: [PATCH] Convert a lot of :a => b to a: b and bring peace to the world --- app/controllers/application_controller.rb | 2 +- app/controllers/forums_controller.rb | 2 +- app/controllers/topics_controller.rb | 2 +- .../users/omniauth_callbacks_controller.rb | 8 +-- app/controllers/users_controller.rb | 8 +-- app/helpers/common_helper.rb | 4 +- app/mailers/user_notifications.rb | 4 +- app/models/category_list.rb | 2 +- app/models/user_action.rb | 4 +- app/serializers/application_serializer.rb | 2 +- config/application.rb | 2 +- config/environments/development.rb | 4 +- config/environments/profile.rb | 2 +- config/initializers/04-message_bus.rb | 2 +- config/initializers/mini_profiler.rb | 2 +- config/initializers/omniauth.rb | 20 +++--- config/initializers/sidekiq.rb | 4 +- config/initializers/silence_logger.rb | 2 +- config/routes.rb | 68 +++++++++---------- db/migrate/20120311170118_create_users.rb | 2 +- .../20120423151548_remove_last_post_id.rb | 2 +- .../20120427154330_create_vestal_versions.rb | 4 +- .../20120518200115_create_read_posts.rb | 2 +- .../20120716020835_create_site_settings.rb | 6 +- ...20720013733_add_username_lower_to_users.rb | 2 +- ..._password_new_salt_email_token_to_users.rb | 6 +- db/migrate/20120807223020_create_actions.rb | 4 +- db/migrate/20120809020415_remove_site_id.rb | 14 ++-- ...0120809053414_correct_indexing_on_posts.rb | 2 +- .../20120809154750_remove_index_for_now.rb | 2 +- .../20120921055428_add_twitter_user_info.rb | 10 +-- ...121018133039_create_topic_allowed_users.rb | 8 +-- ...121122033316_add_muted_at_to_topic_user.rb | 2 +- ...0121123054127_make_post_number_distinct.rb | 2 +- .../20130205021905_alter_facebook_user_id.rb | 2 +- .../20130226015336_add_github_user_info.rb | 18 ++--- lib/canonical_url.rb | 2 +- lib/current_user.rb | 2 +- lib/discourse_redis.rb | 2 +- lib/jobs.rb | 2 +- lib/jobs/exporter.rb | 2 +- lib/jobs/importer.rb | 4 +- lib/post_creator.rb | 2 +- lib/pretty_text.rb | 6 +- lib/site_setting_extension.rb | 6 +- lib/topic_query.rb | 2 +- spec/components/cooked_post_processor_spec.rb | 2 +- spec/components/guardian_spec.rb | 4 +- .../components/oneboxer/amazon_onebox_spec.rb | 2 +- .../oneboxer/android_app_store_onebox_spec.rb | 2 +- .../oneboxer/apple_app_onebox_spec.rb | 2 +- .../components/oneboxer/flickr_onebox_spec.rb | 2 +- .../oneboxer/wikipedia_onebox_spec.rb | 4 +- spec/controllers/list_controller_spec.rb | 2 +- spec/controllers/static_controller_spec.rb | 4 +- spec/controllers/users_controller_spec.rb | 24 +++---- spec/models/error_log_spec.rb | 2 +- spec/models/notification_spec.rb | 2 +- spec/models/topic_spec.rb | 2 +- spec/models/topic_user_spec.rb | 8 +-- .../complete.html.erb_spec.rb | 8 +-- vendor/backports/notification.rb | 10 +-- 62 files changed, 171 insertions(+), 171 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0d0f97cc9..812d5bcdd 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -217,7 +217,7 @@ class ApplicationController < ActionController::Base def check_restricted_access # note current_user is defined in the CurrentUser mixin if SiteSetting.access_password.present? && cookies[:_access] != SiteSetting.access_password - redirect_to request_access_path(:return_path => request.fullpath) + redirect_to request_access_path(return_path: request.fullpath) return false end end diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index 4cd50ee8c..29d3600d6 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -6,7 +6,7 @@ class ForumsController < ApplicationController def status if $shutdown - render text: 'shutting down', :status => 500 + render text: 'shutting down', status: 500 else render text: 'ok' end diff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rb index 4015dfdb3..f477852fb 100644 --- a/app/controllers/topics_controller.rb +++ b/app/controllers/topics_controller.rb @@ -20,7 +20,7 @@ class TopicsController < ApplicationController before_filter :consider_user_for_promotion, only: :show skip_before_filter :check_xhr, only: [:avatar, :show, :feed] - caches_action :avatar, :cache_path => Proc.new {|c| "#{c.params[:post_number]}-#{c.params[:topic_id]}" } + caches_action :avatar, cache_path: Proc.new {|c| "#{c.params[:post_number]}-#{c.params[:topic_id]}" } def show diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index efa4872d2..7b320d0b4 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -14,7 +14,7 @@ class Users::OmniauthCallbacksController < ApplicationController skip_before_filter :check_xhr # must be done, cause we may trigger a POST - skip_before_filter :verify_authenticity_token, :only => :complete + skip_before_filter :verify_authenticity_token, only: :complete def complete # Make sure we support that provider @@ -49,7 +49,7 @@ class Users::OmniauthCallbacksController < ApplicationController twitter_screen_name: screen_name } - user_info = TwitterUserInfo.where(:twitter_user_id => twitter_user_id).first + user_info = TwitterUserInfo.where(twitter_user_id: twitter_user_id).first @data = { username: screen_name, @@ -97,7 +97,7 @@ class Users::OmniauthCallbacksController < ApplicationController email_valid: true } - user_info = FacebookUserInfo.where(:facebook_user_id => fb_uid ).first + user_info = FacebookUserInfo.where(facebook_user_id: fb_uid).first @data = { username: username, @@ -194,7 +194,7 @@ class Users::OmniauthCallbacksController < ApplicationController github_screen_name: screen_name } - user_info = GithubUserInfo.where(:github_user_id => github_user_id).first + user_info = GithubUserInfo.where(github_user_id: github_user_id).first @data = { username: screen_name, diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index b337a9536..41924d546 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -27,7 +27,7 @@ class UsersController < ApplicationController end def update - user = User.where(:username_lower => params[:username].downcase).first + user = User.where(username_lower: params[:username].downcase).first guardian.ensure_can_edit!(user) json_result(user) do |u| @@ -179,7 +179,7 @@ class UsersController < ApplicationController # Create auth records if auth.present? if auth[:twitter_user_id] && auth[:twitter_screen_name] && TwitterUserInfo.find_by_twitter_user_id(auth[:twitter_user_id]).nil? - TwitterUserInfo.create(:user_id => user.id, :screen_name => auth[:twitter_screen_name], :twitter_user_id => auth[:twitter_user_id]) + TwitterUserInfo.create(user_id: user.id, screen_name: auth[:twitter_screen_name], twitter_user_id: auth[:twitter_user_id]) end if auth[:facebook].present? && FacebookUserInfo.find_by_facebook_user_id(auth[:facebook][:facebook_user_id]).nil? @@ -187,7 +187,7 @@ class UsersController < ApplicationController end if auth[:github_user_id] && auth[:github_screen_name] && GithubUserInfo.find_by_github_user_id(auth[:github_user_id]).nil? - GithubUserInfo.create(:user_id => user.id, :screen_name => auth[:github_screen_name], :github_user_id => auth[:github_user_id]) + GithubUserInfo.create(user_id: user.id, screen_name: auth[:github_screen_name], github_user_id: auth[:github_user_id]) end end @@ -219,7 +219,7 @@ class UsersController < ApplicationController # TEMP to catch all missing spots # raise ActiveRecord::RecordNotFound - user = User.select(:email).where(:username_lower => params[:username].downcase).first + user = User.select(:email).where(username_lower: params[:username].downcase).first if user # for now we only support gravatar in square (redirect cached for a day), later we can use x-sendfile and/or a cdn to serve local size = params[:size].to_i diff --git a/app/helpers/common_helper.rb b/app/helpers/common_helper.rb index 83ee98efa..8a1efe427 100644 --- a/app/helpers/common_helper.rb +++ b/app/helpers/common_helper.rb @@ -1,7 +1,7 @@ module CommonHelper def render_google_analytics_code if Rails.env == "production" && SiteSetting.ga_tracking_code.present? - render :partial => "common/google_analytics" + render partial: "common/google_analytics" end end -end \ No newline at end of file +end diff --git a/app/mailers/user_notifications.rb b/app/mailers/user_notifications.rb index 4a1bc1de9..25f37ae64 100644 --- a/app/mailers/user_notifications.rb +++ b/app/mailers/user_notifications.rb @@ -53,8 +53,8 @@ class UserNotifications < ActionMailer::Base mail to: user.email, from: "#{I18n.t('user_notifications.digest.from', site_name: SiteSetting.title)} <#{SiteSetting.notification_email}>", subject: I18n.t('user_notifications.digest.subject_template', - :site_name => @site_name, - :date => I18n.l(Time.now, format: :short)) + site_name: @site_name, + date: I18n.l(Time.now, format: :short)) end end diff --git a/app/models/category_list.rb b/app/models/category_list.rb index 255f52d16..60ff863de 100644 --- a/app/models/category_list.rb +++ b/app/models/category_list.rb @@ -5,7 +5,7 @@ class CategoryList def initialize(current_user) @categories = Category - .includes(:featured_topics => [:category]) + .includes(featured_topics: [:category]) .includes(:featured_users) .order('topics_week desc, topics_month desc, topics_year desc') .to_a diff --git a/app/models/user_action.rb b/app/models/user_action.rb index b7d6363a5..283e22bed 100644 --- a/app/models/user_action.rb +++ b/app/models/user_action.rb @@ -1,7 +1,7 @@ class UserAction < ActiveRecord::Base belongs_to :user - belongs_to :target_post, :class_name => "Post" - belongs_to :target_topic, :class_name => "Topic" + belongs_to :target_post, class_name: "Post" + belongs_to :target_topic, class_name: "Topic" attr_accessible :acting_user_id, :action_type, :target_topic_id, :target_post_id, :target_user_id, :user_id validates_presence_of :action_type diff --git a/app/serializers/application_serializer.rb b/app/serializers/application_serializer.rb index 3065792ea..ad570267a 100644 --- a/app/serializers/application_serializer.rb +++ b/app/serializers/application_serializer.rb @@ -1,3 +1,3 @@ class ApplicationSerializer < ActiveModel::Serializer - embed :ids, :include => true + embed :ids, include: true end diff --git a/config/application.rb b/config/application.rb index b27a51805..5bbd27675 100644 --- a/config/application.rb +++ b/config/application.rb @@ -7,7 +7,7 @@ require './lib/discourse_plugin_registry' if defined?(Bundler) # If you precompile assets before deploying to production, use this line - Bundler.require(*Rails.groups(:assets => %w(development test profile))) + Bundler.require(*Rails.groups(assets: %w(development test profile))) # If you want your assets lazily compiled in production, use this line # Bundler.require(:default, :assets, Rails.env) end diff --git a/config/environments/development.rb b/config/environments/development.rb index 01fa3e654..f7152f887 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -34,9 +34,9 @@ Discourse::Application.configure do config.handlebars.precompile = false config.action_mailer.delivery_method = :smtp - config.action_mailer.smtp_settings = { :address => "localhost", :port => 1025 } + config.action_mailer.smtp_settings = { address: "localhost", port: 1025 } config.action_mailer.raise_delivery_errors = true - + BetterErrors::Middleware.allow_ip! ENV['TRUSTED_IP'] if ENV['TRUSTED_IP'] end diff --git a/config/environments/profile.rb b/config/environments/profile.rb index 48b234707..97db037d7 100644 --- a/config/environments/profile.rb +++ b/config/environments/profile.rb @@ -40,6 +40,6 @@ Discourse::Application.configure do config.ember.handlebars_location = "#{Rails.root}/app/assets/javascripts/external/handlebars-1.0.rc.3.js" config.handlebars.precompile = true - # config.middleware.use ::Rack::PerftoolsProfiler, :default_printer => 'gif' + # config.middleware.use ::Rack::PerftoolsProfiler, default_printer: 'gif' end diff --git a/config/initializers/04-message_bus.rb b/config/initializers/04-message_bus.rb index 21c43847a..67b0e27c2 100644 --- a/config/initializers/04-message_bus.rb +++ b/config/initializers/04-message_bus.rb @@ -8,7 +8,7 @@ MessageBus.user_id_lookup do |env| end MessageBus.on_connect do |site_id| - RailsMultisite::ConnectionManagement.establish_connection(:db => site_id) + RailsMultisite::ConnectionManagement.establish_connection(db: site_id) end MessageBus.on_disconnect do |site_id| diff --git a/config/initializers/mini_profiler.rb b/config/initializers/mini_profiler.rb index 189067e2e..8872cf017 100644 --- a/config/initializers/mini_profiler.rb +++ b/config/initializers/mini_profiler.rb @@ -1,7 +1,7 @@ # If Mini Profiler is included via gem if defined?(Rack::MiniProfiler) - Rack::MiniProfiler.config.storage_instance = Rack::MiniProfiler::RedisStore.new(:connection => DiscourseRedis.new) + Rack::MiniProfiler.config.storage_instance = Rack::MiniProfiler::RedisStore.new(connection: DiscourseRedis.new) # For our app, let's just show mini profiler always, polling is chatty so nuke that Rack::MiniProfiler.config.pre_authorize_cb = lambda do |env| diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb index 5c393bdc2..200460273 100644 --- a/config/initializers/omniauth.rb +++ b/config/initializers/omniauth.rb @@ -7,21 +7,21 @@ require 'openid_redis_store' Rails.application.config.middleware.use OmniAuth::Builder do provider :open_id, - :store => OpenID::Store::Redis.new($redis), - :name => 'google', - :identifier => 'https://www.google.com/accounts/o8/id', - :require => 'omniauth-openid' + store: OpenID::Store::Redis.new($redis), + name: 'google', + identifier: 'https://www.google.com/accounts/o8/id', + require: 'omniauth-openid' provider :open_id, - :store => OpenID::Store::Redis.new($redis), - :name => 'yahoo', - :identifier => 'https://me.yahoo.com', - :require => 'omniauth-openid' + store: OpenID::Store::Redis.new($redis), + name: 'yahoo', + identifier: 'https://me.yahoo.com', + require: 'omniauth-openid' provider :facebook, SiteSetting.facebook_app_id, SiteSetting.facebook_app_secret, - :scope => "email" + scope: "email" provider :twitter, SiteSetting.twitter_consumer_key, @@ -32,6 +32,6 @@ Rails.application.config.middleware.use OmniAuth::Builder do SiteSetting.github_client_secret provider :browser_id, - :name => 'persona' + name: 'persona' end diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb index 81bce9cf2..a121d750f 100644 --- a/config/initializers/sidekiq.rb +++ b/config/initializers/sidekiq.rb @@ -1,7 +1,7 @@ Sidekiq.configure_server do |config| - config.redis = { :url => $redis.url, :namespace => 'sidekiq' } + config.redis = { url: $redis.url, namespace: 'sidekiq' } end Sidekiq.configure_client do |config| - config.redis = { :url => $redis.url, :namespace => 'sidekiq' } + config.redis = { url: $redis.url, namespace: 'sidekiq' } end diff --git a/config/initializers/silence_logger.rb b/config/initializers/silence_logger.rb index 95e8d8b48..2d42bd18b 100644 --- a/config/initializers/silence_logger.rb +++ b/config/initializers/silence_logger.rb @@ -24,4 +24,4 @@ class SilenceLogger < Rails::Rack::Logger end silenced = ["/mini-profiler-resources/results", "/mini-profiler-resources/includes.js", "/mini-profiler-resources/includes.css", "/mini-profiler-resources/jquery.tmpl.js"] -Rails.configuration.middleware.swap Rails::Rack::Logger, SilenceLogger, :silenced => silenced +Rails.configuration.middleware.swap Rails::Rack::Logger, SilenceLogger, silenced: silenced diff --git a/config/routes.rb b/config/routes.rb index 364001614..e88fbf073 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -8,7 +8,7 @@ USERNAME_ROUTE_FORMAT = /[A-Za-z0-9\_]+/ Discourse::Application.routes.draw do - match "/404", :to => "exceptions#not_found" + match "/404", to: "exceptions#not_found" mount Sidekiq::Web => '/sidekiq', constraints: AdminConstraint.new @@ -63,13 +63,13 @@ Discourse::Application.routes.draw do post 'email/resubscribe/:key' => 'email#resubscribe', as: 'email_resubscribe' - resources :session, id: USERNAME_ROUTE_FORMAT, :only => [:create, :destroy] do + resources :session, id: USERNAME_ROUTE_FORMAT, only: [:create, :destroy] do collection do post 'forgot_password' end end - resources :users, :except => [:show, :update] do + resources :users, except: [:show, :update] do collection do get 'check_username' get 'is_local_username' @@ -90,17 +90,17 @@ Discourse::Application.routes.draw do get 'users/hp' => 'users#get_honeypot_value' get 'user_preferences' => 'users#user_preferences_redirect' - get 'users/:username/private-messages' => 'user_actions#private_messages', :constraints => {:username => USERNAME_ROUTE_FORMAT} - get 'users/:username' => 'users#show', :constraints => {:username => USERNAME_ROUTE_FORMAT} - put 'users/:username' => 'users#update', :constraints => {:username => USERNAME_ROUTE_FORMAT} - get 'users/:username/preferences' => 'users#preferences', :constraints => {:username => USERNAME_ROUTE_FORMAT}, :as => :email_preferences - get 'users/:username/preferences/email' => 'users#preferences', :constraints => {:username => USERNAME_ROUTE_FORMAT} - put 'users/:username/preferences/email' => 'users#change_email', :constraints => {:username => USERNAME_ROUTE_FORMAT} - get 'users/:username/preferences/username' => 'users#preferences', :constraints => {:username => USERNAME_ROUTE_FORMAT} - put 'users/:username/preferences/username' => 'users#username', :constraints => {:username => USERNAME_ROUTE_FORMAT} - get 'users/:username/avatar(/:size)' => 'users#avatar', :constraints => {:username => USERNAME_ROUTE_FORMAT} - get 'users/:username/invited' => 'users#invited', :constraints => {:username => USERNAME_ROUTE_FORMAT} - get 'users/:username/send_activation_email' => 'users#send_activation_email', :constraints => {:username => USERNAME_ROUTE_FORMAT} + get 'users/:username/private-messages' => 'user_actions#private_messages', constraints: {username: USERNAME_ROUTE_FORMAT} + get 'users/:username' => 'users#show', constraints: {username: USERNAME_ROUTE_FORMAT} + put 'users/:username' => 'users#update', constraints: {username: USERNAME_ROUTE_FORMAT} + get 'users/:username/preferences' => 'users#preferences', constraints: {username: USERNAME_ROUTE_FORMAT}, as: :email_preferences + get 'users/:username/preferences/email' => 'users#preferences', constraints: {username: USERNAME_ROUTE_FORMAT} + put 'users/:username/preferences/email' => 'users#change_email', constraints: {username: USERNAME_ROUTE_FORMAT} + get 'users/:username/preferences/username' => 'users#preferences', constraints: {username: USERNAME_ROUTE_FORMAT} + put 'users/:username/preferences/username' => 'users#username', constraints: {username: USERNAME_ROUTE_FORMAT} + get 'users/:username/avatar(/:size)' => 'users#avatar', constraints: {username: USERNAME_ROUTE_FORMAT} + get 'users/:username/invited' => 'users#invited', constraints: {username: USERNAME_ROUTE_FORMAT} + get 'users/:username/send_activation_email' => 'users#send_activation_email', constraints: {username: USERNAME_ROUTE_FORMAT} resources :uploads @@ -168,30 +168,30 @@ Discourse::Application.routes.draw do get 'topics/similar_to' # Legacy route for old avatars - get 'threads/:topic_id/:post_number/avatar' => 'topics#avatar', :constraints => {:topic_id => /\d+/, :post_number => /\d+/} + get 'threads/:topic_id/:post_number/avatar' => 'topics#avatar', constraints: {topic_id: /\d+/, post_number: /\d+/} # Topic routes - get 't/:slug/:topic_id/best_of' => 'topics#show', :defaults => {best_of: true}, :constraints => {:topic_id => /\d+/, :post_number => /\d+/} - get 't/:topic_id/best_of' => 'topics#show', :constraints => {:topic_id => /\d+/, :post_number => /\d+/} - put 't/:slug/:topic_id' => 'topics#update', :constraints => {:topic_id => /\d+/} - put 't/:slug/:topic_id/star' => 'topics#star', :constraints => {:topic_id => /\d+/} - put 't/:topic_id/star' => 'topics#star', :constraints => {:topic_id => /\d+/} - put 't/:slug/:topic_id/status' => 'topics#status', :constraints => {:topic_id => /\d+/} - put 't/:topic_id/status' => 'topics#status', :constraints => {:topic_id => /\d+/} - put 't/:topic_id/clear-pin' => 'topics#clear_pin', :constraints => {:topic_id => /\d+/} - put 't/:topic_id/mute' => 'topics#mute', :constraints => {:topic_id => /\d+/} - put 't/:topic_id/unmute' => 'topics#unmute', :constraints => {:topic_id => /\d+/} + get 't/:slug/:topic_id/best_of' => 'topics#show', defaults: {best_of: true}, constraints: {topic_id: /\d+/, post_number: /\d+/} + get 't/:topic_id/best_of' => 'topics#show', constraints: {topic_id: /\d+/, post_number: /\d+/} + put 't/:slug/:topic_id' => 'topics#update', constraints: {topic_id: /\d+/} + put 't/:slug/:topic_id/star' => 'topics#star', constraints: {topic_id: /\d+/} + put 't/:topic_id/star' => 'topics#star', constraints: {topic_id: /\d+/} + put 't/:slug/:topic_id/status' => 'topics#status', constraints: {topic_id: /\d+/} + put 't/:topic_id/status' => 'topics#status', constraints: {topic_id: /\d+/} + put 't/:topic_id/clear-pin' => 'topics#clear_pin', constraints: {topic_id: /\d+/} + put 't/:topic_id/mute' => 'topics#mute', constraints: {topic_id: /\d+/} + put 't/:topic_id/unmute' => 'topics#unmute', constraints: {topic_id: /\d+/} - get 't/:topic_id/:post_number' => 'topics#show', :constraints => {:topic_id => /\d+/, :post_number => /\d+/} - get 't/:slug/:topic_id.rss' => 'topics#feed', :format => :rss, :constraints => {:topic_id => /\d+/} - get 't/:slug/:topic_id' => 'topics#show', :constraints => {:topic_id => /\d+/} - get 't/:slug/:topic_id/:post_number' => 'topics#show', :constraints => {:topic_id => /\d+/, :post_number => /\d+/} - post 't/:topic_id/timings' => 'topics#timings', :constraints => {:topic_id => /\d+/} - post 't/:topic_id/invite' => 'topics#invite', :constraints => {:topic_id => /\d+/} - post 't/:topic_id/move-posts' => 'topics#move_posts', :constraints => {:topic_id => /\d+/} - delete 't/:topic_id/timings' => 'topics#destroy_timings', :constraints => {:topic_id => /\d+/} + get 't/:topic_id/:post_number' => 'topics#show', constraints: {topic_id: /\d+/, post_number: /\d+/} + get 't/:slug/:topic_id.rss' => 'topics#feed', format: :rss, constraints: {topic_id: /\d+/} + get 't/:slug/:topic_id' => 'topics#show', constraints: {topic_id: /\d+/} + get 't/:slug/:topic_id/:post_number' => 'topics#show', constraints: {topic_id: /\d+/, post_number: /\d+/} + post 't/:topic_id/timings' => 'topics#timings', constraints: {topic_id: /\d+/} + post 't/:topic_id/invite' => 'topics#invite', constraints: {topic_id: /\d+/} + post 't/:topic_id/move-posts' => 'topics#move_posts', constraints: {topic_id: /\d+/} + delete 't/:topic_id/timings' => 'topics#destroy_timings', constraints: {topic_id: /\d+/} - post 't/:topic_id/notifications' => 'topics#set_notifications' , :constraints => {:topic_id => /\d+/} + post 't/:topic_id/notifications' => 'topics#set_notifications' , constraints: {topic_id: /\d+/} resources :invites diff --git a/db/migrate/20120311170118_create_users.rb b/db/migrate/20120311170118_create_users.rb index 625867c90..d8dcdf1b9 100644 --- a/db/migrate/20120311170118_create_users.rb +++ b/db/migrate/20120311170118_create_users.rb @@ -1,7 +1,7 @@ class CreateUsers < ActiveRecord::Migration def change create_table :users do |t| - t.string :username, :limit => 20, null: false + t.string :username, limit: 20, null: false t.string :avatar_url, null: false t.timestamps end diff --git a/db/migrate/20120423151548_remove_last_post_id.rb b/db/migrate/20120423151548_remove_last_post_id.rb index ea0f2066c..f9ec56229 100644 --- a/db/migrate/20120423151548_remove_last_post_id.rb +++ b/db/migrate/20120423151548_remove_last_post_id.rb @@ -4,6 +4,6 @@ class RemoveLastPostId < ActiveRecord::Migration end def down - add_column :forum_threads, :last_post_id, :integer, :default => 0 + add_column :forum_threads, :last_post_id, :integer, default: 0 end end diff --git a/db/migrate/20120427154330_create_vestal_versions.rb b/db/migrate/20120427154330_create_vestal_versions.rb index 2d658ee08..f91211329 100644 --- a/db/migrate/20120427154330_create_vestal_versions.rb +++ b/db/migrate/20120427154330_create_vestal_versions.rb @@ -1,8 +1,8 @@ class CreateVestalVersions < ActiveRecord::Migration def self.up create_table :versions do |t| - t.belongs_to :versioned, :polymorphic => true - t.belongs_to :user, :polymorphic => true + t.belongs_to :versioned, polymorphic: true + t.belongs_to :user, polymorphic: true t.string :user_name t.text :modifications t.integer :number diff --git a/db/migrate/20120518200115_create_read_posts.rb b/db/migrate/20120518200115_create_read_posts.rb index 53f9bac63..dde728089 100644 --- a/db/migrate/20120518200115_create_read_posts.rb +++ b/db/migrate/20120518200115_create_read_posts.rb @@ -7,7 +7,7 @@ class CreateReadPosts < ActiveRecord::Migration t.column :seen, :integer, null: false end - add_index :read_posts, [:forum_thread_id, :user_id, :page], :unique => true + add_index :read_posts, [:forum_thread_id, :user_id, :page], unique: true end def down diff --git a/db/migrate/20120716020835_create_site_settings.rb b/db/migrate/20120716020835_create_site_settings.rb index b86075462..f519c89b5 100644 --- a/db/migrate/20120716020835_create_site_settings.rb +++ b/db/migrate/20120716020835_create_site_settings.rb @@ -1,9 +1,9 @@ class CreateSiteSettings < ActiveRecord::Migration def change create_table :site_settings do |t| - t.string :name, :null => false - t.text :description, :null => false - t.integer :data_type, :null => false + t.string :name, null: false + t.text :description, null: false + t.integer :data_type, null: false t.text :value t.timestamps diff --git a/db/migrate/20120720013733_add_username_lower_to_users.rb b/db/migrate/20120720013733_add_username_lower_to_users.rb index b744d1740..764fae375 100644 --- a/db/migrate/20120720013733_add_username_lower_to_users.rb +++ b/db/migrate/20120720013733_add_username_lower_to_users.rb @@ -2,7 +2,7 @@ class AddUsernameLowerToUsers < ActiveRecord::Migration def up add_column :users, :username_lower, :string, limit: 20 execute "update users set username_lower = lower(username)" - add_index :users, [:username_lower], :unique => true + add_index :users, [:username_lower], unique: true change_column :users, :username_lower, :string, limit: 20, null:false end def down diff --git a/db/migrate/20120806030641_add_new_password_new_salt_email_token_to_users.rb b/db/migrate/20120806030641_add_new_password_new_salt_email_token_to_users.rb index cbfb702a9..dfac912b7 100644 --- a/db/migrate/20120806030641_add_new_password_new_salt_email_token_to_users.rb +++ b/db/migrate/20120806030641_add_new_password_new_salt_email_token_to_users.rb @@ -1,9 +1,9 @@ class AddNewPasswordNewSaltEmailTokenToUsers < ActiveRecord::Migration def change - add_column :users, :new_salt, :string, :limit => 32 - add_column :users, :new_password_hash, :string, :limit => 64 + add_column :users, :new_salt, :string, limit: 32 + add_column :users, :new_password_hash, :string, limit: 64 # email token is more flexible, can be used for both intial activation AND password change confirmation - add_column :users, :email_token, :string, :limit => 32 + add_column :users, :email_token, :string, limit: 32 remove_column :users, :activation_key end end diff --git a/db/migrate/20120807223020_create_actions.rb b/db/migrate/20120807223020_create_actions.rb index 832ec6cf0..623bda592 100644 --- a/db/migrate/20120807223020_create_actions.rb +++ b/db/migrate/20120807223020_create_actions.rb @@ -9,8 +9,8 @@ class CreateActions < ActiveRecord::Migration # but this table is wider and is intended for non-notifying actions as well - t.integer :action_type, :null => false - t.integer :user_id, :null => false + t.integer :action_type, null: false + t.integer :user_id, null: false t.integer :target_forum_thread_id t.integer :target_post_id t.integer :target_user_id diff --git a/db/migrate/20120809020415_remove_site_id.rb b/db/migrate/20120809020415_remove_site_id.rb index 4898882e4..86727e86f 100644 --- a/db/migrate/20120809020415_remove_site_id.rb +++ b/db/migrate/20120809020415_remove_site_id.rb @@ -1,17 +1,17 @@ class RemoveSiteId < ActiveRecord::Migration def up drop_table 'sites' - remove_index 'incoming_links', :name => "incoming_index" - add_index "incoming_links", ["forum_thread_id", "post_number"], :name => "incoming_index" + remove_index 'incoming_links', name: "incoming_index" + add_index "incoming_links", ["forum_thread_id", "post_number"], name: "incoming_index" remove_column 'incoming_links', 'site_id' - remove_index 'users', :name => 'index_users_on_site_id' + remove_index 'users', name: 'index_users_on_site_id' remove_column 'users', 'site_id' - remove_index 'expression_types', :name => 'index_expression_types_on_site_id_and_expression_index' - remove_index 'expression_types', :name => 'index_expression_types_on_site_id_and_name' + remove_index 'expression_types', name: 'index_expression_types_on_site_id_and_expression_index' + remove_index 'expression_types', name: 'index_expression_types_on_site_id_and_name' remove_column 'expression_types','site_id' - add_index "expression_types", ["expression_index"], :unique => true - add_index "expression_types", ["name"], :unique => true + add_index "expression_types", ["expression_index"], unique: true + add_index "expression_types", ["name"], unique: true drop_table 'forums' end diff --git a/db/migrate/20120809053414_correct_indexing_on_posts.rb b/db/migrate/20120809053414_correct_indexing_on_posts.rb index f2921bf54..b3777e093 100644 --- a/db/migrate/20120809053414_correct_indexing_on_posts.rb +++ b/db/migrate/20120809053414_correct_indexing_on_posts.rb @@ -14,7 +14,7 @@ where pp.id = c.id and pp.post_number <> c.real_number" remove_index "posts", ["forum_thread_id","post_number"] # this needs to be unique if it is not we can not use post_number to identify a post - add_index "posts", ["forum_thread_id","post_number"], :unique => true + add_index "posts", ["forum_thread_id","post_number"], unique: true end diff --git a/db/migrate/20120809154750_remove_index_for_now.rb b/db/migrate/20120809154750_remove_index_for_now.rb index afd90d83b..148cbe70a 100644 --- a/db/migrate/20120809154750_remove_index_for_now.rb +++ b/db/migrate/20120809154750_remove_index_for_now.rb @@ -6,6 +6,6 @@ class RemoveIndexForNow < ActiveRecord::Migration def down remove_index "posts", ["forum_thread_id","post_number"] - add_index "posts", ["forum_thread_id","post_number"], :unique => true + add_index "posts", ["forum_thread_id","post_number"], unique: true end end diff --git a/db/migrate/20120921055428_add_twitter_user_info.rb b/db/migrate/20120921055428_add_twitter_user_info.rb index d7b7508e0..7aa0f81f0 100644 --- a/db/migrate/20120921055428_add_twitter_user_info.rb +++ b/db/migrate/20120921055428_add_twitter_user_info.rb @@ -1,13 +1,13 @@ class AddTwitterUserInfo < ActiveRecord::Migration def change create_table :twitter_user_infos do |t| - t.integer :user_id, :null => false - t.string :screen_name, :null => false - t.integer :twitter_user_id, :null => false + t.integer :user_id, null: false + t.string :screen_name, null: false + t.integer :twitter_user_id, null: false t.timestamps end - add_index :twitter_user_infos, [:twitter_user_id], :unique => true - add_index :twitter_user_infos, [:user_id], :unique => true + add_index :twitter_user_infos, [:twitter_user_id], unique: true + add_index :twitter_user_infos, [:user_id], unique: true end end diff --git a/db/migrate/20121018133039_create_topic_allowed_users.rb b/db/migrate/20121018133039_create_topic_allowed_users.rb index 30d5acf1b..04a832f60 100644 --- a/db/migrate/20121018133039_create_topic_allowed_users.rb +++ b/db/migrate/20121018133039_create_topic_allowed_users.rb @@ -1,12 +1,12 @@ class CreateTopicAllowedUsers < ActiveRecord::Migration def change create_table :topic_allowed_users do |t| - t.integer :user_id, :null => false - t.integer :topic_id, :null => false + t.integer :user_id, null: false + t.integer :topic_id, null: false t.timestamps end - add_index :topic_allowed_users, [:topic_id, :user_id], :unique => true - add_index :topic_allowed_users, [:user_id, :topic_id], :unique => true + add_index :topic_allowed_users, [:topic_id, :user_id], unique: true + add_index :topic_allowed_users, [:user_id, :topic_id], unique: true end end diff --git a/db/migrate/20121122033316_add_muted_at_to_topic_user.rb b/db/migrate/20121122033316_add_muted_at_to_topic_user.rb index 0a558f3ee..9ecd7d07a 100644 --- a/db/migrate/20121122033316_add_muted_at_to_topic_user.rb +++ b/db/migrate/20121122033316_add_muted_at_to_topic_user.rb @@ -1,7 +1,7 @@ class AddMutedAtToTopicUser < ActiveRecord::Migration def change add_column :topic_users, :muted_at, :datetime - change_column :topic_users, :last_read_post_number, :integer, :null => true + change_column :topic_users, :last_read_post_number, :integer, null: true change_column_default :topic_users, :last_read_post_number, nil end end diff --git a/db/migrate/20121123054127_make_post_number_distinct.rb b/db/migrate/20121123054127_make_post_number_distinct.rb index bf61533d0..4bca13b78 100644 --- a/db/migrate/20121123054127_make_post_number_distinct.rb +++ b/db/migrate/20121123054127_make_post_number_distinct.rb @@ -21,7 +21,7 @@ from where calc <> p.post_number and X.id = p.id') remove_index :posts, :forum_thread_id_and_post_number - add_index :posts, [:topic_id, :post_number], :unique => true + add_index :posts, [:topic_id, :post_number], unique: true end def down diff --git a/db/migrate/20130205021905_alter_facebook_user_id.rb b/db/migrate/20130205021905_alter_facebook_user_id.rb index 407299541..8517a9799 100644 --- a/db/migrate/20130205021905_alter_facebook_user_id.rb +++ b/db/migrate/20130205021905_alter_facebook_user_id.rb @@ -1,6 +1,6 @@ class AlterFacebookUserId < ActiveRecord::Migration def up - change_column :facebook_user_infos, :facebook_user_id, :integer, :limit => 8, null: false + change_column :facebook_user_infos, :facebook_user_id, :integer, limit: 8, null: false end def down diff --git a/db/migrate/20130226015336_add_github_user_info.rb b/db/migrate/20130226015336_add_github_user_info.rb index 4887aa374..431fb29d9 100644 --- a/db/migrate/20130226015336_add_github_user_info.rb +++ b/db/migrate/20130226015336_add_github_user_info.rb @@ -1,13 +1,13 @@ class AddGithubUserInfo < ActiveRecord::Migration def change - create_table :github_user_infos do |t| - t.integer :user_id, :null => false - t.string :screen_name, :null => false - t.integer :github_user_id, :null => false - t.timestamps + create_table :github_user_infos do |t| + t.integer :user_id, null: false + t.string :screen_name, null: false + t.integer :github_user_id, null: false + t.timestamps end - - add_index :github_user_infos, [:github_user_id], :unique => true - add_index :github_user_infos, [:user_id], :unique => true + + add_index :github_user_infos, [:github_user_id], unique: true + add_index :github_user_infos, [:user_id], unique: true end -end \ No newline at end of file +end diff --git a/lib/canonical_url.rb b/lib/canonical_url.rb index f00b2764c..0612c6650 100644 --- a/lib/canonical_url.rb +++ b/lib/canonical_url.rb @@ -14,7 +14,7 @@ module CanonicalURL def canonical_link_tag(url = nil) return '' unless url || @canonical_url - tag('link', :rel => 'canonical', :href => url || @canonical_url || request.url) + tag('link', rel: 'canonical', href: url || @canonical_url || request.url) end end end diff --git a/lib/current_user.rb b/lib/current_user.rb index d31119b99..52eb6450d 100644 --- a/lib/current_user.rb +++ b/lib/current_user.rb @@ -21,7 +21,7 @@ module CurrentUser end def set_permanent_cookie!(user) - cookies.permanent["_t"] = { :value => user.auth_token, :httponly => true } + cookies.permanent["_t"] = { value: user.auth_token, httponly: true } end def current_user diff --git a/lib/discourse_redis.rb b/lib/discourse_redis.rb index b36975048..5aae45185 100644 --- a/lib/discourse_redis.rb +++ b/lib/discourse_redis.rb @@ -5,7 +5,7 @@ class DiscourseRedis def initialize @config = YAML.load(ERB.new(File.new("#{Rails.root}/config/redis.yml").read).result)[Rails.env] - redis_opts = {:host => @config['host'], :port => @config['port'], :db => @config['db']} + redis_opts = {host: @config['host'], port: @config['port'], db: @config['db']} redis_opts[:password] = @config['password'] if @config['password'] @redis = Redis.new(redis_opts) end diff --git a/lib/jobs.rb b/lib/jobs.rb index a2bd69877..215c2f1b8 100644 --- a/lib/jobs.rb +++ b/lib/jobs.rb @@ -54,7 +54,7 @@ module Jobs dbs.each do |db| begin Jobs::Base.mutex.synchronize do - RailsMultisite::ConnectionManagement.establish_connection(:db => db) + RailsMultisite::ConnectionManagement.establish_connection(db: db) I18n.locale = SiteSetting.default_locale execute(opts) end diff --git a/lib/jobs/exporter.rb b/lib/jobs/exporter.rb index 3620fb9b5..5266bf1b7 100644 --- a/lib/jobs/exporter.rb +++ b/lib/jobs/exporter.rb @@ -6,7 +6,7 @@ module Jobs class Exporter < Jobs::Base - sidekiq_options :retry => false + sidekiq_options retry: false def execute(args) raise Import::ImportInProgressError if Import::is_import_running? diff --git a/lib/jobs/importer.rb b/lib/jobs/importer.rb index ff4053b54..ec7218c8b 100644 --- a/lib/jobs/importer.rb +++ b/lib/jobs/importer.rb @@ -10,7 +10,7 @@ module Jobs class Importer < Jobs::Base - sidekiq_options :retry => false + sidekiq_options retry: false BACKUP_SCHEMA = 'backup' @@ -286,4 +286,4 @@ module Jobs end -end \ No newline at end of file +end diff --git a/lib/post_creator.rb b/lib/post_creator.rb index ccc6407ff..1c91e803d 100644 --- a/lib/post_creator.rb +++ b/lib/post_creator.rb @@ -52,7 +52,7 @@ class PostCreator if @opts[:archetype] == Archetype.private_message usernames = @opts[:target_usernames].split(',') - User.where(:username => usernames).each do |u| + User.where(username: usernames).each do |u| unless guardian.can_send_private_message?(u) topic.errors.add(:archetype, :cant_send_pm) diff --git a/lib/pretty_text.rb b/lib/pretty_text.rb index 212b4d6d9..bf86f7092 100644 --- a/lib/pretty_text.rb +++ b/lib/pretty_text.rb @@ -5,14 +5,14 @@ module PrettyText def self.whitelist { - :elements => %w[ + elements: %w[ a abbr aside b bdo blockquote br caption cite code col colgroup dd div del dfn dl dt em hr figcaption figure h1 h2 h3 h4 h5 h6 hgroup i img ins kbd li mark ol p pre q rp rt ruby s samp small span strike strong sub sup table tbody td tfoot th thead time tr u ul var wbr ], - :attributes => { + attributes: { :all => ['dir', 'lang', 'title', 'class'], 'aside' => ['data-post', 'data-full', 'data-topic'], 'a' => ['href'], @@ -32,7 +32,7 @@ module PrettyText 'ul' => ['type'] }, - :protocols => { + protocols: { 'a' => {'href' => ['ftp', 'http', 'https', 'mailto', :relative]}, 'blockquote' => {'cite' => ['http', 'https', :relative]}, 'del' => {'cite' => ['http', 'https', :relative]}, diff --git a/lib/site_setting_extension.rb b/lib/site_setting_extension.rb index db6fb207b..301377d2a 100644 --- a/lib/site_setting_extension.rb +++ b/lib/site_setting_extension.rb @@ -133,13 +133,13 @@ module SiteSettingExtension def remove_override!(name) return unless table_exists? - SiteSetting.where(:name => name).destroy_all + SiteSetting.where(name: name).destroy_all end def add_override!(name,val) return unless table_exists? - setting = SiteSetting.where(:name => name).first + setting = SiteSetting.where(name: name).first type = get_data_type(defaults[name]) if type == types[:bool] && val != true && val != false @@ -159,7 +159,7 @@ module SiteSettingExtension setting.data_type = type setting.save else - SiteSetting.create!(:name => name, :value => val, :data_type => type) + SiteSetting.create!(name: name, value: val, data_type: type) end MessageBus.publish('/site_settings', {process: process_id}) diff --git a/lib/topic_query.rb b/lib/topic_query.rb index fbc54b15a..61d8a9590 100644 --- a/lib/topic_query.rb +++ b/lib/topic_query.rb @@ -196,7 +196,7 @@ class TopicQuery end end - result = result.listable_topics.includes(:category => :topic_only_relative_url) + result = result.listable_topics.includes(category: :topic_only_relative_url) result = result.where('categories.name is null or categories.name <> ?', query_opts[:exclude_category]) if query_opts[:exclude_category] result = result.where('categories.name = ?', query_opts[:only_category]) if query_opts[:only_category] result = result.limit(page_size) unless query_opts[:limit] == false diff --git a/spec/components/cooked_post_processor_spec.rb b/spec/components/cooked_post_processor_spec.rb index 799b03aab..3f1dc01fd 100644 --- a/spec/components/cooked_post_processor_spec.rb +++ b/spec/components/cooked_post_processor_spec.rb @@ -43,7 +43,7 @@ EXPECTED before do @topic = Fabricate(:topic) @post = Fabricate.build(:post_with_image_url, topic: @topic, user: @topic.user) - @cpp = CookedPostProcessor.new(@post, :image_sizes => {'http://www.forumwarz.com/images/header/logo.png' => {'width' => 111, 'height' => 222}}) + @cpp = CookedPostProcessor.new(@post, image_sizes: {'http://www.forumwarz.com/images/header/logo.png' => {'width' => 111, 'height' => 222}}) @cpp.expects(:get_size).returns([111,222]) end diff --git a/spec/components/guardian_spec.rb b/spec/components/guardian_spec.rb index 90cdf9b52..61bc3adf2 100644 --- a/spec/components/guardian_spec.rb +++ b/spec/components/guardian_spec.rb @@ -374,11 +374,11 @@ describe Guardian do it "isn't allowed if the user voted and the topic doesn't allow multiple votes" do Topic.any_instance.expects(:has_meta_data_boolean?).with(:single_vote).returns(true) - Guardian.new(user).can_vote?(post, :voted_in_topic => true).should be_false + Guardian.new(user).can_vote?(post, voted_in_topic: true).should be_false end it "is allowed if the user voted and the topic doesn't allow multiple votes" do - Guardian.new(user).can_vote?(post, :voted_in_topic => false).should be_true + Guardian.new(user).can_vote?(post, voted_in_topic: false).should be_true end end diff --git a/spec/components/oneboxer/amazon_onebox_spec.rb b/spec/components/oneboxer/amazon_onebox_spec.rb index 9728472ab..af994534d 100644 --- a/spec/components/oneboxer/amazon_onebox_spec.rb +++ b/spec/components/oneboxer/amazon_onebox_spec.rb @@ -7,7 +7,7 @@ require 'oneboxer/amazon_onebox' describe Oneboxer::AmazonOnebox do before(:each) do @o = Oneboxer::AmazonOnebox.new("http://www.amazon.com/Ruby-Programming-Language-David-Flanagan/dp/0596516177") - FakeWeb.register_uri(:get, @o.translate_url, :response => fixture_file('oneboxer/amazon.response')) + FakeWeb.register_uri(:get, @o.translate_url, response: fixture_file('oneboxer/amazon.response')) end it "translates the URL" do diff --git a/spec/components/oneboxer/android_app_store_onebox_spec.rb b/spec/components/oneboxer/android_app_store_onebox_spec.rb index ec4cd66cc..f28eeab64 100644 --- a/spec/components/oneboxer/android_app_store_onebox_spec.rb +++ b/spec/components/oneboxer/android_app_store_onebox_spec.rb @@ -7,7 +7,7 @@ require 'oneboxer/android_app_store_onebox' describe Oneboxer::AndroidAppStoreOnebox do before(:each) do @o = Oneboxer::AndroidAppStoreOnebox.new("https://play.google.com/store/apps/details?id=com.moosoft.parrot") - FakeWeb.register_uri(:get, @o.translate_url, :response => fixture_file('oneboxer/android.response')) + FakeWeb.register_uri(:get, @o.translate_url, response: fixture_file('oneboxer/android.response')) end it "generates the expected onebox for Android App Store" do diff --git a/spec/components/oneboxer/apple_app_onebox_spec.rb b/spec/components/oneboxer/apple_app_onebox_spec.rb index 5cb50cbb2..3e6a5c996 100644 --- a/spec/components/oneboxer/apple_app_onebox_spec.rb +++ b/spec/components/oneboxer/apple_app_onebox_spec.rb @@ -7,7 +7,7 @@ require 'oneboxer/apple_app_onebox' describe Oneboxer::AppleAppOnebox do before(:each) do @o = Oneboxer::AppleAppOnebox.new("https://itunes.apple.com/us/app/minecraft-pocket-edition-lite/id479651754") - FakeWeb.register_uri(:get, @o.translate_url, :response => fixture_file('oneboxer/apple.response')) + FakeWeb.register_uri(:get, @o.translate_url, response: fixture_file('oneboxer/apple.response')) end it "generates the expected onebox for Apple app" do diff --git a/spec/components/oneboxer/flickr_onebox_spec.rb b/spec/components/oneboxer/flickr_onebox_spec.rb index fc38072b6..442647a9e 100644 --- a/spec/components/oneboxer/flickr_onebox_spec.rb +++ b/spec/components/oneboxer/flickr_onebox_spec.rb @@ -7,7 +7,7 @@ require 'oneboxer/flickr_onebox' describe Oneboxer::FlickrOnebox do before(:each) do @o = Oneboxer::FlickrOnebox.new("http://www.flickr.com/photos/jaimeiniesta/3303881265") - FakeWeb.register_uri(:get, @o.translate_url, :response => fixture_file('oneboxer/flickr.response')) + FakeWeb.register_uri(:get, @o.translate_url, response: fixture_file('oneboxer/flickr.response')) end it "generates the expected onebox for Flickr" do diff --git a/spec/components/oneboxer/wikipedia_onebox_spec.rb b/spec/components/oneboxer/wikipedia_onebox_spec.rb index 43d2e8055..443148dca 100644 --- a/spec/components/oneboxer/wikipedia_onebox_spec.rb +++ b/spec/components/oneboxer/wikipedia_onebox_spec.rb @@ -8,8 +8,8 @@ describe Oneboxer::WikipediaOnebox do it "generates the expected onebox for Wikipedia" do o = Oneboxer::WikipediaOnebox.new('http://en.wikipedia.org/wiki/Ruby') - FakeWeb.register_uri(:get, o.translate_url, :response => fixture_file('oneboxer/wikipedia.response')) - FakeWeb.register_uri(:get, 'http://en.m.wikipedia.org/wiki/Ruby', :response => fixture_file('oneboxer/wikipedia_redirected.response')) + FakeWeb.register_uri(:get, o.translate_url, response: fixture_file('oneboxer/wikipedia.response')) + FakeWeb.register_uri(:get, 'http://en.m.wikipedia.org/wiki/Ruby', response: fixture_file('oneboxer/wikipedia_redirected.response')) o.onebox.should == expected_wikipedia_result end diff --git a/spec/controllers/list_controller_spec.rb b/spec/controllers/list_controller_spec.rb index ab711016b..e9cb598d3 100644 --- a/spec/controllers/list_controller_spec.rb +++ b/spec/controllers/list_controller_spec.rb @@ -5,7 +5,7 @@ describe ListController do # we need some data before do @user = Fabricate(:coding_horror) - @post = Fabricate(:post, :user => @user) + @post = Fabricate(:post, user: @user) end context 'index' do diff --git a/spec/controllers/static_controller_spec.rb b/spec/controllers/static_controller_spec.rb index f236f9feb..2e2bccc51 100644 --- a/spec/controllers/static_controller_spec.rb +++ b/spec/controllers/static_controller_spec.rb @@ -5,7 +5,7 @@ describe StaticController do context "with a static file that's present" do before do - xhr :get, :show, :id => 'faq' + xhr :get, :show, id: 'faq' end it 'renders the static file if present' do @@ -19,7 +19,7 @@ describe StaticController do context "with a missing file" do it "should respond 404" do - xhr :get, :show, :id => 'does-not-exist' + xhr :get, :show, id: 'does-not-exist' response.response_code.should == 404 end end diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index d3a030cc1..0d5d8b648 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -276,12 +276,12 @@ describe UsersController do context 'when creating a non active user (unconfirmed email)' do it 'should enqueue a signup email' do Jobs.expects(:enqueue).with(:user_email, has_entries(type: :signup)) - xhr :post, :create, :name => @user.name, :username => @user.username, :password => "strongpassword", :email => @user.email + xhr :post, :create, name: @user.name, username: @user.username, password: "strongpassword", email: @user.email end it "doesn't send a welcome email" do User.any_instance.expects(:enqueue_welcome_message).with('welcome_user').never - xhr :post, :create, :name => @user.name, :username => @user.username, :password => "strongpassword", :email => @user.email + xhr :post, :create, name: @user.name, username: @user.username, password: "strongpassword", email: @user.email end end @@ -293,25 +293,25 @@ describe UsersController do it 'should enqueue a signup email' do User.any_instance.expects(:enqueue_welcome_message).with('welcome_user') - xhr :post, :create, :name => @user.name, :username => @user.username, :password => "strongpassword", :email => @user.email + xhr :post, :create, name: @user.name, username: @user.username, password: "strongpassword", email: @user.email end it "should be logged in" do User.any_instance.expects(:enqueue_welcome_message) - xhr :post, :create, :name => @user.name, :username => @user.username, :password => "strongpassword", :email => @user.email + xhr :post, :create, name: @user.name, username: @user.username, password: "strongpassword", email: @user.email session[:current_user_id].should be_present end it "returns true in the active part of the JSON" do User.any_instance.expects(:enqueue_welcome_message) - xhr :post, :create, :name => @user.name, :username => @user.username, :password => "strongpassword", :email => @user.email + xhr :post, :create, name: @user.name, username: @user.username, password: "strongpassword", email: @user.email ::JSON.parse(response.body)['active'].should == true end context 'when approving of users is required' do before do SiteSetting.expects(:must_approve_users).returns(true) - xhr :post, :create, :name => @user.name, :username => @user.username, :password => "strongpassword", :email => @user.email + xhr :post, :create, name: @user.name, username: @user.username, password: "strongpassword", email: @user.email end it "doesn't log in the user" do @@ -328,7 +328,7 @@ describe UsersController do context 'after success' do before do - xhr :post, :create, :name => @user.name, :username => @user.username, :password => "strongpassword", :email => @user.email + xhr :post, :create, name: @user.name, username: @user.username, password: "strongpassword", email: @user.email end it 'should succeed' do @@ -368,7 +368,7 @@ describe UsersController do before do UsersController.any_instance.stubs(:honeypot_value).returns('abc') end - let(:create_params) { {:name => @user.name, :username => @user.username, :password => "strongpassword", :email => @user.email, :password_confirmation => 'wrong'} } + let(:create_params) { {name: @user.name, username: @user.username, password: "strongpassword", email: @user.email, password_confirmation: 'wrong'} } it_should_behave_like 'honeypot fails' end @@ -376,7 +376,7 @@ describe UsersController do before do UsersController.any_instance.stubs(:challenge_value).returns('abc') end - let(:create_params) { {:name => @user.name, :username => @user.username, :password => "strongpassword", :email => @user.email, :challenge => 'abc'} } + let(:create_params) { {name: @user.name, username: @user.username, password: "strongpassword", email: @user.email, challenge: 'abc'} } it_should_behave_like 'honeypot fails' end @@ -393,12 +393,12 @@ describe UsersController do end context 'when password is blank' do - let(:create_params) { {:name => @user.name, :username => @user.username, :password => "", :email => @user.email} } + let(:create_params) { {name: @user.name, username: @user.username, password: "", email: @user.email} } it_should_behave_like 'failed signup' end context 'when password param is missing' do - let(:create_params) { {:name => @user.name, :username => @user.username, :email => @user.email} } + let(:create_params) { {name: @user.name, username: @user.username, email: @user.email} } it_should_behave_like 'failed signup' end @@ -406,7 +406,7 @@ describe UsersController do before do User.any_instance.stubs(:save).raises(ActiveRecord::StatementInvalid) end - let(:create_params) { {:name => @user.name, :username => @user.username, :password => "strongpassword", :email => @user.email} } + let(:create_params) { {name: @user.name, username: @user.username, password: "strongpassword", email: @user.email} } it_should_behave_like 'failed signup' end end diff --git a/spec/models/error_log_spec.rb b/spec/models/error_log_spec.rb index bcee623c0..bb49068a5 100644 --- a/spec/models/error_log_spec.rb +++ b/spec/models/error_log_spec.rb @@ -18,7 +18,7 @@ describe ErrorLog do end def request - ActionController::TestRequest.new(:host => 'test') + ActionController::TestRequest.new(host: 'test') end describe "add_row!" do diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb index da9755722..2abf7c624 100644 --- a/spec/models/notification_spec.rb +++ b/spec/models/notification_spec.rb @@ -72,7 +72,7 @@ describe Notification do describe 'private message' do before do @topic = Fabricate(:private_message_topic) - @post = Fabricate(:post, :topic => @topic, :user => @topic.user) + @post = Fabricate(:post, topic: @topic, user: @topic.user) @target = @post.topic.topic_allowed_users.reject{|a| a.user_id == @post.user_id}[0].user end diff --git a/spec/models/topic_spec.rb b/spec/models/topic_spec.rb index 92632dfc7..f4cffabf8 100644 --- a/spec/models/topic_spec.rb +++ b/spec/models/topic_spec.rb @@ -823,7 +823,7 @@ describe Topic do end describe 'meta data' do - let(:topic) { Fabricate(:topic, :meta_data => {hello: 'world'}) } + let(:topic) { Fabricate(:topic, meta_data: {hello: 'world'}) } it 'allows us to create a topic with meta data' do topic.meta_data['hello'].should == 'world' diff --git a/spec/models/topic_user_spec.rb b/spec/models/topic_user_spec.rb index c1c5debb3..029af8c92 100644 --- a/spec/models/topic_user_spec.rb +++ b/spec/models/topic_user_spec.rb @@ -24,7 +24,7 @@ describe TopicUser do describe "unpinned" do before do - TopicUser.change(user, topic, {:starred_at => yesterday}) + TopicUser.change(user, topic, {starred_at: yesterday}) end it "defaults to blank" do @@ -37,19 +37,19 @@ describe TopicUser do it 'should be set to tracking if auto_track_topics is enabled' do user.update_column(:auto_track_topics_after_msecs, 0) - TopicUser.change(user, topic, {:starred_at => yesterday}) + TopicUser.change(user, topic, {starred_at: yesterday}) TopicUser.get(topic, user).notification_level.should == TopicUser.notification_levels[:tracking] end it 'should reset regular topics to tracking topics if auto track is changed' do - TopicUser.change(user, topic, {:starred_at => yesterday}) + TopicUser.change(user, topic, {starred_at: yesterday}) user.auto_track_topics_after_msecs = 0 user.save topic_user.notification_level.should == TopicUser.notification_levels[:tracking] end it 'should be set to "regular" notifications, by default on non creators' do - TopicUser.change(user, topic, {:starred_at => yesterday}) + TopicUser.change(user, topic, {starred_at: yesterday}) TopicUser.get(topic,user).notification_level.should == TopicUser.notification_levels[:regular] end diff --git a/spec/views/omniauth_callbacks/complete.html.erb_spec.rb b/spec/views/omniauth_callbacks/complete.html.erb_spec.rb index 098e79bc7..c29c4e12c 100644 --- a/spec/views/omniauth_callbacks/complete.html.erb_spec.rb +++ b/spec/views/omniauth_callbacks/complete.html.erb_spec.rb @@ -2,7 +2,7 @@ require "spec_helper" describe "users/omniauth_callbacks/complete.html.erb" do it "renders facebook data " do - assign(:data, {:username =>"username", :auth_provider=> "Facebook", :awaiting_activation=>true}) + assign(:data, {username: "username", :auth_provider=> "Facebook", :awaiting_activation=>true}) render @@ -14,7 +14,7 @@ describe "users/omniauth_callbacks/complete.html.erb" do end it "renders twitter data " do - assign(:data, {:username =>"username", :auth_provider=>"Twitter", :awaiting_activation=>true}) + assign(:data, {username: "username", :auth_provider=>"Twitter", :awaiting_activation=>true}) render @@ -27,7 +27,7 @@ describe "users/omniauth_callbacks/complete.html.erb" do it "renders openid data " do - assign(:data, {:username =>"username", :auth_provider=>"OpenId", :awaiting_activation=>true}) + assign(:data, {username: "username", :auth_provider=>"OpenId", :awaiting_activation=>true}) render @@ -39,7 +39,7 @@ describe "users/omniauth_callbacks/complete.html.erb" do end it "renders github data " do - assign(:data, {:username =>"username", :auth_provider=>"Github", :awaiting_activation=>true}) + assign(:data, {username: "username", :auth_provider=>"Github", :awaiting_activation=>true}) render diff --git a/vendor/backports/notification.rb b/vendor/backports/notification.rb index 886b120dd..d02028fb1 100644 --- a/vendor/backports/notification.rb +++ b/vendor/backports/notification.rb @@ -198,8 +198,8 @@ module ActiveSupport # # To instrument an event you just need to do: # - # ActiveSupport::Notifications.instrument("render", :extra => :information) do - # render :text => "Foo" + # ActiveSupport::Notifications.instrument("render", extra: :information) do + # render text: "Foo" # end # # That executes the block first and notifies all subscribers once done. @@ -223,14 +223,14 @@ module ActiveSupport # That code returns right away, you are just subscribing to "render" events. # The block will be called asynchronously whenever someone instruments "render": # - # ActiveSupport::Notifications.instrument("render", :extra => :information) do - # render :text => "Foo" + # ActiveSupport::Notifications.instrument("render", extra: :information) do + # render text: "Foo" # end # # event = events.first # event.name # => "render" # event.duration # => 10 (in milliseconds) - # event.payload # => { :extra => :information } + # event.payload # => { extra: :information } # # The block in the subscribe call gets the name of the event, start # timestamp, end timestamp, a string with a unique identifier for that event