Merge pull request #547 from kid0m4n/convert-ruby-1-9-syntax

Convert a lot of :a => b to a: b and bring peace to the world
This commit is contained in:
Sam 2013-03-24 16:43:17 -07:00
commit deb603f41c
62 changed files with 171 additions and 171 deletions

View File

@ -217,7 +217,7 @@ class ApplicationController < ActionController::Base
def check_restricted_access def check_restricted_access
# note current_user is defined in the CurrentUser mixin # note current_user is defined in the CurrentUser mixin
if SiteSetting.access_password.present? && cookies[:_access] != SiteSetting.access_password 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 return false
end end
end end

View File

@ -6,7 +6,7 @@ class ForumsController < ApplicationController
def status def status
if $shutdown if $shutdown
render text: 'shutting down', :status => 500 render text: 'shutting down', status: 500
else else
render text: 'ok' render text: 'ok'
end end

View File

@ -20,7 +20,7 @@ class TopicsController < ApplicationController
before_filter :consider_user_for_promotion, only: :show before_filter :consider_user_for_promotion, only: :show
skip_before_filter :check_xhr, only: [:avatar, :show, :feed] 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 def show

View File

@ -14,7 +14,7 @@ class Users::OmniauthCallbacksController < ApplicationController
skip_before_filter :check_xhr skip_before_filter :check_xhr
# must be done, cause we may trigger a POST # 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 def complete
# Make sure we support that provider # Make sure we support that provider
@ -49,7 +49,7 @@ class Users::OmniauthCallbacksController < ApplicationController
twitter_screen_name: screen_name 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 = { @data = {
username: screen_name, username: screen_name,
@ -97,7 +97,7 @@ class Users::OmniauthCallbacksController < ApplicationController
email_valid: true email_valid: true
} }
user_info = FacebookUserInfo.where(:facebook_user_id => fb_uid ).first user_info = FacebookUserInfo.where(facebook_user_id: fb_uid).first
@data = { @data = {
username: username, username: username,
@ -194,7 +194,7 @@ class Users::OmniauthCallbacksController < ApplicationController
github_screen_name: screen_name 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 = { @data = {
username: screen_name, username: screen_name,

View File

@ -27,7 +27,7 @@ class UsersController < ApplicationController
end end
def update 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) guardian.ensure_can_edit!(user)
json_result(user) do |u| json_result(user) do |u|
@ -179,7 +179,7 @@ class UsersController < ApplicationController
# Create auth records # Create auth records
if auth.present? if auth.present?
if auth[:twitter_user_id] && auth[:twitter_screen_name] && TwitterUserInfo.find_by_twitter_user_id(auth[:twitter_user_id]).nil? 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 end
if auth[:facebook].present? && FacebookUserInfo.find_by_facebook_user_id(auth[:facebook][:facebook_user_id]).nil? if auth[:facebook].present? && FacebookUserInfo.find_by_facebook_user_id(auth[:facebook][:facebook_user_id]).nil?
@ -187,7 +187,7 @@ class UsersController < ApplicationController
end end
if auth[:github_user_id] && auth[:github_screen_name] && GithubUserInfo.find_by_github_user_id(auth[:github_user_id]).nil? 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
end end
@ -219,7 +219,7 @@ class UsersController < ApplicationController
# TEMP to catch all missing spots # TEMP to catch all missing spots
# raise ActiveRecord::RecordNotFound # 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 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 # 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 size = params[:size].to_i

View File

@ -1,7 +1,7 @@
module CommonHelper module CommonHelper
def render_google_analytics_code def render_google_analytics_code
if Rails.env == "production" && SiteSetting.ga_tracking_code.present? if Rails.env == "production" && SiteSetting.ga_tracking_code.present?
render :partial => "common/google_analytics" render partial: "common/google_analytics"
end end
end end
end end

View File

@ -53,8 +53,8 @@ class UserNotifications < ActionMailer::Base
mail to: user.email, mail to: user.email,
from: "#{I18n.t('user_notifications.digest.from', site_name: SiteSetting.title)} <#{SiteSetting.notification_email}>", from: "#{I18n.t('user_notifications.digest.from', site_name: SiteSetting.title)} <#{SiteSetting.notification_email}>",
subject: I18n.t('user_notifications.digest.subject_template', subject: I18n.t('user_notifications.digest.subject_template',
:site_name => @site_name, site_name: @site_name,
:date => I18n.l(Time.now, format: :short)) date: I18n.l(Time.now, format: :short))
end end
end end

View File

@ -5,7 +5,7 @@ class CategoryList
def initialize(current_user) def initialize(current_user)
@categories = Category @categories = Category
.includes(:featured_topics => [:category]) .includes(featured_topics: [:category])
.includes(:featured_users) .includes(:featured_users)
.order('topics_week desc, topics_month desc, topics_year desc') .order('topics_week desc, topics_month desc, topics_year desc')
.to_a .to_a

View File

@ -1,7 +1,7 @@
class UserAction < ActiveRecord::Base class UserAction < ActiveRecord::Base
belongs_to :user belongs_to :user
belongs_to :target_post, :class_name => "Post" belongs_to :target_post, class_name: "Post"
belongs_to :target_topic, :class_name => "Topic" 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 attr_accessible :acting_user_id, :action_type, :target_topic_id, :target_post_id, :target_user_id, :user_id
validates_presence_of :action_type validates_presence_of :action_type

View File

@ -1,3 +1,3 @@
class ApplicationSerializer < ActiveModel::Serializer class ApplicationSerializer < ActiveModel::Serializer
embed :ids, :include => true embed :ids, include: true
end end

View File

@ -7,7 +7,7 @@ require './lib/discourse_plugin_registry'
if defined?(Bundler) if defined?(Bundler)
# If you precompile assets before deploying to production, use this line # 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 # If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env) # Bundler.require(:default, :assets, Rails.env)
end end

View File

@ -34,7 +34,7 @@ Discourse::Application.configure do
config.handlebars.precompile = false config.handlebars.precompile = false
config.action_mailer.delivery_method = :smtp 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 config.action_mailer.raise_delivery_errors = true
BetterErrors::Middleware.allow_ip! ENV['TRUSTED_IP'] if ENV['TRUSTED_IP'] BetterErrors::Middleware.allow_ip! ENV['TRUSTED_IP'] if ENV['TRUSTED_IP']

View File

@ -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.ember.handlebars_location = "#{Rails.root}/app/assets/javascripts/external/handlebars-1.0.rc.3.js"
config.handlebars.precompile = true config.handlebars.precompile = true
# config.middleware.use ::Rack::PerftoolsProfiler, :default_printer => 'gif' # config.middleware.use ::Rack::PerftoolsProfiler, default_printer: 'gif'
end end

View File

@ -8,7 +8,7 @@ MessageBus.user_id_lookup do |env|
end end
MessageBus.on_connect do |site_id| MessageBus.on_connect do |site_id|
RailsMultisite::ConnectionManagement.establish_connection(:db => site_id) RailsMultisite::ConnectionManagement.establish_connection(db: site_id)
end end
MessageBus.on_disconnect do |site_id| MessageBus.on_disconnect do |site_id|

View File

@ -1,7 +1,7 @@
# If Mini Profiler is included via gem # If Mini Profiler is included via gem
if defined?(Rack::MiniProfiler) 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 # 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| Rack::MiniProfiler.config.pre_authorize_cb = lambda do |env|

View File

@ -7,21 +7,21 @@ require 'openid_redis_store'
Rails.application.config.middleware.use OmniAuth::Builder do Rails.application.config.middleware.use OmniAuth::Builder do
provider :open_id, provider :open_id,
:store => OpenID::Store::Redis.new($redis), store: OpenID::Store::Redis.new($redis),
:name => 'google', name: 'google',
:identifier => 'https://www.google.com/accounts/o8/id', identifier: 'https://www.google.com/accounts/o8/id',
:require => 'omniauth-openid' require: 'omniauth-openid'
provider :open_id, provider :open_id,
:store => OpenID::Store::Redis.new($redis), store: OpenID::Store::Redis.new($redis),
:name => 'yahoo', name: 'yahoo',
:identifier => 'https://me.yahoo.com', identifier: 'https://me.yahoo.com',
:require => 'omniauth-openid' require: 'omniauth-openid'
provider :facebook, provider :facebook,
SiteSetting.facebook_app_id, SiteSetting.facebook_app_id,
SiteSetting.facebook_app_secret, SiteSetting.facebook_app_secret,
:scope => "email" scope: "email"
provider :twitter, provider :twitter,
SiteSetting.twitter_consumer_key, SiteSetting.twitter_consumer_key,
@ -32,6 +32,6 @@ Rails.application.config.middleware.use OmniAuth::Builder do
SiteSetting.github_client_secret SiteSetting.github_client_secret
provider :browser_id, provider :browser_id,
:name => 'persona' name: 'persona'
end end

View File

@ -1,7 +1,7 @@
Sidekiq.configure_server do |config| Sidekiq.configure_server do |config|
config.redis = { :url => $redis.url, :namespace => 'sidekiq' } config.redis = { url: $redis.url, namespace: 'sidekiq' }
end end
Sidekiq.configure_client do |config| Sidekiq.configure_client do |config|
config.redis = { :url => $redis.url, :namespace => 'sidekiq' } config.redis = { url: $redis.url, namespace: 'sidekiq' }
end end

View File

@ -24,4 +24,4 @@ class SilenceLogger < Rails::Rack::Logger
end end
silenced = ["/mini-profiler-resources/results", "/mini-profiler-resources/includes.js", "/mini-profiler-resources/includes.css", "/mini-profiler-resources/jquery.tmpl.js"] 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

View File

@ -8,7 +8,7 @@ USERNAME_ROUTE_FORMAT = /[A-Za-z0-9\_]+/
Discourse::Application.routes.draw do Discourse::Application.routes.draw do
match "/404", :to => "exceptions#not_found" match "/404", to: "exceptions#not_found"
mount Sidekiq::Web => '/sidekiq', constraints: AdminConstraint.new 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' 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 collection do
post 'forgot_password' post 'forgot_password'
end end
end end
resources :users, :except => [:show, :update] do resources :users, except: [:show, :update] do
collection do collection do
get 'check_username' get 'check_username'
get 'is_local_username' get 'is_local_username'
@ -90,17 +90,17 @@ Discourse::Application.routes.draw do
get 'users/hp' => 'users#get_honeypot_value' get 'users/hp' => 'users#get_honeypot_value'
get 'user_preferences' => 'users#user_preferences_redirect' get 'user_preferences' => 'users#user_preferences_redirect'
get 'users/:username/private-messages' => 'user_actions#private_messages', :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} get 'users/:username' => 'users#show', constraints: {username: USERNAME_ROUTE_FORMAT}
put 'users/:username' => 'users#update', :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' => 'users#preferences', constraints: {username: USERNAME_ROUTE_FORMAT}, as: :email_preferences
get 'users/:username/preferences/email' => 'users#preferences', :constraints => {:username => USERNAME_ROUTE_FORMAT} 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} 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} get 'users/:username/preferences/username' => 'users#preferences', constraints: {username: USERNAME_ROUTE_FORMAT}
put 'users/:username/preferences/username' => 'users#username', :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/avatar(/:size)' => 'users#avatar', constraints: {username: USERNAME_ROUTE_FORMAT}
get 'users/:username/invited' => 'users#invited', :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/send_activation_email' => 'users#send_activation_email', constraints: {username: USERNAME_ROUTE_FORMAT}
resources :uploads resources :uploads
@ -168,30 +168,30 @@ Discourse::Application.routes.draw do
get 'topics/similar_to' get 'topics/similar_to'
# Legacy route for old avatars # 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 # Topic routes
get 't/:slug/:topic_id/best_of' => 'topics#show', :defaults => {best_of: true}, :constraints => {:topic_id => /\d+/, :post_number => /\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+/} 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' => 'topics#update', constraints: {topic_id: /\d+/}
put 't/:slug/:topic_id/star' => 'topics#star', :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/:topic_id/star' => 'topics#star', constraints: {topic_id: /\d+/}
put 't/:slug/:topic_id/status' => 'topics#status', :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/status' => 'topics#status', constraints: {topic_id: /\d+/}
put 't/:topic_id/clear-pin' => 'topics#clear_pin', :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/mute' => 'topics#mute', constraints: {topic_id: /\d+/}
put 't/:topic_id/unmute' => 'topics#unmute', :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/: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.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' => 'topics#show', constraints: {topic_id: /\d+/}
get 't/:slug/:topic_id/:post_number' => 'topics#show', :constraints => {:topic_id => /\d+/, :post_number => /\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/timings' => 'topics#timings', constraints: {topic_id: /\d+/}
post 't/:topic_id/invite' => 'topics#invite', :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+/} 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+/} 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 resources :invites

View File

@ -1,7 +1,7 @@
class CreateUsers < ActiveRecord::Migration class CreateUsers < ActiveRecord::Migration
def change def change
create_table :users do |t| 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.string :avatar_url, null: false
t.timestamps t.timestamps
end end

View File

@ -4,6 +4,6 @@ class RemoveLastPostId < ActiveRecord::Migration
end end
def down def down
add_column :forum_threads, :last_post_id, :integer, :default => 0 add_column :forum_threads, :last_post_id, :integer, default: 0
end end
end end

View File

@ -1,8 +1,8 @@
class CreateVestalVersions < ActiveRecord::Migration class CreateVestalVersions < ActiveRecord::Migration
def self.up def self.up
create_table :versions do |t| create_table :versions do |t|
t.belongs_to :versioned, :polymorphic => true t.belongs_to :versioned, polymorphic: true
t.belongs_to :user, :polymorphic => true t.belongs_to :user, polymorphic: true
t.string :user_name t.string :user_name
t.text :modifications t.text :modifications
t.integer :number t.integer :number

View File

@ -7,7 +7,7 @@ class CreateReadPosts < ActiveRecord::Migration
t.column :seen, :integer, null: false t.column :seen, :integer, null: false
end 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 end
def down def down

View File

@ -1,9 +1,9 @@
class CreateSiteSettings < ActiveRecord::Migration class CreateSiteSettings < ActiveRecord::Migration
def change def change
create_table :site_settings do |t| create_table :site_settings do |t|
t.string :name, :null => false t.string :name, null: false
t.text :description, :null => false t.text :description, null: false
t.integer :data_type, :null => false t.integer :data_type, null: false
t.text :value t.text :value
t.timestamps t.timestamps

View File

@ -2,7 +2,7 @@ class AddUsernameLowerToUsers < ActiveRecord::Migration
def up def up
add_column :users, :username_lower, :string, limit: 20 add_column :users, :username_lower, :string, limit: 20
execute "update users set username_lower = lower(username)" 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 change_column :users, :username_lower, :string, limit: 20, null:false
end end
def down def down

View File

@ -1,9 +1,9 @@
class AddNewPasswordNewSaltEmailTokenToUsers < ActiveRecord::Migration class AddNewPasswordNewSaltEmailTokenToUsers < ActiveRecord::Migration
def change def change
add_column :users, :new_salt, :string, :limit => 32 add_column :users, :new_salt, :string, limit: 32
add_column :users, :new_password_hash, :string, :limit => 64 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 # 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 remove_column :users, :activation_key
end end
end end

View File

@ -9,8 +9,8 @@ class CreateActions < ActiveRecord::Migration
# but this table is wider and is intended for non-notifying actions as well # but this table is wider and is intended for non-notifying actions as well
t.integer :action_type, :null => false t.integer :action_type, null: false
t.integer :user_id, :null => false t.integer :user_id, null: false
t.integer :target_forum_thread_id t.integer :target_forum_thread_id
t.integer :target_post_id t.integer :target_post_id
t.integer :target_user_id t.integer :target_user_id

View File

@ -1,17 +1,17 @@
class RemoveSiteId < ActiveRecord::Migration class RemoveSiteId < ActiveRecord::Migration
def up def up
drop_table 'sites' drop_table 'sites'
remove_index 'incoming_links', :name => "incoming_index" remove_index 'incoming_links', name: "incoming_index"
add_index "incoming_links", ["forum_thread_id", "post_number"], :name => "incoming_index" add_index "incoming_links", ["forum_thread_id", "post_number"], name: "incoming_index"
remove_column 'incoming_links', 'site_id' 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_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_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_name'
remove_column 'expression_types','site_id' remove_column 'expression_types','site_id'
add_index "expression_types", ["expression_index"], :unique => true add_index "expression_types", ["expression_index"], unique: true
add_index "expression_types", ["name"], :unique => true add_index "expression_types", ["name"], unique: true
drop_table 'forums' drop_table 'forums'
end end

View File

@ -14,7 +14,7 @@ where pp.id = c.id and pp.post_number <> c.real_number"
remove_index "posts", ["forum_thread_id","post_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 # 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 end

View File

@ -6,6 +6,6 @@ class RemoveIndexForNow < ActiveRecord::Migration
def down def down
remove_index "posts", ["forum_thread_id","post_number"] 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
end end

View File

@ -1,13 +1,13 @@
class AddTwitterUserInfo < ActiveRecord::Migration class AddTwitterUserInfo < ActiveRecord::Migration
def change def change
create_table :twitter_user_infos do |t| create_table :twitter_user_infos do |t|
t.integer :user_id, :null => false t.integer :user_id, null: false
t.string :screen_name, :null => false t.string :screen_name, null: false
t.integer :twitter_user_id, :null => false t.integer :twitter_user_id, null: false
t.timestamps t.timestamps
end end
add_index :twitter_user_infos, [:twitter_user_id], :unique => true add_index :twitter_user_infos, [:twitter_user_id], unique: true
add_index :twitter_user_infos, [:user_id], :unique => true add_index :twitter_user_infos, [:user_id], unique: true
end end
end end

View File

@ -1,12 +1,12 @@
class CreateTopicAllowedUsers < ActiveRecord::Migration class CreateTopicAllowedUsers < ActiveRecord::Migration
def change def change
create_table :topic_allowed_users do |t| create_table :topic_allowed_users do |t|
t.integer :user_id, :null => false t.integer :user_id, null: false
t.integer :topic_id, :null => false t.integer :topic_id, null: false
t.timestamps t.timestamps
end end
add_index :topic_allowed_users, [:topic_id, :user_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 add_index :topic_allowed_users, [:user_id, :topic_id], unique: true
end end
end end

View File

@ -1,7 +1,7 @@
class AddMutedAtToTopicUser < ActiveRecord::Migration class AddMutedAtToTopicUser < ActiveRecord::Migration
def change def change
add_column :topic_users, :muted_at, :datetime 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 change_column_default :topic_users, :last_read_post_number, nil
end end
end end

View File

@ -21,7 +21,7 @@ from
where calc <> p.post_number and X.id = p.id') where calc <> p.post_number and X.id = p.id')
remove_index :posts, :forum_thread_id_and_post_number 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 end
def down def down

View File

@ -1,6 +1,6 @@
class AlterFacebookUserId < ActiveRecord::Migration class AlterFacebookUserId < ActiveRecord::Migration
def up 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 end
def down def down

View File

@ -1,13 +1,13 @@
class AddGithubUserInfo < ActiveRecord::Migration class AddGithubUserInfo < ActiveRecord::Migration
def change def change
create_table :github_user_infos do |t| create_table :github_user_infos do |t|
t.integer :user_id, :null => false t.integer :user_id, null: false
t.string :screen_name, :null => false t.string :screen_name, null: false
t.integer :github_user_id, :null => false t.integer :github_user_id, null: false
t.timestamps t.timestamps
end end
add_index :github_user_infos, [:github_user_id], :unique => true add_index :github_user_infos, [:github_user_id], unique: true
add_index :github_user_infos, [:user_id], :unique => true add_index :github_user_infos, [:user_id], unique: true
end end
end end

View File

@ -14,7 +14,7 @@ module CanonicalURL
def canonical_link_tag(url = nil) def canonical_link_tag(url = nil)
return '' unless url || @canonical_url 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 end
end end

View File

@ -21,7 +21,7 @@ module CurrentUser
end end
def set_permanent_cookie!(user) def set_permanent_cookie!(user)
cookies.permanent["_t"] = { :value => user.auth_token, :httponly => true } cookies.permanent["_t"] = { value: user.auth_token, httponly: true }
end end
def current_user def current_user

View File

@ -5,7 +5,7 @@ class DiscourseRedis
def initialize def initialize
@config = YAML.load(ERB.new(File.new("#{Rails.root}/config/redis.yml").read).result)[Rails.env] @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_opts[:password] = @config['password'] if @config['password']
@redis = Redis.new(redis_opts) @redis = Redis.new(redis_opts)
end end

View File

@ -54,7 +54,7 @@ module Jobs
dbs.each do |db| dbs.each do |db|
begin begin
Jobs::Base.mutex.synchronize do Jobs::Base.mutex.synchronize do
RailsMultisite::ConnectionManagement.establish_connection(:db => db) RailsMultisite::ConnectionManagement.establish_connection(db: db)
I18n.locale = SiteSetting.default_locale I18n.locale = SiteSetting.default_locale
execute(opts) execute(opts)
end end

View File

@ -6,7 +6,7 @@ module Jobs
class Exporter < Jobs::Base class Exporter < Jobs::Base
sidekiq_options :retry => false sidekiq_options retry: false
def execute(args) def execute(args)
raise Import::ImportInProgressError if Import::is_import_running? raise Import::ImportInProgressError if Import::is_import_running?

View File

@ -10,7 +10,7 @@ module Jobs
class Importer < Jobs::Base class Importer < Jobs::Base
sidekiq_options :retry => false sidekiq_options retry: false
BACKUP_SCHEMA = 'backup' BACKUP_SCHEMA = 'backup'

View File

@ -52,7 +52,7 @@ class PostCreator
if @opts[:archetype] == Archetype.private_message if @opts[:archetype] == Archetype.private_message
usernames = @opts[:target_usernames].split(',') 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) unless guardian.can_send_private_message?(u)
topic.errors.add(:archetype, :cant_send_pm) topic.errors.add(:archetype, :cant_send_pm)

View File

@ -5,14 +5,14 @@ module PrettyText
def self.whitelist def self.whitelist
{ {
:elements => %w[ elements: %w[
a abbr aside b bdo blockquote br caption cite code col colgroup dd div del dfn dl 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 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 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 tfoot th thead time tr u ul var wbr
], ],
:attributes => { attributes: {
:all => ['dir', 'lang', 'title', 'class'], :all => ['dir', 'lang', 'title', 'class'],
'aside' => ['data-post', 'data-full', 'data-topic'], 'aside' => ['data-post', 'data-full', 'data-topic'],
'a' => ['href'], 'a' => ['href'],
@ -32,7 +32,7 @@ module PrettyText
'ul' => ['type'] 'ul' => ['type']
}, },
:protocols => { protocols: {
'a' => {'href' => ['ftp', 'http', 'https', 'mailto', :relative]}, 'a' => {'href' => ['ftp', 'http', 'https', 'mailto', :relative]},
'blockquote' => {'cite' => ['http', 'https', :relative]}, 'blockquote' => {'cite' => ['http', 'https', :relative]},
'del' => {'cite' => ['http', 'https', :relative]}, 'del' => {'cite' => ['http', 'https', :relative]},

View File

@ -133,13 +133,13 @@ module SiteSettingExtension
def remove_override!(name) def remove_override!(name)
return unless table_exists? return unless table_exists?
SiteSetting.where(:name => name).destroy_all SiteSetting.where(name: name).destroy_all
end end
def add_override!(name,val) def add_override!(name,val)
return unless table_exists? return unless table_exists?
setting = SiteSetting.where(:name => name).first setting = SiteSetting.where(name: name).first
type = get_data_type(defaults[name]) type = get_data_type(defaults[name])
if type == types[:bool] && val != true && val != false if type == types[:bool] && val != true && val != false
@ -159,7 +159,7 @@ module SiteSettingExtension
setting.data_type = type setting.data_type = type
setting.save setting.save
else else
SiteSetting.create!(:name => name, :value => val, :data_type => type) SiteSetting.create!(name: name, value: val, data_type: type)
end end
MessageBus.publish('/site_settings', {process: process_id}) MessageBus.publish('/site_settings', {process: process_id})

View File

@ -196,7 +196,7 @@ class TopicQuery
end end
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 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.where('categories.name = ?', query_opts[:only_category]) if query_opts[:only_category]
result = result.limit(page_size) unless query_opts[:limit] == false result = result.limit(page_size) unless query_opts[:limit] == false

View File

@ -43,7 +43,7 @@ EXPECTED
before do before do
@topic = Fabricate(:topic) @topic = Fabricate(:topic)
@post = Fabricate.build(:post_with_image_url, topic: @topic, user: @topic.user) @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]) @cpp.expects(:get_size).returns([111,222])
end end

View File

@ -374,11 +374,11 @@ describe Guardian do
it "isn't allowed if the user voted and the topic doesn't allow multiple votes" 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) 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 end
it "is allowed if the user voted and the topic doesn't allow multiple votes" do 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
end end

View File

@ -7,7 +7,7 @@ require 'oneboxer/amazon_onebox'
describe Oneboxer::AmazonOnebox do describe Oneboxer::AmazonOnebox do
before(:each) do before(:each) do
@o = Oneboxer::AmazonOnebox.new("http://www.amazon.com/Ruby-Programming-Language-David-Flanagan/dp/0596516177") @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 end
it "translates the URL" do it "translates the URL" do

View File

@ -7,7 +7,7 @@ require 'oneboxer/android_app_store_onebox'
describe Oneboxer::AndroidAppStoreOnebox do describe Oneboxer::AndroidAppStoreOnebox do
before(:each) do before(:each) do
@o = Oneboxer::AndroidAppStoreOnebox.new("https://play.google.com/store/apps/details?id=com.moosoft.parrot") @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 end
it "generates the expected onebox for Android App Store" do it "generates the expected onebox for Android App Store" do

View File

@ -7,7 +7,7 @@ require 'oneboxer/apple_app_onebox'
describe Oneboxer::AppleAppOnebox do describe Oneboxer::AppleAppOnebox do
before(:each) do before(:each) do
@o = Oneboxer::AppleAppOnebox.new("https://itunes.apple.com/us/app/minecraft-pocket-edition-lite/id479651754") @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 end
it "generates the expected onebox for Apple app" do it "generates the expected onebox for Apple app" do

View File

@ -7,7 +7,7 @@ require 'oneboxer/flickr_onebox'
describe Oneboxer::FlickrOnebox do describe Oneboxer::FlickrOnebox do
before(:each) do before(:each) do
@o = Oneboxer::FlickrOnebox.new("http://www.flickr.com/photos/jaimeiniesta/3303881265") @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 end
it "generates the expected onebox for Flickr" do it "generates the expected onebox for Flickr" do

View File

@ -8,8 +8,8 @@ describe Oneboxer::WikipediaOnebox do
it "generates the expected onebox for Wikipedia" do it "generates the expected onebox for Wikipedia" do
o = Oneboxer::WikipediaOnebox.new('http://en.wikipedia.org/wiki/Ruby') 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, 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, 'http://en.m.wikipedia.org/wiki/Ruby', response: fixture_file('oneboxer/wikipedia_redirected.response'))
o.onebox.should == expected_wikipedia_result o.onebox.should == expected_wikipedia_result
end end

View File

@ -5,7 +5,7 @@ describe ListController do
# we need some data # we need some data
before do before do
@user = Fabricate(:coding_horror) @user = Fabricate(:coding_horror)
@post = Fabricate(:post, :user => @user) @post = Fabricate(:post, user: @user)
end end
context 'index' do context 'index' do

View File

@ -5,7 +5,7 @@ describe StaticController do
context "with a static file that's present" do context "with a static file that's present" do
before do before do
xhr :get, :show, :id => 'faq' xhr :get, :show, id: 'faq'
end end
it 'renders the static file if present' do it 'renders the static file if present' do
@ -19,7 +19,7 @@ describe StaticController do
context "with a missing file" do context "with a missing file" do
it "should respond 404" 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 response.response_code.should == 404
end end
end end

View File

@ -276,12 +276,12 @@ describe UsersController do
context 'when creating a non active user (unconfirmed email)' do context 'when creating a non active user (unconfirmed email)' do
it 'should enqueue a signup email' do it 'should enqueue a signup email' do
Jobs.expects(:enqueue).with(:user_email, has_entries(type: :signup)) 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 end
it "doesn't send a welcome email" do it "doesn't send a welcome email" do
User.any_instance.expects(:enqueue_welcome_message).with('welcome_user').never 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
end end
@ -293,25 +293,25 @@ describe UsersController do
it 'should enqueue a signup email' do it 'should enqueue a signup email' do
User.any_instance.expects(:enqueue_welcome_message).with('welcome_user') 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 end
it "should be logged in" do it "should be logged in" do
User.any_instance.expects(:enqueue_welcome_message) 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 session[:current_user_id].should be_present
end end
it "returns true in the active part of the JSON" do it "returns true in the active part of the JSON" do
User.any_instance.expects(:enqueue_welcome_message) 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 ::JSON.parse(response.body)['active'].should == true
end end
context 'when approving of users is required' do context 'when approving of users is required' do
before do before do
SiteSetting.expects(:must_approve_users).returns(true) 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 end
it "doesn't log in the user" do it "doesn't log in the user" do
@ -328,7 +328,7 @@ describe UsersController do
context 'after success' do context 'after success' do
before 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 end
it 'should succeed' do it 'should succeed' do
@ -368,7 +368,7 @@ describe UsersController do
before do before do
UsersController.any_instance.stubs(:honeypot_value).returns('abc') UsersController.any_instance.stubs(:honeypot_value).returns('abc')
end 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' it_should_behave_like 'honeypot fails'
end end
@ -376,7 +376,7 @@ describe UsersController do
before do before do
UsersController.any_instance.stubs(:challenge_value).returns('abc') UsersController.any_instance.stubs(:challenge_value).returns('abc')
end 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' it_should_behave_like 'honeypot fails'
end end
@ -393,12 +393,12 @@ describe UsersController do
end end
context 'when password is blank' do 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' it_should_behave_like 'failed signup'
end end
context 'when password param is missing' do 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' it_should_behave_like 'failed signup'
end end
@ -406,7 +406,7 @@ describe UsersController do
before do before do
User.any_instance.stubs(:save).raises(ActiveRecord::StatementInvalid) User.any_instance.stubs(:save).raises(ActiveRecord::StatementInvalid)
end 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' it_should_behave_like 'failed signup'
end end
end end

View File

@ -18,7 +18,7 @@ describe ErrorLog do
end end
def request def request
ActionController::TestRequest.new(:host => 'test') ActionController::TestRequest.new(host: 'test')
end end
describe "add_row!" do describe "add_row!" do

View File

@ -72,7 +72,7 @@ describe Notification do
describe 'private message' do describe 'private message' do
before do before do
@topic = Fabricate(:private_message_topic) @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 @target = @post.topic.topic_allowed_users.reject{|a| a.user_id == @post.user_id}[0].user
end end

View File

@ -823,7 +823,7 @@ describe Topic do
end end
describe 'meta data' do 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 it 'allows us to create a topic with meta data' do
topic.meta_data['hello'].should == 'world' topic.meta_data['hello'].should == 'world'

View File

@ -24,7 +24,7 @@ describe TopicUser do
describe "unpinned" do describe "unpinned" do
before do before do
TopicUser.change(user, topic, {:starred_at => yesterday}) TopicUser.change(user, topic, {starred_at: yesterday})
end end
it "defaults to blank" do 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 it 'should be set to tracking if auto_track_topics is enabled' do
user.update_column(:auto_track_topics_after_msecs, 0) 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] TopicUser.get(topic, user).notification_level.should == TopicUser.notification_levels[:tracking]
end end
it 'should reset regular topics to tracking topics if auto track is changed' do 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.auto_track_topics_after_msecs = 0
user.save user.save
topic_user.notification_level.should == TopicUser.notification_levels[:tracking] topic_user.notification_level.should == TopicUser.notification_levels[:tracking]
end end
it 'should be set to "regular" notifications, by default on non creators' do 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] TopicUser.get(topic,user).notification_level.should == TopicUser.notification_levels[:regular]
end end

View File

@ -2,7 +2,7 @@ require "spec_helper"
describe "users/omniauth_callbacks/complete.html.erb" do describe "users/omniauth_callbacks/complete.html.erb" do
it "renders facebook data " 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 render
@ -14,7 +14,7 @@ describe "users/omniauth_callbacks/complete.html.erb" do
end end
it "renders twitter data " do 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 render
@ -27,7 +27,7 @@ describe "users/omniauth_callbacks/complete.html.erb" do
it "renders openid data " 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 render
@ -39,7 +39,7 @@ describe "users/omniauth_callbacks/complete.html.erb" do
end end
it "renders github data " do 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 render

View File

@ -198,8 +198,8 @@ module ActiveSupport
# #
# To instrument an event you just need to do: # To instrument an event you just need to do:
# #
# ActiveSupport::Notifications.instrument("render", :extra => :information) do # ActiveSupport::Notifications.instrument("render", extra: :information) do
# render :text => "Foo" # render text: "Foo"
# end # end
# #
# That executes the block first and notifies all subscribers once done. # 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. # That code returns right away, you are just subscribing to "render" events.
# The block will be called asynchronously whenever someone instruments "render": # The block will be called asynchronously whenever someone instruments "render":
# #
# ActiveSupport::Notifications.instrument("render", :extra => :information) do # ActiveSupport::Notifications.instrument("render", extra: :information) do
# render :text => "Foo" # render text: "Foo"
# end # end
# #
# event = events.first # event = events.first
# event.name # => "render" # event.name # => "render"
# event.duration # => 10 (in milliseconds) # event.duration # => 10 (in milliseconds)
# event.payload # => { :extra => :information } # event.payload # => { extra: :information }
# #
# The block in the <tt>subscribe</tt> call gets the name of the event, start # The block in the <tt>subscribe</tt> call gets the name of the event, start
# timestamp, end timestamp, a string with a unique identifier for that event # timestamp, end timestamp, a string with a unique identifier for that event