<%if flash[:error]%>
- <%=flash[:error]%>
+ <%=flash[:error]%>
<%end%>
<% if @user.present? and @user.errors.any? %>
@@ -14,7 +14,7 @@
<%if flash[:success]%>
- <%=flash[:success]%>
+ <%=flash[:success]%>
<%- if @requires_approval %>
@@ -22,8 +22,8 @@
<% else %>
<%= raw t 'activation.please_continue', link: link_to(SiteSetting.title, root_path) %>
<% end %>
-
-
+
+
<% else %>
<%if @user.present? %>
diff --git a/chef/cookbooks/apt/templates/default/acng.conf.erb b/chef/cookbooks/apt/templates/default/acng.conf.erb
index 869fdfd4e..a98de8542 100644
--- a/chef/cookbooks/apt/templates/default/acng.conf.erb
+++ b/chef/cookbooks/apt/templates/default/acng.conf.erb
@@ -101,13 +101,13 @@ ExTreshold: 4
# Experimental feature for apt-listbugs: pass-through SOAP requests and
# responses to/from bugs.debian.org. If not set, default is true if
# ForceManaged is enabled and false otherwise.
-# ForwardBtsSoap: 1
+# ForwardBtsSoap: 1
# The daemon has a small cache for DNS data, to speed up resolution. The
# expiration time of the DNS entries can be configured in seconds.
# DnsCacheSeconds: 3600
-# Don't touch the following values without good consideration!
+# Don't touch the following values without good consideration!
#
# Max. count of connection threads kept ready (for faster response in the
# future). Should be a sane value between 0 and average number of connections,
@@ -196,7 +196,7 @@ ExTreshold: 4
#
#
# It's possible to use use apt-cacher-ng as a regular web server with limited
-# feature set, i.e.
+# feature set, i.e.
# including directory browsing and download of any file;
# excluding sorting, mime types/encodings, CGI execution, index page
# redirection and other funny things.
@@ -213,13 +213,13 @@ ExTreshold: 4
# Precache a set of files referenced by specified index files. This can be used
# to create a partial mirror usable for offline work. There are certain limits
# and restrictions on the path specification, see manual for details. A list of
-# (maybe) relevant index files could be retrieved via
+# (maybe) relevant index files could be retrieved via
# "apt-get --print-uris update" on a client machine.
#
# PrecacheFor: debrep/dists/unstable/*/source/Sources* debrep/dists/unstable/*/binary-amd64/Packages*
# Arbitrary set of data to append to request headers sent over the wire. Should
-# be a well formated HTTP headers part including newlines (DOS style) which
+# be a well formated HTTP headers part including newlines (DOS style) which
# can be entered as escape sequences (\r\n).
# RequestAppendix: X-Tracking-Choice: do-not-track\r\n
@@ -273,4 +273,4 @@ ExTreshold: 4
# follow per request, 0 disables the internal redirection. If not set,
# default value is 0 if ForceManaged is used and 5 otherwise.
#
-# RedirMax: 5
\ No newline at end of file
+# RedirMax: 5
diff --git a/chef/cookbooks/discourse/files/default/redis.yml b/chef/cookbooks/discourse/files/default/redis.yml
index 68d138b5f..213d48f28 100644
--- a/chef/cookbooks/discourse/files/default/redis.yml
+++ b/chef/cookbooks/discourse/files/default/redis.yml
@@ -8,7 +8,7 @@ development:
<<: *defaults
test:
- <<: *defaults
+ <<: *defaults
db: 1
staging:
diff --git a/chef/cookbooks/omnibus_updater/recipes/set_remote_path.rb b/chef/cookbooks/omnibus_updater/recipes/set_remote_path.rb
index d5410cc31..64d737011 100644
--- a/chef/cookbooks/omnibus_updater/recipes/set_remote_path.rb
+++ b/chef/cookbooks/omnibus_updater/recipes/set_remote_path.rb
@@ -84,7 +84,7 @@ when 'deb'
if(pkgs_avail)
path_name = pkgs_avail.find_all{ |path|
ver = node[:omnibus_updater][:version] || '.'
- path.include?('.deb') && path.include?(platform_name) &&
+ path.include?('.deb') && path.include?(platform_name) &&
path.include?(platform_version) && path.include?(node.kernel.machine) &&
path.include?(ver)
}.sort.last
@@ -104,7 +104,7 @@ when 'rpm'
if(pkgs_avail)
path_name = pkgs_avail.find_all{ |path|
ver = node[:omnibus_updater][:version] || '.'
- path.include?('.rpm') && path.include?(platform_name) &&
+ path.include?('.rpm') && path.include?(platform_name) &&
path.include?(platform_version) && path.include?(node.kernel.machine) &&
path.include?(ver)
}.sort.last
diff --git a/config/application.rb b/config/application.rb
index d5991c4df..a0b25472f 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -30,15 +30,15 @@ module Discourse
config.assets.paths += %W(#{config.root}/config/locales)
config.assets.precompile += [
- 'admin.js', 'admin.css', 'shiny/shiny.css', 'preload_store.js',
+ 'admin.js', 'admin.css', 'shiny/shiny.css', 'preload_store.js',
'jquery.js', 'defer/html-sanitizer-bundle.js', 'defer/fastclick.js'
]
# Activate observers that should always be running.
config.active_record.observers = [
:user_email_observer,
- :user_action_observer,
- :message_bus_observer,
+ :user_action_observer,
+ :message_bus_observer,
:post_alert_observer,
:search_observer
]
@@ -66,10 +66,10 @@ module Discourse
# We need to be able to spin threads
config.active_record.thread_safe!
- # see: http://stackoverflow.com/questions/11894180/how-does-one-correctly-add-custom-sql-dml-in-migrations/11894420#11894420
+ # see: http://stackoverflow.com/questions/11894180/how-does-one-correctly-add-custom-sql-dml-in-migrations/11894420#11894420
config.active_record.schema_format = :sql
- # per https://www.owasp.org/index.php/Password_Storage_Cheat_Sheet
+ # per https://www.owasp.org/index.php/Password_Storage_Cheat_Sheet
config.pbkdf2_iterations = 64000
# dumping rack lock cause the message bus does not work with it (throw :async, it catches Exception)
@@ -93,7 +93,7 @@ module Discourse
config.action_dispatch.rack_cache = nil
# So open id logs somewhere sane
- config.after_initialize do
+ config.after_initialize do
OpenID::Util.logger = Rails.logger
end
end
diff --git a/config/clock.rb b/config/clock.rb
index 0b8ea7ff6..edb6078ec 100644
--- a/config/clock.rb
+++ b/config/clock.rb
@@ -2,7 +2,7 @@ require 'clockwork'
require_relative 'boot'
require_relative 'environment'
-# These are jobs you should run on a regular basis to make your
+# These are jobs you should run on a regular basis to make your
# forum work properly.
module Clockwork
diff --git a/config/environments/development.rb b/config/environments/development.rb
index c6e00d428..9fd57f9eb 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -26,15 +26,15 @@ Discourse::Application.configure do
config.assets.debug = true
config.watchable_dirs['lib'] = [:rb]
-
+
config.sass.debug_info = false
config.ember.variant = :development
config.ember.handlebars_location = "#{Rails.root}/app/assets/javascripts/external/handlebars-1.0.rc.3.js"
config.ember.ember_location = "#{Rails.root}/app/assets/javascripts/external/ember.js"
config.handlebars.precompile = false
-
+
# a bit hacky but works
- config.after_initialize do
+ config.after_initialize do
config.middleware.delete Airbrake::UserInformer
config.middleware.delete Airbrake::Rack
end
diff --git a/config/environments/production.rb b/config/environments/production.rb
index e04cbb2ae..2af04cf03 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -16,7 +16,7 @@ Discourse::Application.configure do
# stuff should be pre-compiled
config.assets.compile = false
-
+
# Generate digests for assets URLs
config.assets.digest = true
diff --git a/config/environments/test.rb b/config/environments/test.rb
index 6aeabe65e..81f1e7f4b 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -38,7 +38,7 @@ Discourse::Application.configure do
# Print deprecation notices to the stderr
config.active_support.deprecation = :stderr
-
+
# lower iteration count for test
config.pbkdf2_iterations = 10
config.ember.variant = :development
diff --git a/config/initializers/message_bus.rb b/config/initializers/message_bus.rb
index ad12cf1c7..d63b36a59 100644
--- a/config/initializers/message_bus.rb
+++ b/config/initializers/message_bus.rb
@@ -1,4 +1,4 @@
-MessageBus.site_id_lookup do
+MessageBus.site_id_lookup do
RailsMultisite::ConnectionManagement.current_db
end
@@ -21,7 +21,7 @@ MessageBus.redis_config = YAML::load(File.open("#{Rails.root}/config/redis.yml")
MessageBus.long_polling_enabled = SiteSetting.enable_long_polling
MessageBus.long_polling_interval = SiteSetting.long_polling_interval
-MessageBus.is_admin_lookup do |env|
+MessageBus.is_admin_lookup do |env|
user = CurrentUser.lookup_from_env(env)
if user && user.admin
true
diff --git a/config/initializers/mini_profiler.rb b/config/initializers/mini_profiler.rb
index 1a1b19151..69346a850 100644
--- a/config/initializers/mini_profiler.rb
+++ b/config/initializers/mini_profiler.rb
@@ -5,14 +5,14 @@ if defined?(Rack::MiniProfiler)
Rack::MiniProfiler.config.storage = Rack::MiniProfiler::RedisStore
# 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|
(env['HTTP_USER_AGENT'] !~ /iPad|iPhone|Nexus 7/) and
(env['PATH_INFO'] !~ /^\/message-bus/) and
(env['PATH_INFO'] !~ /topics\/timings/) and
(env['PATH_INFO'] !~ /assets/) and
(env['PATH_INFO'] !~ /jasmine/) and
(env['PATH_INFO'] !~ /users\/.*\/avatar/) and
- (env['PATH_INFO'] !~ /srv\/status/)
+ (env['PATH_INFO'] !~ /srv\/status/)
end
Rack::MiniProfiler.config.position = 'left'
@@ -24,8 +24,8 @@ if defined?(Rack::MiniProfiler)
# require "#{Rails.root}/vendor/backports/notification"
- inst = Class.new
- class << inst
+ inst = Class.new
+ class << inst
def start(name,id,payload)
if Rack::MiniProfiler.current and name !~ /(process_action.action_controller)|(render_template.action_view)/
@prf ||= {}
diff --git a/config/initializers/quiet_logger.rb b/config/initializers/quiet_logger.rb
index 8025fcb52..ab4295f4b 100644
--- a/config/initializers/quiet_logger.rb
+++ b/config/initializers/quiet_logger.rb
@@ -4,7 +4,7 @@ Rails::Rack::Logger.class_eval do
previous_level = Rails.logger.level
if (env['PATH_INFO'].index("/assets/") == 0) or
(env['PATH_INFO'].index("mini-profiler-resources") == 0)
- Rails.logger.level = Logger::ERROR
+ Rails.logger.level = Logger::ERROR
end
call_without_quiet_assets(env).tap do
@@ -12,4 +12,4 @@ Rails::Rack::Logger.class_eval do
end
end
alias_method_chain :call, :quiet_assets
-end
\ No newline at end of file
+end
diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb
index 3d3d9a6c7..857e80e30 100644
--- a/config/initializers/secret_token.rb
+++ b/config/initializers/secret_token.rb
@@ -1,18 +1,18 @@
# Definitely change this when you deploy to production. Ours is replaced by jenkins.
# This token is used to secure sessions, we don't mind shipping with one to ease test and debug,
-# however, the stock one should never be used in production, people will be able to crack
-# session cookies.
+# however, the stock one should never be used in production, people will be able to crack
+# session cookies.
#
# Generate a new secret with "rake secret". Copy the output of that command and paste it
# in your secret_token.rb as the value of Discourse::Application.config.secret_token:
#
-# Discourse::Application.config.secret_token = "SET_SECRET_HERE"
+# Discourse::Application.config.secret_token = "SET_SECRET_HERE"
# delete all lines below in production
-if Rails.env.test? || Rails.env.development?
- Discourse::Application.config.secret_token = "47f5390004bf6d25bb97083fb98e7cc133ab450ba814dd19638a78282b4ca291"
-else
+if Rails.env.test? || Rails.env.development?
+ Discourse::Application.config.secret_token = "47f5390004bf6d25bb97083fb98e7cc133ab450ba814dd19638a78282b4ca291"
+else
raise "You must set a secret token in config/initializers/secret_token.rb"
end
diff --git a/config/initializers/silence_logger.rb b/config/initializers/silence_logger.rb
index 76c156725..95e8d8b48 100644
--- a/config/initializers/silence_logger.rb
+++ b/config/initializers/silence_logger.rb
@@ -3,8 +3,8 @@ class SilenceLogger < Rails::Rack::Logger
@app = app
@opts = opts
@opts[:silenced] ||= []
-
- # Rails introduces something called taggers in the Logger, needs to be initialized
+
+ # Rails introduces something called taggers in the Logger, needs to be initialized
super(app)
end
diff --git a/config/initializers/site_settings.rb b/config/initializers/site_settings.rb
index f41eea89e..b7868d861 100644
--- a/config/initializers/site_settings.rb
+++ b/config/initializers/site_settings.rb
@@ -1,5 +1,3 @@
-
-
-RailsMultisite::ConnectionManagement.each_connection do
+RailsMultisite::ConnectionManagement.each_connection do
SiteSetting.refresh!
end
diff --git a/config/initializers/watch_for_restart.rb b/config/initializers/watch_for_restart.rb
index e1fb4403e..04a1db64d 100644
--- a/config/initializers/watch_for_restart.rb
+++ b/config/initializers/watch_for_restart.rb
@@ -1,4 +1,4 @@
-# this is a trivial graceful restart on touch of tmp/restart.
+# this is a trivial graceful restart on touch of tmp/restart.
#
# It simply drains all the requests (waits up to 4 seconds) and issues a HUP
# if you need a more sophisticated cycling restart for multiple thins it will need to be written
@@ -6,13 +6,13 @@
# This works fine for Discourse.org cause we host our app accross multiple machines, if you hosting
# on a single machine you have a trickier problem at hand as you need to cycle the processes in order
-Thread.new do
+Thread.new do
file = "#{Rails.root}/tmp/restart"
old_time = File.ctime(file).to_i if File.exists? file
wait_seconds = 4
return if $PROGRAM_NAME !~ /thin/
-
+
while true
time = File.ctime(file).to_i if File.exists? file
@@ -20,8 +20,8 @@ Thread.new do
Rails.logger.info "attempting to reload #{$$} #{$PROGRAM_NAME} in #{wait_seconds} seconds"
$shutdown = true
sleep wait_seconds
- Rails.logger.info "restarting #{$$}"
- Process.kill("HUP", $$)
+ Rails.logger.info "restarting #{$$}"
+ Process.kill("HUP", $$)
return
end
diff --git a/config/locales/client.nl.yml b/config/locales/client.nl.yml
index d732ec1c7..957e3c1de 100644
--- a/config/locales/client.nl.yml
+++ b/config/locales/client.nl.yml
@@ -1,7 +1,7 @@
----
-nl:
+---
+nl:
js: ~
-share:
+share:
? "0"
: "Je negeert alle notificaties in dit topic."
? "0_2"
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 060124f7d..94e205216 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -350,7 +350,7 @@ en:
body_min_entropy: "The minimum allowed entropy for post body"
new_user_period_days: "How long a user is highlighted as being new, in days"
title_fancy_entities: "Convert fancy HTML entities in topic titles"
-
+
notification_types:
mentioned: "%{display_username} mentioned you in %{link}"
liked: "%{display_username} liked your post in %{link}"
diff --git a/config/locales/server.nl.yml b/config/locales/server.nl.yml
index de39b4005..d2a131343 100644
--- a/config/locales/server.nl.yml
+++ b/config/locales/server.nl.yml
@@ -66,7 +66,7 @@ nl:
trust_levels:
new:
title: "nieuwe gebruiker"
- basic:
+ basic:
title: "basisgebruiker"
regular:
title: "gemiddelde gebruiker"
@@ -91,7 +91,7 @@ nl:
datetime:
distance_in_words:
- half_a_minute: "< 1m"
+ half_a_minute: "< 1m"
less_than_x_seconds:
one: "< 1s"
other: "< %{count}s"
@@ -127,7 +127,7 @@ nl:
other: "%{count}j"
distance_in_words_verbose:
- half_a_minute: "een halve minuut geleden"
+ half_a_minute: "een halve minuut geleden"
less_than_x_seconds:
one: "nu"
other: "nu"
@@ -182,7 +182,7 @@ nl:
approval_required: "Een moderator moet je nieuwe account handmatig goedkeuren voordat je toegang krijgt tot dit forum. Je krijgt een e-mail van ons wanneer je account is goedgekeurd!"
post_action_types:
-
+
off_topic:
title: 'Off-Topic'
description: 'Deze post wijkt erg af van het onderwerp van deze discussie, en moet wellicht naar een ander topic worden verplaatst.'
@@ -213,7 +213,7 @@ nl:
user_must_edit: '
Gemelde inhoud verborgen.
'
archetypes:
- regular:
+ regular:
title: "Standaard-topic"
unsubscribed:
@@ -346,7 +346,7 @@ nl:
new_user_period_days: "Hoe lang een gebruiker als nieuw wordt aangetoond, in dagen."
-
+
notification_types:
mentioned: "%{display_username} heeft je genoemd in %{link}"
@@ -362,13 +362,13 @@ nl:
# This section is exported to the javascript for i18n
js:
-
+
search:
types:
category: 'Categorieën'
topic: 'Topics'
- user: 'Gebruikers'
+ user: 'Gebruikers'
youve_posted: "Jij Hebt Dit Gepost"
original_poster: "Originele Poster"
@@ -402,7 +402,7 @@ nl:
edited: "bewerkte"
move_posts:
- moderator_post:
+ moderator_post:
one: "Ik heb een post naar een nieuw topic verplaatst: %{topic_link}"
other: "Ik heb %{count} posts naar een nieuw topic verplaatst: %{topic_link}"
@@ -416,7 +416,7 @@ nl:
visible_enabled: "Dit topic is nu zichtbaar; het zal weer worden weergegeven in topiclijsten."
visible_disabled: "Dit topic is nu onzichtbaar; het zal niet worden weergegeven in topiclijsten, en kan alleen via een directe link worden bezocht."
- login:
+ login:
not_approved: "Je account is nog niet goedgekeurd. Je zal via de mail een bericht van ons ontvangen wanneer je klaar bent om in te kunnen loggen."
incorrect_username_email_or_password: "Incorrecte gebruikersnaam, e-mailadres of wachtwoord"
wait_approval: "Bedankt voor je inschrijving. We zullen het je laten weten als je account is goedgekeurd."
@@ -503,7 +503,7 @@ nl:
subject_template: "Bericht van %{site_name}: Je Post is verborgen wegens meldingen uit de site-gemeenschap"
text_body_template: |
Hallo,
-
+
Dit is een geautomatiseerd bericht van %{site_name} om je te laten weten dat de volgende post is verborgen naar aanleiding van meldingen binnen de site-gemeenschap.
%{base_url}%{url}
@@ -515,7 +515,7 @@ nl:
Je kan je post bewerken na %{edit_delay} minuten, en het zal automatisch weer zichtbaar worden. Dit verhoogt je forum vertrouwensniveau.
- Echter, als de post een tweede keer wordt verborgen door de site-gemeenschap, wordt er een moderator ingelicht.
+ Echter, als de post een tweede keer wordt verborgen door de site-gemeenschap, wordt er een moderator ingelicht.
Zij kunnen verdere actie ondernemen, waaronder een mogelijke schorsing van je account.
@@ -560,9 +560,9 @@ nl:
- Om terug te gaan naar de homepage, kan je op elk moment **op het icoontje in de linker bovenhoek klikken.**
- - Mocht je iets willen opzoeken, naar je gebruikerspagina gaan, of ergens anders toe willen navigeren, klik dan op de icoontjes in de rechter bovenhoek.
- - Wanneer je een topic leest, kan je naar boven scrollen door op de topic-titel bovenaan de pagina te klikken.
- Om de *onderkant* te bereiken, klik op de pijl naar beneden op de topic voortgangsindicator aan de onderkant van de pagina,
+ - Mocht je iets willen opzoeken, naar je gebruikerspagina gaan, of ergens anders toe willen navigeren, klik dan op de icoontjes in de rechter bovenhoek.
+ - Wanneer je een topic leest, kan je naar boven scrollen door op de topic-titel bovenaan de pagina te klikken.
+ Om de *onderkant* te bereiken, klik op de pijl naar beneden op de topic voortgangsindicator aan de onderkant van de pagina,
of klik je op het Laatste Post-veld in de topic-samenvatting onder de eerste post.
welcome_approved:
@@ -600,7 +600,7 @@ nl:
Om nogmaals in te loggen kan je het volgende gebruiken:
- 1. Facebook, Google, Twitter, of vele andere ondersteunde logingegevens
+ 1. Facebook, Google, Twitter, of vele andere ondersteunde logingegevens
-- let er wel op dat dit **het zelfde e-mailadres** is waarop je je originele uitnodiging hebt gekregen. Anders weten we niet zeker dat jij het bent!
2. Maak een uniek wachtwoord voor %{site_name} aan binnen [je gebruikersprofiel][prefs], en log daarmee in.
@@ -626,7 +626,7 @@ nl:
unsubscribe_link: "Mocht je deze e-mails niet langer willen ontvangen, bezoek dan [je gebruikersinstellingen](%{user_preferences_url})."
user_notifications:
- unsubscribe:
+ unsubscribe:
title: "Uitschrijven"
description: "Niet geïnteresseerd in deze e-mails? Geen probleem! Klik hieronder om direct uitgeschreven te worden:"
@@ -645,7 +645,7 @@ nl:
---
%{message}
- ---
+ ---
Bezoek deze link om te reageren: %{base_url}%{url}
user_quoted:
@@ -656,7 +656,7 @@ nl:
---
%{message}
- ---
+ ---
Bezoek deze link om te reageren: %{base_url}%{url}
user_mentioned:
@@ -667,7 +667,7 @@ nl:
---
%{message}
- ---
+ ---
Bezoek deze link om te reageren: %{base_url}%{url}
@@ -693,9 +693,9 @@ nl:
subject_template: "[%{site_name}] Wachtwoord herstellen"
text_body_template: |
Iemand heeft aangegeven je wachtwoord te willen herstellen op [%{site_name}](%{base_url}).
-
- Ben jij dit niet, kan je zonder problemen deze e-mail negeren.
-
+
+ Ben jij dit niet, kan je zonder problemen deze e-mail negeren.
+
Klik op de volgende link om een nieuw wachtwoord te kiezen:
%{base_url}/users/password-reset/%{email_token}
@@ -703,14 +703,14 @@ nl:
subject_template: "[%{site_name}] Bevestig je nieuwe e-mailadres"
text_body_template: |
Bevestig je nieuwe e-mailadres voor %{site_name} door op de volgende link te klikken:
-
+
%{base_url}/users/authorize-email/%{email_token}
signup:
subject_template: "[%{site_name}] Activeer je nieuwe account"
text_body_template: |
Welkom op %{site_name}!
-
+
Klik op de volgende link om je nieuwe account te bevestigen en te activeren:
%{base_url}/users/activate-account/%{email_token}
diff --git a/db/migrate/20120311163914_create_forum_threads.rb b/db/migrate/20120311163914_create_forum_threads.rb
index 43ff07f39..286791581 100644
--- a/db/migrate/20120311163914_create_forum_threads.rb
+++ b/db/migrate/20120311163914_create_forum_threads.rb
@@ -1,6 +1,6 @@
class CreateForumThreads < ActiveRecord::Migration
def change
- create_table :forum_threads do |t|
+ create_table :forum_threads do |t|
t.integer :forum_id, null: false
t.string :title, null: false
t.integer :last_post_id
diff --git a/db/migrate/20120311164326_create_posts.rb b/db/migrate/20120311164326_create_posts.rb
index 9529d01de..41108b2bd 100644
--- a/db/migrate/20120311164326_create_posts.rb
+++ b/db/migrate/20120311164326_create_posts.rb
@@ -5,7 +5,7 @@ class CreatePosts < ActiveRecord::Migration
t.integer :forum_thread_id, null: false
t.integer :post_number, null: false
t.text :content, null: false
- t.text :formatted_content, null: false
+ t.text :formatted_content, null: false
t.timestamps
end
diff --git a/db/migrate/20120311201341_create_forums.rb b/db/migrate/20120311201341_create_forums.rb
index 4148a0694..748c6f6ee 100644
--- a/db/migrate/20120311201341_create_forums.rb
+++ b/db/migrate/20120311201341_create_forums.rb
@@ -1,7 +1,7 @@
class CreateForums < ActiveRecord::Migration
def change
- create_table :forums do |t|
- t.integer :site_id, null: false
+ create_table :forums do |t|
+ t.integer :site_id, null: false
t.string :title, limit: 100, null: false
t.timestamps
end
diff --git a/db/migrate/20120502183240_add_created_by_to_forum_threads.rb b/db/migrate/20120502183240_add_created_by_to_forum_threads.rb
index 888fb86f4..b9dd947e9 100644
--- a/db/migrate/20120502183240_add_created_by_to_forum_threads.rb
+++ b/db/migrate/20120502183240_add_created_by_to_forum_threads.rb
@@ -1,10 +1,10 @@
class AddCreatedByToForumThreads < ActiveRecord::Migration
def up
add_column :forum_threads, :user_id, :integer
-
- execute "update forum_threads t
- set user_id = (select user_id from posts where forum_thread_id = t.Id order by post_number asc limit 1)"
-
+
+ execute "update forum_threads t
+ set user_id = (select user_id from posts where forum_thread_id = t.Id order by post_number asc limit 1)"
+
change_column :forum_threads, :user_id, :integer, null: false
end
diff --git a/db/migrate/20120502192121_add_last_post_user_id_to_forum_threads.rb b/db/migrate/20120502192121_add_last_post_user_id_to_forum_threads.rb
index cd9a872bd..9f7daa274 100644
--- a/db/migrate/20120502192121_add_last_post_user_id_to_forum_threads.rb
+++ b/db/migrate/20120502192121_add_last_post_user_id_to_forum_threads.rb
@@ -4,8 +4,8 @@ class AddLastPostUserIdToForumThreads < ActiveRecord::Migration
add_column :forum_threads, :last_post_user_id, :integer
- execute "update forum_threads t
- set last_post_user_id = (select user_id from posts where forum_thread_id = t.Id order by post_number desc limit 1)"
+ execute "update forum_threads t
+ set last_post_user_id = (select user_id from posts where forum_thread_id = t.Id order by post_number desc limit 1)"
change_column :forum_threads, :last_post_user_id, :integer, null: false
end
@@ -13,5 +13,5 @@ class AddLastPostUserIdToForumThreads < ActiveRecord::Migration
def down
remove_column :forum_threads, :last_post_user_id
end
-
+
end
diff --git a/db/migrate/20120503205521_add_site_id_to_users.rb b/db/migrate/20120503205521_add_site_id_to_users.rb
index c6f8eab49..9b1121eee 100644
--- a/db/migrate/20120503205521_add_site_id_to_users.rb
+++ b/db/migrate/20120503205521_add_site_id_to_users.rb
@@ -4,6 +4,6 @@ class AddSiteIdToUsers < ActiveRecord::Migration
add_column :users, :bio, :text
add_index :users, :site_id
- execute "UPDATE users SET site_id = 1"
+ execute "UPDATE users SET site_id = 1"
end
end
diff --git a/db/migrate/20120523180723_create_views.rb b/db/migrate/20120523180723_create_views.rb
index 750c6cb88..68638ef50 100644
--- a/db/migrate/20120523180723_create_views.rb
+++ b/db/migrate/20120523180723_create_views.rb
@@ -5,7 +5,7 @@ class CreateViews < ActiveRecord::Migration
t.string :parent_type, limit: 50, null: false
t.integer :ip, limit: 8, null: false
t.datetime :viewed_at, null: false
- t.integer :user_id, null: true
+ t.integer :user_id, null: true
end
add_index :views, [:parent_id, :parent_type]
diff --git a/db/migrate/20120529202707_create_stars.rb b/db/migrate/20120529202707_create_stars.rb
index 0c885bde4..91c609ac3 100644
--- a/db/migrate/20120529202707_create_stars.rb
+++ b/db/migrate/20120529202707_create_stars.rb
@@ -3,7 +3,7 @@ class CreateStars < ActiveRecord::Migration
create_table :stars, id: false do |t|
t.integer :parent_id, null: false
t.string :parent_type, limit: 50, null: false
- t.integer :user_id, null: true
+ t.integer :user_id, null: true
t.timestamps
end
diff --git a/db/migrate/20120530150726_create_forum_thread_user.rb b/db/migrate/20120530150726_create_forum_thread_user.rb
index dfa16bf7e..98ecd85a8 100644
--- a/db/migrate/20120530150726_create_forum_thread_user.rb
+++ b/db/migrate/20120530150726_create_forum_thread_user.rb
@@ -10,25 +10,25 @@ class CreateForumThreadUser < ActiveRecord::Migration
end
execute "DELETE FROM read_posts"
-
- add_index :forum_thread_users, [:forum_thread_id, :user_id], unique: true
+
+ add_index :forum_thread_users, [:forum_thread_id, :user_id], unique: true
drop_table :stars
drop_table :last_read_posts
end
def down
- drop_table :forum_thread_users
+ drop_table :forum_thread_users
create_table :stars, id: false do |t|
t.integer :parent_id, null: false
t.string :parent_type, limit: 50, null: false
- t.integer :user_id, null: true
+ t.integer :user_id, null: true
t.timestamps
end
- add_index :stars, [:parent_id, :parent_type, :user_id]
-
+ add_index :stars, [:parent_id, :parent_type, :user_id]
+
create_table :last_read_posts do |t|
t.integer :user_id, null: false
t.integer :forum_thread_id, null: false
diff --git a/db/migrate/20120530212912_create_forum_thread_links.rb b/db/migrate/20120530212912_create_forum_thread_links.rb
index 2decb4d76..91cb347a8 100644
--- a/db/migrate/20120530212912_create_forum_thread_links.rb
+++ b/db/migrate/20120530212912_create_forum_thread_links.rb
@@ -4,7 +4,7 @@ class CreateForumThreadLinks < ActiveRecord::Migration
t.integer :forum_thread_id, null: false
t.integer :post_id, null: false
t.integer :user_id, null: false
- t.string :url, limit: 500, null: false
+ t.string :url, limit: 500, null: false
t.string :domain, limit: 100, null: false
t.boolean :internal, null: false, default: false
t.integer :link_forum_thread_id, null: true
diff --git a/db/migrate/20120614202024_add_quote_count_to_posts.rb b/db/migrate/20120614202024_add_quote_count_to_posts.rb
index 5d7c549a3..46994edb6 100644
--- a/db/migrate/20120614202024_add_quote_count_to_posts.rb
+++ b/db/migrate/20120614202024_add_quote_count_to_posts.rb
@@ -8,5 +8,5 @@ class AddQuoteCountToPosts < ActiveRecord::Migration
def down
remove_column :posts, :quote_count
add_column :posts, :quoteless, :boolean, default: false
- end
+ end
end
diff --git a/db/migrate/20120619150807_fix_post_timings.rb b/db/migrate/20120619150807_fix_post_timings.rb
index 90ab38c2d..1d06d8f6d 100644
--- a/db/migrate/20120619150807_fix_post_timings.rb
+++ b/db/migrate/20120619150807_fix_post_timings.rb
@@ -4,11 +4,11 @@ class FixPostTimings < ActiveRecord::Migration
remove_index :post_timings, [:thread_id, :post_number, :user_id]
rename_column :post_timings, :thread_id, :forum_thread_id
add_index :post_timings, [:forum_thread_id, :post_number], name: 'post_timings_summary'
- add_index :post_timings, [:forum_thread_id, :post_number, :user_id], unique: true, name: 'post_timings_unique'
+ add_index :post_timings, [:forum_thread_id, :post_number, :user_id], unique: true, name: 'post_timings_unique'
end
def down
- rename_column :post_timings, :forum_thread_id, :thread_id
+ rename_column :post_timings, :forum_thread_id, :thread_id
end
end
diff --git a/db/migrate/20120619153349_drop_read_posts.rb b/db/migrate/20120619153349_drop_read_posts.rb
index 6902574e7..f23dc488e 100644
--- a/db/migrate/20120619153349_drop_read_posts.rb
+++ b/db/migrate/20120619153349_drop_read_posts.rb
@@ -9,6 +9,6 @@ class DropReadPosts < ActiveRecord::Migration
t.integer :user_id, null: false
t.column :page, :integer, null: false
t.column :seen, :integer, null: false
- end
+ end
end
end
diff --git a/db/migrate/20120625145714_add_seen_notification_id_to_users.rb b/db/migrate/20120625145714_add_seen_notification_id_to_users.rb
index b3aff9c55..920f136d3 100644
--- a/db/migrate/20120625145714_add_seen_notification_id_to_users.rb
+++ b/db/migrate/20120625145714_add_seen_notification_id_to_users.rb
@@ -2,9 +2,9 @@ class AddSeenNotificationIdToUsers < ActiveRecord::Migration
def change
execute "TRUNCATE TABLE notifications"
-
+
add_column :users, :seen_notificaiton_id, :integer, default: 0, null: false
add_column :notifications, :forum_thread_id, :integer, null: true
- add_column :notifications, :post_number, :integer, null: true
+ add_column :notifications, :post_number, :integer, null: true
end
end
diff --git a/db/migrate/20120629143908_rename_expression_type_id.rb b/db/migrate/20120629143908_rename_expression_type_id.rb
index ea5ca93d1..eb19b14a2 100644
--- a/db/migrate/20120629143908_rename_expression_type_id.rb
+++ b/db/migrate/20120629143908_rename_expression_type_id.rb
@@ -5,11 +5,11 @@ class RenameExpressionTypeId < ActiveRecord::Migration
execute "UPDATE expression_types SET expression_index = id"
remove_column :expression_types, :id
- add_index :expression_types, [:site_id, :expression_index], unique: true
+ add_index :expression_types, [:site_id, :expression_index], unique: true
end
def down
- add_column :expression_types, :id, :integer
+ add_column :expression_types, :id, :integer
execute "UPDATE expression_types SET id = expression_index"
remove_column :expression_types, :expression_index
end
diff --git a/db/migrate/20120629182637_create_incoming_links.rb b/db/migrate/20120629182637_create_incoming_links.rb
index 4e0c60a4d..d5215c1ec 100644
--- a/db/migrate/20120629182637_create_incoming_links.rb
+++ b/db/migrate/20120629182637_create_incoming_links.rb
@@ -3,7 +3,7 @@ class CreateIncomingLinks < ActiveRecord::Migration
create_table :incoming_links do |t|
t.integer :site_id, null: false
t.string :url, limit: 1000, null: false
- t.string :referer, limit: 1000, null: false
+ t.string :referer, limit: 1000, null: false
t.string :domain, limit: 100, null: false
t.integer :forum_thread_id, null: true
t.integer :post_number, null: true
diff --git a/db/migrate/20120703210004_add_bookmark_count_to_posts.rb b/db/migrate/20120703210004_add_bookmark_count_to_posts.rb
index 9c8efde22..c9e5cf9b3 100644
--- a/db/migrate/20120703210004_add_bookmark_count_to_posts.rb
+++ b/db/migrate/20120703210004_add_bookmark_count_to_posts.rb
@@ -4,16 +4,16 @@ class AddBookmarkCountToPosts < ActiveRecord::Migration
add_column :forum_threads, :bookmark_count, :integer, default: 0, null: false
add_column :forum_threads, :star_count, :integer, default: 0, null: false
- execute "UPDATE posts SET bookmark_count = (SELECT COUNT(*)
- FROM bookmarks
+ execute "UPDATE posts SET bookmark_count = (SELECT COUNT(*)
+ FROM bookmarks
WHERE post_number = posts.post_number AND forum_thread_id = posts.forum_thread_id)"
- execute "UPDATE forum_threads SET bookmark_count = (SELECT COUNT(*)
- FROM bookmarks
+ execute "UPDATE forum_threads SET bookmark_count = (SELECT COUNT(*)
+ FROM bookmarks
WHERE forum_thread_id = forum_threads.id)"
- execute "UPDATE forum_threads SET star_count = (SELECT COUNT(*)
- FROM forum_thread_users
+ execute "UPDATE forum_threads SET star_count = (SELECT COUNT(*)
+ FROM forum_thread_users
WHERE forum_thread_id = forum_threads.id AND starred = true)"
end
end
diff --git a/db/migrate/20120704201743_add_view_count_to_posts.rb b/db/migrate/20120704201743_add_view_count_to_posts.rb
index 2c4f983dd..9ea94e0be 100644
--- a/db/migrate/20120704201743_add_view_count_to_posts.rb
+++ b/db/migrate/20120704201743_add_view_count_to_posts.rb
@@ -2,7 +2,7 @@ class AddViewCountToPosts < ActiveRecord::Migration
def change
add_column :posts, :views, :integer, default: 0, null: false
- execute "UPDATE posts SET views =
+ execute "UPDATE posts SET views =
(SELECT COUNT(*) FROM post_timings WHERE forum_thread_id = posts.forum_thread_id AND post_number = posts.post_number)"
end
end
diff --git a/db/migrate/20120708210305_add_last_posted_at_to_users.rb b/db/migrate/20120708210305_add_last_posted_at_to_users.rb
index 6e176698b..b41d35569 100644
--- a/db/migrate/20120708210305_add_last_posted_at_to_users.rb
+++ b/db/migrate/20120708210305_add_last_posted_at_to_users.rb
@@ -3,8 +3,8 @@ class AddLastPostedAtToUsers < ActiveRecord::Migration
add_column :users, :last_posted_at, :datetime, null: true
add_index :users, :last_posted_at
- execute "UPDATE users
- SET last_posted_at = (SELECT MAX(posts.created_at)
+ execute "UPDATE users
+ SET last_posted_at = (SELECT MAX(posts.created_at)
FROM posts
WHERE posts.user_id = users.id)"
end
diff --git a/db/migrate/20120712150500_create_categories.rb b/db/migrate/20120712150500_create_categories.rb
index 83431deb7..3cd4ccdd7 100644
--- a/db/migrate/20120712150500_create_categories.rb
+++ b/db/migrate/20120712150500_create_categories.rb
@@ -8,7 +8,7 @@ class CreateCategories < ActiveRecord::Migration
t.integer :top2_forum_thread_id, null: true
t.integer :top1_user_id, null: true
t.integer :top2_user_id, null: true
- t.integer :forum_thread_count, null: false, default: 0
+ t.integer :forum_thread_count, null: false, default: 0
t.timestamps
end
@@ -22,7 +22,7 @@ class CreateCategories < ActiveRecord::Migration
end
def down
- drop_table :categories
+ drop_table :categories
end
end
diff --git a/db/migrate/20120712151934_add_category_id_to_forum_threads.rb b/db/migrate/20120712151934_add_category_id_to_forum_threads.rb
index 2606ba575..c918ebbdf 100644
--- a/db/migrate/20120712151934_add_category_id_to_forum_threads.rb
+++ b/db/migrate/20120712151934_add_category_id_to_forum_threads.rb
@@ -2,8 +2,8 @@ class AddCategoryIdToForumThreads < ActiveRecord::Migration
def up
add_column :forum_threads, :category_id, :integer
- execute "UPDATE forum_threads SET category_id =
- (SELECT id
+ execute "UPDATE forum_threads SET category_id =
+ (SELECT id
FROM categories
WHERE name = forum_threads.tag)"
diff --git a/db/migrate/20120719004636_add_email_hashed_password_name_salt_to_users.rb b/db/migrate/20120719004636_add_email_hashed_password_name_salt_to_users.rb
index 65fc6a611..bd1e05bea 100644
--- a/db/migrate/20120719004636_add_email_hashed_password_name_salt_to_users.rb
+++ b/db/migrate/20120719004636_add_email_hashed_password_name_salt_to_users.rb
@@ -1,24 +1,24 @@
class AddEmailHashedPasswordNameSaltToUsers < ActiveRecord::Migration
def up
- add_column :users, :email, :string, limit: 256
+ add_column :users, :email, :string, limit: 256
execute "update users set email= md5(random()::text) || 'domain.com'"
change_column :users, :email, :string, limit:256, null: false
- add_index :users, [:email], unique: true
+ add_index :users, [:email], unique: true
rename_column :users, :display_username, :name
add_column :users, :password_hash, :string, limit: 64
add_column :users, :salt, :string, limit: 32
- add_column :users, :active, :boolean
+ add_column :users, :active, :boolean
add_column :users, :activation_key,:string, limit: 32
add_column :user_open_ids, :active, :boolean, null: false
end
- def down
+ def down
remove_column :users, :email
remove_column :users, :password_hash
remove_column :users, :salt
diff --git a/db/migrate/20120727005556_remove_excerpt_from_categories.rb b/db/migrate/20120727005556_remove_excerpt_from_categories.rb
index aa3f8faf7..aef33cbf9 100644
--- a/db/migrate/20120727005556_remove_excerpt_from_categories.rb
+++ b/db/migrate/20120727005556_remove_excerpt_from_categories.rb
@@ -4,6 +4,6 @@ class RemoveExcerptFromCategories < ActiveRecord::Migration
end
def down
- add_column :categories, :excerpt, :string, limit: 250
+ add_column :categories, :excerpt, :string, limit: 250
end
end
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 ccf40ba9a..cbfb702a9 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
@@ -2,7 +2,7 @@ class AddNewPasswordNewSaltEmailTokenToUsers < ActiveRecord::Migration
def change
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
+ # email token is more flexible, can be used for both intial activation AND password change confirmation
add_column :users, :email_token, :string, :limit => 32
remove_column :users, :activation_key
end
diff --git a/db/migrate/20120807223020_create_actions.rb b/db/migrate/20120807223020_create_actions.rb
index 15ab85623..832ec6cf0 100644
--- a/db/migrate/20120807223020_create_actions.rb
+++ b/db/migrate/20120807223020_create_actions.rb
@@ -2,12 +2,12 @@ class CreateActions < ActiveRecord::Migration
def change
create_table :actions do |t|
- # I elected for multiple ids as opposed to using :as cause it makes the table
+ # I elected for multiple ids as opposed to using :as cause it makes the table
# thinner, and the joining semantics much simpler (a simple multiple left join will do)
#
- # There is a notificiation table as well that covers much of this,
- # but this table is wider and is intended for non-notifying actions as well
-
+ # There is a notificiation table as well that covers much of this,
+ # 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
diff --git a/db/migrate/20120809020415_remove_site_id.rb b/db/migrate/20120809020415_remove_site_id.rb
index 7b9125c2b..4898882e4 100644
--- a/db/migrate/20120809020415_remove_site_id.rb
+++ b/db/migrate/20120809020415_remove_site_id.rb
@@ -1,18 +1,18 @@
class RemoveSiteId < ActiveRecord::Migration
def up
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"
remove_column 'incoming_links', '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_column 'expression_types','site_id'
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 9a654aee2..f2921bf54 100644
--- a/db/migrate/20120809053414_correct_indexing_on_posts.rb
+++ b/db/migrate/20120809053414_correct_indexing_on_posts.rb
@@ -1,17 +1,17 @@
class CorrectIndexingOnPosts < ActiveRecord::Migration
def up
execute "update posts pp
-set post_number = c.real_number
-from
+set post_number = c.real_number
+from
(
select p1.id, count(*) real_number from posts p1
join posts p2 on p1.forum_thread_id = p2.forum_thread_id
- where p2.id <= p1.id and p1.forum_thread_id = p2.forum_thread_id
+ where p2.id <= p1.id and p1.forum_thread_id = p2.forum_thread_id
group by p1.id
) as c
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
add_index "posts", ["forum_thread_id","post_number"], :unique => true
diff --git a/db/migrate/20120809174649_create_post_actions.rb b/db/migrate/20120809174649_create_post_actions.rb
index c00449c5d..ddcf4d463 100644
--- a/db/migrate/20120809174649_create_post_actions.rb
+++ b/db/migrate/20120809174649_create_post_actions.rb
@@ -9,11 +9,11 @@ class CreatePostActions < ActiveRecord::Migration
end
add_index :post_actions, ["post_id"]
-
+
# no support for this till rails 4
- execute 'create unique index idx_unique_actions on
+ execute 'create unique index idx_unique_actions on
post_actions(user_id, post_action_type_id, post_id) where deleted_at is null'
-
+
end
def down
drop_table :post_actions
diff --git a/db/migrate/20120812235417_retire_expressions.rb b/db/migrate/20120812235417_retire_expressions.rb
index 1e1f427f2..164e19990 100644
--- a/db/migrate/20120812235417_retire_expressions.rb
+++ b/db/migrate/20120812235417_retire_expressions.rb
@@ -1,8 +1,8 @@
class RetireExpressions < ActiveRecord::Migration
def up
execute 'insert into post_actions (post_action_type_id, user_id, post_id, created_at, updated_at)
-select
- case
+select
+ case
when expression_index=1 then 3
when expression_index=2 then 4
when expression_index=3 then 2
diff --git a/db/migrate/20120813201426_create_forum_thread_link_clicks.rb b/db/migrate/20120813201426_create_forum_thread_link_clicks.rb
index ec550f854..41eb7d009 100644
--- a/db/migrate/20120813201426_create_forum_thread_link_clicks.rb
+++ b/db/migrate/20120813201426_create_forum_thread_link_clicks.rb
@@ -3,7 +3,7 @@ class CreateForumThreadLinkClicks < ActiveRecord::Migration
create_table :forum_thread_link_clicks do |t|
t.references :forum_thread_link, null: false
t.references :user, null: true
- t.integer :ip, null: false, limit: 8
+ t.integer :ip, null: false, limit: 8
t.timestamps
end
diff --git a/db/migrate/20120815004411_add_unique_index_to_forum_thread_links.rb b/db/migrate/20120815004411_add_unique_index_to_forum_thread_links.rb
index 3656e36ff..55352f63b 100644
--- a/db/migrate/20120815004411_add_unique_index_to_forum_thread_links.rb
+++ b/db/migrate/20120815004411_add_unique_index_to_forum_thread_links.rb
@@ -6,7 +6,7 @@ class AddUniqueIndexToForumThreadLinks < ActiveRecord::Migration
AND ftl2.post_id = forum_thread_links.post_id
AND ftl2.url = forum_thread_links.url
AND ftl2.id < forum_thread_links.id"
-
+
# Add the unique index
add_index :forum_thread_links, [:forum_thread_id, :post_id, :url], unique: true, as: 'unique_post_links'
end
diff --git a/db/migrate/20120815204733_add_moderator_posts_count_to_forum_threads.rb b/db/migrate/20120815204733_add_moderator_posts_count_to_forum_threads.rb
index cb348f65b..0f3ff3496 100644
--- a/db/migrate/20120815204733_add_moderator_posts_count_to_forum_threads.rb
+++ b/db/migrate/20120815204733_add_moderator_posts_count_to_forum_threads.rb
@@ -3,7 +3,7 @@ class AddModeratorPostsCountToForumThreads < ActiveRecord::Migration
add_column :forum_threads, :moderator_posts_count, :integer, default: 0, null: false
execute "UPDATE forum_threads
- SET moderator_posts_count = (SELECT COUNT(*)
+ SET moderator_posts_count = (SELECT COUNT(*)
FROM posts WHERE posts.forum_thread_id = forum_threads.id
AND posts.post_type = 2)"
end
diff --git a/db/migrate/20120816205538_add_starred_at_to_forum_thread_user.rb b/db/migrate/20120816205538_add_starred_at_to_forum_thread_user.rb
index d49209edf..6cbe575a3 100644
--- a/db/migrate/20120816205538_add_starred_at_to_forum_thread_user.rb
+++ b/db/migrate/20120816205538_add_starred_at_to_forum_thread_user.rb
@@ -1,8 +1,8 @@
class AddStarredAtToForumThreadUser < ActiveRecord::Migration
def up
- add_column :forum_thread_users, :starred_at, :datetime
- User.exec_sql 'update forum_thread_users f set starred_at = COALESCE(created_at, ?)
- from
+ add_column :forum_thread_users, :starred_at, :datetime
+ User.exec_sql 'update forum_thread_users f set starred_at = COALESCE(created_at, ?)
+ from
(
select f1.forum_thread_id, f1.user_id, t.created_at from forum_thread_users f1
left join forum_threads t on f1.forum_thread_id = t.id
diff --git a/db/migrate/20120919152846_add_has_best_of_to_forum_threads.rb b/db/migrate/20120919152846_add_has_best_of_to_forum_threads.rb
index ffb7f85cd..d6fd5599f 100644
--- a/db/migrate/20120919152846_add_has_best_of_to_forum_threads.rb
+++ b/db/migrate/20120919152846_add_has_best_of_to_forum_threads.rb
@@ -1,7 +1,7 @@
class AddHasBestOfToForumThreads < ActiveRecord::Migration
def change
- add_column :forum_threads, :has_best_of, :boolean, default: false, null: false
+ add_column :forum_threads, :has_best_of, :boolean, default: false, null: false
change_column :posts, :score, :float
end
diff --git a/db/migrate/20120921055428_add_twitter_user_info.rb b/db/migrate/20120921055428_add_twitter_user_info.rb
index 04f46e304..d7b7508e0 100644
--- a/db/migrate/20120921055428_add_twitter_user_info.rb
+++ b/db/migrate/20120921055428_add_twitter_user_info.rb
@@ -1,12 +1,12 @@
class AddTwitterUserInfo < ActiveRecord::Migration
def change
- create_table :twitter_user_infos do |t|
+ 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.timestamps
+ t.timestamps
end
-
+
add_index :twitter_user_infos, [:twitter_user_id], :unique => true
add_index :twitter_user_infos, [:user_id], :unique => true
end
diff --git a/db/migrate/20120921162512_add_meta_data_to_forum_threads.rb b/db/migrate/20120921162512_add_meta_data_to_forum_threads.rb
index 99d646ae7..7543fe987 100644
--- a/db/migrate/20120921162512_add_meta_data_to_forum_threads.rb
+++ b/db/migrate/20120921162512_add_meta_data_to_forum_threads.rb
@@ -1,6 +1,6 @@
class AddMetaDataToForumThreads < ActiveRecord::Migration
def change
- execute "CREATE EXTENSION IF NOT EXISTS hstore"
+ execute "CREATE EXTENSION IF NOT EXISTS hstore"
add_column :forum_threads, :meta_data, :hstore
end
end
diff --git a/db/migrate/20120921163606_create_archetype_options.rb b/db/migrate/20120921163606_create_archetype_options.rb
index 7513921f6..acac37d89 100644
--- a/db/migrate/20120921163606_create_archetype_options.rb
+++ b/db/migrate/20120921163606_create_archetype_options.rb
@@ -9,9 +9,9 @@ class CreateArchetypeOptions < ActiveRecord::Migration
add_index :archetype_options, :archetype_id
- execute "INSERT INTO archetype_options (archetype_id, key, option_type, created_at, updated_at)
+ execute "INSERT INTO archetype_options (archetype_id, key, option_type, created_at, updated_at)
VALUES (2, 'private_poll', 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)"
- execute "INSERT INTO archetype_options (archetype_id, key, option_type, created_at, updated_at)
+ execute "INSERT INTO archetype_options (archetype_id, key, option_type, created_at, updated_at)
VALUES (2, 'single_vote', 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)"
end
end
diff --git a/db/migrate/20120928170023_add_sort_order_to_posts.rb b/db/migrate/20120928170023_add_sort_order_to_posts.rb
index 63cfe0d2c..de98ed3b7 100644
--- a/db/migrate/20120928170023_add_sort_order_to_posts.rb
+++ b/db/migrate/20120928170023_add_sort_order_to_posts.rb
@@ -3,11 +3,11 @@ class AddSortOrderToPosts < ActiveRecord::Migration
add_column :posts, :sort_order, :integer
remove_index :posts, :user_id
execute "UPDATE posts AS p SET sort_order = post_number FROM forum_threads AS ft WHERE ft.id = p.forum_thread_id AND ft.archetype_id = 1"
- execute "UPDATE posts AS p SET sort_order =
+ execute "UPDATE posts AS p SET sort_order =
CASE WHEN post_number = 1 THEN 1
- ELSE 2147483647 - p.vote_count
+ ELSE 2147483647 - p.vote_count
END
- FROM forum_threads AS ft
+ FROM forum_threads AS ft
WHERE ft.id = p.forum_thread_id AND ft.archetype_id = 2"
end
end
diff --git a/db/migrate/20121018103721_rename_forum_thread_tables.rb b/db/migrate/20121018103721_rename_forum_thread_tables.rb
index c4f69ef88..d513d1b0e 100644
--- a/db/migrate/20121018103721_rename_forum_thread_tables.rb
+++ b/db/migrate/20121018103721_rename_forum_thread_tables.rb
@@ -18,23 +18,23 @@ class RenameForumThreadTables < ActiveRecord::Migration
rename_column 'category_featured_topics', 'forum_thread_id', 'topic_id'
rename_column 'topic_link_clicks', 'forum_thread_link_id', 'topic_link_id'
-
+
rename_column 'topic_links', 'forum_thread_id', 'topic_id'
rename_column 'topic_links', 'link_forum_thread_id', 'link_topic_id'
-
+
rename_column 'topic_users', 'forum_thread_id', 'topic_id'
rename_column 'incoming_links', 'forum_thread_id', 'topic_id'
-
+
rename_column 'notifications', 'forum_thread_id', 'topic_id'
-
+
rename_column 'post_timings', 'forum_thread_id', 'topic_id'
-
+
rename_column 'posts', 'forum_thread_id', 'topic_id'
-
+
rename_column 'user_actions', 'target_forum_thread_id', 'target_topic_id'
-
+
rename_column 'uploads', 'forum_thread_id', 'topic_id'
end
end
diff --git a/db/migrate/20121106015500_drop_avatar_url_from_users.rb b/db/migrate/20121106015500_drop_avatar_url_from_users.rb
index 3194bbbb9..a9cc69114 100644
--- a/db/migrate/20121106015500_drop_avatar_url_from_users.rb
+++ b/db/migrate/20121106015500_drop_avatar_url_from_users.rb
@@ -1,5 +1,5 @@
-# avatar_url does not function properly as it does not properly deal with scaling.
-# css based scaling is inefficient and has terrible results in both firefox and ie. canvas based scaling is slow.
+# avatar_url does not function properly as it does not properly deal with scaling.
+# css based scaling is inefficient and has terrible results in both firefox and ie. canvas based scaling is slow.
#
# for local urls we need to upload an image and have a pointer to the upload, then use the upload id in the user table
# for gravatar we already have the email and can hash it
@@ -10,6 +10,6 @@ class DropAvatarUrlFromUsers < ActiveRecord::Migration
end
def down
- add_column :users, :avatar_url, :string, null: false, default: ''
+ add_column :users, :avatar_url, :string, null: false, default: ''
end
end
diff --git a/db/migrate/20121123054127_make_post_number_distinct.rb b/db/migrate/20121123054127_make_post_number_distinct.rb
index f70cbc61d..bf61533d0 100644
--- a/db/migrate/20121123054127_make_post_number_distinct.rb
+++ b/db/migrate/20121123054127_make_post_number_distinct.rb
@@ -2,22 +2,22 @@ class MakePostNumberDistinct < ActiveRecord::Migration
def up
Topic.exec_sql('update posts p
-set post_number = calc
+set post_number = calc
from
(
- select
- id,
- post_number,
- topic_id,
+ select
+ id,
+ post_number,
+ topic_id,
row_number() over (partition by topic_id order by post_number, created_at) calc
- from posts
+ from posts
where topic_id in (
select topic_id from posts
group by topic_id, post_number
having count(*)>1
)
-) as X
+) as X
where calc <> p.post_number and X.id = p.id')
remove_index :posts, :forum_thread_id_and_post_number
@@ -25,7 +25,7 @@ where calc <> p.post_number and X.id = p.id')
end
def down
- # don't want to mess with the index ... its annoying
+ # don't want to mess with the index ... its annoying
raise ActiveRecord::IrreversibleMigration
end
end
diff --git a/db/migrate/20121129160035_create_email_tokens.rb b/db/migrate/20121129160035_create_email_tokens.rb
index 7508a05aa..6dcfd64c3 100644
--- a/db/migrate/20121129160035_create_email_tokens.rb
+++ b/db/migrate/20121129160035_create_email_tokens.rb
@@ -8,6 +8,6 @@ class CreateEmailTokens < ActiveRecord::Migration
t.boolean :expired, null: false, default: false
t.timestamps
end
- add_index :email_tokens, :token, unique: true
+ add_index :email_tokens, :token, unique: true
end
end
diff --git a/db/migrate/20121129184948_remove_email_token_from_users.rb b/db/migrate/20121129184948_remove_email_token_from_users.rb
index fece82cae..f605820da 100644
--- a/db/migrate/20121129184948_remove_email_token_from_users.rb
+++ b/db/migrate/20121129184948_remove_email_token_from_users.rb
@@ -4,7 +4,7 @@ class RemoveEmailTokenFromUsers < ActiveRecord::Migration
SELECT id, email, email_token, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP
FROM users WHERE email_token IS NOT NULL"
- remove_column :users, :email_token
+ remove_column :users, :email_token
end
def down
diff --git a/db/migrate/20121204183855_fix_link_post_id.rb b/db/migrate/20121204183855_fix_link_post_id.rb
index da19ef7ba..f61a0acdc 100644
--- a/db/migrate/20121204183855_fix_link_post_id.rb
+++ b/db/migrate/20121204183855_fix_link_post_id.rb
@@ -3,7 +3,7 @@ class FixLinkPostId < ActiveRecord::Migration
to_remove = []
TopicLink.where('internal = TRUE AND link_post_id IS NULL').each do |tl|
-
+
begin
parsed = URI.parse(tl.url)
route = Rails.application.routes.recognize_path(parsed.path)
diff --git a/db/migrate/20121207000741_add_notifications_to_topic_users.rb b/db/migrate/20121207000741_add_notifications_to_topic_users.rb
index 5eb82f19a..37eb8129c 100644
--- a/db/migrate/20121207000741_add_notifications_to_topic_users.rb
+++ b/db/migrate/20121207000741_add_notifications_to_topic_users.rb
@@ -1,6 +1,6 @@
class AddNotificationsToTopicUsers < ActiveRecord::Migration
def change
- add_column :topic_users, :notifications, :integer, default: 2
+ add_column :topic_users, :notifications, :integer, default: 2
add_column :topic_users, :notifications_changed_at, :datetime
add_column :topic_users, :notifications_reason_id, :integer
end
diff --git a/db/migrate/20130115012140_merge_mute_options_on_topic_users.rb b/db/migrate/20130115012140_merge_mute_options_on_topic_users.rb
index b8072553d..a3b80104a 100644
--- a/db/migrate/20130115012140_merge_mute_options_on_topic_users.rb
+++ b/db/migrate/20130115012140_merge_mute_options_on_topic_users.rb
@@ -5,7 +5,7 @@ class MergeMuteOptionsOnTopicUsers < ActiveRecord::Migration
execute "update topic_users set notifications = 2 where notifications = 1"
execute "update topic_users set notifications = 0 where muted_at is not null"
- rename_column :topic_users, :notifications, :notification_level
+ rename_column :topic_users, :notifications, :notification_level
remove_column :topic_users, :muted_at
end
end
diff --git a/db/migrate/20130122232825_add_auto_track_after_seconds_and_banning_and_dob_to_user.rb b/db/migrate/20130122232825_add_auto_track_after_seconds_and_banning_and_dob_to_user.rb
index 95e91b35a..1432d8ba7 100644
--- a/db/migrate/20130122232825_add_auto_track_after_seconds_and_banning_and_dob_to_user.rb
+++ b/db/migrate/20130122232825_add_auto_track_after_seconds_and_banning_and_dob_to_user.rb
@@ -10,10 +10,10 @@ class AddAutoTrackAfterSecondsAndBanningAndDobToUser < ActiveRecord::Migration
add_column :topic_users, :total_msecs_viewed, :integer, null: false, default: 0
- execute 'update topic_users set total_msecs_viewed =
+ execute 'update topic_users set total_msecs_viewed =
(
- select coalesce(sum(msecs) ,0)
- from post_timings t
+ select coalesce(sum(msecs) ,0)
+ from post_timings t
where topic_users.topic_id = t.topic_id and topic_users.user_id = t.user_id
)'
end
diff --git a/db/migrate/20130123070909_auto_track_all_topics_replied_to.rb b/db/migrate/20130123070909_auto_track_all_topics_replied_to.rb
index 83408d4c6..0989ff343 100644
--- a/db/migrate/20130123070909_auto_track_all_topics_replied_to.rb
+++ b/db/migrate/20130123070909_auto_track_all_topics_replied_to.rb
@@ -2,8 +2,8 @@ class AutoTrackAllTopicsRepliedTo < ActiveRecord::Migration
def up
execute 'update topic_users set notification_level = 2, notifications_reason_id = 4
from posts p
- where
- notification_level = 1 and
+ where
+ notification_level = 1 and
notifications_reason_id is null and
p.topic_id = topic_users.topic_id and
p.user_id = topic_users.user_id
diff --git a/db/migrate/20130127213646_remove_trust_levels.rb b/db/migrate/20130127213646_remove_trust_levels.rb
index 7ee0e51a4..9dc3e24e7 100644
--- a/db/migrate/20130127213646_remove_trust_levels.rb
+++ b/db/migrate/20130127213646_remove_trust_levels.rb
@@ -5,7 +5,7 @@ class RemoveTrustLevels < ActiveRecord::Migration
rename_column :users, :trust_level_id, :trust_level
update "UPDATE users set trust_level = #{TrustLevel.Levels[:regular]}"
- update "UPDATE users set trust_level = #{TrustLevel.Levels[:moderator]} where moderator = true"
+ update "UPDATE users set trust_level = #{TrustLevel.Levels[:moderator]} where moderator = true"
remove_column :users, :moderator
add_column :users, :flag_level, :integer, null: false, default: 0
diff --git a/db/migrate/20130128182013_trust_level_default_null.rb b/db/migrate/20130128182013_trust_level_default_null.rb
index f61ce26a3..3031ade91 100644
--- a/db/migrate/20130128182013_trust_level_default_null.rb
+++ b/db/migrate/20130128182013_trust_level_default_null.rb
@@ -4,6 +4,6 @@ class TrustLevelDefaultNull < ActiveRecord::Migration
end
def down
- change_column_default :users, :trust_level, 0
+ change_column_default :users, :trust_level, 0
end
end
diff --git a/db/migrate/20130213021450_remove_topic_response_actions.rb b/db/migrate/20130213021450_remove_topic_response_actions.rb
index eb09fe267..f993a9049 100644
--- a/db/migrate/20130213021450_remove_topic_response_actions.rb
+++ b/db/migrate/20130213021450_remove_topic_response_actions.rb
@@ -1,11 +1,11 @@
class RemoveTopicResponseActions < ActiveRecord::Migration
def up
- # 2 notes:
+ # 2 notes:
# migrations should never use the object model to run sql, otherwise they are a time bomb
# this action type is not valid, we log a "response" action type anyway due to the watch implementation, its a relic.
#
# There is an open question about we should keep stuff in the user stream on the user page, even if a topic is unwatched
- # Eg: I am not watching a topic I created, when somebody responds to the topic should I be notified on the user page?
+ # Eg: I am not watching a topic I created, when somebody responds to the topic should I be notified on the user page?
execute 'delete from user_actions where action_type = 8'
end
diff --git a/db/migrate/20130213203300_add_new_topic_duration_minutes_to_users.rb b/db/migrate/20130213203300_add_new_topic_duration_minutes_to_users.rb
index ed7215020..51685cd59 100644
--- a/db/migrate/20130213203300_add_new_topic_duration_minutes_to_users.rb
+++ b/db/migrate/20130213203300_add_new_topic_duration_minutes_to_users.rb
@@ -1,8 +1,8 @@
class AddNewTopicDurationMinutesToUsers < ActiveRecord::Migration
def change
- # note, no constants allowed here, -1 means since last visit
- # -2 means always
- # larger than 0 is an hour time span
+ # note, no constants allowed here, -1 means since last visit
+ # -2 means always
+ # larger than 0 is an hour time span
add_column :users, :new_topic_duration_minutes, :integer
end
end
diff --git a/db/migrate/20130221215017_add_description_to_categories.rb b/db/migrate/20130221215017_add_description_to_categories.rb
index d2e99e7b1..443f291d8 100644
--- a/db/migrate/20130221215017_add_description_to_categories.rb
+++ b/db/migrate/20130221215017_add_description_to_categories.rb
@@ -9,7 +9,7 @@ class AddDescriptionToCategories < ActiveRecord::Migration
remove_column :categories, :top2_user_id
# Migrate excerpts over
- Category.all.each do |c|
+ Category.all.each do |c|
post = c.topic.posts.order(:post_number).first
PostRevisor.new(post).send(:update_category_description)
end
diff --git a/db/structure.sql b/db/structure.sql
index c03f0bed1..39b4cd846 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -8,6 +8,13 @@ SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
+--
+-- Name: backup; Type: SCHEMA; Schema: -; Owner: -
+--
+
+CREATE SCHEMA backup;
+
+
--
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -
--
@@ -36,12 +43,1176 @@ CREATE EXTENSION IF NOT EXISTS hstore WITH SCHEMA public;
COMMENT ON EXTENSION hstore IS 'data type for storing sets of (key, value) pairs';
-SET search_path = public, pg_catalog;
+SET search_path = backup, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
+--
+-- Name: categories; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE categories (
+ id integer NOT NULL,
+ name character varying(50) NOT NULL,
+ color character varying(6) DEFAULT 'AB9364'::character varying NOT NULL,
+ topic_id integer,
+ top1_topic_id integer,
+ top2_topic_id integer,
+ top1_user_id integer,
+ top2_user_id integer,
+ topic_count integer DEFAULT 0 NOT NULL,
+ created_at timestamp without time zone NOT NULL,
+ updated_at timestamp without time zone NOT NULL,
+ user_id integer NOT NULL,
+ topics_year integer,
+ topics_month integer,
+ topics_week integer,
+ slug character varying(255) NOT NULL
+);
+
+
+--
+-- Name: categories_id_seq; Type: SEQUENCE; Schema: backup; Owner: -
+--
+
+CREATE SEQUENCE categories_id_seq
+ START WITH 5
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: categories_id_seq; Type: SEQUENCE OWNED BY; Schema: backup; Owner: -
+--
+
+ALTER SEQUENCE categories_id_seq OWNED BY categories.id;
+
+
+--
+-- Name: category_featured_topics; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE category_featured_topics (
+ category_id integer NOT NULL,
+ topic_id integer NOT NULL,
+ created_at timestamp without time zone NOT NULL,
+ updated_at timestamp without time zone NOT NULL
+);
+
+
+--
+-- Name: category_featured_users; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE category_featured_users (
+ id integer NOT NULL,
+ category_id integer,
+ user_id integer,
+ created_at timestamp without time zone NOT NULL,
+ updated_at timestamp without time zone NOT NULL
+);
+
+
+--
+-- Name: category_featured_users_id_seq; Type: SEQUENCE; Schema: backup; Owner: -
+--
+
+CREATE SEQUENCE category_featured_users_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: category_featured_users_id_seq; Type: SEQUENCE OWNED BY; Schema: backup; Owner: -
+--
+
+ALTER SEQUENCE category_featured_users_id_seq OWNED BY category_featured_users.id;
+
+
+--
+-- Name: draft_sequences; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE draft_sequences (
+ id integer NOT NULL,
+ user_id integer NOT NULL,
+ draft_key character varying(255) NOT NULL,
+ sequence integer NOT NULL
+);
+
+
+--
+-- Name: draft_sequences_id_seq; Type: SEQUENCE; Schema: backup; Owner: -
+--
+
+CREATE SEQUENCE draft_sequences_id_seq
+ START WITH 20
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: draft_sequences_id_seq; Type: SEQUENCE OWNED BY; Schema: backup; Owner: -
+--
+
+ALTER SEQUENCE draft_sequences_id_seq OWNED BY draft_sequences.id;
+
+
+--
+-- Name: drafts; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE drafts (
+ id integer NOT NULL,
+ user_id integer NOT NULL,
+ draft_key character varying(255) NOT NULL,
+ data text NOT NULL,
+ created_at timestamp without time zone NOT NULL,
+ updated_at timestamp without time zone NOT NULL,
+ sequence integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: drafts_id_seq; Type: SEQUENCE; Schema: backup; Owner: -
+--
+
+CREATE SEQUENCE drafts_id_seq
+ START WITH 2
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: drafts_id_seq; Type: SEQUENCE OWNED BY; Schema: backup; Owner: -
+--
+
+ALTER SEQUENCE drafts_id_seq OWNED BY drafts.id;
+
+
+--
+-- Name: email_logs; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE email_logs (
+ id integer NOT NULL,
+ to_address character varying(255) NOT NULL,
+ email_type character varying(255) NOT NULL,
+ user_id integer,
+ created_at timestamp without time zone NOT NULL,
+ updated_at timestamp without time zone NOT NULL
+);
+
+
+--
+-- Name: email_logs_id_seq; Type: SEQUENCE; Schema: backup; Owner: -
+--
+
+CREATE SEQUENCE email_logs_id_seq
+ START WITH 3
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: email_logs_id_seq; Type: SEQUENCE OWNED BY; Schema: backup; Owner: -
+--
+
+ALTER SEQUENCE email_logs_id_seq OWNED BY email_logs.id;
+
+
+--
+-- Name: email_tokens; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE email_tokens (
+ id integer NOT NULL,
+ user_id integer NOT NULL,
+ email character varying(255) NOT NULL,
+ token character varying(255) NOT NULL,
+ confirmed boolean DEFAULT false NOT NULL,
+ expired boolean DEFAULT false NOT NULL,
+ created_at timestamp without time zone NOT NULL,
+ updated_at timestamp without time zone NOT NULL
+);
+
+
+--
+-- Name: email_tokens_id_seq; Type: SEQUENCE; Schema: backup; Owner: -
+--
+
+CREATE SEQUENCE email_tokens_id_seq
+ START WITH 3
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: email_tokens_id_seq; Type: SEQUENCE OWNED BY; Schema: backup; Owner: -
+--
+
+ALTER SEQUENCE email_tokens_id_seq OWNED BY email_tokens.id;
+
+
+--
+-- Name: facebook_user_infos; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE facebook_user_infos (
+ id integer NOT NULL,
+ user_id integer NOT NULL,
+ facebook_user_id integer NOT NULL,
+ username character varying(255) NOT NULL,
+ first_name character varying(255),
+ last_name character varying(255),
+ email character varying(255),
+ gender character varying(255),
+ name character varying(255),
+ link character varying(255),
+ created_at timestamp without time zone NOT NULL,
+ updated_at timestamp without time zone NOT NULL
+);
+
+
+--
+-- Name: facebook_user_infos_id_seq; Type: SEQUENCE; Schema: backup; Owner: -
+--
+
+CREATE SEQUENCE facebook_user_infos_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: facebook_user_infos_id_seq; Type: SEQUENCE OWNED BY; Schema: backup; Owner: -
+--
+
+ALTER SEQUENCE facebook_user_infos_id_seq OWNED BY facebook_user_infos.id;
+
+
+--
+-- Name: incoming_links; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE incoming_links (
+ id integer NOT NULL,
+ url character varying(1000) NOT NULL,
+ referer character varying(1000) NOT NULL,
+ domain character varying(100) NOT NULL,
+ topic_id integer,
+ post_number integer,
+ created_at timestamp without time zone NOT NULL,
+ updated_at timestamp without time zone NOT NULL
+);
+
+
+--
+-- Name: incoming_links_id_seq; Type: SEQUENCE; Schema: backup; Owner: -
+--
+
+CREATE SEQUENCE incoming_links_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: incoming_links_id_seq; Type: SEQUENCE OWNED BY; Schema: backup; Owner: -
+--
+
+ALTER SEQUENCE incoming_links_id_seq OWNED BY incoming_links.id;
+
+
+--
+-- Name: invites; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE invites (
+ id integer NOT NULL,
+ invite_key character varying(32) NOT NULL,
+ email character varying(255) NOT NULL,
+ invited_by_id integer NOT NULL,
+ user_id integer,
+ redeemed_at timestamp without time zone,
+ created_at timestamp without time zone NOT NULL,
+ updated_at timestamp without time zone NOT NULL,
+ deleted_at timestamp without time zone
+);
+
+
+--
+-- Name: invites_id_seq; Type: SEQUENCE; Schema: backup; Owner: -
+--
+
+CREATE SEQUENCE invites_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: invites_id_seq; Type: SEQUENCE OWNED BY; Schema: backup; Owner: -
+--
+
+ALTER SEQUENCE invites_id_seq OWNED BY invites.id;
+
+
+--
+-- Name: notifications; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE notifications (
+ id integer NOT NULL,
+ notification_type integer NOT NULL,
+ user_id integer NOT NULL,
+ data character varying(255) NOT NULL,
+ read boolean DEFAULT false NOT NULL,
+ created_at timestamp without time zone NOT NULL,
+ updated_at timestamp without time zone NOT NULL,
+ topic_id integer,
+ post_number integer,
+ post_action_id integer
+);
+
+
+--
+-- Name: notifications_id_seq; Type: SEQUENCE; Schema: backup; Owner: -
+--
+
+CREATE SEQUENCE notifications_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: notifications_id_seq; Type: SEQUENCE OWNED BY; Schema: backup; Owner: -
+--
+
+ALTER SEQUENCE notifications_id_seq OWNED BY notifications.id;
+
+
+--
+-- Name: onebox_renders; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE onebox_renders (
+ id integer NOT NULL,
+ url character varying(255) NOT NULL,
+ cooked text NOT NULL,
+ expires_at timestamp without time zone NOT NULL,
+ created_at timestamp without time zone NOT NULL,
+ updated_at timestamp without time zone NOT NULL,
+ preview text
+);
+
+
+--
+-- Name: onebox_renders_id_seq; Type: SEQUENCE; Schema: backup; Owner: -
+--
+
+CREATE SEQUENCE onebox_renders_id_seq
+ START WITH 2
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: onebox_renders_id_seq; Type: SEQUENCE OWNED BY; Schema: backup; Owner: -
+--
+
+ALTER SEQUENCE onebox_renders_id_seq OWNED BY onebox_renders.id;
+
+
+--
+-- Name: post_action_types; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE post_action_types (
+ name_key character varying(50) NOT NULL,
+ is_flag boolean DEFAULT false NOT NULL,
+ icon character varying(20),
+ created_at timestamp without time zone NOT NULL,
+ updated_at timestamp without time zone NOT NULL,
+ id integer NOT NULL
+);
+
+
+--
+-- Name: post_action_types_id_seq; Type: SEQUENCE; Schema: backup; Owner: -
+--
+
+CREATE SEQUENCE post_action_types_id_seq
+ START WITH 6
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: post_action_types_id_seq; Type: SEQUENCE OWNED BY; Schema: backup; Owner: -
+--
+
+ALTER SEQUENCE post_action_types_id_seq OWNED BY post_action_types.id;
+
+
+--
+-- Name: post_actions; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE post_actions (
+ id integer NOT NULL,
+ post_id integer NOT NULL,
+ user_id integer NOT NULL,
+ post_action_type_id integer NOT NULL,
+ deleted_at timestamp without time zone,
+ created_at timestamp without time zone NOT NULL,
+ updated_at timestamp without time zone NOT NULL
+);
+
+
+--
+-- Name: post_actions_id_seq; Type: SEQUENCE; Schema: backup; Owner: -
+--
+
+CREATE SEQUENCE post_actions_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: post_actions_id_seq; Type: SEQUENCE OWNED BY; Schema: backup; Owner: -
+--
+
+ALTER SEQUENCE post_actions_id_seq OWNED BY post_actions.id;
+
+
+--
+-- Name: post_onebox_renders; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE post_onebox_renders (
+ post_id integer NOT NULL,
+ onebox_render_id integer NOT NULL,
+ created_at timestamp without time zone NOT NULL,
+ updated_at timestamp without time zone NOT NULL
+);
+
+
+--
+-- Name: post_replies; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE post_replies (
+ post_id integer,
+ reply_id integer,
+ created_at timestamp without time zone NOT NULL,
+ updated_at timestamp without time zone NOT NULL
+);
+
+
+--
+-- Name: post_timings; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE post_timings (
+ topic_id integer NOT NULL,
+ post_number integer NOT NULL,
+ user_id integer NOT NULL,
+ msecs integer NOT NULL
+);
+
+
+--
+-- Name: posts; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE posts (
+ id integer NOT NULL,
+ user_id integer NOT NULL,
+ topic_id integer NOT NULL,
+ post_number integer NOT NULL,
+ raw text NOT NULL,
+ cooked text NOT NULL,
+ created_at timestamp without time zone NOT NULL,
+ updated_at timestamp without time zone NOT NULL,
+ reply_to_post_number integer,
+ cached_version integer DEFAULT 1 NOT NULL,
+ reply_count integer DEFAULT 0 NOT NULL,
+ quote_count integer DEFAULT 0 NOT NULL,
+ reply_below_post_number integer,
+ deleted_at timestamp without time zone,
+ off_topic_count integer DEFAULT 0 NOT NULL,
+ offensive_count integer DEFAULT 0 NOT NULL,
+ like_count integer DEFAULT 0 NOT NULL,
+ incoming_link_count integer DEFAULT 0 NOT NULL,
+ bookmark_count integer DEFAULT 0 NOT NULL,
+ avg_time integer,
+ score double precision,
+ reads integer DEFAULT 0 NOT NULL,
+ post_type integer DEFAULT 1 NOT NULL,
+ vote_count integer DEFAULT 0 NOT NULL,
+ sort_order integer,
+ last_editor_id integer
+);
+
+
+--
+-- Name: posts_id_seq; Type: SEQUENCE; Schema: backup; Owner: -
+--
+
+CREATE SEQUENCE posts_id_seq
+ START WITH 16
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: posts_id_seq; Type: SEQUENCE OWNED BY; Schema: backup; Owner: -
+--
+
+ALTER SEQUENCE posts_id_seq OWNED BY posts.id;
+
+
+--
+-- Name: site_customizations; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE site_customizations (
+ id integer NOT NULL,
+ name character varying(255) NOT NULL,
+ stylesheet text,
+ header text,
+ "position" integer NOT NULL,
+ user_id integer NOT NULL,
+ enabled boolean NOT NULL,
+ key character varying(255) NOT NULL,
+ created_at timestamp without time zone NOT NULL,
+ updated_at timestamp without time zone NOT NULL,
+ override_default_style boolean DEFAULT false NOT NULL,
+ stylesheet_baked text DEFAULT ''::text NOT NULL
+);
+
+
+--
+-- Name: site_customizations_id_seq; Type: SEQUENCE; Schema: backup; Owner: -
+--
+
+CREATE SEQUENCE site_customizations_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: site_customizations_id_seq; Type: SEQUENCE OWNED BY; Schema: backup; Owner: -
+--
+
+ALTER SEQUENCE site_customizations_id_seq OWNED BY site_customizations.id;
+
+
+--
+-- Name: site_settings; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE site_settings (
+ id integer NOT NULL,
+ name character varying(255) NOT NULL,
+ data_type integer NOT NULL,
+ value text,
+ created_at timestamp without time zone NOT NULL,
+ updated_at timestamp without time zone NOT NULL
+);
+
+
+--
+-- Name: site_settings_id_seq; Type: SEQUENCE; Schema: backup; Owner: -
+--
+
+CREATE SEQUENCE site_settings_id_seq
+ START WITH 4
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: site_settings_id_seq; Type: SEQUENCE OWNED BY; Schema: backup; Owner: -
+--
+
+ALTER SEQUENCE site_settings_id_seq OWNED BY site_settings.id;
+
+
+--
+-- Name: topic_allowed_users; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE topic_allowed_users (
+ id integer NOT NULL,
+ user_id integer NOT NULL,
+ topic_id integer NOT NULL,
+ created_at timestamp without time zone NOT NULL,
+ updated_at timestamp without time zone NOT NULL
+);
+
+
+--
+-- Name: topic_allowed_users_id_seq; Type: SEQUENCE; Schema: backup; Owner: -
+--
+
+CREATE SEQUENCE topic_allowed_users_id_seq
+ START WITH 3
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: topic_allowed_users_id_seq; Type: SEQUENCE OWNED BY; Schema: backup; Owner: -
+--
+
+ALTER SEQUENCE topic_allowed_users_id_seq OWNED BY topic_allowed_users.id;
+
+
+--
+-- Name: topic_invites; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE topic_invites (
+ id integer NOT NULL,
+ topic_id integer NOT NULL,
+ invite_id integer NOT NULL,
+ created_at timestamp without time zone NOT NULL,
+ updated_at timestamp without time zone NOT NULL
+);
+
+
+--
+-- Name: topic_invites_id_seq; Type: SEQUENCE; Schema: backup; Owner: -
+--
+
+CREATE SEQUENCE topic_invites_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: topic_invites_id_seq; Type: SEQUENCE OWNED BY; Schema: backup; Owner: -
+--
+
+ALTER SEQUENCE topic_invites_id_seq OWNED BY topic_invites.id;
+
+
+--
+-- Name: topic_link_clicks; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE topic_link_clicks (
+ id integer NOT NULL,
+ topic_link_id integer NOT NULL,
+ user_id integer,
+ ip bigint NOT NULL,
+ created_at timestamp without time zone NOT NULL,
+ updated_at timestamp without time zone NOT NULL
+);
+
+
+--
+-- Name: topic_link_clicks_id_seq; Type: SEQUENCE; Schema: backup; Owner: -
+--
+
+CREATE SEQUENCE topic_link_clicks_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: topic_link_clicks_id_seq; Type: SEQUENCE OWNED BY; Schema: backup; Owner: -
+--
+
+ALTER SEQUENCE topic_link_clicks_id_seq OWNED BY topic_link_clicks.id;
+
+
+--
+-- Name: topic_links; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE topic_links (
+ id integer NOT NULL,
+ topic_id integer NOT NULL,
+ post_id integer,
+ user_id integer NOT NULL,
+ url character varying(500) NOT NULL,
+ domain character varying(100) NOT NULL,
+ internal boolean DEFAULT false NOT NULL,
+ link_topic_id integer,
+ created_at timestamp without time zone NOT NULL,
+ updated_at timestamp without time zone NOT NULL,
+ reflection boolean DEFAULT false,
+ clicks integer DEFAULT 0 NOT NULL,
+ link_post_id integer
+);
+
+
+--
+-- Name: topic_links_id_seq; Type: SEQUENCE; Schema: backup; Owner: -
+--
+
+CREATE SEQUENCE topic_links_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: topic_links_id_seq; Type: SEQUENCE OWNED BY; Schema: backup; Owner: -
+--
+
+ALTER SEQUENCE topic_links_id_seq OWNED BY topic_links.id;
+
+
+--
+-- Name: topic_users; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE topic_users (
+ user_id integer NOT NULL,
+ topic_id integer NOT NULL,
+ starred boolean DEFAULT false NOT NULL,
+ posted boolean DEFAULT false NOT NULL,
+ last_read_post_number integer,
+ seen_post_count integer,
+ starred_at timestamp without time zone,
+ muted_at timestamp without time zone,
+ last_visited_at timestamp without time zone,
+ first_visited_at timestamp without time zone,
+ notifications integer DEFAULT 2,
+ notifications_changed_at timestamp without time zone,
+ notifications_reason_id integer,
+ CONSTRAINT test_starred_at CHECK (((starred = false) OR (starred_at IS NOT NULL)))
+);
+
+
+--
+-- Name: topics; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE topics (
+ id integer NOT NULL,
+ title character varying(255) NOT NULL,
+ last_posted_at timestamp without time zone,
+ created_at timestamp without time zone NOT NULL,
+ updated_at timestamp without time zone NOT NULL,
+ views integer DEFAULT 0 NOT NULL,
+ posts_count integer DEFAULT 0 NOT NULL,
+ user_id integer NOT NULL,
+ last_post_user_id integer NOT NULL,
+ reply_count integer DEFAULT 0 NOT NULL,
+ featured_user1_id integer,
+ featured_user2_id integer,
+ featured_user3_id integer,
+ avg_time integer,
+ deleted_at timestamp without time zone,
+ highest_post_number integer DEFAULT 0 NOT NULL,
+ image_url character varying(255),
+ off_topic_count integer DEFAULT 0 NOT NULL,
+ offensive_count integer DEFAULT 0 NOT NULL,
+ like_count integer DEFAULT 0 NOT NULL,
+ incoming_link_count integer DEFAULT 0 NOT NULL,
+ bookmark_count integer DEFAULT 0 NOT NULL,
+ star_count integer DEFAULT 0 NOT NULL,
+ category_id integer,
+ visible boolean DEFAULT true NOT NULL,
+ moderator_posts_count integer DEFAULT 0 NOT NULL,
+ closed boolean DEFAULT false NOT NULL,
+ pinned boolean DEFAULT false NOT NULL,
+ archived boolean DEFAULT false NOT NULL,
+ bumped_at timestamp without time zone NOT NULL,
+ sub_tag character varying(255),
+ has_best_of boolean DEFAULT false NOT NULL,
+ meta_data public.hstore,
+ vote_count integer DEFAULT 0 NOT NULL,
+ archetype character varying(255) DEFAULT 'regular'::character varying NOT NULL,
+ featured_user4_id integer
+);
+
+
+--
+-- Name: topics_id_seq; Type: SEQUENCE; Schema: backup; Owner: -
+--
+
+CREATE SEQUENCE topics_id_seq
+ START WITH 16
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: topics_id_seq; Type: SEQUENCE OWNED BY; Schema: backup; Owner: -
+--
+
+ALTER SEQUENCE topics_id_seq OWNED BY topics.id;
+
+
+--
+-- Name: trust_levels; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE trust_levels (
+ id integer NOT NULL,
+ name_key character varying(255) NOT NULL,
+ created_at timestamp without time zone NOT NULL,
+ updated_at timestamp without time zone NOT NULL
+);
+
+
+--
+-- Name: trust_levels_id_seq; Type: SEQUENCE; Schema: backup; Owner: -
+--
+
+CREATE SEQUENCE trust_levels_id_seq
+ START WITH 3
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: trust_levels_id_seq; Type: SEQUENCE OWNED BY; Schema: backup; Owner: -
+--
+
+ALTER SEQUENCE trust_levels_id_seq OWNED BY trust_levels.id;
+
+
+--
+-- Name: twitter_user_infos; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE twitter_user_infos (
+ id integer NOT NULL,
+ user_id integer NOT NULL,
+ screen_name character varying(255) NOT NULL,
+ twitter_user_id integer NOT NULL,
+ created_at timestamp without time zone NOT NULL,
+ updated_at timestamp without time zone NOT NULL
+);
+
+
+--
+-- Name: twitter_user_infos_id_seq; Type: SEQUENCE; Schema: backup; Owner: -
+--
+
+CREATE SEQUENCE twitter_user_infos_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: twitter_user_infos_id_seq; Type: SEQUENCE OWNED BY; Schema: backup; Owner: -
+--
+
+ALTER SEQUENCE twitter_user_infos_id_seq OWNED BY twitter_user_infos.id;
+
+
+--
+-- Name: uploads; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE uploads (
+ id integer NOT NULL,
+ user_id integer NOT NULL,
+ topic_id integer NOT NULL,
+ original_filename character varying(255) NOT NULL,
+ filesize integer NOT NULL,
+ width integer,
+ height integer,
+ url character varying(255) NOT NULL,
+ created_at timestamp without time zone NOT NULL,
+ updated_at timestamp without time zone NOT NULL
+);
+
+
+--
+-- Name: uploads_id_seq; Type: SEQUENCE; Schema: backup; Owner: -
+--
+
+CREATE SEQUENCE uploads_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: uploads_id_seq; Type: SEQUENCE OWNED BY; Schema: backup; Owner: -
+--
+
+ALTER SEQUENCE uploads_id_seq OWNED BY uploads.id;
+
+
+--
+-- Name: user_actions; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE user_actions (
+ id integer NOT NULL,
+ action_type integer NOT NULL,
+ user_id integer NOT NULL,
+ target_topic_id integer,
+ target_post_id integer,
+ target_user_id integer,
+ acting_user_id integer,
+ created_at timestamp without time zone NOT NULL,
+ updated_at timestamp without time zone NOT NULL
+);
+
+
+--
+-- Name: user_actions_id_seq; Type: SEQUENCE; Schema: backup; Owner: -
+--
+
+CREATE SEQUENCE user_actions_id_seq
+ START WITH 40
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: user_actions_id_seq; Type: SEQUENCE OWNED BY; Schema: backup; Owner: -
+--
+
+ALTER SEQUENCE user_actions_id_seq OWNED BY user_actions.id;
+
+
+--
+-- Name: user_open_ids; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE user_open_ids (
+ id integer NOT NULL,
+ user_id integer NOT NULL,
+ email character varying(255) NOT NULL,
+ url character varying(255) NOT NULL,
+ created_at timestamp without time zone NOT NULL,
+ updated_at timestamp without time zone NOT NULL,
+ active boolean NOT NULL
+);
+
+
+--
+-- Name: user_open_ids_id_seq; Type: SEQUENCE; Schema: backup; Owner: -
+--
+
+CREATE SEQUENCE user_open_ids_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: user_open_ids_id_seq; Type: SEQUENCE OWNED BY; Schema: backup; Owner: -
+--
+
+ALTER SEQUENCE user_open_ids_id_seq OWNED BY user_open_ids.id;
+
+
+--
+-- Name: user_visits; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE user_visits (
+ id integer NOT NULL,
+ user_id integer NOT NULL,
+ visited_at date NOT NULL
+);
+
+
+--
+-- Name: user_visits_id_seq; Type: SEQUENCE; Schema: backup; Owner: -
+--
+
+CREATE SEQUENCE user_visits_id_seq
+ START WITH 4
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: user_visits_id_seq; Type: SEQUENCE OWNED BY; Schema: backup; Owner: -
+--
+
+ALTER SEQUENCE user_visits_id_seq OWNED BY user_visits.id;
+
+
+--
+-- Name: users; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE users (
+ id integer NOT NULL,
+ username character varying(20) NOT NULL,
+ created_at timestamp without time zone NOT NULL,
+ updated_at timestamp without time zone NOT NULL,
+ name character varying(255),
+ bio_raw text,
+ seen_notification_id integer DEFAULT 0 NOT NULL,
+ last_posted_at timestamp without time zone,
+ email character varying(256) NOT NULL,
+ password_hash character varying(64),
+ salt character varying(32),
+ active boolean,
+ username_lower character varying(20) NOT NULL,
+ auth_token character varying(32),
+ last_seen_at timestamp without time zone,
+ website character varying(255),
+ admin boolean DEFAULT false NOT NULL,
+ moderator boolean DEFAULT false NOT NULL,
+ last_emailed_at timestamp without time zone,
+ email_digests boolean DEFAULT true NOT NULL,
+ trust_level_id integer DEFAULT 1 NOT NULL,
+ bio_cooked text,
+ email_private_messages boolean DEFAULT true,
+ email_direct boolean DEFAULT true NOT NULL,
+ approved boolean DEFAULT false NOT NULL,
+ approved_by_id integer,
+ approved_at timestamp without time zone,
+ topics_entered integer DEFAULT 0 NOT NULL,
+ posts_read_count integer DEFAULT 0 NOT NULL,
+ digest_after_days integer DEFAULT 7 NOT NULL,
+ previous_visit_at timestamp without time zone
+);
+
+
+--
+-- Name: users_id_seq; Type: SEQUENCE; Schema: backup; Owner: -
+--
+
+CREATE SEQUENCE users_id_seq
+ START WITH 3
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: backup; Owner: -
+--
+
+ALTER SEQUENCE users_id_seq OWNED BY users.id;
+
+
+--
+-- Name: versions; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE versions (
+ id integer NOT NULL,
+ versioned_id integer,
+ versioned_type character varying(255),
+ user_id integer,
+ user_type character varying(255),
+ user_name character varying(255),
+ modifications text,
+ number integer,
+ reverted_from integer,
+ tag character varying(255),
+ created_at timestamp without time zone NOT NULL,
+ updated_at timestamp without time zone NOT NULL
+);
+
+
+--
+-- Name: versions_id_seq; Type: SEQUENCE; Schema: backup; Owner: -
+--
+
+CREATE SEQUENCE versions_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: versions_id_seq; Type: SEQUENCE OWNED BY; Schema: backup; Owner: -
+--
+
+ALTER SEQUENCE versions_id_seq OWNED BY versions.id;
+
+
+--
+-- Name: views; Type: TABLE; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE TABLE views (
+ parent_id integer NOT NULL,
+ parent_type character varying(50) NOT NULL,
+ ip bigint NOT NULL,
+ viewed_at timestamp without time zone NOT NULL,
+ user_id integer
+);
+
+
+SET search_path = public, pg_catalog;
+
--
-- Name: categories; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
@@ -68,7 +1239,7 @@ CREATE TABLE categories (
--
CREATE SEQUENCE categories_id_seq
- START WITH 1
+ START WITH 5
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
@@ -153,7 +1324,7 @@ CREATE TABLE draft_sequences (
--
CREATE SEQUENCE draft_sequences_id_seq
- START WITH 1
+ START WITH 20
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
@@ -187,7 +1358,7 @@ CREATE TABLE drafts (
--
CREATE SEQUENCE drafts_id_seq
- START WITH 1
+ START WITH 2
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
@@ -220,7 +1391,7 @@ CREATE TABLE email_logs (
--
CREATE SEQUENCE email_logs_id_seq
- START WITH 1
+ START WITH 3
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
@@ -255,7 +1426,7 @@ CREATE TABLE email_tokens (
--
CREATE SEQUENCE email_tokens_id_seq
- START WITH 1
+ START WITH 3
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
@@ -468,7 +1639,7 @@ CREATE TABLE onebox_renders (
--
CREATE SEQUENCE onebox_renders_id_seq
- START WITH 1
+ START WITH 2
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
@@ -502,7 +1673,7 @@ CREATE TABLE post_action_types (
--
CREATE SEQUENCE post_action_types_id_seq
- START WITH 1
+ START WITH 6
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
@@ -633,7 +1804,7 @@ CREATE TABLE posts (
--
CREATE SEQUENCE posts_id_seq
- START WITH 1
+ START WITH 16
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
@@ -724,7 +1895,7 @@ CREATE TABLE site_settings (
--
CREATE SEQUENCE site_settings_id_seq
- START WITH 1
+ START WITH 4
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
@@ -756,7 +1927,7 @@ CREATE TABLE topic_allowed_users (
--
CREATE SEQUENCE topic_allowed_users_id_seq
- START WITH 1
+ START WITH 3
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
@@ -948,7 +2119,7 @@ CREATE TABLE topics (
--
CREATE SEQUENCE topics_id_seq
- START WITH 1
+ START WITH 16
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
@@ -1054,7 +2225,7 @@ CREATE TABLE user_actions (
--
CREATE SEQUENCE user_actions_id_seq
- START WITH 1
+ START WITH 40
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
@@ -1118,7 +2289,7 @@ CREATE TABLE user_visits (
--
CREATE SEQUENCE user_visits_id_seq
- START WITH 1
+ START WITH 4
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
@@ -1185,7 +2356,7 @@ CREATE TABLE users (
--
CREATE SEQUENCE users_id_seq
- START WITH 1
+ START WITH 3
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
@@ -1261,6 +2432,213 @@ CREATE TABLE views (
);
+SET search_path = backup, pg_catalog;
+
+--
+-- Name: id; Type: DEFAULT; Schema: backup; Owner: -
+--
+
+ALTER TABLE ONLY categories ALTER COLUMN id SET DEFAULT nextval('categories_id_seq'::regclass);
+
+
+--
+-- Name: id; Type: DEFAULT; Schema: backup; Owner: -
+--
+
+ALTER TABLE ONLY category_featured_users ALTER COLUMN id SET DEFAULT nextval('category_featured_users_id_seq'::regclass);
+
+
+--
+-- Name: id; Type: DEFAULT; Schema: backup; Owner: -
+--
+
+ALTER TABLE ONLY draft_sequences ALTER COLUMN id SET DEFAULT nextval('draft_sequences_id_seq'::regclass);
+
+
+--
+-- Name: id; Type: DEFAULT; Schema: backup; Owner: -
+--
+
+ALTER TABLE ONLY drafts ALTER COLUMN id SET DEFAULT nextval('drafts_id_seq'::regclass);
+
+
+--
+-- Name: id; Type: DEFAULT; Schema: backup; Owner: -
+--
+
+ALTER TABLE ONLY email_logs ALTER COLUMN id SET DEFAULT nextval('email_logs_id_seq'::regclass);
+
+
+--
+-- Name: id; Type: DEFAULT; Schema: backup; Owner: -
+--
+
+ALTER TABLE ONLY email_tokens ALTER COLUMN id SET DEFAULT nextval('email_tokens_id_seq'::regclass);
+
+
+--
+-- Name: id; Type: DEFAULT; Schema: backup; Owner: -
+--
+
+ALTER TABLE ONLY facebook_user_infos ALTER COLUMN id SET DEFAULT nextval('facebook_user_infos_id_seq'::regclass);
+
+
+--
+-- Name: id; Type: DEFAULT; Schema: backup; Owner: -
+--
+
+ALTER TABLE ONLY incoming_links ALTER COLUMN id SET DEFAULT nextval('incoming_links_id_seq'::regclass);
+
+
+--
+-- Name: id; Type: DEFAULT; Schema: backup; Owner: -
+--
+
+ALTER TABLE ONLY invites ALTER COLUMN id SET DEFAULT nextval('invites_id_seq'::regclass);
+
+
+--
+-- Name: id; Type: DEFAULT; Schema: backup; Owner: -
+--
+
+ALTER TABLE ONLY notifications ALTER COLUMN id SET DEFAULT nextval('notifications_id_seq'::regclass);
+
+
+--
+-- Name: id; Type: DEFAULT; Schema: backup; Owner: -
+--
+
+ALTER TABLE ONLY onebox_renders ALTER COLUMN id SET DEFAULT nextval('onebox_renders_id_seq'::regclass);
+
+
+--
+-- Name: id; Type: DEFAULT; Schema: backup; Owner: -
+--
+
+ALTER TABLE ONLY post_action_types ALTER COLUMN id SET DEFAULT nextval('post_action_types_id_seq'::regclass);
+
+
+--
+-- Name: id; Type: DEFAULT; Schema: backup; Owner: -
+--
+
+ALTER TABLE ONLY post_actions ALTER COLUMN id SET DEFAULT nextval('post_actions_id_seq'::regclass);
+
+
+--
+-- Name: id; Type: DEFAULT; Schema: backup; Owner: -
+--
+
+ALTER TABLE ONLY posts ALTER COLUMN id SET DEFAULT nextval('posts_id_seq'::regclass);
+
+
+--
+-- Name: id; Type: DEFAULT; Schema: backup; Owner: -
+--
+
+ALTER TABLE ONLY site_customizations ALTER COLUMN id SET DEFAULT nextval('site_customizations_id_seq'::regclass);
+
+
+--
+-- Name: id; Type: DEFAULT; Schema: backup; Owner: -
+--
+
+ALTER TABLE ONLY site_settings ALTER COLUMN id SET DEFAULT nextval('site_settings_id_seq'::regclass);
+
+
+--
+-- Name: id; Type: DEFAULT; Schema: backup; Owner: -
+--
+
+ALTER TABLE ONLY topic_allowed_users ALTER COLUMN id SET DEFAULT nextval('topic_allowed_users_id_seq'::regclass);
+
+
+--
+-- Name: id; Type: DEFAULT; Schema: backup; Owner: -
+--
+
+ALTER TABLE ONLY topic_invites ALTER COLUMN id SET DEFAULT nextval('topic_invites_id_seq'::regclass);
+
+
+--
+-- Name: id; Type: DEFAULT; Schema: backup; Owner: -
+--
+
+ALTER TABLE ONLY topic_link_clicks ALTER COLUMN id SET DEFAULT nextval('topic_link_clicks_id_seq'::regclass);
+
+
+--
+-- Name: id; Type: DEFAULT; Schema: backup; Owner: -
+--
+
+ALTER TABLE ONLY topic_links ALTER COLUMN id SET DEFAULT nextval('topic_links_id_seq'::regclass);
+
+
+--
+-- Name: id; Type: DEFAULT; Schema: backup; Owner: -
+--
+
+ALTER TABLE ONLY topics ALTER COLUMN id SET DEFAULT nextval('topics_id_seq'::regclass);
+
+
+--
+-- Name: id; Type: DEFAULT; Schema: backup; Owner: -
+--
+
+ALTER TABLE ONLY trust_levels ALTER COLUMN id SET DEFAULT nextval('trust_levels_id_seq'::regclass);
+
+
+--
+-- Name: id; Type: DEFAULT; Schema: backup; Owner: -
+--
+
+ALTER TABLE ONLY twitter_user_infos ALTER COLUMN id SET DEFAULT nextval('twitter_user_infos_id_seq'::regclass);
+
+
+--
+-- Name: id; Type: DEFAULT; Schema: backup; Owner: -
+--
+
+ALTER TABLE ONLY uploads ALTER COLUMN id SET DEFAULT nextval('uploads_id_seq'::regclass);
+
+
+--
+-- Name: id; Type: DEFAULT; Schema: backup; Owner: -
+--
+
+ALTER TABLE ONLY user_actions ALTER COLUMN id SET DEFAULT nextval('user_actions_id_seq'::regclass);
+
+
+--
+-- Name: id; Type: DEFAULT; Schema: backup; Owner: -
+--
+
+ALTER TABLE ONLY user_open_ids ALTER COLUMN id SET DEFAULT nextval('user_open_ids_id_seq'::regclass);
+
+
+--
+-- Name: id; Type: DEFAULT; Schema: backup; Owner: -
+--
+
+ALTER TABLE ONLY user_visits ALTER COLUMN id SET DEFAULT nextval('user_visits_id_seq'::regclass);
+
+
+--
+-- Name: id; Type: DEFAULT; Schema: backup; Owner: -
+--
+
+ALTER TABLE ONLY users ALTER COLUMN id SET DEFAULT nextval('users_id_seq'::regclass);
+
+
+--
+-- Name: id; Type: DEFAULT; Schema: backup; Owner: -
+--
+
+ALTER TABLE ONLY versions ALTER COLUMN id SET DEFAULT nextval('versions_id_seq'::regclass);
+
+
+SET search_path = public, pg_catalog;
+
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
@@ -1464,6 +2842,242 @@ ALTER TABLE ONLY users ALTER COLUMN id SET DEFAULT nextval('users_id_seq'::regcl
ALTER TABLE ONLY versions ALTER COLUMN id SET DEFAULT nextval('versions_id_seq'::regclass);
+SET search_path = backup, pg_catalog;
+
+--
+-- Name: actions_pkey; Type: CONSTRAINT; Schema: backup; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY user_actions
+ ADD CONSTRAINT actions_pkey PRIMARY KEY (id);
+
+
+--
+-- Name: categories_pkey; Type: CONSTRAINT; Schema: backup; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY categories
+ ADD CONSTRAINT categories_pkey PRIMARY KEY (id);
+
+
+--
+-- Name: category_featured_users_pkey; Type: CONSTRAINT; Schema: backup; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY category_featured_users
+ ADD CONSTRAINT category_featured_users_pkey PRIMARY KEY (id);
+
+
+--
+-- Name: draft_sequences_pkey; Type: CONSTRAINT; Schema: backup; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY draft_sequences
+ ADD CONSTRAINT draft_sequences_pkey PRIMARY KEY (id);
+
+
+--
+-- Name: drafts_pkey; Type: CONSTRAINT; Schema: backup; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY drafts
+ ADD CONSTRAINT drafts_pkey PRIMARY KEY (id);
+
+
+--
+-- Name: email_logs_pkey; Type: CONSTRAINT; Schema: backup; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY email_logs
+ ADD CONSTRAINT email_logs_pkey PRIMARY KEY (id);
+
+
+--
+-- Name: email_tokens_pkey; Type: CONSTRAINT; Schema: backup; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY email_tokens
+ ADD CONSTRAINT email_tokens_pkey PRIMARY KEY (id);
+
+
+--
+-- Name: facebook_user_infos_pkey; Type: CONSTRAINT; Schema: backup; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY facebook_user_infos
+ ADD CONSTRAINT facebook_user_infos_pkey PRIMARY KEY (id);
+
+
+--
+-- Name: forum_thread_link_clicks_pkey; Type: CONSTRAINT; Schema: backup; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY topic_link_clicks
+ ADD CONSTRAINT forum_thread_link_clicks_pkey PRIMARY KEY (id);
+
+
+--
+-- Name: forum_thread_links_pkey; Type: CONSTRAINT; Schema: backup; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY topic_links
+ ADD CONSTRAINT forum_thread_links_pkey PRIMARY KEY (id);
+
+
+--
+-- Name: forum_threads_pkey; Type: CONSTRAINT; Schema: backup; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY topics
+ ADD CONSTRAINT forum_threads_pkey PRIMARY KEY (id);
+
+
+--
+-- Name: incoming_links_pkey; Type: CONSTRAINT; Schema: backup; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY incoming_links
+ ADD CONSTRAINT incoming_links_pkey PRIMARY KEY (id);
+
+
+--
+-- Name: invites_pkey; Type: CONSTRAINT; Schema: backup; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY invites
+ ADD CONSTRAINT invites_pkey PRIMARY KEY (id);
+
+
+--
+-- Name: notifications_pkey; Type: CONSTRAINT; Schema: backup; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY notifications
+ ADD CONSTRAINT notifications_pkey PRIMARY KEY (id);
+
+
+--
+-- Name: onebox_renders_pkey; Type: CONSTRAINT; Schema: backup; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY onebox_renders
+ ADD CONSTRAINT onebox_renders_pkey PRIMARY KEY (id);
+
+
+--
+-- Name: post_action_types_pkey; Type: CONSTRAINT; Schema: backup; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY post_action_types
+ ADD CONSTRAINT post_action_types_pkey PRIMARY KEY (id);
+
+
+--
+-- Name: post_actions_pkey; Type: CONSTRAINT; Schema: backup; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY post_actions
+ ADD CONSTRAINT post_actions_pkey PRIMARY KEY (id);
+
+
+--
+-- Name: posts_pkey; Type: CONSTRAINT; Schema: backup; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY posts
+ ADD CONSTRAINT posts_pkey PRIMARY KEY (id);
+
+
+--
+-- Name: site_customizations_pkey; Type: CONSTRAINT; Schema: backup; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY site_customizations
+ ADD CONSTRAINT site_customizations_pkey PRIMARY KEY (id);
+
+
+--
+-- Name: site_settings_pkey; Type: CONSTRAINT; Schema: backup; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY site_settings
+ ADD CONSTRAINT site_settings_pkey PRIMARY KEY (id);
+
+
+--
+-- Name: topic_allowed_users_pkey; Type: CONSTRAINT; Schema: backup; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY topic_allowed_users
+ ADD CONSTRAINT topic_allowed_users_pkey PRIMARY KEY (id);
+
+
+--
+-- Name: topic_invites_pkey; Type: CONSTRAINT; Schema: backup; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY topic_invites
+ ADD CONSTRAINT topic_invites_pkey PRIMARY KEY (id);
+
+
+--
+-- Name: trust_levels_pkey; Type: CONSTRAINT; Schema: backup; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY trust_levels
+ ADD CONSTRAINT trust_levels_pkey PRIMARY KEY (id);
+
+
+--
+-- Name: twitter_user_infos_pkey; Type: CONSTRAINT; Schema: backup; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY twitter_user_infos
+ ADD CONSTRAINT twitter_user_infos_pkey PRIMARY KEY (id);
+
+
+--
+-- Name: uploads_pkey; Type: CONSTRAINT; Schema: backup; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY uploads
+ ADD CONSTRAINT uploads_pkey PRIMARY KEY (id);
+
+
+--
+-- Name: user_open_ids_pkey; Type: CONSTRAINT; Schema: backup; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY user_open_ids
+ ADD CONSTRAINT user_open_ids_pkey PRIMARY KEY (id);
+
+
+--
+-- Name: user_visits_pkey; Type: CONSTRAINT; Schema: backup; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY user_visits
+ ADD CONSTRAINT user_visits_pkey PRIMARY KEY (id);
+
+
+--
+-- Name: users_pkey; Type: CONSTRAINT; Schema: backup; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY users
+ ADD CONSTRAINT users_pkey PRIMARY KEY (id);
+
+
+--
+-- Name: versions_pkey; Type: CONSTRAINT; Schema: backup; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY versions
+ ADD CONSTRAINT versions_pkey PRIMARY KEY (id);
+
+
+SET search_path = public, pg_catalog;
+
--
-- Name: actions_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
@@ -1720,6 +3334,430 @@ ALTER TABLE ONLY versions
ADD CONSTRAINT versions_pkey PRIMARY KEY (id);
+SET search_path = backup, pg_catalog;
+
+--
+-- Name: cat_featured_threads; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE UNIQUE INDEX cat_featured_threads ON category_featured_topics USING btree (category_id, topic_id);
+
+
+--
+-- Name: idx_search_thread; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_thread ON topics USING gin (to_tsvector('english'::regconfig, (title)::text));
+
+
+--
+-- Name: idx_search_user; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_user ON users USING gin (to_tsvector('english'::regconfig, (username)::text));
+
+
+--
+-- Name: idx_unique_actions; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE UNIQUE INDEX idx_unique_actions ON post_actions USING btree (user_id, post_action_type_id, post_id) WHERE (deleted_at IS NULL);
+
+
+--
+-- Name: idx_unique_rows; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE UNIQUE INDEX idx_unique_rows ON user_actions USING btree (action_type, user_id, target_topic_id, target_post_id, acting_user_id);
+
+
+--
+-- Name: incoming_index; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE INDEX incoming_index ON incoming_links USING btree (topic_id, post_number);
+
+
+--
+-- Name: index_actions_on_acting_user_id; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE INDEX index_actions_on_acting_user_id ON user_actions USING btree (acting_user_id);
+
+
+--
+-- Name: index_actions_on_user_id_and_action_type; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE INDEX index_actions_on_user_id_and_action_type ON user_actions USING btree (user_id, action_type);
+
+
+--
+-- Name: index_categories_on_forum_thread_count; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE INDEX index_categories_on_forum_thread_count ON categories USING btree (topic_count);
+
+
+--
+-- Name: index_categories_on_name; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE UNIQUE INDEX index_categories_on_name ON categories USING btree (name);
+
+
+--
+-- Name: index_category_featured_users_on_category_id_and_user_id; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE UNIQUE INDEX index_category_featured_users_on_category_id_and_user_id ON category_featured_users USING btree (category_id, user_id);
+
+
+--
+-- Name: index_draft_sequences_on_user_id_and_draft_key; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE UNIQUE INDEX index_draft_sequences_on_user_id_and_draft_key ON draft_sequences USING btree (user_id, draft_key);
+
+
+--
+-- Name: index_drafts_on_user_id_and_draft_key; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE INDEX index_drafts_on_user_id_and_draft_key ON drafts USING btree (user_id, draft_key);
+
+
+--
+-- Name: index_email_logs_on_created_at; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE INDEX index_email_logs_on_created_at ON email_logs USING btree (created_at DESC);
+
+
+--
+-- Name: index_email_logs_on_user_id_and_created_at; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE INDEX index_email_logs_on_user_id_and_created_at ON email_logs USING btree (user_id, created_at DESC);
+
+
+--
+-- Name: index_email_tokens_on_token; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE UNIQUE INDEX index_email_tokens_on_token ON email_tokens USING btree (token);
+
+
+--
+-- Name: index_facebook_user_infos_on_facebook_user_id; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE UNIQUE INDEX index_facebook_user_infos_on_facebook_user_id ON facebook_user_infos USING btree (facebook_user_id);
+
+
+--
+-- Name: index_facebook_user_infos_on_user_id; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE UNIQUE INDEX index_facebook_user_infos_on_user_id ON facebook_user_infos USING btree (user_id);
+
+
+--
+-- Name: index_forum_thread_link_clicks_on_forum_thread_link_id; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE INDEX index_forum_thread_link_clicks_on_forum_thread_link_id ON topic_link_clicks USING btree (topic_link_id);
+
+
+--
+-- Name: index_forum_thread_links_on_forum_thread_id; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE INDEX index_forum_thread_links_on_forum_thread_id ON topic_links USING btree (topic_id);
+
+
+--
+-- Name: index_forum_thread_links_on_forum_thread_id_and_post_id_and_url; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE UNIQUE INDEX index_forum_thread_links_on_forum_thread_id_and_post_id_and_url ON topic_links USING btree (topic_id, post_id, url);
+
+
+--
+-- Name: index_forum_thread_users_on_forum_thread_id_and_user_id; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE UNIQUE INDEX index_forum_thread_users_on_forum_thread_id_and_user_id ON topic_users USING btree (topic_id, user_id);
+
+
+--
+-- Name: index_forum_threads_on_bumped_at; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE INDEX index_forum_threads_on_bumped_at ON topics USING btree (bumped_at DESC);
+
+
+--
+-- Name: index_forum_threads_on_category_id_and_sub_tag_and_bumped_at; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE INDEX index_forum_threads_on_category_id_and_sub_tag_and_bumped_at ON topics USING btree (category_id, sub_tag, bumped_at);
+
+
+--
+-- Name: index_invites_on_email_and_invited_by_id; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE UNIQUE INDEX index_invites_on_email_and_invited_by_id ON invites USING btree (email, invited_by_id);
+
+
+--
+-- Name: index_invites_on_invite_key; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE UNIQUE INDEX index_invites_on_invite_key ON invites USING btree (invite_key);
+
+
+--
+-- Name: index_notifications_on_post_action_id; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE INDEX index_notifications_on_post_action_id ON notifications USING btree (post_action_id);
+
+
+--
+-- Name: index_notifications_on_user_id_and_created_at; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE INDEX index_notifications_on_user_id_and_created_at ON notifications USING btree (user_id, created_at);
+
+
+--
+-- Name: index_onebox_renders_on_url; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE UNIQUE INDEX index_onebox_renders_on_url ON onebox_renders USING btree (url);
+
+
+--
+-- Name: index_post_actions_on_post_id; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE INDEX index_post_actions_on_post_id ON post_actions USING btree (post_id);
+
+
+--
+-- Name: index_post_onebox_renders_on_post_id_and_onebox_render_id; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE UNIQUE INDEX index_post_onebox_renders_on_post_id_and_onebox_render_id ON post_onebox_renders USING btree (post_id, onebox_render_id);
+
+
+--
+-- Name: index_post_replies_on_post_id_and_reply_id; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE UNIQUE INDEX index_post_replies_on_post_id_and_reply_id ON post_replies USING btree (post_id, reply_id);
+
+
+--
+-- Name: index_posts_on_reply_to_post_number; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE INDEX index_posts_on_reply_to_post_number ON posts USING btree (reply_to_post_number);
+
+
+--
+-- Name: index_posts_on_topic_id_and_post_number; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE UNIQUE INDEX index_posts_on_topic_id_and_post_number ON posts USING btree (topic_id, post_number);
+
+
+--
+-- Name: index_site_customizations_on_key; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE INDEX index_site_customizations_on_key ON site_customizations USING btree (key);
+
+
+--
+-- Name: index_topic_allowed_users_on_topic_id_and_user_id; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE UNIQUE INDEX index_topic_allowed_users_on_topic_id_and_user_id ON topic_allowed_users USING btree (topic_id, user_id);
+
+
+--
+-- Name: index_topic_allowed_users_on_user_id_and_topic_id; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE UNIQUE INDEX index_topic_allowed_users_on_user_id_and_topic_id ON topic_allowed_users USING btree (user_id, topic_id);
+
+
+--
+-- Name: index_topic_invites_on_invite_id; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE INDEX index_topic_invites_on_invite_id ON topic_invites USING btree (invite_id);
+
+
+--
+-- Name: index_topic_invites_on_topic_id_and_invite_id; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE UNIQUE INDEX index_topic_invites_on_topic_id_and_invite_id ON topic_invites USING btree (topic_id, invite_id);
+
+
+--
+-- Name: index_twitter_user_infos_on_twitter_user_id; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE UNIQUE INDEX index_twitter_user_infos_on_twitter_user_id ON twitter_user_infos USING btree (twitter_user_id);
+
+
+--
+-- Name: index_twitter_user_infos_on_user_id; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE UNIQUE INDEX index_twitter_user_infos_on_user_id ON twitter_user_infos USING btree (user_id);
+
+
+--
+-- Name: index_uploads_on_forum_thread_id; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE INDEX index_uploads_on_forum_thread_id ON uploads USING btree (topic_id);
+
+
+--
+-- Name: index_uploads_on_user_id; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE INDEX index_uploads_on_user_id ON uploads USING btree (user_id);
+
+
+--
+-- Name: index_user_open_ids_on_url; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE INDEX index_user_open_ids_on_url ON user_open_ids USING btree (url);
+
+
+--
+-- Name: index_user_visits_on_user_id_and_visited_at; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE UNIQUE INDEX index_user_visits_on_user_id_and_visited_at ON user_visits USING btree (user_id, visited_at);
+
+
+--
+-- Name: index_users_on_auth_token; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE INDEX index_users_on_auth_token ON users USING btree (auth_token);
+
+
+--
+-- Name: index_users_on_email; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE UNIQUE INDEX index_users_on_email ON users USING btree (email);
+
+
+--
+-- Name: index_users_on_last_posted_at; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE INDEX index_users_on_last_posted_at ON users USING btree (last_posted_at);
+
+
+--
+-- Name: index_users_on_username; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE UNIQUE INDEX index_users_on_username ON users USING btree (username);
+
+
+--
+-- Name: index_users_on_username_lower; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE UNIQUE INDEX index_users_on_username_lower ON users USING btree (username_lower);
+
+
+--
+-- Name: index_versions_on_created_at; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE INDEX index_versions_on_created_at ON versions USING btree (created_at);
+
+
+--
+-- Name: index_versions_on_number; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE INDEX index_versions_on_number ON versions USING btree (number);
+
+
+--
+-- Name: index_versions_on_tag; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE INDEX index_versions_on_tag ON versions USING btree (tag);
+
+
+--
+-- Name: index_versions_on_user_id_and_user_type; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE INDEX index_versions_on_user_id_and_user_type ON versions USING btree (user_id, user_type);
+
+
+--
+-- Name: index_versions_on_user_name; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE INDEX index_versions_on_user_name ON versions USING btree (user_name);
+
+
+--
+-- Name: index_versions_on_versioned_id_and_versioned_type; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE INDEX index_versions_on_versioned_id_and_versioned_type ON versions USING btree (versioned_id, versioned_type);
+
+
+--
+-- Name: index_views_on_parent_id_and_parent_type; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE INDEX index_views_on_parent_id_and_parent_type ON views USING btree (parent_id, parent_type);
+
+
+--
+-- Name: post_timings_summary; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE INDEX post_timings_summary ON post_timings USING btree (topic_id, post_number);
+
+
+--
+-- Name: post_timings_unique; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE UNIQUE INDEX post_timings_unique ON post_timings USING btree (topic_id, post_number, user_id);
+
+
+--
+-- Name: unique_views; Type: INDEX; Schema: backup; Owner: -; Tablespace:
+--
+
+CREATE UNIQUE INDEX unique_views ON views USING btree (parent_id, parent_type, ip, viewed_at);
+
+
+SET search_path = public, pg_catalog;
+
--
-- Name: cat_featured_threads; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
diff --git a/lib/archetype.rb b/lib/archetype.rb
index 22cdba0af..caa8cc95b 100644
--- a/lib/archetype.rb
+++ b/lib/archetype.rb
@@ -5,16 +5,16 @@ class Archetype
def initialize(id, options)
@id = id
- @options = options
+ @options = options
end
def attributes
- {'id' => @id,
+ {'id' => @id,
'options' => @options}
end
def self.default
- 'regular'
+ 'regular'
end
def self.poll
diff --git a/lib/canonical_url.rb b/lib/canonical_url.rb
index 7322b70af..f00b2764c 100644
--- a/lib/canonical_url.rb
+++ b/lib/canonical_url.rb
@@ -22,7 +22,7 @@ end
# https://github.com/mbleigh/canonical-url/blob/master/lib/canonical_url.rb
# Copyright (c) 2009 Michael Bleigh and Intridea, Inc.
-#
+#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
@@ -30,14 +30,14 @@ end
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
-#
+#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.#
\ No newline at end of file
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.#
diff --git a/lib/content_buffer.rb b/lib/content_buffer.rb
index d7f525dac..f448b7ce9 100644
--- a/lib/content_buffer.rb
+++ b/lib/content_buffer.rb
@@ -15,12 +15,12 @@ class ContentBuffer
text = transform[:text]
if transform[:operation] == :delete
-
- # fix first line
-
- l = @lines[start_row]
+
+ # fix first line
+
+ l = @lines[start_row]
l = l[0...start_col]
-
+
if (finish_row == start_row)
l << @lines[start_row][finish_col..-1]
@lines[start_row] = l
@@ -29,21 +29,21 @@ class ContentBuffer
@lines[start_row] = l
- # remove middle lines
- (finish_row - start_row).times do
+ # remove middle lines
+ (finish_row - start_row).times do
l = @lines.delete_at start_row + 1
end
- # fix last line
+ # fix last line
@lines[start_row] << @lines[finish_row][finish_col-1..-1]
end
if transform[:operation] == :insert
-
+
@lines[start_row].insert(start_col, text)
-
+
split = @lines[start_row].split("\n")
-
+
if split.length > 1
@lines[start_row] = split[0]
i = 1
diff --git a/lib/cooked_post_processor.rb b/lib/cooked_post_processor.rb
index 750cf202b..94ccd5e92 100644
--- a/lib/cooked_post_processor.rb
+++ b/lib/cooked_post_processor.rb
@@ -19,23 +19,23 @@ class CookedPostProcessor
end
# Bake onebox content into the post
- def post_process_oneboxes
+ def post_process_oneboxes
args = {post_id: @post.id}
args[:invalidate_oneboxes] = true if @opts[:invalidate_oneboxes]
Oneboxer.each_onebox_link(@doc) do |url, element|
onebox = Oneboxer.onebox(url, args)
if onebox
- element.swap onebox
+ element.swap onebox
@dirty = true
end
- end
+ end
end
- # First let's consider the images
- def post_process_images
+ # First let's consider the images
+ def post_process_images
images = @doc.search("img")
- return unless images.present?
+ return unless images.present?
# Extract the first image from the first post and use it as the 'topic image'
if @post.post_number == 1
@@ -49,8 +49,8 @@ class CookedPostProcessor
if src.present? && (img['width'].blank? || img['height'].blank?)
- w,h =
- get_size_from_image_sizes(src, @opts[:image_sizes]) ||
+ w,h =
+ get_size_from_image_sizes(src, @opts[:image_sizes]) ||
image_dimensions(src)
if w && h
@@ -59,13 +59,13 @@ class CookedPostProcessor
@dirty = true
end
end
-
- if src.present?
+
+ if src.present?
if src != img['src']
img['src'] = src
@dirty = true
end
- convert_to_link!(img)
+ convert_to_link!(img)
img.set_attribute('src', optimize_image(src))
end
@@ -75,7 +75,7 @@ class CookedPostProcessor
def optimize_image(src)
# uri = get_image_uri(src)
# uri.open(read_timeout: 20) do |f|
- #
+ #
# end
src
@@ -99,7 +99,7 @@ class CookedPostProcessor
parent = parent.parent
end
- # not a hyperlink so we can apply
+ # not a hyperlink so we can apply
a = Nokogiri::XML::Node.new "a", @doc
img.add_next_sibling(a)
a["href"] = src
@@ -143,7 +143,7 @@ class CookedPostProcessor
# Retrieve the image dimensions for a url
def image_dimensions(url)
- uri = get_image_uri(url)
+ uri = get_image_uri(url)
return nil unless uri
w, h = get_size(url)
ImageSizer.resize(w, h) if w && h
diff --git a/lib/current_user.rb b/lib/current_user.rb
index 943ad1618..d31119b99 100644
--- a/lib/current_user.rb
+++ b/lib/current_user.rb
@@ -7,7 +7,7 @@ module CurrentUser
def self.lookup_from_auth_token(auth_token)
if auth_token && auth_token.length == 32
- User.where(auth_token: auth_token).first
+ User.where(auth_token: auth_token).first
end
end
@@ -28,12 +28,12 @@ module CurrentUser
return @current_user if @current_user || @not_logged_in
if session[:current_user_id].blank?
- # maybe we have a cookie?
+ # maybe we have a cookie?
@current_user = CurrentUser.lookup_from_auth_token(cookies["_t"])
session[:current_user_id] = @current_user.id if @current_user
else
@current_user ||= User.where(id: session[:current_user_id]).first
-
+
# I have flip flopped on this (sam), if our permanent cookie
# conflicts with our current session assume session is bust
# kill it
@@ -43,13 +43,13 @@ module CurrentUser
end
- if @current_user && @current_user.is_banned?
+ if @current_user && @current_user.is_banned?
@current_user = nil
end
@not_logged_in = session[:current_user_id].blank?
if @current_user
- @current_user.update_last_seen!
+ @current_user.update_last_seen!
@current_user.update_ip_address!(request.remote_ip)
end
@current_user
diff --git a/lib/diff_engine.rb b/lib/diff_engine.rb
index 37bbeea39..7c9208fa4 100644
--- a/lib/diff_engine.rb
+++ b/lib/diff_engine.rb
@@ -1,11 +1,11 @@
-# This class is used to generate diffs, it will be consumed by the UI on
+# This class is used to generate diffs, it will be consumed by the UI on
# on the client the displays diffs.
#
-# Ruby has the diff/lcs engine that can do some of the work, the devil
+# Ruby has the diff/lcs engine that can do some of the work, the devil
# is in the details
class DiffEngine
-
+
# generate an html friendly diff similar to the way Stack Exchange generate
# html diffs
#
diff --git a/lib/discourse.rb b/lib/discourse.rb
index 58349b039..1021f49f8 100644
--- a/lib/discourse.rb
+++ b/lib/discourse.rb
@@ -1,6 +1,6 @@
module Discourse
- # When they try to do something they should be logged in for
+ # When they try to do something they should be logged in for
class NotLoggedIn < Exception; end
# When the input is somehow bad
@@ -22,13 +22,13 @@ module Discourse
protocol = "http"
protocol = "https" if SiteSetting.use_ssl?
if SiteSetting.force_hostname.present?
- result = "#{protocol}://#{SiteSetting.force_hostname}"
+ result = "#{protocol}://#{SiteSetting.force_hostname}"
else
- result = "#{protocol}://#{current_hostname}"
+ result = "#{protocol}://#{current_hostname}"
end
result << ":#{SiteSetting.port}" if SiteSetting.port.present? && SiteSetting.port.to_i > 0
result
- end
+ end
def self.enable_maintenance_mode
$redis.set maintenance_mode_key, 1
@@ -45,7 +45,7 @@ module Discourse
end
def self.git_version
- return $git_version if $git_version
+ return $git_version if $git_version
f = Rails.root.to_s + "/config/version"
require f if File.exists?("#{f}.rb")
diff --git a/lib/discourse_observer.rb b/lib/discourse_observer.rb
index eea9b0399..eebdba73c 100644
--- a/lib/discourse_observer.rb
+++ b/lib/discourse_observer.rb
@@ -10,9 +10,9 @@ class DiscourseObserver < ActiveRecord::Observer
def after_create_delegator(model)
observer_method = :"after_create_#{model.class.name.underscore}"
- send(observer_method, model) if respond_to?(observer_method)
+ send(observer_method, model) if respond_to?(observer_method)
end
-
+
def after_destroy_delegator(model)
observer_method = :"after_destroy_#{model.class.name.underscore}"
send(observer_method, model) if respond_to?(observer_method)
@@ -25,7 +25,7 @@ if Rails.env.test?
# In test mode, call the delegator right away
class DiscourseObserver < ActiveRecord::Observer
alias_method :after_create, :after_create_delegator
- alias_method :after_destroy, :after_destroy_delegator
+ alias_method :after_destroy, :after_destroy_delegator
end
else
@@ -40,7 +40,7 @@ else
if model.send(:transaction_include_action?, :destroy)
after_destroy_delegator(model)
end
-
+
end
end
diff --git a/lib/discourse_plugin_registry.rb b/lib/discourse_plugin_registry.rb
index 8f7abca4c..bf5fa95fa 100644
--- a/lib/discourse_plugin_registry.rb
+++ b/lib/discourse_plugin_registry.rb
@@ -14,11 +14,11 @@ class DiscoursePluginRegistry
def self.stylesheets
@stylesheets ||= Set.new
end
-
+
def self.javascripts
@javascripts ||= Set.new
end
-
+
def self.server_side_javascripts
@server_side_javascripts ||= Set.new
end
@@ -56,7 +56,7 @@ class DiscoursePluginRegistry
self.javascripts = nil
end
- def self.setup(plugin_class)
+ def self.setup(plugin_class)
registry = DiscoursePluginRegistry.new
plugin = plugin_class.new(registry)
plugin.setup
diff --git a/lib/discourse_redis.rb b/lib/discourse_redis.rb
index c6f824c04..e6abbb9ca 100644
--- a/lib/discourse_redis.rb
+++ b/lib/discourse_redis.rb
@@ -2,17 +2,17 @@
# A wrapper around redis that namespaces keys with the current site id
#
class DiscourseRedis
-
+
def initialize
@config = YAML::load(File.open("#{Rails.root}/config/redis.yml"))[Rails.env]
redis_opts = {:host => @config['host'], :port => @config['port'], :db => @config['db']}
- @redis = Redis.new(redis_opts)
+ @redis = Redis.new(redis_opts)
end
# prefix the key with the namespace
def method_missing(meth, *args, &block)
if @redis.respond_to?(meth)
- @redis.send(meth, *args, &block)
+ @redis.send(meth, *args, &block)
else
super
end
diff --git a/lib/distributed_hash.rb b/lib/distributed_hash.rb
index b4938d5f5..4d0cf658c 100644
--- a/lib/distributed_hash.rb
+++ b/lib/distributed_hash.rb
@@ -1,4 +1,4 @@
-# Like a hash, just does its best to stay in sync accross the farm
+# Like a hash, just does its best to stay in sync accross the farm
#
# Redis backed with an allowance for a certain amount of latency
@@ -8,8 +8,8 @@ class DistributedHash
@lock = Mutex.new
def self.ensure_subscribed
- @lock.synchronize do
- unless @subscribed
+ @lock.synchronize do
+ unless @subscribed
end
@subscribed = true
diff --git a/lib/email.rb b/lib/email.rb
index 08c12a42f..8d1c956e9 100644
--- a/lib/email.rb
+++ b/lib/email.rb
@@ -1,12 +1,12 @@
require 'mail'
module Email
-
- def self.is_valid?(email)
+
+ def self.is_valid?(email)
parser = Mail::RFC2822Parser.new
parser.root = :addr_spec
result = parser.parse(email)
-
+
# Don't allow for a TLD by itself list (sam@localhost)
# The Grammar is: (local_part "@" domain) / local_part ... need to discard latter
result && result.respond_to?(:domain) && result.domain.dot_atom_text.elements.size > 1
diff --git a/lib/email_builder.rb b/lib/email_builder.rb
index 660adc7d0..c2909f1f6 100644
--- a/lib/email_builder.rb
+++ b/lib/email_builder.rb
@@ -13,8 +13,8 @@ module EmailBuilder
body << "\n"
body << I18n.t("unsubscribe_link", params)
end
-
+
mail to: to, subject: I18n.t("#{email_key}.subject_template", params), body: body
end
-end
\ No newline at end of file
+end
diff --git a/lib/email_sender.rb b/lib/email_sender.rb
index b24bcbf2f..2265a13c7 100644
--- a/lib/email_sender.rb
+++ b/lib/email_sender.rb
@@ -1,6 +1,6 @@
#
# A helper class to send an email. It will also handle a nil message, which it considers
-# to be "do nothing". This is because some Mailers will decide not to do work for some
+# to be "do nothing". This is because some Mailers will decide not to do work for some
# reason. For example, emailing a user too frequently. A nil to address is also considered
# "do nothing"
#
diff --git a/lib/freedom_patches/active_record_base.rb b/lib/freedom_patches/active_record_base.rb
index 1d0e0c3d8..89d5d7eba 100644
--- a/lib/freedom_patches/active_record_base.rb
+++ b/lib/freedom_patches/active_record_base.rb
@@ -1,4 +1,4 @@
-class ActiveRecord::Base
+class ActiveRecord::Base
# Execute SQL manually
def self.exec_sql(*args)
@@ -8,7 +8,7 @@ class ActiveRecord::Base
end
def self.exec_sql_row_count(*args)
- exec_sql(*args).cmd_tuples
+ exec_sql(*args).cmd_tuples
end
def exec_sql(*args)
@@ -39,4 +39,4 @@ class ActiveRecord::Base
exec_sql(*args).cmd_tuples
end
-end
\ No newline at end of file
+end
diff --git a/lib/guardian.rb b/lib/guardian.rb
index 7577afaf2..b7f4cc5ed 100644
--- a/lib/guardian.rb
+++ b/lib/guardian.rb
@@ -2,7 +2,7 @@
class Guardian
attr_reader :user
-
+
def initialize(user=nil)
@user = user
end
@@ -19,10 +19,10 @@ class Guardian
def can_see?(obj)
return false if obj.blank?
- see_method = :"can_see_#{obj.class.name.underscore}?"
+ see_method = :"can_see_#{obj.class.name.underscore}?"
return send(see_method, obj) if respond_to?(see_method)
- return true
+ return true
end
# Can the user edit the obj
@@ -30,7 +30,7 @@ class Guardian
return false if obj.blank?
return false if @user.blank?
- edit_method = :"can_edit_#{obj.class.name.underscore}?"
+ edit_method = :"can_edit_#{obj.class.name.underscore}?"
return send(edit_method, obj) if respond_to?(edit_method)
true
@@ -39,7 +39,7 @@ class Guardian
# Can we delete the object
def can_delete?(obj)
return false if obj.blank?
- return false if @user.blank?
+ return false if @user.blank?
delete_method = :"can_delete_#{obj.class.name.underscore}?"
return send(delete_method, obj) if respond_to?(delete_method)
@@ -52,7 +52,7 @@ class Guardian
return false if @user.blank?
@user.has_trust_level?(:moderator)
end
- alias :can_move_posts? :can_moderate?
+ alias :can_move_posts? :can_moderate?
alias :can_see_flags? :can_moderate?
# Can the user create a topic in the forum
@@ -70,12 +70,12 @@ class Guardian
return false unless can_see?(parent)
target << "_on_#{parent.class.name.underscore}"
end
- create_method = :"can_create_#{target}?"
+ create_method = :"can_create_#{target}?"
return send(create_method, parent) if respond_to?(create_method)
true
- end
+ end
# Can we impersonate this user?
def can_impersonate?(target)
@@ -194,7 +194,7 @@ class Guardian
return false unless is_admin?
return false if user.created_at < 7.days.ago
- true
+ true
end
# Support for ensure_{blah}! methods.
@@ -203,7 +203,7 @@ class Guardian
can_method = :"#{Regexp.last_match[1]}?"
if respond_to?(can_method)
- raise Discourse::InvalidAccess.new("#{can_method} failed") unless send(can_method, *args, &block)
+ raise Discourse::InvalidAccess.new("#{can_method} failed") unless send(can_method, *args, &block)
return
end
end
@@ -254,7 +254,7 @@ class Guardian
def can_delete_post?(post)
# Can't delete the first post
return false if post.post_number == 1
-
+
# You can delete your own posts
return !post.user_deleted? if post.user == @user
@@ -263,23 +263,23 @@ class Guardian
# Recovery Method
def can_recover_post?(post)
- return false if @user.blank?
+ return false if @user.blank?
@user.has_trust_level?(:moderator)
end
def can_delete_category?(category)
return false unless @user.has_trust_level?(:moderator)
- return category.topic_count == 0
+ return category.topic_count == 0
end
def can_delete_topic?(topic)
return false unless @user.has_trust_level?(:moderator)
- return false if Category.exists?(topic_id: topic.id)
+ return false if Category.exists?(topic_id: topic.id)
true
end
def can_delete_post_action?(post_action)
-
+
# You can only undo your own actions
return false unless post_action.user == @user
@@ -291,12 +291,12 @@ class Guardian
return false unless User === target_user
return false if @user.blank?
- # Can't send message to yourself
+ # Can't send message to yourself
return false if @user.id == target_user.id
# Have to be a basic level at least
return false unless @user.has_trust_level?(:basic)
-
+
SiteSetting.enable_private_messages
end
@@ -321,10 +321,10 @@ class Guardian
post_can_act?(post,:vote, opts)
end
- # Can the user act on the post in a particular way.
+ # Can the user act on the post in a particular way.
# taken_actions = the list of actions the user has already taken
def post_can_act?(post, action_key, opts={})
- return false if @user.blank?
+ return false if @user.blank?
return false if post.blank?
return false if post.topic.archived?
@@ -335,16 +335,16 @@ class Guardian
return false unless @user.has_trust_level?(:basic)
if taken
- return false unless (taken & PostActionType.FlagTypes).empty?
+ return false unless (taken & PostActionType.FlagTypes).empty?
end
- else
- return false if taken && taken.include?(PostActionType.Types[action_key])
+ else
+ return false if taken && taken.include?(PostActionType.Types[action_key])
end
case action_key
when :like
- return false if post.user == @user
- when :vote then
+ return false if post.user == @user
+ when :vote then
return false if opts[:voted_in_topic] and post.topic.has_meta_data_boolean?(:single_vote)
end
diff --git a/lib/headless-ember.js b/lib/headless-ember.js
index 9bdf72d75..28ad8af25 100644
--- a/lib/headless-ember.js
+++ b/lib/headless-ember.js
@@ -16,7 +16,7 @@ var jQuery = window.jQuery = function() { return jQuery; };
jQuery.ready = function() { return jQuery; };
jQuery.inArray = function() { return jQuery; };
jQuery.event = {
- fixHooks: function() {
+ fixHooks: function() {
}
};
@@ -26,4 +26,4 @@ var $ = jQuery;
// Ember
function precompileEmberHandlebars(string) {
return Ember.Handlebars.precompile(string).toString();
-}
\ No newline at end of file
+}
diff --git a/lib/image_optimizer.rb b/lib/image_optimizer.rb
index 4373e56f0..709bf68f3 100644
--- a/lib/image_optimizer.rb
+++ b/lib/image_optimizer.rb
@@ -1,47 +1,47 @@
# This class is used to download and optimize images.
#
-# I have not had a chance to implement me, and will not for about 3 weeks.
-# If you are looking for a small project this simple API would be a good stint.
+# I have not had a chance to implement me, and will not for about 3 weeks.
+# If you are looking for a small project this simple API would be a good stint.
#
-# Implement the following methods. With tests, the tests are a HUGE PITA cause
-# network, disk and external dependencies are involved.
+# Implement the following methods. With tests, the tests are a HUGE PITA cause
+# network, disk and external dependencies are involved.
class ImageOptimizer
attr_accessor :url, :root_dir
- # url is a url of an image ex:
+ # url is a url of an image ex:
# 'http://site.com/image.png'
# '/uploads/site/image.png'
#
- # root_dir is the path where we
+ # root_dir is the path where we
# store optimized images
def initialize(opts = {})
@url = opts[:url]
@root_dir = opts[:root_dir]
end
- # attempt to refresh the original image, if refreshed
+ # attempt to refresh the original image, if refreshed
# remove old downsized copies
- def refresh_local!
- end
-
+ def refresh_local!
+ end
+
# clear all local copies of the images
def clear_local!
end
-
+
# yeild a list of relative paths to local images cached
def each_local
end
-
- # return the path of an optimized image,
- # if already cached return cached, else download and cache
- # at the original size.
+
+ # return the path of an optimized image,
+ # if already cached return cached, else download and cache
+ # at the original size.
# if size is specified return a resized image
- # if height or width are nil maintain aspect ratio
- #
- # Optimised image is the "most efficient" storage for an image
+ # if height or width are nil maintain aspect ratio
+ #
+ # Optimised image is the "most efficient" storage for an image
# at the basic level it runs through image_optim https://github.com/toy/image_optim
- # it also has a failsafe that converts jpg to png or the opposite. if jpg size is 1.5*
- # as efficient as png it flips formats.
+ # it also has a failsafe that converts jpg to png or the opposite. if jpg size is 1.5*
+ # as efficient as png it flips formats.
def optimized_image_path(width=nil, height=nil)
end
diff --git a/lib/image_sizer.rb b/lib/image_sizer.rb
index 9063ae484..8b3e7d5bf 100644
--- a/lib/image_sizer.rb
+++ b/lib/image_sizer.rb
@@ -1,10 +1,10 @@
module ImageSizer
# Resize an image to the aspect ratio we want
- def self.resize(width, height)
+ def self.resize(width, height)
max_width = SiteSetting.max_image_width.to_f
return nil if width.blank? or height.blank?
-
+
w = width.to_f
h = height.to_f
diff --git a/lib/imgur.rb b/lib/imgur.rb
index 5de9e8cd7..48df3b01f 100644
--- a/lib/imgur.rb
+++ b/lib/imgur.rb
@@ -15,7 +15,7 @@ module Imgur
# Resize the image
json['image']['width'], json['image']['height'] = ImageSizer.resize(json['image']['width'], json['image']['height'])
- {url: json['links']['original'],
+ {url: json['links']['original'],
filesize: json['image']['size'],
width: json['image']['width'],
height: json['image']['height']}
diff --git a/lib/import/adapter/merge_mute_options_on_topic_users.rb b/lib/import/adapter/merge_mute_options_on_topic_users.rb
index dd160fa3d..ea109380e 100644
--- a/lib/import/adapter/merge_mute_options_on_topic_users.rb
+++ b/lib/import/adapter/merge_mute_options_on_topic_users.rb
@@ -5,7 +5,7 @@ module Import
register version: '20130115012140', tables: [:topic_users]
def up_column_names(table_name, column_names)
- # rename_column :topic_users, :notifications, :notification_level
+ # rename_column :topic_users, :notifications, :notification_level
# remove_column :topic_users, :muted_at
if table_name.to_sym == :topic_users
column_names.map {|col| col == 'notifications' ? 'notification_level' : col}.reject {|col| col == 'muted_at'}
@@ -25,4 +25,4 @@ module Import
end
end
-end
\ No newline at end of file
+end
diff --git a/lib/jobs.rb b/lib/jobs.rb
index f9a44ef92..103c9f1fa 100644
--- a/lib/jobs.rb
+++ b/lib/jobs.rb
@@ -17,7 +17,7 @@ module Jobs
def perform(opts={})
opts = opts.with_indifferent_access
-
+
if opts.delete(:sync_exec)
if opts.has_key?(:current_site_id) and opts[:current_site_id] != RailsMultisite::ConnectionManagement.current_db
raise ArgumentError.new("You can't connect to another database when executing a job synchronously.")
@@ -28,9 +28,9 @@ module Jobs
dbs =
- if opts[:current_site_id]
+ if opts[:current_site_id]
[opts[:current_site_id]]
- else
+ else
RailsMultisite::ConnectionManagement.all_dbs
end
diff --git a/lib/jobs/calculate_avg_time.rb b/lib/jobs/calculate_avg_time.rb
index 10c9918c7..a8338fd0a 100644
--- a/lib/jobs/calculate_avg_time.rb
+++ b/lib/jobs/calculate_avg_time.rb
@@ -3,10 +3,10 @@ module Jobs
class CalculateAvgTime < Jobs::Base
def execute(args)
- Post.calculate_avg_time
+ Post.calculate_avg_time
Topic.calculate_avg_time
end
end
-end
\ No newline at end of file
+end
diff --git a/lib/jobs/enqueue_digest_emails.rb b/lib/jobs/enqueue_digest_emails.rb
index 2c2636160..accb97875 100644
--- a/lib/jobs/enqueue_digest_emails.rb
+++ b/lib/jobs/enqueue_digest_emails.rb
@@ -6,13 +6,13 @@ module Jobs
def execute(args)
target_users.each do |u|
Jobs.enqueue(:user_email, type: :digest, user_id: u.id)
- end
+ end
end
def target_users
# Users who want to receive emails and haven't been emailed int he last day
User
- .select(:id)
+ .select(:id)
.where(email_digests: true)
.where("COALESCE(last_emailed_at, '2010-01-01') <= CURRENT_TIMESTAMP - ('1 DAY'::INTERVAL * digest_after_days)")
.where("COALESCE(last_seen_at, '2010-01-01') <= CURRENT_TIMESTAMP - ('1 DAY'::INTERVAL * digest_after_days)")
@@ -20,4 +20,4 @@ module Jobs
end
-end
\ No newline at end of file
+end
diff --git a/lib/jobs/process_post.rb b/lib/jobs/process_post.rb
index ee056ddf4..5451bb7f4 100644
--- a/lib/jobs/process_post.rb
+++ b/lib/jobs/process_post.rb
@@ -5,7 +5,7 @@ module Jobs
class ProcessPost < Jobs::Base
- def execute(args)
+ def execute(args)
post = Post.where(id: args[:post_id]).first
return unless post.present?
diff --git a/lib/jobs/send_system_message.rb b/lib/jobs/send_system_message.rb
index f0f96eb90..e77169ec9 100644
--- a/lib/jobs/send_system_message.rb
+++ b/lib/jobs/send_system_message.rb
@@ -5,13 +5,13 @@ module Jobs
class SendSystemMessage < Jobs::Base
- def execute(args)
+ def execute(args)
raise Discourse::InvalidParameters.new(:user_id) unless args[:user_id].present?
raise Discourse::InvalidParameters.new(:message_type) unless args[:message_type].present?
user = User.where(id: args[:user_id]).first
return if user.blank?
-
+
system_message = SystemMessage.new(user)
system_message.create(args[:message_type])
end
diff --git a/lib/jobs/user_email.rb b/lib/jobs/user_email.rb
index c795c5415..42cf787d4 100644
--- a/lib/jobs/user_email.rb
+++ b/lib/jobs/user_email.rb
@@ -18,7 +18,7 @@ module Jobs
seen_recently = (user.last_seen_at.present? and user.last_seen_at > SiteSetting.email_time_window_mins.minutes.ago)
email_args = {}
-
+
if args[:post_id]
# Don't email a user about a post when we've seen them recently.
@@ -43,9 +43,9 @@ module Jobs
# Don't email a user about a post when we've seen them recently.
return if seen_recently
-
+
# Load the post if present
- email_args[:post] ||= notification.post if notification.post.present?
+ email_args[:post] ||= notification.post if notification.post.present?
email_args[:notification] = notification
# Don't send email if the notification this email is about has already been read
@@ -54,7 +54,7 @@ module Jobs
# Make sure that mailer exists
raise Discourse::InvalidParameters.new(:type) unless UserNotifications.respond_to?(args[:type])
-
+
message = UserNotifications.send(args[:type], user, email_args)
# Update the to address if we have a custom one
diff --git a/lib/markdown_linker.rb b/lib/markdown_linker.rb
index 68e79444d..c7dca036a 100644
--- a/lib/markdown_linker.rb
+++ b/lib/markdown_linker.rb
@@ -9,9 +9,9 @@ class MarkdownLinker
end
def create(title, url)
- @markdown_links[@index] = "#{@base_url}#{url}"
+ @markdown_links[@index] = "#{@base_url}#{url}"
result = "[#{title}][#{@index}]"
- @index += 1
+ @index += 1
result
end
@@ -23,5 +23,5 @@ class MarkdownLinker
@rendered = @index
result
end
-
+
end
diff --git a/lib/message_bus_diags.rb b/lib/message_bus_diags.rb
index 5d86bb61d..3d7f795dc 100644
--- a/lib/message_bus_diags.rb
+++ b/lib/message_bus_diags.rb
@@ -17,7 +17,7 @@ class MessageBusDiags
def self.seen_hosts
@host_info
end
-
+
unless @subscribed
MessageBus.subscribe "/server-name-reply/#{my_id}" do |msg|
diff --git a/lib/multisite_i18n.rb b/lib/multisite_i18n.rb
index 2d59c0c73..a50ae6fce 100644
--- a/lib/multisite_i18n.rb
+++ b/lib/multisite_i18n.rb
@@ -2,7 +2,7 @@
module MultisiteI18n
class << self
-
+
# It would be nice if there was an easier way to detect if a key is missing.
def translation_or_nil(key, opts)
missing_text = "missing multisite translation"
@@ -17,12 +17,12 @@ module MultisiteI18n
if translation.blank?
return I18n.t(key, opts)
else
- return translation
+ return translation
end
end
def t(*args)
- MultisiteI18n.site_translate(RailsMultisite::ConnectionManagement.current_db, *args)
+ MultisiteI18n.site_translate(RailsMultisite::ConnectionManagement.current_db, *args)
end
alias :translate :t
diff --git a/lib/oneboxer.rb b/lib/oneboxer.rb
index 01b7da6ad..65e7bbe33 100644
--- a/lib/oneboxer.rb
+++ b/lib/oneboxer.rb
@@ -2,8 +2,8 @@ require 'open-uri'
require_dependency 'oneboxer/base'
require_dependency 'oneboxer/whitelist'
-Dir["#{Rails.root}/lib/oneboxer/*_onebox.rb"].each {|f|
- require_dependency(f.split('/')[-2..-1].join('/'))
+Dir["#{Rails.root}/lib/oneboxer/*_onebox.rb"].each {|f|
+ require_dependency(f.split('/')[-2..-1].join('/'))
}
module Oneboxer
@@ -41,7 +41,7 @@ module Oneboxer
return OembedOnebox.new(oembed[:href]).onebox
end
(doc/"link[@type='text/json+oembed']").each do |oembed|
- return OembedOnebox.new(oembed[:href]).onebox
+ return OembedOnebox.new(oembed[:href]).onebox
end
# Check for opengraph
@@ -74,7 +74,7 @@ module Oneboxer
def self.create_post_reference(result, args={})
result.post_onebox_renders.create(post_id: args[:post_id]) if args[:post_id].present?
- rescue ActiveRecord::RecordNotUnique
+ rescue ActiveRecord::RecordNotUnique
end
def self.render_from_cache(url, args={})
@@ -85,7 +85,7 @@ module Oneboxer
create_post_reference(result, args)
return result
end
- nil
+ nil
end
# Cache results from a onebox call
@@ -99,13 +99,13 @@ module Oneboxer
render = OneboxRender.create(url: url, preview: preview, cooked: cooked, expires_at: Oneboxer.default_expiry.from_now)
create_post_reference(render, args)
rescue ActiveRecord::RecordNotUnique
- end
- end
+ end
+ end
- [cooked, preview]
+ [cooked, preview]
end
- # Retrieve a preview of a onebox, caching the result for performance
+ # Retrieve a preview of a onebox, caching the result for performance
def self.preview(url, args={})
cached = render_from_cache(url, args) unless args[:no_cache].present?
diff --git a/lib/oneboxer/amazon_onebox.rb b/lib/oneboxer/amazon_onebox.rb
index d3e26aab7..e2eb05f76 100644
--- a/lib/oneboxer/amazon_onebox.rb
+++ b/lib/oneboxer/amazon_onebox.rb
@@ -5,11 +5,11 @@ module Oneboxer
matcher /^https?:\/\/(?:www\.)?amazon.(com|ca)\/.*$/
favicon 'amazon.png'
-
+
def template
template_path("simple_onebox")
end
-
+
# Use the mobile version of the site
def translate_url
@@ -34,7 +34,7 @@ module Oneboxer
result[:by_info] = html_doc.at("#by-line")
result[:by_info] = BaseOnebox.remove_whitespace(result[:by_info].inner_html) if result[:by_info].present?
- summary = html_doc.at("#description-and-details-content")
+ summary = html_doc.at("#description-and-details-content")
result[:text] = summary.inner_html if summary.present?
result
diff --git a/lib/oneboxer/android_app_store_onebox.rb b/lib/oneboxer/android_app_store_onebox.rb
index cb190e5c7..8d165c275 100644
--- a/lib/oneboxer/android_app_store_onebox.rb
+++ b/lib/oneboxer/android_app_store_onebox.rb
@@ -9,7 +9,7 @@ module Oneboxer
def template
template_path('simple_onebox')
end
-
+
def parse(data)
html_doc = Nokogiri::HTML(data)
diff --git a/lib/oneboxer/apple_app_onebox.rb b/lib/oneboxer/apple_app_onebox.rb
index 3dce646c9..37bac565f 100644
--- a/lib/oneboxer/apple_app_onebox.rb
+++ b/lib/oneboxer/apple_app_onebox.rb
@@ -5,7 +5,7 @@ module Oneboxer
matcher /^https?:\/\/itunes\.apple\.com\/.+$/
favicon 'apple.png'
-
+
# Don't masquerade as mobile
def http_params
{}
@@ -14,7 +14,7 @@ module Oneboxer
def template
template_path('simple_onebox')
end
-
+
def parse(data)
html_doc = Nokogiri::HTML(data)
diff --git a/lib/oneboxer/base.rb b/lib/oneboxer/base.rb
index 2d1a160c1..7e45daff0 100644
--- a/lib/oneboxer/base.rb
+++ b/lib/oneboxer/base.rb
@@ -1,14 +1,14 @@
module Oneboxer
class << self
- def parse_open_graph(doc)
+ def parse_open_graph(doc)
result = {}
%w(title type image url description).each do |prop|
node = doc.at("/html/head/meta[@property='og:#{prop}']")
result[prop] = (node['content'] || node['value']) if node
end
-
+
# If there's no title, try using the page's title
if result['title'].blank?
result['title'] = doc.title
@@ -33,7 +33,7 @@ module Oneboxer
def matchers
@matchers ||= {}
@matchers
- end
+ end
# Add a matcher
def add_matcher(regexp, klass)
diff --git a/lib/oneboxer/base_onebox.rb b/lib/oneboxer/base_onebox.rb
index fd8f2fce4..74da12598 100644
--- a/lib/oneboxer/base_onebox.rb
+++ b/lib/oneboxer/base_onebox.rb
@@ -35,7 +35,7 @@ module Oneboxer
end
def initialize(url, opts={})
- @url = url
+ @url = url
@opts = opts
end
diff --git a/lib/oneboxer/gist_onebox.rb b/lib/oneboxer/gist_onebox.rb
index a3f63cb86..35ca2e1f6 100644
--- a/lib/oneboxer/gist_onebox.rb
+++ b/lib/oneboxer/gist_onebox.rb
@@ -6,7 +6,7 @@ module Oneboxer
matcher /^https?:\/\/gist\.github\.com/
favicon 'github.png'
- def translate_url
+ def translate_url
m = @url.match(/gist\.github\.com\/([^\/]+\/)?(?
[0-9a-f]+)/mi)
return "https://api.github.com/gists/#{m[:id]}" if m
end
@@ -17,7 +17,7 @@ module Oneboxer
parsed['files'].each do |filename, attrs|
result[:files] << {filename: filename}.merge!(attrs)
end
- result
+ result
end
end
diff --git a/lib/oneboxer/github_blob_onebox.rb b/lib/oneboxer/github_blob_onebox.rb
index 59fb282dc..b1643a6f1 100644
--- a/lib/oneboxer/github_blob_onebox.rb
+++ b/lib/oneboxer/github_blob_onebox.rb
@@ -6,7 +6,7 @@ module Oneboxer
matcher /github\.com\/[^\/]+\/[^\/]+\/blob\/.*/
favicon 'github.png'
- def translate_url
+ def translate_url
m = @url.match(/github\.com\/(?[^\/]+)\/(?[^\/]+)\/blob\/(?[^\/]+)\/(?[^#]+)(#(L(?[^-]*)(-L(?.*))?))?/mi)
if m
@from = (m[:from] || -1).to_i
@@ -19,7 +19,7 @@ module Oneboxer
def parse(data)
- if @from > 0
+ if @from > 0
if @to < 0
@from = @from - 10
@to = @from + 20
@@ -42,7 +42,7 @@ module Oneboxer
truncated = true
end
- {content: data, truncated: truncated}
+ {content: data, truncated: truncated}
end
end
diff --git a/lib/oneboxer/handlebars_onebox.rb b/lib/oneboxer/handlebars_onebox.rb
index 7741d95a8..48047b2a0 100644
--- a/lib/oneboxer/handlebars_onebox.rb
+++ b/lib/oneboxer/handlebars_onebox.rb
@@ -26,7 +26,7 @@ module Oneboxer
end
def onebox
- html = open(translate_url, http_params).read
+ html = open(translate_url, http_params).read
args = parse(html)
return default_url unless args.present?
args[:original_url] = @url
@@ -42,8 +42,8 @@ module Oneboxer
Mustache.render(File.read(template), args)
rescue => ex
# If there's an exception, just embed the link
- raise ex if Rails.env.development?
- default_url
+ raise ex if Rails.env.development?
+ default_url
end
end
diff --git a/lib/oneboxer/oembed_onebox.rb b/lib/oneboxer/oembed_onebox.rb
index c9aa50c04..d0de79195 100644
--- a/lib/oneboxer/oembed_onebox.rb
+++ b/lib/oneboxer/oembed_onebox.rb
@@ -10,7 +10,7 @@ module Oneboxer
def oembed_endpoint
@url
end
-
+
def template
template_path('oembed_onebox')
end
diff --git a/lib/oneboxer/twitter_onebox.rb b/lib/oneboxer/twitter_onebox.rb
index 9d6976cc6..7cdb9065e 100644
--- a/lib/oneboxer/twitter_onebox.rb
+++ b/lib/oneboxer/twitter_onebox.rb
@@ -5,7 +5,7 @@ module Oneboxer
matcher /^https?:\/\/(?:www\.)?twitter.com\/.*$/
favicon 'twitter.png'
-
+
def translate_url
m = @url.match(/\/(?[^\/]+)\/status\/(?\d+)/mi)
return "http://api.twitter.com/1/statuses/show/#{URI::encode(m[:id])}.json" if m.present?
@@ -19,7 +19,7 @@ module Oneboxer
result["created_at"] = Time.parse(result["created_at"]).strftime("%I:%M%p - %d %b %y")
# Hyperlink URLs
- URI.extract(result['text'], %w(http https)).each do |url|
+ URI.extract(result['text'], %w(http https)).each do |url|
result['text'].gsub!(url, "#{url} ")
end
diff --git a/lib/oneboxer/whitelist.rb b/lib/oneboxer/whitelist.rb
index 199a42c74..e280134c9 100644
--- a/lib/oneboxer/whitelist.rb
+++ b/lib/oneboxer/whitelist.rb
@@ -74,7 +74,7 @@ module Oneboxer
/thinkgeek\.com\/.+/,
/deadline\.com\/.+/
]
- end
+ end
def self.allowed?(url)
#return true
diff --git a/lib/oneboxer/wikipedia_onebox.rb b/lib/oneboxer/wikipedia_onebox.rb
index 98e8a0161..bfcef67cb 100644
--- a/lib/oneboxer/wikipedia_onebox.rb
+++ b/lib/oneboxer/wikipedia_onebox.rb
@@ -29,7 +29,7 @@ module Oneboxer
# get the first image > 150 pix high
images = html_doc.search("img").select { |img| img['height'].to_i > 150 }
-
+
result[:image] = "http:#{images[0]["src"]}" unless images.empty?
# remove the table from mobile layout, as it can contain paras in some rare cases
diff --git a/lib/post_creator.rb b/lib/post_creator.rb
index f73cc1c85..b36c0209c 100644
--- a/lib/post_creator.rb
+++ b/lib/post_creator.rb
@@ -10,7 +10,7 @@ class PostCreator
# Acceptable options:
#
# raw - raw text of post
- # image_sizes - We can pass a list of the sizes of images in the post as a shortcut.
+ # image_sizes - We can pass a list of the sizes of images in the post as a shortcut.
#
# When replying to a topic:
# topic_id - topic we're replying to
@@ -23,7 +23,7 @@ class PostCreator
# target_usernames - comma delimited list of usernames for membership (private message)
# meta_data - Topic meta data hash
def initialize(user, opts)
- @user = user
+ @user = user
@opts = opts
raise Discourse::InvalidParameters.new(:raw) if @opts[:raw].blank?
end
@@ -48,7 +48,7 @@ class PostCreator
topic_params[:meta_data] = @opts[:meta_data] if @opts[:meta_data].present?
topic = Topic.new(topic_params)
-
+
if @opts[:archetype] == Archetype.private_message
usernames = @opts[:target_usernames].split(',')
@@ -67,23 +67,23 @@ class PostCreator
unless topic.save
@errors = topic.errors
- raise ActiveRecord::Rollback.new
+ raise ActiveRecord::Rollback.new
end
else
topic = Topic.where(id: @opts[:topic_id]).first
guardian.ensure_can_create!(Post, topic)
end
- post = topic.posts.new(raw: @opts[:raw],
+ post = topic.posts.new(raw: @opts[:raw],
user: @user,
reply_to_post_number: @opts[:reply_to_post_number])
post.image_sizes = @opts[:image_sizes] if @opts[:image_sizes].present?
unless post.save
@errors = post.errors
- raise ActiveRecord::Rollback.new
+ raise ActiveRecord::Rollback.new
end
- # Extract links
+ # Extract links
TopicLink.extract_from(post)
end
@@ -92,7 +92,7 @@ class PostCreator
# Shortcut
def self.create(user, opts)
- PostCreator.new(user, opts).create
+ PostCreator.new(user, opts).create
end
end
diff --git a/lib/post_revisor.rb b/lib/post_revisor.rb
index 4eb7656fc..984eb1743 100644
--- a/lib/post_revisor.rb
+++ b/lib/post_revisor.rb
@@ -91,7 +91,7 @@ class PostRevisor
# If found, update its description
body = @post.cooked
matches = body.scan(/\(.*)\<\/p\>/)
- if matches and matches[0] and matches[0][0]
+ if matches and matches[0] and matches[0][0]
new_description = matches[0][0]
new_description = nil if new_description == I18n.t("category.replace_paragraph")
category.update_column(:description, new_description)
diff --git a/lib/pretty_text.rb b/lib/pretty_text.rb
index fc2906325..d36c7d7ab 100644
--- a/lib/pretty_text.rb
+++ b/lib/pretty_text.rb
@@ -40,12 +40,12 @@ module PrettyText
'ins' => {'cite' => ['http', 'https', :relative]},
'q' => {'cite' => ['http', 'https', :relative]}
}
- }
+ }
end
class Helpers
- # function here are available to v8
+ # function here are available to v8
def avatar_template(username)
return "" unless username
@@ -66,7 +66,7 @@ module PrettyText
def self.mention_matcher
/(\@[a-zA-Z0-9\-]+)/
- end
+ end
def self.app_root
Rails.root
@@ -76,13 +76,13 @@ module PrettyText
return @ctx unless @ctx.nil?
@ctx = V8::Context.new
-
- @ctx["helpers"] = Helpers.new
+
+ @ctx["helpers"] = Helpers.new
@ctx.load(app_root + "app/assets/javascripts/external/Markdown.Converter.js")
- @ctx.load(app_root + "app/assets/javascripts/external/twitter-text-1.5.0.js")
+ @ctx.load(app_root + "app/assets/javascripts/external/twitter-text-1.5.0.js")
@ctx.load(app_root + "lib/headless-ember.js")
- @ctx.load(app_root + "app/assets/javascripts/external/rsvp.js")
+ @ctx.load(app_root + "app/assets/javascripts/external/rsvp.js")
@ctx.load(Rails.configuration.ember.handlebars_location)
#@ctx.load(Rails.configuration.ember.ember_location)
@@ -102,7 +102,7 @@ module PrettyText
@ctx['quoteTemplate'] = File.open(app_root + 'app/assets/javascripts/discourse/templates/quote.js.shbrs') {|f| f.read}
@ctx['quoteEmailTemplate'] = File.open(app_root + 'lib/assets/quote_email.js.shbrs') {|f| f.read}
- @ctx.eval("HANDLEBARS_TEMPLATES = {
+ @ctx.eval("HANDLEBARS_TEMPLATES = {
'quote': Handlebars.compile(quoteTemplate),
'quote_email': Handlebars.compile(quoteEmailTemplate),
};")
@@ -111,11 +111,11 @@ module PrettyText
def self.markdown(text, opts=nil)
# we use the exact same markdown converter as the client
- # TODO: use the same extensions on both client and server (in particular the template for mentions)
-
+ # TODO: use the same extensions on both client and server (in particular the template for mentions)
+
baked = nil
- @mutex.synchronize do
+ @mutex.synchronize do
# we need to do this to work in a multi site environment, many sites, many settings
v8.eval("Discourse.SiteSettings = #{SiteSetting.client_settings_json};")
v8.eval("Discourse.BaseUrl = 'http://#{RailsMultisite::ConnectionManagement.current_hostname}';")
@@ -123,24 +123,24 @@ module PrettyText
v8['raw'] = text
v8.eval('opts["mentionLookup"] = function(u){return helpers.is_username_valid(u);}')
v8.eval('opts["lookupAvatar"] = function(p){return Discourse.Utilities.avatarImg({username: p, size: "tiny", avatarTemplate: helpers.avatar_template(p)});}')
- baked = v8.eval('Discourse.Utilities.markdownConverter(opts).makeHtml(raw)')
+ baked = v8.eval('Discourse.Utilities.markdownConverter(opts).makeHtml(raw)')
end
# we need some minimal server side stuff, apply CDN and TODO filter disallowed markup
- baked = apply_cdn(baked, Rails.configuration.action_controller.asset_host)
+ baked = apply_cdn(baked, Rails.configuration.action_controller.asset_host)
baked
end
# leaving this here, cause it invokes v8, don't want to implement twice
def self.avatar_img(username, size)
r = nil
- @mutex.synchronize do
+ @mutex.synchronize do
v8['username'] = username
v8['size'] = size
v8.eval("Discourse.SiteSettings = #{SiteSetting.client_settings_json};")
v8.eval("Discourse.CDN = '#{Rails.configuration.action_controller.asset_host}';")
v8.eval("Discourse.BaseUrl = '#{RailsMultisite::ConnectionManagement.current_hostname}';")
- r = v8.eval("Discourse.Utilities.avatarImg({ username: username, size: size });")
+ r = v8.eval("Discourse.Utilities.avatarImg({ username: username, size: size });")
end
r
end
@@ -159,7 +159,7 @@ module PrettyText
end
doc.css("img").each do |l|
src = l.attributes["src"].to_s
- if src[0] == '/'
+ if src[0] == '/'
l["src"] = url + src
end
end
@@ -171,38 +171,38 @@ module PrettyText
cloned = opts.dup
# we have a minor inconsistency
cloned[:topicId] = opts[:topic_id]
- sanitized = Sanitize.clean(markdown(text.dup, cloned), PrettyText.whitelist)
+ sanitized = Sanitize.clean(markdown(text.dup, cloned), PrettyText.whitelist)
if SiteSetting.add_rel_nofollow_to_user_content
- sanitized = add_rel_nofollow_to_user_content(sanitized)
+ sanitized = add_rel_nofollow_to_user_content(sanitized)
end
sanitized
end
-
+
def self.add_rel_nofollow_to_user_content(html)
whitelist = []
l = SiteSetting.exclude_rel_nofollow_domains
if l.present?
- whitelist = l.split(",")
+ whitelist = l.split(",")
end
site_uri = nil
doc = Nokogiri::HTML.fragment(html)
doc.css("a").each do |l|
href = l["href"].to_s
- begin
+ begin
uri = URI(href)
site_uri ||= URI(Discourse.base_url)
-
- if !uri.host.present? ||
- uri.host.ends_with?(site_uri.host) ||
+
+ if !uri.host.present? ||
+ uri.host.ends_with?(site_uri.host) ||
whitelist.any?{|u| uri.host.ends_with?(u)}
# we are good no need for nofollow
else
l["rel"] = "nofollow"
end
rescue URI::InvalidURIError
- # add a nofollow anyway
+ # add a nofollow anyway
l["rel"] = "nofollow"
end
end
@@ -218,7 +218,7 @@ module PrettyText
doc.css("aside.quote").each do |a|
topic_id = a.attributes['data-topic']
-
+
url = "/t/topic/#{topic_id}"
if post_number = a.attributes['data-post']
url << "/#{post_number}"
@@ -232,12 +232,12 @@ module PrettyText
class ExcerptParser < Nokogiri::XML::SAX::Document
- class DoneException < StandardError; end
+ class DoneException < StandardError; end
attr_reader :excerpt
def initialize(length)
- @length = length
+ @length = length
@excerpt = ""
@current_length = 0
end
@@ -245,19 +245,19 @@ module PrettyText
def self.get_excerpt(html, length)
me = self.new(length)
parser = Nokogiri::HTML::SAX::Parser.new(me)
- begin
- copy = "
"
+ begin
+ copy = "
"
copy << html unless html.nil?
copy << "
"
parser.parse(html) unless html.nil?
rescue DoneException
- # we are done
+ # we are done
end
me.excerpt
end
def start_element(name, attributes=[])
- case name
+ case name
when "img"
attributes = Hash[*attributes.flatten]
if attributes["alt"]
@@ -274,12 +274,12 @@ module PrettyText
characters(c, false, false, false)
@in_a = true
when "aside"
- @in_quote = true
+ @in_quote = true
end
end
def end_element(name)
- case name
+ case name
when "a"
characters("",false, false, false)
@in_a = false
@@ -292,7 +292,7 @@ module PrettyText
def characters(string, truncate = true, count_it = true, encode = true)
return if @in_quote
- encode = encode ? lambda{|s| ERB::Util.html_escape(s)} : lambda {|s| s}
+ encode = encode ? lambda{|s| ERB::Util.html_escape(s)} : lambda {|s| s}
if @current_length + string.length > @length && count_it
@excerpt << encode.call(string[0..(@length-@current_length)-1]) if truncate
@excerpt << "…"
diff --git a/lib/promotion.rb b/lib/promotion.rb
index 5fd793f72..557b6ff8b 100644
--- a/lib/promotion.rb
+++ b/lib/promotion.rb
@@ -4,7 +4,7 @@
class Promotion
def initialize(user)
- @user = user
+ @user = user
end
# Review a user for a promotion. Delegates work to a review_#{trust_level} method.
@@ -21,14 +21,14 @@ class Promotion
false
end
- def review_new
+ def review_new
return false if @user.topics_entered < SiteSetting.basic_requires_topics_entered
return false if @user.posts_read_count < SiteSetting.basic_requires_read_posts
return false if (@user.time_read / 60) < SiteSetting.basic_requires_time_spent_mins
@user.trust_level = TrustLevel.Levels[:basic]
@user.save
-
+
true
end
diff --git a/lib/rate_limiter.rb b/lib/rate_limiter.rb
index 74c998812..5cb12d18f 100644
--- a/lib/rate_limiter.rb
+++ b/lib/rate_limiter.rb
@@ -6,7 +6,7 @@ class RateLimiter
# We don't observe rate limits in test mode
def self.disabled?
- Rails.env.test?
+ Rails.env.test?
end
def initialize(user, key, max, secs)
@@ -41,7 +41,7 @@ class RateLimiter
# In case we go over, clamp it to the maximum
$redis.decr(@key)
- raise LimitExceeded.new($redis.ttl(@key))
+ raise LimitExceeded.new($redis.ttl(@key))
end
end
diff --git a/lib/rate_limiter/limit_exceeded.rb b/lib/rate_limiter/limit_exceeded.rb
index aa66b721d..ca6025f8e 100644
--- a/lib/rate_limiter/limit_exceeded.rb
+++ b/lib/rate_limiter/limit_exceeded.rb
@@ -1,6 +1,6 @@
class RateLimiter
- # A rate limit has been exceeded.
+ # A rate limit has been exceeded.
class LimitExceeded < Exception
attr_accessor :available_in
def initialize(available_in)
@@ -8,4 +8,4 @@ class RateLimiter
end
end
-end
\ No newline at end of file
+end
diff --git a/lib/rate_limiter/on_create_record.rb b/lib/rate_limiter/on_create_record.rb
index 2c0987594..33d27a103 100644
--- a/lib/rate_limiter/on_create_record.rb
+++ b/lib/rate_limiter/on_create_record.rb
@@ -4,7 +4,7 @@ class RateLimiter
# based on a SiteSetting.
#
# It expects a SiteSetting called `rate_limit_create_{model_name}` where
- # `model_name` is the class name of your model, underscored.
+ # `model_name` is the class name of your model, underscored.
#
module OnCreateRecord
@@ -14,20 +14,20 @@ class RateLimiter
limit_key = "create_#{self.class.name.underscore}"
max_setting = SiteSetting.send("rate_limit_#{limit_key}")
- @rate_limiter = RateLimiter.new(user, limit_key, 1, max_setting)
+ @rate_limiter = RateLimiter.new(user, limit_key, 1, max_setting)
end
def self.included(base)
- base.extend(ClassMethods)
+ base.extend(ClassMethods)
end
module ClassMethods
def rate_limit(limiter_method=nil)
-
+
limiter_method = limiter_method || :default_rate_limiter
- self.after_create do
-
+ self.after_create do
+
rate_limiter = send(limiter_method)
return unless rate_limiter.present?
@@ -58,4 +58,4 @@ class RateLimiter
end
-end
\ No newline at end of file
+end
diff --git a/lib/score_calculator.rb b/lib/score_calculator.rb
index 456bec753..96421d970 100644
--- a/lib/score_calculator.rb
+++ b/lib/score_calculator.rb
@@ -1,6 +1,6 @@
class ScoreCalculator
- def self.default_score_weights
+ def self.default_score_weights
{
reply_count: 5,
like_count: 15,
@@ -16,14 +16,14 @@ class ScoreCalculator
end
# Calculate the score for all posts based on the weightings
- def calculate
+ def calculate
# First update the scores of the posts
exec_sql(post_score_sql, @weightings)
# Update the best of flag
exec_sql "
- UPDATE topics SET has_best_of =
+ UPDATE topics SET has_best_of =
CASE
WHEN like_count >= :likes_required AND
posts_count >= :posts_required AND
@@ -34,8 +34,8 @@ class ScoreCalculator
END",
likes_required: SiteSetting.best_of_likes_required,
posts_required: SiteSetting.best_of_posts_required,
- score_required: SiteSetting.best_of_score_threshold
-
+ score_required: SiteSetting.best_of_score_threshold
+
end
@@ -53,6 +53,6 @@ class ScoreCalculator
components << "COALESCE(#{k.to_s}, 0) * :#{k.to_s}"
end
sql << components.join(" + ")
- end
+ end
end
end
diff --git a/lib/search.rb b/lib/search.rb
index 84b3c0d1a..ab2c0787c 100644
--- a/lib/search.rb
+++ b/lib/search.rb
@@ -40,13 +40,13 @@ module Search
AND ft.deleted_at IS NULL
AND ft.visible
AND ft.archetype <> '#{Archetype.private_message}'
- ORDER BY
+ ORDER BY
TS_RANK_CD(TO_TSVECTOR('english', ft.title), TO_TSQUERY('english', :query)) desc,
TS_RANK_CD(search_data, TO_TSQUERY('english', :query)) desc,
bumped_at desc"
- end
+ end
+
-
def self.post_query_sql
"SELECT cast('topic' as varchar) AS type,
CAST(ft.id AS VARCHAR),
@@ -61,11 +61,11 @@ module Search
AND ft.deleted_at IS NULL and p.deleted_at IS NULL
AND ft.visible
AND ft.archetype <> '#{Archetype.private_message}'
- ORDER BY
+ ORDER BY
TS_RANK_CD(TO_TSVECTOR('english', ft.title), TO_TSQUERY('english', :query)) desc,
TS_RANK_CD(search_data, TO_TSQUERY('english', :query)) desc,
- bumped_at desc"
- end
+ bumped_at desc"
+ end
def self.category_query_sql
"SELECT 'category' AS type,
@@ -81,7 +81,7 @@ module Search
"
end
- def self.query(term, type_filter=nil)
+ def self.query(term, type_filter=nil)
return nil if term.blank?
sanitized_term = term.gsub(/[^0-9a-zA-Z_ ]/, '')
@@ -92,7 +92,7 @@ module Search
terms = sanitized_term.split
terms.map! {|t| "#{t}:*"}
- if type_filter.present?
+ if type_filter.present?
raise Discourse::InvalidAccess.new("invalid type filter") unless Search.facets.include?(type_filter)
sql = Search.send("#{type_filter}_query_sql") << " LIMIT #{Search.per_facet * Search.facets.size}"
db_result = ActiveRecord::Base.exec_sql(sql , query: terms.join(" & "))
@@ -106,26 +106,26 @@ module Search
end
db_result = db_result.to_a
-
+
expected_topics = 0
expected_topics = Search.facets.size unless type_filter.present?
expected_topics = Search.per_facet * Search.facets.size if type_filter == 'topic'
-
- if expected_topics > 0
+
+ if expected_topics > 0
db_result.each do |row|
expected_topics -= 1 if row['type'] == 'topic'
end
end
-
- if expected_topics > 0
- tmp = ActiveRecord::Base.exec_sql "#{post_query_sql} limit :per_facet",
+
+ if expected_topics > 0
+ tmp = ActiveRecord::Base.exec_sql "#{post_query_sql} limit :per_facet",
query: terms.join(" & "), per_facet: expected_topics * 3
topic_ids = Set.new db_result.map{|r| r["id"]}
tmp = tmp.to_a
tmp = tmp.reject{ |i|
- if topic_ids.include? i["id"]
+ if topic_ids.include? i["id"]
true
else
topic_ids << i["id"]
@@ -149,7 +149,7 @@ module Search
if type == 'user'
row['avatar_template'] = User.avatar_template(row['email'])
end
- row.delete('email')
+ row.delete('email')
row.delete('color') unless type == 'category'
grouped[type] ||= []
@@ -159,8 +159,8 @@ module Search
result = grouped.map do |type, results|
more = type_filter.blank? && (results.size > Search.per_facet)
results = results[0..([results.length, Search.per_facet].min - 1)] if type_filter.blank?
-
- {type: type,
+
+ {type: type,
name: I18n.t("search.types.#{type}"),
more: more,
results: results}
diff --git a/lib/site_setting_extension.rb b/lib/site_setting_extension.rb
index 2df54da9a..b29a6a7c5 100644
--- a/lib/site_setting_extension.rb
+++ b/lib/site_setting_extension.rb
@@ -2,7 +2,7 @@ module SiteSettingExtension
module Types
String = 1
- Time = 2
+ Time = 2
Fixnum = 3
Float = 4
Bool = 5
@@ -19,18 +19,18 @@ module SiteSettingExtension
end
def defaults
- @defaults ||= {}
+ @defaults ||= {}
end
def setting(name, default = nil, type = nil)
- mutex.synchronize do
+ mutex.synchronize do
self.defaults[name] = default
current_value = current.has_key?(name) ? current[name] : default
setup_methods(name, current_value)
end
end
- # just like a setting, except that it is available in javascript via DiscourseSession
+ # just like a setting, except that it is available in javascript via DiscourseSession
def client_setting(name, default = nil, type = nil)
setting(name,default,type)
@@client_settings ||= []
@@ -38,7 +38,7 @@ module SiteSettingExtension
end
def client_settings
- @@client_settings
+ @@client_settings
end
@@ -73,9 +73,9 @@ module SiteSettingExtension
end
# refresh all the site settings
- def refresh!
- return unless table_exists?
- mutex.synchronize do
+ def refresh!
+ return unless table_exists?
+ mutex.synchronize do
ensure_listen_for_changes
old = current
changes = []
@@ -91,14 +91,14 @@ module SiteSettingExtension
changes << [name,value] if !old.has_key?(name) || old[name] != value
end
- old.each do |name,value|
- deletions << [name,value] unless new_hash.has_key?(name)
+ old.each do |name,value|
+ deletions << [name,value] unless new_hash.has_key?(name)
end
if deletions.length > 0 || changes.length > 0
@current = new_hash
- changes.each do |name, val|
- setup_methods name, val
+ changes.each do |name, val|
+ setup_methods name, val
end
deletions.each do |name,val|
setup_methods name, defaults[name]
@@ -112,12 +112,12 @@ module SiteSettingExtension
def ensure_listen_for_changes
unless @subscribed
pid = process_id
- MessageBus.subscribe("/site_settings") do |msg|
+ MessageBus.subscribe("/site_settings") do |msg|
message = msg.data
- if message["process"] != pid
+ if message["process"] != pid
begin
# picks a db
- MessageBus.on_connect.call(msg.site_id)
+ MessageBus.on_connect.call(msg.site_id)
SiteSetting.refresh!
ensure
MessageBus.on_disconnect.call(msg.site_id)
@@ -133,7 +133,7 @@ module SiteSettingExtension
end
def remove_override!(name)
- return unless table_exists?
+ return unless table_exists?
SiteSetting.where(:name => name).destroy_all
end
@@ -142,7 +142,7 @@ module SiteSettingExtension
setting = SiteSetting.where(:name => name).first
type = get_data_type(defaults[name])
-
+
if type == Types::Bool && val != true && val != false
val = (val == "t" || val == "true")
end
@@ -153,9 +153,9 @@ module SiteSettingExtension
if setting
setting.value = val
- setting.data_type = type
+ setting.data_type = type
setting.save
- else
+ else
SiteSetting.create!(:name => name, :value => val, :data_type => type)
end
@@ -163,24 +163,24 @@ module SiteSettingExtension
end
- protected
+ protected
def get_data_type(val)
return Types::Null if val.nil?
if String === val
Types::String
- elsif Fixnum === val
+ elsif Fixnum === val
Types::Fixnum
- elsif TrueClass === val || FalseClass === val
+ elsif TrueClass === val || FalseClass === val
Types::Bool
- else
+ else
raise ArgumentError.new :val
end
end
def convert(value, type)
- case type
+ case type
when Types::Fixnum
value.to_i
when Types::String
@@ -195,21 +195,21 @@ module SiteSettingExtension
def setup_methods(name, current_value)
- # trivial multi db support, we can optimize this later
+ # trivial multi db support, we can optimize this later
db = RailsMultisite::ConnectionManagement.current_db
-
+
@@containers ||= {}
@@containers[db] ||= {}
@@containers[db][name] = current_value
setter = ("#{name}=").sub("?","")
- eval "define_singleton_method :#{name} do
+ eval "define_singleton_method :#{name} do
c = @@containers[RailsMultisite::ConnectionManagement.current_db]
c = c[name] if c
c
end
-
+
define_singleton_method :#{setter} do |val|
add_override!(:#{name}, val)
refresh!
@@ -219,8 +219,8 @@ module SiteSettingExtension
def method_missing(method, *args, &block)
as_question = method.to_s.gsub(/\?$/, '')
- if respond_to?(as_question)
- return send(as_question, *args, &block)
+ if respond_to?(as_question)
+ return send(as_question, *args, &block)
end
super(method, *args, &block)
end
diff --git a/lib/slug.rb b/lib/slug.rb
index 39afd86f6..8ce5ec74b 100644
--- a/lib/slug.rb
+++ b/lib/slug.rb
@@ -1,6 +1,6 @@
# encoding: utf-8
-# Generates a slug. This is annoying beacuse it's duplicating what the javascript
+# Generates a slug. This is annoying beacuse it's duplicating what the javascript
# does, but on the other hand slugs are never matched so it's okay if they differ
# a little.
module Slug
diff --git a/lib/sql_builder.rb b/lib/sql_builder.rb
index c0477c77b..80ad0b211 100644
--- a/lib/sql_builder.rb
+++ b/lib/sql_builder.rb
@@ -22,7 +22,7 @@ class SqlBuilder
@sections.each do |k,v|
joined = nil
- case k
+ case k
when :where, :where2
joined = "WHERE " << v.join(" AND ")
when :join
@@ -41,7 +41,7 @@ class SqlBuilder
sql.sub!("/*#{k}*/", joined)
end
-
+
if @klass
@klass.find_by_sql(ActiveRecord::Base.send(:sanitize_sql_array, [sql, @args]))
else
@@ -50,7 +50,7 @@ class SqlBuilder
end
end
-class ActiveRecord::Base
+class ActiveRecord::Base
def self.sql_builder(template)
SqlBuilder.new(template, self)
end
diff --git a/lib/system_message.rb b/lib/system_message.rb
index ed54356f5..2abc5ecdf 100644
--- a/lib/system_message.rb
+++ b/lib/system_message.rb
@@ -9,10 +9,10 @@ class SystemMessage
end
def initialize(recipient)
- @recipient = recipient
+ @recipient = recipient
end
- def create(type, params = {})
+ def create(type, params = {})
defaults = {site_name: SiteSetting.title,
username: @recipient.username,
@@ -26,7 +26,7 @@ class SystemMessage
if SiteSetting.restrict_access?
params[:site_password] = MultisiteI18n.t('system_messages.site_password', access_password: SiteSetting.access_password)
end
-
+
title = MultisiteI18n.t("system_messages.#{type}.subject_template", params)
raw_body = MultisiteI18n.t("system_messages.#{type}.text_body_template", params)
diff --git a/lib/tasks/add_topic_to_quotes.rake b/lib/tasks/add_topic_to_quotes.rake
index 037e37cd9..51d1cf2ed 100644
--- a/lib/tasks/add_topic_to_quotes.rake
+++ b/lib/tasks/add_topic_to_quotes.rake
@@ -1,5 +1,5 @@
desc "Add the topic to quotes"
-task "add_topic_to_quotes" => :environment do
+task "add_topic_to_quotes" => :environment do
Post.where("raw like '%topic:%'").each do |p|
new_raw = p.raw.gsub(/topic:(\d+)\]/, "topic:#{p.topic_id}\"]")
new_cooked = p.cook(new_raw, topic_id: p.topic_id)
diff --git a/lib/tasks/build.rake b/lib/tasks/build.rake
index 2ee206d4a..0f698be15 100644
--- a/lib/tasks/build.rake
+++ b/lib/tasks/build.rake
@@ -1,5 +1,5 @@
desc "stamp the current build with the git hash placed in version.rb"
-task "build:stamp" => :environment do
+task "build:stamp" => :environment do
git_version = `git rev-parse HEAD`.strip
File.open(Rails.root.to_s + '/config/version.rb', 'w') do |f|
f.write("$git_version = #{git_version.inspect}\n")
diff --git a/lib/tasks/build_test_topic.rake b/lib/tasks/build_test_topic.rake
index 333257dda..e135cabc9 100644
--- a/lib/tasks/build_test_topic.rake
+++ b/lib/tasks/build_test_topic.rake
@@ -8,7 +8,7 @@ task 'build_test_topic' => :environment do
# Acceptable options:
#
# raw - raw text of post
- # image_sizes - We can pass a list of the sizes of images in the post as a shortcut.
+ # image_sizes - We can pass a list of the sizes of images in the post as a shortcut.
#
# When replying to a topic:
# topic_id - topic we're replying to
@@ -37,14 +37,14 @@ task 'build_test_topic' => :environment do
links << "Link to ##{where}: #{topic_url}/#{where}"
end
end
-
+
raw = <
:environment do |t|
require "net/https"
require "uri"
-
+
config = YAML::load(File.open("#{Rails.root}/config/cdn.yml"))
# pre-stage css/js only for now
@@ -17,7 +17,7 @@ task 'assets:prestage' => :environment do |t|
puts "pre staging: #{a.join(' ')}"
start = Time.now
- uri = URI.parse("https://client.cdn77.com/api/prefetch")
+ uri = URI.parse("https://client.cdn77.com/api/prefetch")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
@@ -36,5 +36,5 @@ task 'assets:prestage' => :environment do |t|
raise "Failed to pre-stage"
end
puts "Done (took: #{((Time.now - start) * 1000.0).to_i}ms)"
-
+
end
diff --git a/lib/tasks/images.rake b/lib/tasks/images.rake
index 8c4168184..cdcb2b78d 100644
--- a/lib/tasks/images.rake
+++ b/lib/tasks/images.rake
@@ -1,4 +1,4 @@
-task "images:compress" => :environment do
+task "images:compress" => :environment do
io = ImageOptim.new
images = Dir.glob("#{Rails.root}/app/**/*.png")
image_sizes = Hash[*images.map{|i| [i,File.size(i)]}.to_a.flatten]
diff --git a/lib/tasks/posts.rake b/lib/tasks/posts.rake
index 4499dbf0a..81c5f9dd1 100644
--- a/lib/tasks/posts.rake
+++ b/lib/tasks/posts.rake
@@ -1,5 +1,5 @@
desc "walk all posts updating cooked with latest markdown"
-task "posts:rebake" => :environment do
+task "posts:rebake" => :environment do
RailsMultisite::ConnectionManagement.each_connection do |db|
puts "Re baking post markdown for #{db} , changes are denoted with # , no change with ."
i = 0
diff --git a/lib/tasks/search.rake b/lib/tasks/search.rake
index c990e7d76..db4835aae 100644
--- a/lib/tasks/search.rake
+++ b/lib/tasks/search.rake
@@ -1,10 +1,10 @@
-task "search:reindex" => :environment do
+task "search:reindex" => :environment do
RailsMultisite::ConnectionManagement.each_connection do |db|
puts "Reindexing #{db}"
puts ""
puts "Posts:"
- Post.exec_sql("select p.id, p.cooked, c.name category, t.title from
- posts p
+ Post.exec_sql("select p.id, p.cooked, c.name category, t.title from
+ posts p
join topics t on t.id = p.topic_id
left join categories c on c.id = t.category_id
").each do |p|
@@ -12,18 +12,18 @@ task "search:reindex" => :environment do
cooked = p["cooked"]
title = p["title"]
category = p["cat"]
- SearchObserver.update_posts_index(post_id, cooked, title, category)
-
+ SearchObserver.update_posts_index(post_id, cooked, title, category)
+
putc "."
end
- puts
+ puts
puts "Users:"
User.exec_sql("select id, name, username from users").each do |u|
id = u["id"]
name = u["name"]
username = u["username"]
- SearchObserver.update_users_index(id, username, name)
+ SearchObserver.update_users_index(id, username, name)
putc "."
end
@@ -34,9 +34,9 @@ task "search:reindex" => :environment do
Category.exec_sql("select id, name from categories").each do |c|
id = c["id"]
name = c["name"]
- SearchObserver.update_categories_index(id, name)
+ SearchObserver.update_categories_index(id, name)
end
-
+
puts
end
end
diff --git a/lib/tasks/smoke_test.rake b/lib/tasks/smoke_test.rake
index 483a02d4c..ae86008de 100644
--- a/lib/tasks/smoke_test.rake
+++ b/lib/tasks/smoke_test.rake
@@ -1,12 +1,12 @@
desc "run phantomjs based smoke tests on current build"
task "smoke:test" => :environment do
- phantom_path = File.expand_path('~/phantomjs/bin/phantomjs')
+ phantom_path = File.expand_path('~/phantomjs/bin/phantomjs')
phantom_path = nil unless File.exists?(phantom_path)
phantom_path = phantom_path || 'phantomjs'
url = ENV["URL"] || Discourse.base_url
-
+
puts "Testing: #{url}"
require 'open-uri'
diff --git a/lib/tasks/user_actions.rake b/lib/tasks/user_actions.rake
index 39168c911..b9ced27e4 100644
--- a/lib/tasks/user_actions.rake
+++ b/lib/tasks/user_actions.rake
@@ -1,13 +1,13 @@
desc "rebuild the user_actions table"
-task "user_actions:rebuild" => :environment do
- o = UserActionObserver.send :new
+task "user_actions:rebuild" => :environment do
+ o = UserActionObserver.send :new
MessageBus.off
UserAction.delete_all
PostAction.all.each{|i| o.after_save(i)}
Topic.all.each {|i| o.after_save(i)}
Post.all.each {|i| o.after_save(i)}
Notification.all.each {|i| o.after_save(i)}
- # not really needed but who knows
+ # not really needed but who knows
MessageBus.on
end
diff --git a/lib/text_sentinel.rb b/lib/text_sentinel.rb
index 68563c67f..5a482369f 100644
--- a/lib/text_sentinel.rb
+++ b/lib/text_sentinel.rb
@@ -21,20 +21,20 @@ class TextSentinel
end
def self.title_sentinel(text)
- TextSentinel.new(text,
+ TextSentinel.new(text,
min_entropy: SiteSetting.title_min_entropy,
max_word_length: SiteSetting.max_word_length,
remove_interior_spaces: true,
strip: true)
end
- # Entropy is a number of how many unique characters the string needs.
+ # Entropy is a number of how many unique characters the string needs.
def entropy
return 0 if @text.blank?
@entropy ||= @text.strip.each_char.to_a.uniq.size
end
- def valid?
+ def valid?
# Blank strings are not valid
return false if @text.blank? || @text.strip.blank?
diff --git a/lib/topic_query.rb b/lib/topic_query.rb
index 23998c3e5..e2802f5ce 100644
--- a/lib/topic_query.rb
+++ b/lib/topic_query.rb
@@ -1,4 +1,4 @@
-#
+#
# Helps us find topics. Returns a TopicList object containing the topics
# found.
#
@@ -7,7 +7,7 @@ require_dependency 'topic_list'
class TopicQuery
def initialize(user=nil, opts={})
- @user = user
+ @user = user
# Cast to int to avoid sql injection
@user_id = user.id.to_i if @user.present?
@@ -16,7 +16,7 @@ class TopicQuery
end
# Return a list of suggested topics for a topic
- def list_suggested_for(topic)
+ def list_suggested_for(topic)
exclude_topic_ids = [topic.id]
@@ -73,7 +73,7 @@ class TopicQuery
def list_favorited
return_list do |list|
list.joins("INNER JOIN topic_users AS tu ON (topics.id = tu.topic_id AND tu.starred AND tu.user_id = #{@user_id})")
- end
+ end
end
def list_read
@@ -117,7 +117,7 @@ class TopicQuery
protected
def return_list(list_opts={})
- TopicList.new(@user, yield(default_list(list_opts)))
+ TopicList.new(@user, yield(default_list(list_opts)))
end
# Create a list based on a bunch of detault options
@@ -127,15 +127,15 @@ class TopicQuery
page_size = query_opts[:per_page] || SiteSetting.topics_per_page
result = Topic
- result = result.topic_list_order unless query_opts[:unordered]
- result = result.listable_topics.includes(:category)
+ result = result.topic_list_order unless query_opts[:unordered]
+ result = result.listable_topics.includes(: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.limit(page_size) unless query_opts[:limit] == false
+ result = result.limit(page_size) unless query_opts[:limit] == false
result = result.visible if @user.blank? or @user.regular?
- result = result.where('topics.id <> ?', query_opts[:except_topic_id]) if query_opts[:except_topic_id].present?
+ result = result.where('topics.id <> ?', query_opts[:except_topic_id]) if query_opts[:except_topic_id].present?
result = result.offset(query_opts[:page].to_i * page_size) if query_opts[:page].present?
- result
+ result
end
def new_results(list_opts={})
@@ -159,7 +159,7 @@ class TopicQuery
.where(closed: false, archived: false, visible: true)
.order('RANDOM()')
- results = results.where('category_id = ?', topic.category_id) if topic.category_id.present?
+ results = results.where('category_id = ?', topic.category_id) if topic.category_id.present?
results
end
diff --git a/lib/topic_view.rb b/lib/topic_view.rb
index 5ccbd398d..5504aef58 100644
--- a/lib/topic_view.rb
+++ b/lib/topic_view.rb
@@ -153,7 +153,7 @@ class TopicView
end
def all_post_actions
- @all_post_actions ||= PostAction.counts_for(posts, @user)
+ @all_post_actions ||= PostAction.counts_for(posts, @user)
end
def voted_in_topic?
@@ -182,8 +182,8 @@ class TopicView
end
def link_counts
- @link_counts ||= TopicLinkClick.counts_for(@topic, posts)
- end
+ @link_counts ||= TopicLinkClick.counts_for(@topic, posts)
+ end
# Binary search for closest value
def self.closest(array, target, min, max)
@@ -226,9 +226,9 @@ class TopicView
end
# This is pending a larger refactor, that allows custom orders
- # for now we need to look for the highest_post_number in the stream
- # the cache on topics is not correct if there are deleted posts at
- # the end of the stream (for mods), nor is it correct for filtered
+ # for now we need to look for the highest_post_number in the stream
+ # the cache on topics is not correct if there are deleted posts at
+ # the end of the stream (for mods), nor is it correct for filtered
# streams
def highest_post_number
@highest_post_number ||= @all_posts.maximum(:post_number)
@@ -245,7 +245,7 @@ class TopicView
posts_max = @max > (topic_user.last_read_post_number || 1 ) ? (topic_user.last_read_post_number || 1) : @max
PostTiming.select(:post_number)
- .where("topic_id = ? AND user_id = ? AND post_number BETWEEN ? AND ?",
+ .where("topic_id = ? AND user_id = ? AND post_number BETWEEN ? AND ?",
@topic.id, @user.id, @min, posts_max)
.each {|t| result << t.post_number}
result
diff --git a/lib/trust_level.rb b/lib/trust_level.rb
index 586d4a247..ab99dba61 100644
--- a/lib/trust_level.rb
+++ b/lib/trust_level.rb
@@ -18,7 +18,7 @@ class TrustLevel
end
def initialize(name_key, id)
- @name = I18n.t("trust_levels.#{name_key}.title")
+ @name = I18n.t("trust_levels.#{name_key}.title")
@id = id
end
diff --git a/lib/unread.rb b/lib/unread.rb
index 6ac8f273e..5aed0f251 100644
--- a/lib/unread.rb
+++ b/lib/unread.rb
@@ -11,8 +11,8 @@ class Unread
def unread_posts
return 0 if do_not_notify?(@topic_user.notification_level)
result = ((@topic_user.seen_post_count||0) - (@topic_user.last_read_post_number||0))
- result = 0 if result < 0
- result
+ result = 0 if result < 0
+ result
end
def new_posts
diff --git a/spec/components/category_list_spec.rb b/spec/components/category_list_spec.rb
index b88525a7b..1abefbb7c 100644
--- a/spec/components/category_list_spec.rb
+++ b/spec/components/category_list_spec.rb
@@ -7,7 +7,7 @@ describe CategoryList do
let(:category_list) { CategoryList.new(user) }
context "with no categories" do
-
+
it "has no categories" do
category_list.categories.should be_blank
end
@@ -35,7 +35,7 @@ describe CategoryList do
it "contains the topic in featured_topics" do
category.featured_topics.should == [topic]
end
-
+
end
end
@@ -73,7 +73,7 @@ describe CategoryList do
it "should contain our topic" do
category.featured_topics.should == [topic]
- end
+ end
end
diff --git a/spec/components/content_buffer_spec.rb b/spec/components/content_buffer_spec.rb
index 20c77f65e..43c265b2a 100644
--- a/spec/components/content_buffer_spec.rb
+++ b/spec/components/content_buffer_spec.rb
@@ -3,24 +3,24 @@ require 'content_buffer'
describe ContentBuffer do
- it "handles deletion across lines properly" do
+ it "handles deletion across lines properly" do
c = ContentBuffer.new("a\nbc\nc")
c.apply_transform!(start: {row: 0, col: 0}, finish: {col: 1, row: 1}, operation: :delete)
c.to_s.should == "c\nc"
end
- it "handles deletion inside lines properly" do
+ it "handles deletion inside lines properly" do
c = ContentBuffer.new("hello world")
c.apply_transform!(start: {row: 0, col: 1}, finish: {col: 4, row: 0}, operation: :delete)
c.to_s.should == "ho world"
end
-
- it "handles inserts inside lines properly" do
+
+ it "handles inserts inside lines properly" do
c = ContentBuffer.new("hello!")
c.apply_transform!(start: {row: 0, col: 5}, operation: :insert, text: " world")
c.to_s.should == "hello world!"
end
- it "handles multiline inserts" do
+ it "handles multiline inserts" do
c = ContentBuffer.new("hello!")
c.apply_transform!(start: {row: 0, col: 5}, operation: :insert, text: "\nworld")
c.to_s.should == "hello\nworld!"
diff --git a/spec/components/cooked_post_processor_spec.rb b/spec/components/cooked_post_processor_spec.rb
index 901a309b2..8e4a3df8c 100644
--- a/spec/components/cooked_post_processor_spec.rb
+++ b/spec/components/cooked_post_processor_spec.rb
@@ -66,7 +66,7 @@ EXPECTED
@post = Fabricate(:post_with_images)
end
- it "adds a topic image if there's one in the post" do
+ it "adds a topic image if there's one in the post" do
@post.topic.reload
@post.topic.image_url.should == "/path/to/img.jpg"
end
@@ -79,31 +79,31 @@ EXPECTED
end
end
- context 'link convertor' do
- before do
+ context 'link convertor' do
+ before do
SiteSetting.stubs(:crawl_images?).returns(true)
end
-
- let :post_with_img do
+
+ let :post_with_img do
Fabricate.build(:post, cooked: '
')
end
- let :cpp_for_post do
+ let :cpp_for_post do
CookedPostProcessor.new(post_with_img)
end
- it 'convert img tags to links if they are sized down' do
+ it 'convert img tags to links if they are sized down' do
cpp_for_post.expects(:get_size).returns([2000,2000]).twice
- cpp_for_post.post_process
+ cpp_for_post.post_process
cpp_for_post.html.should =~ /a href/
end
- it 'does not convert img tags to links if they are small' do
+ it 'does not convert img tags to links if they are small' do
cpp_for_post.expects(:get_size).returns([200,200]).twice
- cpp_for_post.post_process
+ cpp_for_post.post_process
(cpp_for_post.html !~ /a href/).should be_true
end
-
+
end
context 'image_dimensions' do
@@ -126,7 +126,7 @@ EXPECTED
SiteSetting.expects(:crawl_images?).returns(true)
FastImage.expects(:size).with(@url)
cpp.image_dimensions(@url)
- end
+ end
end
end
diff --git a/spec/components/current_user_spec.rb b/spec/components/current_user_spec.rb
index ad995b568..b5b021b7d 100644
--- a/spec/components/current_user_spec.rb
+++ b/spec/components/current_user_spec.rb
@@ -2,14 +2,14 @@ require 'spec_helper'
require_dependency 'current_user'
describe CurrentUser do
- it "allows us to lookup a user from our environment" do
+ it "allows us to lookup a user from our environment" do
token = EmailToken.generate_token
user = Fabricate.build(:user)
User.expects(:where).returns([user])
CurrentUser.lookup_from_env("HTTP_COOKIE" => "_t=#{token};").should == user
end
- # it "allows us to lookup a user from our app" do
+ # it "allows us to lookup a user from our app" do
# end
end
diff --git a/spec/components/discourse_plugin_registry_spec.rb b/spec/components/discourse_plugin_registry_spec.rb
index ea2ad312c..3c44a91c7 100644
--- a/spec/components/discourse_plugin_registry_spec.rb
+++ b/spec/components/discourse_plugin_registry_spec.rb
@@ -4,7 +4,7 @@ require 'discourse_plugin_registry'
describe DiscoursePluginRegistry do
let(:registry) { DiscoursePluginRegistry.new }
-
+
context '#stylesheets' do
it 'defaults to an empty Set' do
DiscoursePluginRegistry.stylesheets = nil
@@ -37,7 +37,7 @@ describe DiscoursePluginRegistry do
it "won't add the same file twice" do
lambda { registry.register_css('hello.css') }.should_not change(registry.stylesheets, :size)
- end
+ end
end
context '.register_js' do
@@ -51,7 +51,7 @@ describe DiscoursePluginRegistry do
it "won't add the same file twice" do
lambda { registry.register_js('hello.js') }.should_not change(registry.javascripts, :size)
- end
+ end
end
context '.register_archetype' do
diff --git a/spec/components/discourse_spec.rb b/spec/components/discourse_spec.rb
index 10cc61f45..0059511a8 100644
--- a/spec/components/discourse_spec.rb
+++ b/spec/components/discourse_spec.rb
@@ -48,7 +48,7 @@ describe Discourse do
end
-
+
end
diff --git a/spec/components/distributed_hash_spec.rb b/spec/components/distributed_hash_spec.rb
index 29f04af21..8df49fa47 100644
--- a/spec/components/distributed_hash_spec.rb
+++ b/spec/components/distributed_hash_spec.rb
@@ -2,11 +2,11 @@ require 'spec_helper'
require 'distributed_hash'
describe DiscoursePluginRegistry do
- # it 'should sync the sets across instances' do
+ # it 'should sync the sets across instances' do
# h1 = DistributedHash.new(:hash)
# h2 = DistributedHash.new(:hash)
- # h1[:hello] = "world"
+ # h1[:hello] = "world"
# h2[:hello].should == "world"
# end
end
diff --git a/spec/components/email_sender_spec.rb b/spec/components/email_sender_spec.rb
index 85de8d567..2465a7d75 100644
--- a/spec/components/email_sender_spec.rb
+++ b/spec/components/email_sender_spec.rb
@@ -22,7 +22,7 @@ describe EmailSender do
context 'with a valid message' do
- let(:message) do
+ let(:message) do
message = Mail::Message.new to: 'eviltrout@test.domain',
body: '**hello**'
message.stubs(:deliver)
@@ -67,22 +67,22 @@ describe EmailSender do
email_sender.send
end
- it 'makes the message multipart' do
+ it 'makes the message multipart' do
message.should be_multipart
end
- it 'has a html part' do
+ it 'has a html part' do
message.parts.detect {|p| p.content_type == "text/html; charset=UTF-8"}.should be_true
end
context 'html part' do
let(:html_part) { message.parts.detect {|p| p.content_type == "text/html; charset=UTF-8"} }
- it 'has a html part' do
+ it 'has a html part' do
html_part.should be_present
end
- it 'has run markdown on the body' do
+ it 'has run markdown on the body' do
html_part.body.to_s.should == "hello
"
end
@@ -95,7 +95,7 @@ describe EmailSender do
end
context 'with a user' do
- let(:message) do
+ let(:message) do
message = Mail::Message.new to: 'eviltrout@test.domain', body: 'test body'
message.stubs(:deliver)
message
diff --git a/spec/components/email_spec.rb b/spec/components/email_spec.rb
index 2676d463c..a9c6887e9 100644
--- a/spec/components/email_spec.rb
+++ b/spec/components/email_spec.rb
@@ -11,11 +11,11 @@ describe Email do
it 'should treat a bad email as invalid' do
Email.is_valid?('sam@sam').should be_false
end
-
+
it 'should allow museum tld' do
Email.is_valid?('sam@nic.museum').should be_true
end
-
+
it 'should not think a word is an email' do
Email.is_valid?('sam').should be_false
end
diff --git a/spec/components/guardian_spec.rb b/spec/components/guardian_spec.rb
index a63005a03..3c6034554 100644
--- a/spec/components/guardian_spec.rb
+++ b/spec/components/guardian_spec.rb
@@ -45,7 +45,7 @@ describe Guardian do
Guardian.new(user).post_can_act?(post, :like, taken_actions: {PostActionType.Types[:like] => 1}).should be_false
end
- it "returns false when you already flagged a post" do
+ it "returns false when you already flagged a post" do
Guardian.new(user).post_can_act?(post, :off_topic, taken_actions: {PostActionType.Types[:spam] => 1}).should be_false
end
@@ -68,7 +68,7 @@ describe Guardian do
end
- describe "can_clear_flags" do
+ describe "can_clear_flags" do
let(:post) { Fabricate(:post) }
let(:user) { post.user }
let(:moderator) { Fabricate(:moderator) }
@@ -97,7 +97,7 @@ describe Guardian do
it "returns false when the user is nil" do
Guardian.new(nil).can_send_private_message?(user).should be_false
- end
+ end
it "returns false when the target user is nil" do
Guardian.new(user).can_send_private_message?(nil).should be_false
@@ -320,7 +320,7 @@ describe Guardian do
end
end
-
+
it "allows new posts from moderators" do
Guardian.new(moderator).can_create?(Post, topic).should be_true
end
@@ -341,8 +341,8 @@ describe Guardian do
end
describe 'a Post' do
-
- let (:guardian) do
+
+ let (:guardian) do
Guardian.new(user)
end
@@ -361,14 +361,14 @@ describe Guardian do
it "allows voting if the user has performed a different action" do
guardian.post_can_act?(post,:vote,taken_actions: {PostActionType.Types[:like] => 1}).should be_true
- end
+ end
it "isn't allowed on archived topics" do
topic.archived = true
Guardian.new(user).post_can_act?(post,:like).should be_false
end
-
+
describe 'multiple voting' do
it "isn't allowed if the user voted and the topic doesn't allow multiple votes" do
@@ -490,7 +490,7 @@ describe Guardian do
it 'returns true when trying to edit yourself' do
Guardian.new(user).can_edit?(user).should be_true
- end
+ end
it 'returns false as a moderator' do
Guardian.new(moderator).can_edit?(user).should be_false
@@ -527,7 +527,7 @@ describe Guardian do
Guardian.new(admin).can_moderate?(topic).should be_true
end
- end
+ end
end
@@ -578,7 +578,7 @@ describe Guardian do
Guardian.new(admin).can_move_posts?(topic).should be_true
end
- end
+ end
end
@@ -735,11 +735,11 @@ describe Guardian do
end
it 'wont allow an admin to grant their own access' do
- Guardian.new(admin).can_grant_admin?(admin).should be_false
+ Guardian.new(admin).can_grant_admin?(admin).should be_false
end
it "allows an admin to grant a regular user access" do
- Guardian.new(admin).can_grant_admin?(user).should be_true
+ Guardian.new(admin).can_grant_admin?(user).should be_true
end
end
@@ -753,11 +753,11 @@ describe Guardian do
end
it 'wont allow an admin to revoke their own access' do
- Guardian.new(admin).can_revoke_admin?(admin).should be_false
+ Guardian.new(admin).can_revoke_admin?(admin).should be_false
end
it "allows an admin to revoke another admin's access" do
- Guardian.new(admin).can_revoke_admin?(another_admin).should be_true
+ Guardian.new(admin).can_revoke_admin?(another_admin).should be_true
end
end
@@ -771,15 +771,15 @@ describe Guardian do
end
it 'wont allow an admin to grant their own access' do
- Guardian.new(admin).can_grant_moderation?(admin).should be_false
+ Guardian.new(admin).can_grant_moderation?(admin).should be_false
end
it 'wont allow an admin to grant it to an already moderator' do
- Guardian.new(admin).can_grant_moderation?(moderator).should be_false
+ Guardian.new(admin).can_grant_moderation?(moderator).should be_false
end
it "allows an admin to grant a regular user access" do
- Guardian.new(admin).can_grant_moderation?(user).should be_true
+ Guardian.new(admin).can_grant_moderation?(user).should be_true
end
end
@@ -793,11 +793,11 @@ describe Guardian do
end
it 'wont allow an moderator to revoke their own moderator' do
- Guardian.new(moderator).can_revoke_moderation?(moderator).should be_false
+ Guardian.new(moderator).can_revoke_moderation?(moderator).should be_false
end
it "allows an admin to revoke a moderator's access" do
- Guardian.new(admin).can_revoke_moderation?(moderator).should be_true
+ Guardian.new(admin).can_revoke_moderation?(moderator).should be_true
end
end
@@ -818,4 +818,4 @@ describe Guardian do
end
end
-
+
diff --git a/spec/components/image_sizer_spec.rb b/spec/components/image_sizer_spec.rb
index 78fd4c780..b9c0b1691 100644
--- a/spec/components/image_sizer_spec.rb
+++ b/spec/components/image_sizer_spec.rb
@@ -36,7 +36,7 @@ describe ImageSizer do
it 'resizes the height retaining the aspect ratio' do
@h.should == 102
end
-
+
end
end
diff --git a/spec/components/jobs/enqueue_digest_emails_spec.rb b/spec/components/jobs/enqueue_digest_emails_spec.rb
index 1e54c0275..db0ada1a2 100644
--- a/spec/components/jobs/enqueue_digest_emails_spec.rb
+++ b/spec/components/jobs/enqueue_digest_emails_spec.rb
@@ -5,7 +5,7 @@ describe Jobs::EnqueueDigestEmails do
describe '#target_users' do
-
+
context 'disabled digests' do
let!(:user_no_digests) { Fabricate(:user, email_digests: false, last_emailed_at: 8.days.ago, last_seen_at: 10.days.ago) }
@@ -19,7 +19,7 @@ describe Jobs::EnqueueDigestEmails do
it "doesn't return users who have been emailed recently" do
Jobs::EnqueueDigestEmails.new.target_users.include?(user_emailed_recently).should be_false
- end
+ end
end
context 'visited the site today' do
@@ -27,7 +27,7 @@ describe Jobs::EnqueueDigestEmails do
it "doesn't return users who have been emailed recently" do
Jobs::EnqueueDigestEmails.new.target_users.include?(user_visited_today).should be_false
- end
+ end
end
diff --git a/spec/components/jobs/feature_topic_users_spec.rb b/spec/components/jobs/feature_topic_users_spec.rb
index 5b73e0ecd..073579d04 100644
--- a/spec/components/jobs/feature_topic_users_spec.rb
+++ b/spec/components/jobs/feature_topic_users_spec.rb
@@ -29,7 +29,7 @@ describe Jobs::FeatureTopicUsers do
topic.reload.featured_user_ids.include?(coding_horror.id).should be_true
end
- it "will not feature the second poster if we supply their post to be ignored" do
+ it "will not feature the second poster if we supply their post to be ignored" do
Jobs::FeatureTopicUsers.new.execute(topic_id: topic.id, except_post_id: second_post.id)
topic.reload.featured_user_ids.include?(coding_horror.id).should be_false
end
diff --git a/spec/components/jobs/jobs_base_spec.rb b/spec/components/jobs/jobs_base_spec.rb
index 07fb92033..29c6bc3ab 100644
--- a/spec/components/jobs/jobs_base_spec.rb
+++ b/spec/components/jobs/jobs_base_spec.rb
@@ -11,7 +11,7 @@ describe Jobs::Base do
it 'converts to an indifferent access hash' do
Jobs::Base.any_instance.expects(:execute).with(instance_of(HashWithIndifferentAccess))
Jobs::Base.new.perform('hello' => 'world', 'sync_exec' => true)
- end
+ end
end
diff --git a/spec/components/jobs/process_post_spec.rb b/spec/components/jobs/process_post_spec.rb
index e794b1dc4..622a94ceb 100644
--- a/spec/components/jobs/process_post_spec.rb
+++ b/spec/components/jobs/process_post_spec.rb
@@ -4,7 +4,7 @@ require 'jobs/process_post'
describe Jobs::ProcessPost do
it "returns when the post cannot be found" do
- lambda { Jobs::ProcessPost.new.perform(post_id: 1, sync_exec: true) }.should_not raise_error
+ lambda { Jobs::ProcessPost.new.perform(post_id: 1, sync_exec: true) }.should_not raise_error
end
context 'with a post' do
@@ -29,7 +29,7 @@ describe Jobs::ProcessPost do
CookedPostProcessor.any_instance.expects(:dirty?).returns(false)
Post.any_instance.expects(:update_column).never
Jobs::ProcessPost.new.execute(post_id: @post.id)
- end
+ end
end
diff --git a/spec/components/jobs/send_system_message_spec.rb b/spec/components/jobs/send_system_message_spec.rb
index aad609426..ce1ee1c4a 100644
--- a/spec/components/jobs/send_system_message_spec.rb
+++ b/spec/components/jobs/send_system_message_spec.rb
@@ -16,9 +16,9 @@ describe Jobs::SendSystemMessage do
let(:user) { Fabricate(:user) }
- it "should call SystemMessage.create" do
+ it "should call SystemMessage.create" do
SystemMessage.any_instance.expects(:create).with('welcome_invite')
- Jobs::SendSystemMessage.new.execute(user_id: user.id, message_type: 'welcome_invite')
+ Jobs::SendSystemMessage.new.execute(user_id: user.id, message_type: 'welcome_invite')
end
end
diff --git a/spec/components/jobs/user_email_spec.rb b/spec/components/jobs/user_email_spec.rb
index d4b83ad48..72aa1ec41 100644
--- a/spec/components/jobs/user_email_spec.rb
+++ b/spec/components/jobs/user_email_spec.rb
@@ -25,7 +25,7 @@ describe Jobs::UserEmail do
it "doesn't call the mailer when the user is missing" do
UserNotifications.expects(:digest).never
Jobs::UserEmail.new.execute(type: :digest, user_id: 1234)
- end
+ end
context 'to_address' do
@@ -34,12 +34,12 @@ describe Jobs::UserEmail do
EmailSender.any_instance.expects(:send)
Jobs::UserEmail.new.execute(type: :authorize_email, user_id: user.id, to_address: 'jake@adventuretime.ooo')
mailer.to.should == ['jake@adventuretime.ooo']
- end
+ end
end
context "recently seen" do
let(:post) { Fabricate(:post, user: user) }
-
+
it "doesn't send an email to a user that's been recently seen" do
user.update_column(:last_seen_at, 9.minutes.ago)
EmailSender.any_instance.expects(:send).never
@@ -48,7 +48,7 @@ describe Jobs::UserEmail do
end
context 'args' do
-
+
it 'passes a token as an argument when a token is present' do
UserNotifications.expects(:forgot_password).with(user, {email_token: 'asdfasdf'}).returns(mailer)
EmailSender.any_instance.expects(:send)
@@ -88,7 +88,7 @@ describe Jobs::UserEmail do
Jobs::UserEmail.new.execute(type: :user_mentioned, user_id: user.id, notification_id: notification.id)
end
- end
+ end
end
diff --git a/spec/components/multisite_i18n_spec.rb b/spec/components/multisite_i18n_spec.rb
index abdedac99..662fbd404 100644
--- a/spec/components/multisite_i18n_spec.rb
+++ b/spec/components/multisite_i18n_spec.rb
@@ -18,7 +18,7 @@ describe MultisiteI18n do
context "with a value for the multisite key" do
it "returns the overwritten value" do
MultisiteI18n.site_translate('other_site', 'test').should == "overwritten i18n"
- end
+ end
end
context "when we call t, it uses the current site" do
@@ -34,4 +34,4 @@ describe MultisiteI18n do
end
-end
\ No newline at end of file
+end
diff --git a/spec/components/oneboxer/amazon_onebox_spec.rb b/spec/components/oneboxer/amazon_onebox_spec.rb
index 6541f7c85..9728472ab 100644
--- a/spec/components/oneboxer/amazon_onebox_spec.rb
+++ b/spec/components/oneboxer/amazon_onebox_spec.rb
@@ -9,15 +9,15 @@ describe Oneboxer::AmazonOnebox 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'))
end
-
+
it "translates the URL" do
@o.translate_url.should == "http://www.amazon.com/gp/aw/d/0596516177"
end
-
+
it "generates the expected onebox for Amazon" do
@o.onebox.should == expected_amazon_result
end
-
+
private
def expected_amazon_result
<
EXPECTED
end
-end
\ No newline at end of file
+end
diff --git a/spec/components/oneboxer/android_app_store_onebox_spec.rb b/spec/components/oneboxer/android_app_store_onebox_spec.rb
index 9bed6000c..fca6cf191 100644
--- a/spec/components/oneboxer/android_app_store_onebox_spec.rb
+++ b/spec/components/oneboxer/android_app_store_onebox_spec.rb
@@ -4,16 +4,16 @@ require 'spec_helper'
require 'oneboxer'
require 'oneboxer/android_app_store_onebox'
-describe Oneboxer::AndroidAppStoreOnebox do
+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'))
end
-
+
it "generates the expected onebox for Android App Store" do
@o.onebox.should == expected_android_app_store_result
end
-
+
private
def expected_android_app_store_result
<
EXPECTED
end
-end
\ No newline at end of file
+end
diff --git a/spec/components/oneboxer/apple_app_onebox_spec.rb b/spec/components/oneboxer/apple_app_onebox_spec.rb
index fcf711307..e1ab1f0a8 100644
--- a/spec/components/oneboxer/apple_app_onebox_spec.rb
+++ b/spec/components/oneboxer/apple_app_onebox_spec.rb
@@ -9,11 +9,11 @@ describe Oneboxer::AppleAppOnebox 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'))
end
-
+
it "generates the expected onebox for Apple app" do
@o.onebox.should == expected_apple_app_result
end
-
+
private
def expected_apple_app_result
<
EXPECTED
end
-end
\ No newline at end of file
+end
diff --git a/spec/components/oneboxer/flickr_onebox_spec.rb b/spec/components/oneboxer/flickr_onebox_spec.rb
index b8033beca..fc38072b6 100644
--- a/spec/components/oneboxer/flickr_onebox_spec.rb
+++ b/spec/components/oneboxer/flickr_onebox_spec.rb
@@ -4,18 +4,18 @@ require 'spec_helper'
require 'oneboxer'
require 'oneboxer/flickr_onebox'
-describe Oneboxer::FlickrOnebox do
+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'))
end
-
+
it "generates the expected onebox for Flickr" do
@o.onebox.should == expected_flickr_result
end
-
+
private
def expected_flickr_result
" "
end
-end
\ No newline at end of file
+end
diff --git a/spec/components/oneboxer/gist_onebox_spec.rb b/spec/components/oneboxer/gist_onebox_spec.rb
index 9a8bf5fd4..716716fec 100644
--- a/spec/components/oneboxer/gist_onebox_spec.rb
+++ b/spec/components/oneboxer/gist_onebox_spec.rb
@@ -2,8 +2,8 @@ require 'spec_helper'
require 'oneboxer'
require 'oneboxer/gist_onebox'
-describe Oneboxer::GistOnebox do
- it "does not trip on user names" do
+describe Oneboxer::GistOnebox do
+ it "does not trip on user names" do
o = Oneboxer::GistOnebox.new('https://gist.github.com/aaa/4599619')
o.translate_url.should == 'https://api.github.com/gists/4599619'
end
diff --git a/spec/components/oneboxer/wikipedia_onebox_spec.rb b/spec/components/oneboxer/wikipedia_onebox_spec.rb
index f74b7bf9e..75bd6cc05 100644
--- a/spec/components/oneboxer/wikipedia_onebox_spec.rb
+++ b/spec/components/oneboxer/wikipedia_onebox_spec.rb
@@ -10,11 +10,11 @@ describe Oneboxer::WikipediaOnebox do
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'))
end
-
+
it "generates the expected onebox for Wikipedia" do
@o.onebox.should == expected_wikipedia_result
end
-
+
private
def expected_wikipedia_result
<
EXPECTED
end
-end
\ No newline at end of file
+end
diff --git a/spec/components/oneboxer_spec.rb b/spec/components/oneboxer_spec.rb
index 295b71c7e..5ddec3f29 100644
--- a/spec/components/oneboxer_spec.rb
+++ b/spec/components/oneboxer_spec.rb
@@ -1,12 +1,12 @@
require 'spec_helper'
require 'oneboxer'
-describe "Dynamic Oneboxer" do
+describe "Dynamic Oneboxer" do
class DummyDynamicOnebox < Oneboxer::BaseOnebox
- matcher do
+ matcher do
/^https?:\/\/dummy2.localhost/
end
-
+
def onebox
"dummy2!"
end
@@ -46,7 +46,7 @@ describe Oneboxer do
end
end
-
+
before do
Oneboxer.add_onebox DummyOnebox
@dummy_onebox_url = "http://dummy.localhost/dummy-object"
@@ -72,7 +72,7 @@ describe Oneboxer do
end
- context 'without caching' do
+ context 'without caching' do
it 'calls the onebox method of our matched class' do
Oneboxer.onebox_nocache(@dummy_onebox_url).should == 'dummy!'
end
@@ -108,7 +108,7 @@ describe Oneboxer do
end
it "created a OneboxRender record with the url" do
- @onebox_render.url.should == @dummy_onebox_url
+ @onebox_render.url.should == @dummy_onebox_url
end
it "associated the render with a post" do
@@ -157,11 +157,11 @@ describe Oneboxer do
element.is_a?(Nokogiri::XML::Element).should be_true
url.should == 'http://discourse.org'
end
- end
+ end
end
end
-
+
diff --git a/spec/components/post_creator_spec.rb b/spec/components/post_creator_spec.rb
index 5c5b074ec..e5570b64e 100644
--- a/spec/components/post_creator_spec.rb
+++ b/spec/components/post_creator_spec.rb
@@ -49,8 +49,8 @@ describe PostCreator do
it 'passes the image sizes through' do
Post.any_instance.expects(:image_sizes=).with(image_sizes)
creator_with_image_sizes.create
- end
- end
+ end
+ end
end
@@ -74,7 +74,7 @@ describe PostCreator do
it "passes through the reply_to_post_number" do
creator.create.reply_to_post_number.should == 4
- end
+ end
end
end
@@ -89,11 +89,11 @@ describe PostCreator do
target_usernames: [target_user1.username, target_user2.username].join(','))
end
- it 'has the right archetype' do
+ it 'has the right archetype' do
post.topic.archetype.should == Archetype.private_message
end
- it 'has the right count (me and 2 other users)' do
+ it 'has the right count (me and 2 other users)' do
post.topic.topic_allowed_users.count.should == 3
end
end
diff --git a/spec/components/post_revisor_spec.rb b/spec/components/post_revisor_spec.rb
index 36662d9cd..4430e3e9c 100644
--- a/spec/components/post_revisor_spec.rb
+++ b/spec/components/post_revisor_spec.rb
@@ -117,7 +117,7 @@ describe PostRevisor do
describe 'category topic' do
- let!(:category) do
+ let!(:category) do
category = Fabricate(:category)
category.update_column(:topic_id, topic.id)
category
@@ -156,7 +156,7 @@ describe PostRevisor do
it "updates the description of the category" do
category.description.should == new_description
- end
+ end
end
context 'when updating back to the original paragraph' do
diff --git a/spec/components/pretty_text_spec.rb b/spec/components/pretty_text_spec.rb
index bcd5875b8..943bf0d73 100644
--- a/spec/components/pretty_text_spec.rb
+++ b/spec/components/pretty_text_spec.rb
@@ -3,55 +3,55 @@ require 'pretty_text'
describe PrettyText do
- describe "Cooking" do
+ describe "Cooking" do
it "should support github style code blocks" do
PrettyText.cook("```
test
```").should == "test \n
"
end
- it "should support quoting [] " do
+ it "should support quoting [] " do
PrettyText.cook("[quote=\"EvilTrout, post:123, topic:456, full:true\"][sam][/quote]").should =~ /\[sam\]/
end
- it "produces a quote even with new lines in it" do
- PrettyText.cook("[quote=\"EvilTrout, post:123, topic:456, full:true\"]ddd\n[/quote]").should == "
\n
\n
\n EvilTrout\n said:\n
\n ddd \n
"
+ it "produces a quote even with new lines in it" do
+ PrettyText.cook("[quote=\"EvilTrout, post:123, topic:456, full:true\"]ddd\n[/quote]").should == "
\n
\n
\n EvilTrout\n said:\n
\n ddd \n
"
end
- it "should produce a quote" do
- PrettyText.cook("[quote=\"EvilTrout, post:123, topic:456, full:true\"]ddd[/quote]").should == "
\n
\n
\n EvilTrout\n said:\n
\n ddd \n
"
+ it "should produce a quote" do
+ PrettyText.cook("[quote=\"EvilTrout, post:123, topic:456, full:true\"]ddd[/quote]").should == "
\n
\n
\n EvilTrout\n said:\n
\n ddd \n
"
end
it "trims spaces on quote params" do
- PrettyText.cook("[quote=\"EvilTrout, post:555, topic: 666\"]ddd[/quote]").should == "
\n
\n
\n EvilTrout\n said:\n
\n ddd \n
"
+ PrettyText.cook("[quote=\"EvilTrout, post:555, topic: 666\"]ddd[/quote]").should == "
\n
\n
\n EvilTrout\n said:\n
\n ddd \n
"
end
- it "should handle 3 mentions in a row" do
+ it "should handle 3 mentions in a row" do
PrettyText.cook('@hello @hello @hello').should == "@hello @hello @hello
"
end
- it "should not do weird @ mention stuff inside a pre block" do
-
+ it "should not do weird @ mention stuff inside a pre block" do
+
PrettyText.cook("```
a @test
```").should == "a @test \n
"
-
+
end
it "should sanitize the html" do
PrettyText.cook("").should == "alert(42)"
end
- it "should escape html within the code block" do
-
+ it "should escape html within the code block" do
+
PrettyText.cook("```text
```").should == "<header>hello</header> \n
"
end
- it "should support language choices" do
-
+ it "should support language choices" do
+
PrettyText.cook("```ruby
test
```").should == "test \n
"
@@ -70,81 +70,81 @@ test
PrettyText.cook("[spoiler]hello[/spoiler]").should == "hello
"
end
- it "should only detect ``` at the begining of lines" do
+ it "should only detect ``` at the begining of lines" do
PrettyText.cook(" ```\n hello\n ```")
.should == "```\nhello\n```\n
"
end
end
-
+
describe "rel nofollow" do
- before do
+ before do
SiteSetting.stubs(:add_rel_nofollow_to_user_content).returns(true)
SiteSetting.stubs(:exclude_rel_nofollow_domains).returns("foo.com,bar.com")
end
- it "should inject nofollow in all user provided links" do
+ it "should inject nofollow in all user provided links" do
PrettyText.cook('cnn ').should =~ /nofollow/
end
-
- it "should not inject nofollow in all local links" do
- (PrettyText.cook("cnn ") !~ /nofollow/).should be_true
+
+ it "should not inject nofollow in all local links" do
+ (PrettyText.cook("cnn ") !~ /nofollow/).should be_true
end
-
- it "should not inject nofollow in all subdomain links" do
- (PrettyText.cook("cnn ") !~ /nofollow/).should be_true
+
+ it "should not inject nofollow in all subdomain links" do
+ (PrettyText.cook("cnn ") !~ /nofollow/).should be_true
end
it "should not inject nofollow for foo.com" do
- (PrettyText.cook("cnn ") !~ /nofollow/).should be_true
+ (PrettyText.cook("cnn ") !~ /nofollow/).should be_true
end
-
+
it "should not inject nofollow for bar.foo.com" do
- (PrettyText.cook("cnn ") !~ /nofollow/).should be_true
+ (PrettyText.cook("cnn ") !~ /nofollow/).should be_true
end
end
- describe "Excerpt" do
- it "should preserve links" do
+ describe "Excerpt" do
+ it "should preserve links" do
PrettyText.excerpt("cnn ",100).should == "cnn "
end
- it "should dump images" do
+ it "should dump images" do
PrettyText.excerpt(" ",100).should == "[image]"
end
-
- it "should keep alt tags" do
+
+ it "should keep alt tags" do
PrettyText.excerpt(" ",100).should == "[car]"
end
-
- it "should keep title tags" do
+
+ it "should keep title tags" do
PrettyText.excerpt(" ",100).should == "[car]"
end
- it "should deal with special keys properly" do
+ it "should deal with special keys properly" do
PrettyText.excerpt(" ",100).should == ""
end
- it "should truncate stuff properly" do
+ it "should truncate stuff properly" do
PrettyText.excerpt("hello world",5).should == "hello…"
end
- it "should insert a space between to Ps" do
+ it "should insert a space between to Ps" do
PrettyText.excerpt("a
b
",5).should == "a b "
end
- it "should strip quotes" do
+ it "should strip quotes" do
PrettyText.excerpt("boom",5).should == "boom"
end
- it "should not count the surrounds of a link" do
+ it "should not count the surrounds of a link" do
PrettyText.excerpt("cnn ",3).should == "cnn "
end
- it "should truncate links" do
+ it "should truncate links" do
PrettyText.excerpt("cnn ",2).should == "cn… "
end
- it "should be able to extract links" do
+ it "should be able to extract links" do
PrettyText.extract_links("http://bla.com ").to_a.should == ["http://cnn.com"]
end
@@ -156,7 +156,7 @@ test
PrettyText.extract_links("").to_a.should == ["/t/topic/1234/4567"]
end
- it "should not preserve tags in code blocks" do
+ it "should not preserve tags in code blocks" do
PrettyText.excerpt("<h3>Hours</h3>
",100).should == "<h3>Hours</h3>"
end
@@ -166,12 +166,12 @@ test
end
- describe "apply cdn" do
+ describe "apply cdn" do
it "should detect bare links to images and apply a CDN" do
PrettyText.apply_cdn("hello ","http://a.com").should ==
"hello "
end
- it "should not touch non images" do
+ it "should not touch non images" do
PrettyText.apply_cdn("hello ","http://a.com").should ==
"hello "
end
diff --git a/spec/components/rate_limiter_spec.rb b/spec/components/rate_limiter_spec.rb
index 0bcb304a5..c8d2f8e1e 100644
--- a/spec/components/rate_limiter_spec.rb
+++ b/spec/components/rate_limiter_spec.rb
@@ -10,7 +10,7 @@ describe RateLimiter do
before do
RateLimiter.stubs(:disabled?).returns(true)
rate_limiter.performed!
- rate_limiter.performed!
+ rate_limiter.performed!
end
it "returns true for can_perform?" do
@@ -26,7 +26,7 @@ describe RateLimiter do
context 'enabled' do
before do
RateLimiter.stubs(:disabled?).returns(false)
- rate_limiter.clear!
+ rate_limiter.clear!
end
context 'never done' do
@@ -93,7 +93,7 @@ describe RateLimiter do
end
- end
+ end
end
diff --git a/spec/components/score_calculator_spec.rb b/spec/components/score_calculator_spec.rb
index 703d1bfcc..dd9d7eaec 100644
--- a/spec/components/score_calculator_spec.rb
+++ b/spec/components/score_calculator_spec.rb
@@ -4,7 +4,7 @@ require 'score_calculator'
describe ScoreCalculator do
before do
- @post = Fabricate(:post, reads: 111)
+ @post = Fabricate(:post, reads: 111)
@topic = @post.topic
end
@@ -23,14 +23,14 @@ describe ScoreCalculator do
it "won't update the site settings when the site settings don't match" do
ScoreCalculator.new(reads: 3).calculate
- @topic.reload
+ @topic.reload
@topic.has_best_of.should be_false
end
it "removes the best_of flag if the topic no longer qualifies" do
@topic.update_column(:has_best_of, true)
ScoreCalculator.new(reads: 3).calculate
- @topic.reload
+ @topic.reload
@topic.has_best_of.should be_false
end
@@ -40,7 +40,7 @@ describe ScoreCalculator do
SiteSetting.expects(:best_of_score_threshold).returns(100)
ScoreCalculator.new(reads: 3).calculate
- @topic.reload
+ @topic.reload
@topic.has_best_of.should be_true
end
diff --git a/spec/components/search_spec.rb b/spec/components/search_spec.rb
index 717f63b7c..422b4de20 100644
--- a/spec/components/search_spec.rb
+++ b/spec/components/search_spec.rb
@@ -11,24 +11,24 @@ describe Search do
nil
end
- context 'post indexing observer' do
- before do
+ context 'post indexing observer' do
+ before do
@category = Fabricate(:category, name: 'america')
@topic = Fabricate(:topic, title: 'sam test topic', category: @category)
@post = Fabricate(:post, topic: @topic, raw: 'this fun test ')
@indexed = Topic.exec_sql("select search_data from posts_search where id = #{@post.id}").first["search_data"]
end
- it "should include body in index" do
+ it "should include body in index" do
@indexed.should =~ /fun/
end
- it "should include title in index" do
+ it "should include title in index" do
@indexed.should =~ /sam/
end
- it "should include category in index" do
+ it "should include category in index" do
@indexed.should =~ /america/
end
- it "should pick up on title updates" do
+ it "should pick up on title updates" do
@topic.title = "harpi is the new title"
@topic.save!
@indexed = Topic.exec_sql("select search_data from posts_search where id = #{@post.id}").first["search_data"]
@@ -37,28 +37,28 @@ describe Search do
end
end
- context 'user indexing observer' do
- before do
+ context 'user indexing observer' do
+ before do
@user = Fabricate(:user, username: 'fred', name: 'bob jones')
@indexed = User.exec_sql("select search_data from users_search where id = #{@user.id}").first["search_data"]
end
- it "should pick up on username" do
+ it "should pick up on username" do
@indexed.should =~ /fred/
end
- it "should pick up on name" do
+ it "should pick up on name" do
@indexed.should =~ /jone/
end
end
- context 'category indexing observer' do
- before do
+ context 'category indexing observer' do
+ before do
@category = Fabricate(:category, name: 'america')
@indexed = Topic.exec_sql("select search_data from categories_search where id = #{@category.id}").first["search_data"]
end
- it "should pick up on name" do
+ it "should pick up on name" do
@indexed.should =~ /america/
end
@@ -103,9 +103,9 @@ describe Search do
context 'topics' do
let!(:topic) { Fabricate(:topic) }
- context 'searching the OP' do
+ context 'searching the OP' do
- let!(:post) { Fabricate(:post, topic: topic, user: topic.user) }
+ let!(:post) { Fabricate(:post, topic: topic, user: topic.user) }
let(:result) { first_of_type(Search.query('hello'), 'topic') }
it 'returns a result' do
@@ -118,7 +118,7 @@ describe Search do
it 'has a url for the post' do
result['url'].should == topic.relative_url
- end
+ end
end
end
@@ -138,7 +138,7 @@ describe Search do
it 'has a url for the topic' do
result['url'].should == "/category/#{category.slug}"
- end
+ end
end
@@ -147,7 +147,7 @@ describe Search do
let!(:user) { Fabricate(:user, username: 'amazing', email: 'amazing@amazing.com') }
let!(:category) { Fabricate(:category, name: 'amazing category', user: user) }
-
+
context 'user filter' do
let(:results) { Search.query('amazing', 'user') }
diff --git a/spec/components/slug_spec.rb b/spec/components/slug_spec.rb
index ec4509b10..614dce908 100644
--- a/spec/components/slug_spec.rb
+++ b/spec/components/slug_spec.rb
@@ -17,11 +17,11 @@ describe Slug do
Slug.for('evil#trout').should == 'evil-trout'
end
- it 'handles a.b.c properly' do
+ it 'handles a.b.c properly' do
Slug.for("a.b.c").should == "a-b-c"
end
- it 'handles double dots right' do
+ it 'handles double dots right' do
Slug.for("a....b.....c").should == "a-b-c"
end
diff --git a/spec/components/sql_builder_spec.rb b/spec/components/sql_builder_spec.rb
index da46943e6..baf793a62 100644
--- a/spec/components/sql_builder_spec.rb
+++ b/spec/components/sql_builder_spec.rb
@@ -4,12 +4,12 @@ require_dependency 'sql_builder'
describe SqlBuilder do
- describe "attached" do
- before do
+ describe "attached" do
+ before do
@builder = Post.sql_builder("select * from posts /*where*/ /*limit*/")
end
- it "should find a post by id" do
+ it "should find a post by id" do
p = Fabricate(:post)
@builder.where('id = :id and topic_id = :topic_id', id: p.id, topic_id: p.topic_id)
p2 = @builder.exec.first
@@ -18,18 +18,18 @@ describe SqlBuilder do
end
end
- describe "detached" do
- before do
+ describe "detached" do
+ before do
@builder = SqlBuilder.new("select * from (select :a A union all select :b) as X /*where*/ /*order_by*/ /*limit*/ /*offset*/")
end
- it "should allow for 1 param exec" do
- @builder.exec(a: 1, b: 2).values[0][0].should == '1'
+ it "should allow for 1 param exec" do
+ @builder.exec(a: 1, b: 2).values[0][0].should == '1'
end
- it "should allow for a single where" do
+ it "should allow for a single where" do
@builder.where(":a = 1")
- @builder.exec(a: 1, b: 2).values[0][0].should == '1'
+ @builder.exec(a: 1, b: 2).values[0][0].should == '1'
end
it "should allow where chaining" do
diff --git a/spec/components/system_message_spec.rb b/spec/components/system_message_spec.rb
index c15f47af6..640a4cece 100644
--- a/spec/components/system_message_spec.rb
+++ b/spec/components/system_message_spec.rb
@@ -8,7 +8,7 @@ describe SystemMessage do
context 'send' do
let(:user) { Fabricate(:user) }
- let(:system_message) { SystemMessage.new(user) }
+ let(:system_message) { SystemMessage.new(user) }
let(:post) { system_message.create(:welcome_invite) }
let(:topic) { post.topic }
diff --git a/spec/components/text_sentinel_spec.rb b/spec/components/text_sentinel_spec.rb
index 4356c6ba8..8706c6381 100644
--- a/spec/components/text_sentinel_spec.rb
+++ b/spec/components/text_sentinel_spec.rb
@@ -95,7 +95,7 @@ describe TextSentinel do
TextSentinel.new(valid_string, min_entropy: 16).should be_valid
end
- it "enforces the minimum entropy" do
+ it "enforces the minimum entropy" do
TextSentinel.new(valid_string, min_entropy: 17).should_not be_valid
end
@@ -110,7 +110,7 @@ describe TextSentinel do
it "doesn't except junk symbols as a string" do
TextSentinel.new("[[[").should_not be_valid
TextSentinel.new("<<<").should_not be_valid
- TextSentinel.new("{{$!").should_not be_valid
+ TextSentinel.new("{{$!").should_not be_valid
end
diff --git a/spec/components/topic_query_spec.rb b/spec/components/topic_query_spec.rb
index 7348a6788..5661a69a5 100644
--- a/spec/components/topic_query_spec.rb
+++ b/spec/components/topic_query_spec.rb
@@ -36,10 +36,10 @@ describe TopicQuery do
end
context 'categorized' do
- let(:category) { Fabricate(:category) }
- let!(:topic_no_cat) { Fabricate(:topic) }
+ let(:category) { Fabricate(:category) }
+ let!(:topic_no_cat) { Fabricate(:topic) }
let!(:topic_in_cat) { Fabricate(:topic, category: category) }
-
+
it "returns the topic without a category when filtering uncategorized" do
topic_query.list_uncategorized.topics.should == [topic_no_cat]
end
@@ -89,12 +89,12 @@ describe TopicQuery do
end
end
- context 'user with auto_track_topics list_unread' do
- before do
+ context 'user with auto_track_topics list_unread' do
+ before do
user.auto_track_topics_after_msecs = 0
user.save
end
-
+
it 'only contains the partially read topic' do
topic_query.list_unread.topics.should == [partially_read]
end
@@ -107,7 +107,7 @@ describe TopicQuery do
context 'list_read' do
it 'contain both topics ' do
topic_query.list_read.topics.should =~ [fully_read, partially_read]
- end
+ end
end
end
@@ -122,7 +122,7 @@ describe TopicQuery do
end
context 'with a favorited topic' do
-
+
before do
topic.toggle_star(user, true)
end
@@ -147,7 +147,7 @@ describe TopicQuery do
end
context 'with a new topic' do
- let!(:new_topic) { Fabricate(:topic, user: creator, bumped_at: 10.minutes.ago) }
+ let!(:new_topic) { Fabricate(:topic, user: creator, bumped_at: 10.minutes.ago) }
let(:topics) { topic_query.list_new.topics }
@@ -156,7 +156,7 @@ describe TopicQuery do
end
it "contains no new topics for a user that has missed the window" do
- user.new_topic_duration_minutes = 5
+ user.new_topic_duration_minutes = 5
user.save
new_topic.created_at = 10.minutes.ago
new_topic.save
@@ -168,7 +168,7 @@ describe TopicQuery do
new_topic.notify_muted!(user)
end
- it "returns an empty set" do
+ it "returns an empty set" do
topics.should be_blank
end
@@ -181,9 +181,9 @@ describe TopicQuery do
topics.should == [new_topic]
end
end
- end
+ end
end
-
+
end
context 'list_posted' do
@@ -219,8 +219,8 @@ describe TopicQuery do
let!(:new_topic) { Fabricate(:post, user: creator).topic }
it "should return the new topic" do
- TopicQuery.new.list_suggested_for(topic).topics.should == [new_topic]
- end
+ TopicQuery.new.list_suggested_for(topic).topics.should == [new_topic]
+ end
end
context "anonymously browswing with invisible, closed and archived" do
@@ -231,7 +231,7 @@ describe TopicQuery do
let!(:invisible_topic) { Fabricate(:topic, user: creator, visible: false) }
it "should omit the closed/archived/invisbiel topics from suggested" do
- TopicQuery.new.list_suggested_for(topic).topics.should == [regular_topic]
+ TopicQuery.new.list_suggested_for(topic).topics.should == [regular_topic]
end
end
@@ -247,7 +247,7 @@ describe TopicQuery do
context 'with some existing topics' do
let!(:partially_read) { Fabricate(:post, user: creator).topic }
let!(:new_topic) { Fabricate(:post, user: creator).topic }
- let!(:fully_read) { Fabricate(:post, user: creator).topic }
+ let!(:fully_read) { Fabricate(:post, user: creator).topic }
let!(:closed_topic) { Fabricate(:topic, user: creator, closed: true) }
let!(:archived_topic) { Fabricate(:topic, user: creator, archived: true) }
let!(:invisible_topic) { Fabricate(:topic, user: creator, visible: false) }
@@ -274,7 +274,7 @@ describe TopicQuery do
suggested_topics.should == [partially_read.id, new_topic.id, fully_read.id]
end
- end
+ end
end
end
diff --git a/spec/components/topic_view_spec.rb b/spec/components/topic_view_spec.rb
index 41bf55118..d9d495721 100644
--- a/spec/components/topic_view_spec.rb
+++ b/spec/components/topic_view_spec.rb
@@ -21,7 +21,7 @@ describe TopicView do
lambda { topic_view }.should raise_error(Discourse::InvalidAccess)
end
- it "raises NotLoggedIn if the user isn't logged in and is trying to view a private message" do
+ it "raises NotLoggedIn if the user isn't logged in and is trying to view a private message" do
Topic.any_instance.expects(:private_message?).returns(true)
lambda { TopicView.new(topic.id, nil) }.should raise_error(Discourse::NotLoggedIn)
end
@@ -105,16 +105,16 @@ describe TopicView do
end
end
- it 'allows admins to see deleted posts' do
+ it 'allows admins to see deleted posts' do
post_number = p3.post_number
p3.destroy
admin = Fabricate(:admin)
- topic_view = TopicView.new(topic.id, admin)
+ topic_view = TopicView.new(topic.id, admin)
topic_view.posts.count.should == 3
topic_view.highest_post_number.should == post_number
end
-
- it 'does not allow non admins to see deleted posts' do
+
+ it 'does not allow non admins to see deleted posts' do
p3.destroy
topic_view.posts.count.should == 2
end
@@ -138,7 +138,7 @@ describe TopicView do
it "is allows users to see likes" do
topic_view.post_action_visibility.include?(PostActionType.Types[:like]).should be_true
end
-
+
end
context '.read?' do
@@ -185,7 +185,7 @@ describe TopicView do
it 'is the inital load' do
near_topic_view.should be_initial_load
- end
+ end
end
@@ -231,7 +231,7 @@ describe TopicView do
it "isn't the inital load" do
topic_view.should_not be_initial_load
- end
+ end
end
end
@@ -264,7 +264,7 @@ describe TopicView do
SiteSetting.stubs(:posts_per_page).returns(20)
post_numbers = ((1..20).to_a << [100, 105] << (110..150).to_a).flatten
- TopicView.any_instance.stubs(:post_numbers).returns(post_numbers)
+ TopicView.any_instance.stubs(:post_numbers).returns(post_numbers)
end
it "will return posts even if the post required is missing" do
diff --git a/spec/components/unread_spec.rb b/spec/components/unread_spec.rb
index 1d7d439d7..c567ee9bd 100644
--- a/spec/components/unread_spec.rb
+++ b/spec/components/unread_spec.rb
@@ -18,19 +18,19 @@ describe Unread do
@topic_user.stubs(:last_read_post_number).returns(13)
@topic_user.stubs(:seen_post_count).returns(13)
@unread.unread_posts.should == 0
- end
+ end
it 'should have 6 unread posts if the user has seen all but 6 posts' do
@topic_user.stubs(:last_read_post_number).returns(5)
- @topic_user.stubs(:seen_post_count).returns(11)
+ @topic_user.stubs(:seen_post_count).returns(11)
@unread.unread_posts.should == 6
- end
+ end
it 'should have 0 unread posts if the user has seen more posts than exist (deleted)' do
@topic_user.stubs(:last_read_post_number).returns(100)
@topic_user.stubs(:seen_post_count).returns(13)
@unread.unread_posts.should == 0
- end
+ end
end
describe 'new_posts' do
@@ -48,7 +48,7 @@ describe Unread do
@topic_user.stubs(:seen_post_count).returns(10)
@unread.new_posts.should == 3
end
-
+
it 'has 0 new posts if the user has read 10 posts but is not tracking' do
@topic_user.stubs(:seen_post_count).returns(10)
@topic_user.stubs(:notification_level).returns(TopicUser::NotificationLevel::REGULAR)
@@ -58,7 +58,7 @@ describe Unread do
it 'has 0 new posts if the user read more posts than exist (deleted)' do
@topic_user.stubs(:seen_post_count).returns(16)
@unread.new_posts.should == 0
- end
+ end
end
end
diff --git a/spec/controllers/admin/email_logs_controller_spec.rb b/spec/controllers/admin/email_logs_controller_spec.rb
index 0f027e00b..c6c45c341 100644
--- a/spec/controllers/admin/email_logs_controller_spec.rb
+++ b/spec/controllers/admin/email_logs_controller_spec.rb
@@ -9,7 +9,7 @@ describe Admin::EmailLogsController do
let!(:user) { log_in(:admin) }
context '.index' do
- before do
+ before do
xhr :get, :index
end
@@ -26,7 +26,7 @@ describe Admin::EmailLogsController do
context 'with an email address' do
it 'enqueues a test email job' do
- Jobs.expects(:enqueue).with(:test_email, to_address: 'eviltrout@test.domain')
+ Jobs.expects(:enqueue).with(:test_email, to_address: 'eviltrout@test.domain')
xhr :post, :test, email_address: 'eviltrout@test.domain'
end
@@ -34,4 +34,4 @@ describe Admin::EmailLogsController do
end
-end
\ No newline at end of file
+end
diff --git a/spec/controllers/admin/export_controller_spec.rb b/spec/controllers/admin/export_controller_spec.rb
index 938bcb8c6..5baf74f69 100644
--- a/spec/controllers/admin/export_controller_spec.rb
+++ b/spec/controllers/admin/export_controller_spec.rb
@@ -4,7 +4,7 @@ describe Admin::ExportController do
it "is a subclass of AdminController" do
(Admin::ExportController < Admin::AdminController).should be_true
end
-
+
context 'while logged in as an admin' do
before do
@user = log_in(:admin)
@@ -54,4 +54,4 @@ describe Admin::ExportController do
end
end
end
-end
\ No newline at end of file
+end
diff --git a/spec/controllers/admin/flags_controller_spec.rb b/spec/controllers/admin/flags_controller_spec.rb
index 7cffed99f..4851caea7 100644
--- a/spec/controllers/admin/flags_controller_spec.rb
+++ b/spec/controllers/admin/flags_controller_spec.rb
@@ -23,10 +23,10 @@ describe Admin::FlagsController do
it 'returns a valid json payload when some thing is flagged' do
p = Fabricate(:post)
u = Fabricate(:user)
-
+
PostAction.act(u, p, PostActionType.Types[:spam])
xhr :get, :index
-
+
data = ::JSON.parse(response.body)
data["users"].length == 2
data["posts"].length == 1
@@ -34,4 +34,4 @@ describe Admin::FlagsController do
end
end
end
-
+
diff --git a/spec/controllers/admin/impersonate_controller_spec.rb b/spec/controllers/admin/impersonate_controller_spec.rb
index 0665f1794..835a96170 100644
--- a/spec/controllers/admin/impersonate_controller_spec.rb
+++ b/spec/controllers/admin/impersonate_controller_spec.rb
@@ -50,12 +50,12 @@ describe Admin::ImpersonateController do
it "also works with an email address" do
xhr :post, :create, username_or_email: user.email
session[:current_user_id].should == user.id
- end
+ end
it "also works with a name" do
xhr :post, :create, username_or_email: user.name
session[:current_user_id].should == user.id
- end
+ end
end
diff --git a/spec/controllers/admin/site_customizations_controller_spec.rb b/spec/controllers/admin/site_customizations_controller_spec.rb
index f5f9e33dc..22ab60fb6 100644
--- a/spec/controllers/admin/site_customizations_controller_spec.rb
+++ b/spec/controllers/admin/site_customizations_controller_spec.rb
@@ -20,16 +20,16 @@ describe Admin::SiteCustomizationsController do
it 'returns JSON' do
xhr :get, :index
::JSON.parse(response.body).should be_present
- end
+ end
end
context ' .create' do
- it 'returns success' do
+ it 'returns success' do
xhr :post, :create, site_customization: {name: 'my test name'}
response.should be_success
end
-
- it 'returns json' do
+
+ it 'returns json' do
xhr :post, :create, site_customization: {name: 'my test name'}
::JSON.parse(response.body).should be_present
end
diff --git a/spec/controllers/admin/site_settings_controller_spec.rb b/spec/controllers/admin/site_settings_controller_spec.rb
index 2eeec9fd1..4724518ec 100644
--- a/spec/controllers/admin/site_settings_controller_spec.rb
+++ b/spec/controllers/admin/site_settings_controller_spec.rb
@@ -20,7 +20,7 @@ describe Admin::SiteSettingsController do
it 'returns JSON' do
xhr :get, :index
::JSON.parse(response.body).should be_present
- end
+ end
end
context 'update' do
@@ -40,4 +40,4 @@ describe Admin::SiteSettingsController do
-end
\ No newline at end of file
+end
diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb
index e882b7ab8..1e5d645cc 100644
--- a/spec/controllers/admin/users_controller_spec.rb
+++ b/spec/controllers/admin/users_controller_spec.rb
@@ -20,7 +20,7 @@ describe Admin::UsersController do
it 'returns JSON' do
xhr :get, :index
::JSON.parse(response.body).should be_present
- end
+ end
end
context '.show' do
@@ -81,7 +81,7 @@ describe Admin::UsersController do
response.should be_forbidden
end
- it 'updates the admin flag' do
+ it 'updates the admin flag' do
xhr :put, :revoke_admin, user_id: @another_admin.id
@another_admin.reload
@another_admin.should_not be_admin
@@ -99,12 +99,12 @@ describe Admin::UsersController do
response.should be_forbidden
end
- it "returns a 404 if the username doesn't exist" do
+ it "returns a 404 if the username doesn't exist" do
xhr :put, :grant_admin, user_id: 123123
response.should be_forbidden
end
- it 'updates the admin flag' do
+ it 'updates the admin flag' do
xhr :put, :grant_admin, user_id: @another_user.id
@another_user.reload
@another_user.should be_admin
@@ -122,7 +122,7 @@ describe Admin::UsersController do
response.should be_forbidden
end
- it 'updates the moderator flag' do
+ it 'updates the moderator flag' do
xhr :put, :revoke_moderation, user_id: @moderator.id
@moderator.reload
@moderator.has_trust_level?(:moderator).should_not be_true
@@ -140,12 +140,12 @@ describe Admin::UsersController do
response.should be_forbidden
end
- it "returns a 404 if the username doesn't exist" do
+ it "returns a 404 if the username doesn't exist" do
xhr :put, :grant_moderation, user_id: 123123
response.should be_forbidden
end
- it 'updates the moderator flag' do
+ it 'updates the moderator flag' do
xhr :put, :grant_moderation, user_id: @another_user.id
@another_user.reload
@another_user.has_trust_level?(:moderator).should be_true
diff --git a/spec/controllers/categories_controller_spec.rb b/spec/controllers/categories_controller_spec.rb
index b9db1b586..73979ed65 100644
--- a/spec/controllers/categories_controller_spec.rb
+++ b/spec/controllers/categories_controller_spec.rb
@@ -65,19 +65,19 @@ describe CategoriesController do
describe 'logged in' do
before do
@user = log_in
- @category = Fabricate(:category, user: @user)
+ @category = Fabricate(:category, user: @user)
end
it "raises an exception if they don't have permission to delete it" do
Guardian.any_instance.expects(:can_delete_category?).returns(false)
xhr :delete, :destroy, id: @category.slug
response.should be_forbidden
- end
+ end
it "deletes the record" do
Guardian.any_instance.expects(:can_delete_category?).returns(true)
lambda { xhr :delete, :destroy, id: @category.slug}.should change(Category, :count).by(-1)
- end
+ end
end
end
@@ -90,7 +90,7 @@ describe CategoriesController do
describe 'logged in' do
- before do
+ before do
@user = log_in(:moderator)
@category = Fabricate(:category, user: @user)
end
@@ -101,11 +101,11 @@ describe CategoriesController do
response.should be_forbidden
end
- it "requires a name" do
+ it "requires a name" do
lambda { xhr :put, :update, id: @category.slug, color: '#fff' }.should raise_error(Discourse::InvalidParameters)
end
- it "requires a color" do
+ it "requires a color" do
lambda { xhr :put, :update, id: @category.slug, name: 'asdf'}.should raise_error(Discourse::InvalidParameters)
end
diff --git a/spec/controllers/clicks_controller_spec.rb b/spec/controllers/clicks_controller_spec.rb
index dac92ed13..9c7f252c7 100644
--- a/spec/controllers/clicks_controller_spec.rb
+++ b/spec/controllers/clicks_controller_spec.rb
@@ -25,19 +25,19 @@ describe ClicksController do
context 'with a post_id' do
it 'calls create_from' do
TopicLinkClick.expects(:create_from).with(url: 'http://discourse.org', post_id: 123, ip: '192.168.0.1')
- xhr :get, :track, url: 'http://discourse.org', post_id: 123
+ xhr :get, :track, url: 'http://discourse.org', post_id: 123
response.should redirect_to("http://discourse.org")
end
it 'redirects to the url' do
TopicLinkClick.stubs(:create_from)
- xhr :get, :track, url: 'http://discourse.org', post_id: 123
+ xhr :get, :track, url: 'http://discourse.org', post_id: 123
response.should redirect_to("http://discourse.org")
end
it 'will pass the user_id to create_from' do
TopicLinkClick.expects(:create_from).with(url: 'http://discourse.org', post_id: 123, ip: '192.168.0.1')
- xhr :get, :track, url: 'http://discourse.org', post_id: 123
+ xhr :get, :track, url: 'http://discourse.org', post_id: 123
response.should redirect_to("http://discourse.org")
end
@@ -52,13 +52,13 @@ describe ClicksController do
context 'with a topic_id' do
it 'calls create_from' do
TopicLinkClick.expects(:create_from).with(url: 'http://discourse.org', topic_id: 789, ip: '192.168.0.1')
- xhr :get, :track, url: 'http://discourse.org', topic_id: 789
+ xhr :get, :track, url: 'http://discourse.org', topic_id: 789
response.should redirect_to("http://discourse.org")
- end
+ end
end
end
end
-end
\ No newline at end of file
+end
diff --git a/spec/controllers/draft_controller_spec.rb b/spec/controllers/draft_controller_spec.rb
index ce810f70d..c73b9a6ca 100644
--- a/spec/controllers/draft_controller_spec.rb
+++ b/spec/controllers/draft_controller_spec.rb
@@ -12,11 +12,11 @@ describe DraftController do
Draft.get(user, 'xyz', 0).should == 'my data'
end
- it 'destroys drafts when required' do
+ it 'destroys drafts when required' do
user = log_in
Draft.set(user, 'xxx', 0, 'hi')
delete :destroy, draft_key: 'xxx', sequence: 0
Draft.get(user, 'xxx', 0).should be_nil
end
-
+
end
diff --git a/spec/controllers/education_controller_spec.rb b/spec/controllers/education_controller_spec.rb
index 4593979a0..ab2c8cc69 100644
--- a/spec/controllers/education_controller_spec.rb
+++ b/spec/controllers/education_controller_spec.rb
@@ -21,7 +21,7 @@ describe EducationController do
end
context 'with a valid id' do
-
+
let(:markdown_content) { "Education *markdown* content" }
let(:html_content) {"HTML Content"}
diff --git a/spec/controllers/email_controller_spec.rb b/spec/controllers/email_controller_spec.rb
index 31ebb5eff..0d1d8d6b3 100644
--- a/spec/controllers/email_controller_spec.rb
+++ b/spec/controllers/email_controller_spec.rb
@@ -69,7 +69,7 @@ describe EmailController do
it 'sets not found' do
assigns(:not_found).should be_true
- end
+ end
end
context 'when logged in as the keyed user' do
@@ -86,7 +86,7 @@ describe EmailController do
it "doesn't set not found" do
assigns(:not_found).should be_blank
- end
+ end
end
it "sets not_found when the key didn't match anything" do
diff --git a/spec/controllers/excerpt_controller_spec.rb b/spec/controllers/excerpt_controller_spec.rb
index 6e0dce03c..9647865bf 100644
--- a/spec/controllers/excerpt_controller_spec.rb
+++ b/spec/controllers/excerpt_controller_spec.rb
@@ -25,7 +25,7 @@ describe ExcerptController do
xhr :get, :show, url: @url
end
- it 'returns a valid status' do
+ it 'returns a valid status' do
response.should be_success
end
@@ -44,7 +44,7 @@ describe ExcerptController do
xhr :get, :show, url: @url
end
- it 'returns a valid status' do
+ it 'returns a valid status' do
response.should be_success
end
@@ -63,7 +63,7 @@ describe ExcerptController do
xhr :get, :show, url: @url
end
- it 'returns a valid status' do
+ it 'returns a valid status' do
response.should be_success
end
diff --git a/spec/controllers/invites_controller_spec.rb b/spec/controllers/invites_controller_spec.rb
index f273ccf5e..cfdf94476 100644
--- a/spec/controllers/invites_controller_spec.rb
+++ b/spec/controllers/invites_controller_spec.rb
@@ -10,11 +10,11 @@ describe InvitesController do
}.should raise_error(Discourse::NotLoggedIn)
end
- context 'while logged in' do
+ context 'while logged in' do
let!(:user) { log_in }
let!(:invite) { Fabricate(:invite, invited_by: user) }
let(:another_invite) { Fabricate(:invite, email: 'anotheremail@address.com') }
-
+
it 'raises an error when the email is missing' do
lambda { delete :destroy }.should raise_error(Discourse::InvalidParameters)
@@ -46,13 +46,13 @@ describe InvitesController do
get :show, id: "doesn't exist"
end
- it "redirects to the root" do
+ it "redirects to the root" do
response.should redirect_to("/")
- end
+ end
- it "should not change the session" do
+ it "should not change the session" do
session[:current_user_id].should be_blank
- end
+ end
end
@@ -64,13 +64,13 @@ describe InvitesController do
get :show, id: deleted_invite.invite_key
end
- it "redirects to the root" do
+ it "redirects to the root" do
response.should redirect_to("/")
- end
+ end
- it "should not change the session" do
+ it "should not change the session" do
session[:current_user_id].should be_blank
- end
+ end
end
@@ -78,7 +78,7 @@ describe InvitesController do
context 'with a valid invite id' do
let(:topic) { Fabricate(:topic) }
let(:invite) { topic.invite_by_email(topic.user, "iceking@adventuretime.ooo") }
-
+
it 'redeems the invite' do
Invite.any_instance.expects(:redeem)
@@ -88,10 +88,10 @@ describe InvitesController do
context 'when redeem returns a user' do
let(:user) { Fabricate(:coding_horror) }
- context 'success' do
+ context 'success' do
before do
Invite.any_instance.expects(:redeem).returns(user)
- get :show, id: invite.invite_key
+ get :show, id: invite.invite_key
end
it 'logs in the user' do
@@ -109,13 +109,13 @@ describe InvitesController do
Jobs.expects(:enqueue).with(:invite_email, has_key(:invite_id))
end
- it 'sends a welcome message if set' do
- user.send_welcome_message = true
+ it 'sends a welcome message if set' do
+ user.send_welcome_message = true
user.expects(:enqueue_welcome_message).with('welcome_invite')
get :show, id: invite.invite_key
end
- it "doesn't send a welcome message if not set" do
+ it "doesn't send a welcome message if not set" do
user.expects(:enqueue_welcome_message).with('welcome_invite').never
get :show, id: invite.invite_key
end
@@ -137,11 +137,11 @@ describe InvitesController do
Invite.any_instance.expects(:redeem).returns(user)
get :show, id: invite.invite_key
cookies[:_access].should == 'adventure time!'
- end
+ end
- end
+ end
- end
+ end
end
diff --git a/spec/controllers/list_controller_spec.rb b/spec/controllers/list_controller_spec.rb
index 6827c0390..d349e006d 100644
--- a/spec/controllers/list_controller_spec.rb
+++ b/spec/controllers/list_controller_spec.rb
@@ -2,8 +2,8 @@ require 'spec_helper'
describe ListController do
- # we need some data
- before do
+ # we need some data
+ before do
@user = Fabricate(:coding_horror)
@post = Fabricate(:post, :user => @user)
end
diff --git a/spec/controllers/notifications_controller_spec.rb b/spec/controllers/notifications_controller_spec.rb
index 4d58df56d..0e95b3309 100644
--- a/spec/controllers/notifications_controller_spec.rb
+++ b/spec/controllers/notifications_controller_spec.rb
@@ -5,7 +5,7 @@ describe NotificationsController do
context 'when logged in' do
let!(:user) { log_in }
- before do
+ before do
xhr :get, :index
end
@@ -16,7 +16,7 @@ describe NotificationsController do
context 'when not logged in' do
it 'should raise an error' do
lambda { xhr :get, :index }.should raise_error(Discourse::NotLoggedIn)
- end
+ end
end
end
diff --git a/spec/controllers/post_actions_controller_spec.rb b/spec/controllers/post_actions_controller_spec.rb
index 642ceb60c..b7416c161 100644
--- a/spec/controllers/post_actions_controller_spec.rb
+++ b/spec/controllers/post_actions_controller_spec.rb
@@ -20,7 +20,7 @@ describe PostActionsController do
it 'raises an error when the post_action_type_id index is missing' do
lambda { xhr :post, :create, id: @post.id }.should raise_error(Discourse::InvalidParameters)
end
-
+
it "fails when the user doesn't have permission to see the post" do
Guardian.any_instance.expects(:can_see?).with(@post).returns(false)
xhr :post, :create, id: @post.id, post_action_type_id: PostActionType.Types[:like]
@@ -92,7 +92,7 @@ describe PostActionsController do
context "not logged in" do
it "should not allow them to clear flags" do
lambda { xhr :post, :clear_flags }.should raise_error(Discourse::NotLoggedIn)
- end
+ end
end
context 'logged in' do
@@ -103,21 +103,21 @@ describe PostActionsController do
end
it "raises an error when the user doesn't have access" do
- Guardian.any_instance.expects(:can_clear_flags?).returns(false)
+ Guardian.any_instance.expects(:can_clear_flags?).returns(false)
xhr :post, :clear_flags, id: flagged_post.id, post_action_type_id: PostActionType.Types[:spam]
response.should be_forbidden
end
context "success" do
before do
- Guardian.any_instance.expects(:can_clear_flags?).returns(true)
+ Guardian.any_instance.expects(:can_clear_flags?).returns(true)
PostAction.expects(:clear_flags!).with(flagged_post, user.id, PostActionType.Types[:spam])
end
- it "delegates to clear_flags" do
+ it "delegates to clear_flags" do
xhr :post, :clear_flags, id: flagged_post.id, post_action_type_id: PostActionType.Types[:spam]
response.should be_success
- end
+ end
it "works with a deleted post" do
flagged_post.destroy
@@ -163,7 +163,7 @@ describe PostActionsController do
xhr :get, :users, id: post.id, post_action_type_id: PostActionType.Types[:like]
response.should be_forbidden
end
-
+
it 'succeeds' do
xhr :get, :users, id: post.id, post_action_type_id: PostActionType.Types[:like]
response.should be_success
diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb
index 88c5d85ce..037453fbc 100644
--- a/spec/controllers/posts_controller_spec.rb
+++ b/spec/controllers/posts_controller_spec.rb
@@ -24,18 +24,18 @@ describe PostsController do
post.destroy
end
- it "can't find deleted posts as an anonymous user" do
+ it "can't find deleted posts as an anonymous user" do
xhr :get, :show, id: post.id
response.should be_forbidden
end
- it "can't find deleted posts as a regular user" do
+ it "can't find deleted posts as a regular user" do
log_in(:user)
xhr :get, :show, id: post.id
response.should be_forbidden
end
- it "can find posts as a moderator" do
+ it "can find posts as a moderator" do
log_in(:moderator)
xhr :get, :show, id: post.id
response.should be_success
@@ -121,7 +121,7 @@ describe PostsController do
describe 'destroy_many' do
it 'raises an exception when not logged in' do
lambda { xhr :delete, :destroy_many, post_ids: [123, 345] }.should raise_error(Discourse::NotLoggedIn)
- end
+ end
describe 'when logged in' do
@@ -168,7 +168,7 @@ describe PostsController do
let(:post) { Fabricate(:post, user: log_in) }
let(:update_params) do
- {id: post.id,
+ {id: post.id,
post: {raw: 'edited body'},
image_sizes: {'http://image.com/image.jpg' => {'width' => 123, 'height' => 456}}}
end
@@ -180,7 +180,7 @@ describe PostsController do
it "raises an error when the post parameter is missing" do
update_params.delete(:post)
- lambda {
+ lambda {
xhr :put, :update, update_params
}.should raise_error(Discourse::InvalidParameters)
end
@@ -217,7 +217,7 @@ describe PostsController do
it "raises an error if the user doesn't have permission to see the post" do
Guardian.any_instance.expects(:can_see?).with(post).returns(false)
- xhr :put, :bookmark, post_id: post.id, bookmarked: 'true'
+ xhr :put, :bookmark, post_id: post.id, bookmarked: 'true'
response.should be_forbidden
end
@@ -278,7 +278,7 @@ describe PostsController do
it "passes title through" do
PostCreator.expects(:new).with(user, has_entries(title: 'new topic title')).returns(post_creator)
- xhr :post, :create, post: {raw: 'hello'}, title: 'new topic title'
+ xhr :post, :create, post: {raw: 'hello'}, title: 'new topic title'
end
it "passes topic_id through" do
@@ -293,12 +293,12 @@ describe PostsController do
it "passes category through" do
PostCreator.expects(:new).with(user, has_entries(category: 'cool')).returns(post_creator)
- xhr :post, :create, post: {raw: 'hello', category: 'cool'}
+ xhr :post, :create, post: {raw: 'hello', category: 'cool'}
end
it "passes target_usernames through" do
PostCreator.expects(:new).with(user, has_entries(target_usernames: 'evil,trout')).returns(post_creator)
- xhr :post, :create, post: {raw: 'hello'}, target_usernames: 'evil,trout'
+ xhr :post, :create, post: {raw: 'hello'}, target_usernames: 'evil,trout'
end
it "passes reply_to_post_number through" do
@@ -309,12 +309,12 @@ describe PostsController do
it "passes image_sizes through" do
PostCreator.expects(:new).with(user, has_entries(image_sizes: 'test')).returns(post_creator)
xhr :post, :create, post: {raw: 'hello'}, image_sizes: 'test'
- end
+ end
it "passes meta_data through" do
PostCreator.expects(:new).with(user, has_entries(meta_data: {'xyz' => 'abc'})).returns(post_creator)
xhr :post, :create, post: {raw: 'hello'}, meta_data: {xyz: 'abc'}
- end
+ end
end
diff --git a/spec/controllers/request_access_controller_spec.rb b/spec/controllers/request_access_controller_spec.rb
index d4b9ebc69..07ec02274 100644
--- a/spec/controllers/request_access_controller_spec.rb
+++ b/spec/controllers/request_access_controller_spec.rb
@@ -11,7 +11,7 @@ describe RequestAccessController do
it "assigns the return path we provide" do
get :new, return_path: '/asdf'
assigns(:return_path).should == "/asdf"
- end
+ end
end
@@ -43,7 +43,7 @@ describe RequestAccessController do
it 'redirects to the return path' do
response.should redirect_to('/the-path')
- end
+ end
it 'sets no flash error' do
flash[:error].should be_blank
diff --git a/spec/controllers/robots_txt_controller_spec.rb b/spec/controllers/robots_txt_controller_spec.rb
index 6bd739c06..8b2b29082 100644
--- a/spec/controllers/robots_txt_controller_spec.rb
+++ b/spec/controllers/robots_txt_controller_spec.rb
@@ -13,9 +13,9 @@ describe RobotsTxtController do
SiteSetting.stubs(:allow_index_in_robots_txt).returns(false)
get :index
response.should render_template :no_index
- end
-
- it "serves it regardless if a site is in private mode" do
+ end
+
+ it "serves it regardless if a site is in private mode" do
SiteSetting.stubs(:allow_index_in_robots_txt).returns(true)
SiteSetting.stubs(:restrict_access).returns(true)
get :index
diff --git a/spec/controllers/session_controller_spec.rb b/spec/controllers/session_controller_spec.rb
index 59be73069..44d54e38d 100644
--- a/spec/controllers/session_controller_spec.rb
+++ b/spec/controllers/session_controller_spec.rb
@@ -118,28 +118,28 @@ describe SessionController do
end
context 'for a non existant username' do
- it "doesn't generate a new token for a made up username" do
+ it "doesn't generate a new token for a made up username" do
lambda { xhr :post, :forgot_password, username: 'made_up'}.should_not change(EmailToken, :count)
end
- it "doesn't enqueue an email" do
+ it "doesn't enqueue an email" do
Jobs.expects(:enqueue).with(:user_mail, anything).never
xhr :post, :forgot_password, username: 'made_up'
- end
- end
+ end
+ end
context 'for an existing username' do
let(:user) { Fabricate(:user) }
- it "generates a new token for a made up username" do
+ it "generates a new token for a made up username" do
lambda { xhr :post, :forgot_password, username: user.username}.should change(EmailToken, :count)
end
- it "enqueues an email" do
+ it "enqueues an email" do
Jobs.expects(:enqueue).with(:user_email, has_entries(type: :forgot_password, user_id: user.id))
xhr :post, :forgot_password, username: user.username
- end
- end
+ end
+ end
end
diff --git a/spec/controllers/static_controller_spec.rb b/spec/controllers/static_controller_spec.rb
index b828f2026..f236f9feb 100644
--- a/spec/controllers/static_controller_spec.rb
+++ b/spec/controllers/static_controller_spec.rb
@@ -8,7 +8,7 @@ describe StaticController do
xhr :get, :show, :id => 'faq'
end
- it 'renders the static file if present' do
+ it 'renders the static file if present' do
response.should be_success
end
diff --git a/spec/controllers/topics_controller_spec.rb b/spec/controllers/topics_controller_spec.rb
index d4c4b38d6..fccd19ae2 100644
--- a/spec/controllers/topics_controller_spec.rb
+++ b/spec/controllers/topics_controller_spec.rb
@@ -44,7 +44,7 @@ describe TopicsController do
it "has a url" do
::JSON.parse(response.body)['url'].should be_present
- end
+ end
end
context 'failure' do
@@ -67,7 +67,7 @@ describe TopicsController do
::JSON.parse(response.body)['url'].should be_blank
end
- end
+ end
end
@@ -96,7 +96,7 @@ describe TopicsController do
end
it 'requires the enabled parameter' do
- lambda { xhr :put, :status, topic_id: @topic.id, status: 'visible' }.should raise_error(Discourse::InvalidParameters)
+ lambda { xhr :put, :status, topic_id: @topic.id, status: 'visible' }.should raise_error(Discourse::InvalidParameters)
end
it 'raises an error with a status not in the whitelist' do
@@ -132,7 +132,7 @@ describe TopicsController do
it 'deletes the forum topic user record' do
PostTiming.expects(:destroy_for).with(@user.id, @topic.id)
- xhr :delete, :destroy_timings, topic_id: @topic.id
+ xhr :delete, :destroy_timings, topic_id: @topic.id
end
end
@@ -140,7 +140,7 @@ describe TopicsController do
end
- describe 'mute/unmute' do
+ describe 'mute/unmute' do
it 'needs you to be logged in' do
lambda { xhr :put, :mute, topic_id: 99}.should raise_error(Discourse::NotLoggedIn)
@@ -150,7 +150,7 @@ describe TopicsController do
lambda { xhr :put, :unmute, topic_id: 99}.should raise_error(Discourse::NotLoggedIn)
end
- describe 'when logged in' do
+ describe 'when logged in' do
before do
@topic = Fabricate(:topic, user: log_in)
end
@@ -158,12 +158,12 @@ describe TopicsController do
it "changes the user's starred flag when the parameter is present" do
Topic.any_instance.expects(:toggle_mute).with(@topic.user, true)
xhr :put, :mute, topic_id: @topic.id, starred: 'true'
- end
+ end
it "removes the user's starred flag when the parameter is not true" do
Topic.any_instance.expects(:toggle_mute).with(@topic.user, false)
xhr :put, :unmute, topic_id: @topic.id, starred: 'false'
- end
+ end
end
@@ -182,20 +182,20 @@ describe TopicsController do
it "ensures the user can see the topic" do
Guardian.any_instance.expects(:can_see?).with(@topic).returns(false)
- xhr :put, :star, topic_id: @topic.id, starred: 'true'
+ xhr :put, :star, topic_id: @topic.id, starred: 'true'
response.should be_forbidden
end
it "changes the user's starred flag when the parameter is present" do
Topic.any_instance.expects(:toggle_star).with(@topic.user, true)
xhr :put, :star, topic_id: @topic.id, starred: 'true'
- end
+ end
it "removes the user's starred flag when the parameter is not true" do
Topic.any_instance.expects(:toggle_star).with(@topic.user, false)
xhr :put, :star, topic_id: @topic.id, starred: 'false'
- end
- end
+ end
+ end
end
describe 'delete' do
@@ -213,7 +213,7 @@ describe TopicsController do
Guardian.any_instance.expects(:can_delete?).with(@topic).returns(false)
xhr :delete, :destroy, id: @topic.id
response.should be_forbidden
- end
+ end
end
describe 'with permission' do
@@ -236,7 +236,7 @@ describe TopicsController do
end
end
- describe 'show' do
+ describe 'show' do
let(:topic) { Fabricate(:post).topic }
let!(:p1) { Fabricate(:post, user: topic.user) }
@@ -251,7 +251,7 @@ describe TopicsController do
lambda { xhr :get, :show, id: topic.id }.should change(View, :count).by(1)
end
- it 'tracks a visit for all html requests' do
+ it 'tracks a visit for all html requests' do
current_user = log_in(:coding_horror)
TopicUser.expects(:track_visit!).with(topic, current_user)
get :show, id: topic.id
@@ -293,7 +293,7 @@ describe TopicsController do
it 'delegates a posts_before param to TopicView#filter_posts_before' do
TopicView.any_instance.expects(:filter_posts_before).with(p2.post_number)
xhr :get, :show, id: topic.id, posts_before: p2.post_number
- end
+ end
end
@@ -314,7 +314,7 @@ describe TopicsController do
Guardian.any_instance.expects(:can_edit?).with(@topic).returns(false)
xhr :put, :update, topic_id: @topic.id, slug: @topic.title
response.should be_forbidden
- end
+ end
end
describe 'with permission' do
@@ -345,7 +345,7 @@ describe TopicsController do
describe 'invite' do
it "won't allow us to invite toa topic when we're not logged in" do
lambda { xhr :post, :invite, topic_id: 1, email: 'jake@adventuretime.ooo' }.should raise_error(Discourse::NotLoggedIn)
- end
+ end
describe 'when logged in' do
before do
@@ -361,7 +361,7 @@ describe TopicsController do
Guardian.any_instance.expects(:can_invite_to?).with(@topic).returns(false)
xhr :post, :invite, topic_id: @topic.id, user: 'jake@adventuretime.ooo'
response.should be_forbidden
- end
+ end
end
describe 'with permission' do
@@ -382,7 +382,7 @@ describe TopicsController do
it 'returns success JSON' do
::JSON.parse(response.body).should == {'success' => 'OK'}
- end
+ end
end
context 'when it fails and returns nil' do
@@ -398,7 +398,7 @@ describe TopicsController do
it 'returns success JSON' do
::JSON.parse(response.body).should == {'failed' => 'FAILED'}
- end
+ end
end
diff --git a/spec/fabricators/post_fabricator.rb b/spec/fabricators/post_fabricator.rb
index 55c562c28..a3748136b 100644
--- a/spec/fabricators/post_fabricator.rb
+++ b/spec/fabricators/post_fabricator.rb
@@ -1,7 +1,7 @@
Fabricator(:post) do
user
topic {|attrs| Fabricate(:topic, user: attrs[:user] ) }
- raw "Hello world"
+ raw "Hello world"
end
Fabricator(:post_with_youtube, from: :post) do
@@ -17,7 +17,7 @@ Fabricator(:moderator_post, from: :post) do
user
topic {|attrs| Fabricate(:topic, user: attrs[:user] ) }
post_type Post::MODERATOR_ACTION
- raw "Hello world"
+ raw "Hello world"
end
diff --git a/spec/fabricators/topic_fabricator.rb b/spec/fabricators/topic_fabricator.rb
index bc4e60746..84eb17fe8 100644
--- a/spec/fabricators/topic_fabricator.rb
+++ b/spec/fabricators/topic_fabricator.rb
@@ -4,18 +4,18 @@ Fabricator(:topic) do
end
Fabricator(:deleted_topic, from: :topic) do
- deleted_at Time.now
+ deleted_at Time.now
end
-Fabricator(:topic_allowed_user) do
+Fabricator(:topic_allowed_user) do
end
-Fabricator(:private_message_topic, from: :topic) do
+Fabricator(:private_message_topic, from: :topic) do
user
title { sequence(:title) { |i| "Private Message #{i}" } }
archetype "private_message"
- topic_allowed_users{|t| [
- Fabricate.build(:topic_allowed_user, user_id: t[:user].id),
+ topic_allowed_users{|t| [
+ Fabricate.build(:topic_allowed_user, user_id: t[:user].id),
Fabricate.build(:topic_allowed_user, user_id: Fabricate(:coding_horror).id)
]}
end
diff --git a/spec/fabricators/user_fabricator.rb b/spec/fabricators/user_fabricator.rb
index 879bd6366..dfbcb853b 100644
--- a/spec/fabricators/user_fabricator.rb
+++ b/spec/fabricators/user_fabricator.rb
@@ -9,21 +9,21 @@ end
Fabricator(:coding_horror, from: :user) do
name 'Coding Horror'
- username 'CodingHorror'
+ username 'CodingHorror'
email 'jeff@somewhere.com'
password 'mymoreawesomepassword'
end
Fabricator(:evil_trout, from: :user) do
name 'Evil Trout'
- username 'eviltrout'
+ username 'eviltrout'
email 'eviltrout@somewhere.com'
password 'imafish'
end
Fabricator(:walter_white, from: :user) do
name 'Walter White'
- username 'heisenberg'
+ username 'heisenberg'
email 'wwhite@bluemeth.com'
password 'letscook'
end
diff --git a/spec/integrity/i18n_spec.rb b/spec/integrity/i18n_spec.rb
index cea7f54f2..c9a9d17b1 100644
--- a/spec/integrity/i18n_spec.rb
+++ b/spec/integrity/i18n_spec.rb
@@ -17,7 +17,7 @@ describe "i18n integrity checks" do
it "needs an i18n key (notification_types) for each Notification type" do
Notification.Types.keys.each do |type|
- I18n.t("notification_types.#{type}").should_not =~ /translation missing/
+ I18n.t("notification_types.#{type}").should_not =~ /translation missing/
end
end
diff --git a/spec/javascripts/sanitize_spec.js b/spec/javascripts/sanitize_spec.js
index d5b642ea0..ba8369d52 100644
--- a/spec/javascripts/sanitize_spec.js
+++ b/spec/javascripts/sanitize_spec.js
@@ -4,7 +4,7 @@ describe("sanitize", function(){
it("strips all script tags", function(){
- var sanitized = sanitizeHtml("
");
+ var sanitized = sanitizeHtml("
");
expect(sanitized)
.toBe("
");
diff --git a/spec/javascripts/utilities_spec.js b/spec/javascripts/utilities_spec.js
index a062dbf1a..068f696d7 100644
--- a/spec/javascripts/utilities_spec.js
+++ b/spec/javascripts/utilities_spec.js
@@ -42,7 +42,7 @@
return "" + name;
}
});
- return expect(cooked).toBe("1
\n \n
\n" +
+ return expect(cooked).toBe("
1
\n
2
");
});
it("includes no avatar if none is found", function() {
diff --git a/spec/mailers/invite_mailer_spec.rb b/spec/mailers/invite_mailer_spec.rb
index 08703f769..21953d6be 100644
--- a/spec/mailers/invite_mailer_spec.rb
+++ b/spec/mailers/invite_mailer_spec.rb
@@ -1,7 +1,7 @@
require "spec_helper"
describe InviteMailer do
-
+
describe "send_invite" do
let(:invite) { Fabricate(:invite) }
subject { InviteMailer.send_invite(invite) }
diff --git a/spec/mailers/test_mailer_spec.rb b/spec/mailers/test_mailer_spec.rb
index a9a783736..939d1cfab 100644
--- a/spec/mailers/test_mailer_spec.rb
+++ b/spec/mailers/test_mailer_spec.rb
@@ -1,7 +1,7 @@
require "spec_helper"
describe TestMailer do
-
+
describe "send_test" do
subject { TestMailer.send_test('marcheline@adventuretime.ooo') }
diff --git a/spec/mailers/user_notifications_spec.rb b/spec/mailers/user_notifications_spec.rb
index b75f899bd..c7431c163 100644
--- a/spec/mailers/user_notifications_spec.rb
+++ b/spec/mailers/user_notifications_spec.rb
@@ -1,7 +1,7 @@
require "spec_helper"
describe UserNotifications do
-
+
let(:user) { Fabricate(:user) }
describe ".signup" do
@@ -19,7 +19,7 @@ describe UserNotifications do
its(:to) { should == [user.email] }
its(:subject) { should be_present }
its(:from) { should == [SiteSetting.notification_email] }
- its(:body) { should be_present }
+ its(:body) { should be_present }
end
describe '.daily_digest' do
@@ -37,7 +37,7 @@ describe UserNotifications do
its(:to) { should == [user.email] }
its(:subject) { should be_present }
its(:from) { should == [SiteSetting.notification_email] }
- its(:body) { should be_present }
+ its(:body) { should be_present }
end
end
@@ -53,7 +53,7 @@ describe UserNotifications do
its(:to) { should == [user.email] }
its(:subject) { should be_present }
its(:from) { should == [SiteSetting.notification_email] }
- its(:body) { should be_present }
+ its(:body) { should be_present }
end
diff --git a/spec/models/category_featured_topic_spec.rb b/spec/models/category_featured_topic_spec.rb
index 3d8dc25a2..c327d66c0 100644
--- a/spec/models/category_featured_topic_spec.rb
+++ b/spec/models/category_featured_topic_spec.rb
@@ -4,6 +4,6 @@ describe CategoryFeaturedTopic do
it { should belong_to :category }
it { should belong_to :topic }
-
+
end
diff --git a/spec/models/category_featured_user_spec.rb b/spec/models/category_featured_user_spec.rb
index 35982499f..a4d4a8e74 100644
--- a/spec/models/category_featured_user_spec.rb
+++ b/spec/models/category_featured_user_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
describe CategoryFeaturedUser do
-
+
it { should belong_to :category }
it { should belong_to :user }
diff --git a/spec/models/category_spec.rb b/spec/models/category_spec.rb
index 9f1c713e5..8a69e80a0 100644
--- a/spec/models/category_spec.rb
+++ b/spec/models/category_spec.rb
@@ -24,9 +24,9 @@ describe Category do
let(:category) { Fabricate.build(:category, name: SiteSetting.uncategorized_name) }
it "is invalid to create a category with the reserved name" do
- category.should_not be_valid
+ category.should_not be_valid
end
-
+
end
describe "short name" do
@@ -92,7 +92,7 @@ describe Category do
end
it 'creates a topic post' do
- @topic.should be_present
+ @topic.should be_present
end
it 'points back to itself' do
@@ -160,15 +160,15 @@ describe Category do
end
describe 'update_stats' do
-
+
before do
@category = Fabricate(:category)
end
-
+
context 'with regular topics' do
before do
- @category.topics << Fabricate(:topic, user: @category.user)
+ @category.topics << Fabricate(:topic, user: @category.user)
Category.update_stats
@category.reload
end
@@ -184,13 +184,13 @@ describe Category do
it 'updates topics_year' do
@category.topics_year.should == 1
end
-
+
end
-
+
context 'with deleted topics' do
before do
- @category.topics << Fabricate(:deleted_topic,
+ @category.topics << Fabricate(:deleted_topic,
user: @category.user)
Category.update_stats
@category.reload
diff --git a/spec/models/draft_sequence_spec.rb b/spec/models/draft_sequence_spec.rb
index 0b747ecad..935fe8c7b 100644
--- a/spec/models/draft_sequence_spec.rb
+++ b/spec/models/draft_sequence_spec.rb
@@ -7,7 +7,7 @@ describe DraftSequence do
DraftSequence.next!(u, 'test').should == 2
end
- it 'should return 0 by default' do
+ it 'should return 0 by default' do
u = Fabricate(:user)
DraftSequence.current(u, 'test').should == 0
end
diff --git a/spec/models/draft_spec.rb b/spec/models/draft_spec.rb
index 93114bcf1..680a77910 100644
--- a/spec/models/draft_spec.rb
+++ b/spec/models/draft_spec.rb
@@ -1,10 +1,10 @@
require 'spec_helper'
describe Draft do
- before do
+ before do
@user = Fabricate(:user)
end
- it "can get a draft by user" do
+ it "can get a draft by user" do
Draft.set(@user, "test", 0, "data")
Draft.get(@user, "test", 0).should == "data"
end
@@ -14,19 +14,19 @@ describe Draft do
Draft.get(Fabricate(:coding_horror), "test", 0).should be_nil
end
- it "should overwrite draft data correctly" do
+ it "should overwrite draft data correctly" do
Draft.set(@user, "test", 0, "data")
Draft.set(@user, "test", 0, "new data")
Draft.get(@user, "test", 0).should == "new data"
end
- it "should clear drafts on request" do
+ it "should clear drafts on request" do
Draft.set(@user, "test", 0, "data")
Draft.clear(@user, "test", 0)
Draft.get(@user, "test", 0).should be_nil
end
- it "should disregard old draft if sequence decreases" do
+ it "should disregard old draft if sequence decreases" do
Draft.set(@user, "test", 0, "data")
Draft.set(@user, "test", 1, "hello")
Draft.set(@user, "test", 0, "foo")
@@ -35,26 +35,26 @@ describe Draft do
end
- context 'key expiry' do
- it 'nukes new topic draft after a topic is created' do
+ context 'key expiry' do
+ it 'nukes new topic draft after a topic is created' do
u = Fabricate(:user)
- Draft.set(u, Draft::NEW_TOPIC, 0, 'my draft')
+ Draft.set(u, Draft::NEW_TOPIC, 0, 'my draft')
t = Fabricate(:topic, user: u)
s = DraftSequence.current(u, Draft::NEW_TOPIC)
Draft.get(u, Draft::NEW_TOPIC, s).should be_nil
end
- it 'nukes new pm draft after a pm is created' do
+ it 'nukes new pm draft after a pm is created' do
u = Fabricate(:user)
- Draft.set(u, Draft::NEW_PRIVATE_MESSAGE, 0, 'my draft')
+ Draft.set(u, Draft::NEW_PRIVATE_MESSAGE, 0, 'my draft')
t = Fabricate(:topic, user: u, archetype: Archetype.private_message)
s = DraftSequence.current(t.user, Draft::NEW_PRIVATE_MESSAGE)
Draft.get(u, Draft::NEW_PRIVATE_MESSAGE, s).should be_nil
end
- it 'does not nuke new topic draft after a pm is created' do
+ it 'does not nuke new topic draft after a pm is created' do
u = Fabricate(:user)
- Draft.set(u, Draft::NEW_TOPIC, 0, 'my draft')
+ Draft.set(u, Draft::NEW_TOPIC, 0, 'my draft')
t = Fabricate(:topic, user: u, archetype: Archetype.private_message)
s = DraftSequence.current(t.user, Draft::NEW_TOPIC)
Draft.get(u, Draft::NEW_TOPIC, s).should == 'my draft'
diff --git a/spec/models/email_log_spec.rb b/spec/models/email_log_spec.rb
index 9072af6ad..3e362ff84 100644
--- a/spec/models/email_log_spec.rb
+++ b/spec/models/email_log_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
describe EmailLog do
-
+
it { should belong_to :user }
it { should validate_presence_of :to_address }
diff --git a/spec/models/email_token_spec.rb b/spec/models/email_token_spec.rb
index 30bda644a..18f74ee60 100644
--- a/spec/models/email_token_spec.rb
+++ b/spec/models/email_token_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
describe EmailToken do
-
+
it { should validate_presence_of :user_id }
it { should validate_presence_of :email }
it { should belong_to :user }
@@ -60,13 +60,13 @@ describe EmailToken do
it 'returns nil when a token is expired' do
email_token.update_column(:expired, true)
EmailToken.confirm(email_token.token).should be_blank
- end
+ end
it 'returns nil when a token is older than a specific time' do
EmailToken.expects(:valid_after).returns(1.week.ago)
email_token.update_column(:created_at, 2.weeks.ago)
EmailToken.confirm(email_token.token).should be_blank
- end
+ end
context 'taken email address' do
diff --git a/spec/models/error_log_spec.rb b/spec/models/error_log_spec.rb
index 1a1cc971a..bcee623c0 100644
--- a/spec/models/error_log_spec.rb
+++ b/spec/models/error_log_spec.rb
@@ -5,8 +5,8 @@ describe ErrorLog do
raise "boom"
end
- def exception
- begin
+ def exception
+ begin
boom
rescue => e
return e
@@ -29,30 +29,30 @@ describe ErrorLog do
end
end
- describe "logging data" do
+ describe "logging data" do
it "is able to read the data it writes" do
ErrorLog.clear_all!
ErrorLog.report!(exception, controller, request, nil)
ErrorLog.report!(exception, controller, request, nil)
i = 0
- ErrorLog.each do |h|
+ ErrorLog.each do |h|
i += 1
- end
+ end
i.should == 2
end
- it "is able to skip rows" do
+ it "is able to skip rows" do
ErrorLog.clear_all!
ErrorLog.report!(exception, controller, request, nil)
ErrorLog.report!(exception, controller, request, nil)
ErrorLog.report!(exception, controller, request, nil)
ErrorLog.report!(exception, controller, request, nil)
i = 0
- ErrorLog.skip(3) do |h|
+ ErrorLog.skip(3) do |h|
i += 1
end
i.should == 1
end
end
-end
+end
diff --git a/spec/models/incoming_link_spec.rb b/spec/models/incoming_link_spec.rb
index eb07888a8..b5c7e10aa 100644
--- a/spec/models/incoming_link_spec.rb
+++ b/spec/models/incoming_link_spec.rb
@@ -19,7 +19,7 @@ describe IncomingLink do
before do
@post = Fabricate(:post)
@topic = @post.topic
- @incoming_link = IncomingLink.create(url: "/t/slug/#{@topic.id}/#{@post.post_number}",
+ @incoming_link = IncomingLink.create(url: "/t/slug/#{@topic.id}/#{@post.post_number}",
referer: "http://twitter.com")
end
diff --git a/spec/models/invite_spec.rb b/spec/models/invite_spec.rb
index 4dafae8bd..6b8c92a8d 100644
--- a/spec/models/invite_spec.rb
+++ b/spec/models/invite_spec.rb
@@ -40,7 +40,7 @@ describe Invite do
context 'to a topic' do
let!(:topic) { Fabricate(:topic) }
let(:inviter) { topic.user }
-
+
context 'email' do
it 'enqueues a job to email the invite' do
Jobs.expects(:enqueue).with(:invite_email, has_key(:invite_id))
@@ -54,7 +54,7 @@ describe Invite do
invite.destroy
invite = topic.invite_by_email(inviter, 'iceking@adventuretime.ooo')
invite.should be_present
- end
+ end
end
context 'after created' do
@@ -85,7 +85,7 @@ describe Invite do
it 'has a different key' do
new_invite.invite_key.should_not == @invite.invite_key
- end
+ end
it 'has the topic relationship' do
new_invite.topics.should == [topic]
@@ -120,7 +120,7 @@ describe Invite do
it 'has references to both topics' do
@invite.topics.should =~ [topic, another_topic]
end
- end
+ end
end
end
end
@@ -168,7 +168,7 @@ describe Invite do
end
context 'simple invite' do
-
+
let!(:user) { invite.redeem }
it 'returns a user record' do
@@ -207,7 +207,7 @@ describe Invite do
context 'again' do
it 'will not redeem twice' do
invite.redeem.should == user
- end
+ end
it "doesn't want us to send a welcome message" do
invite.redeem.send_welcome_message.should be_false
@@ -276,11 +276,11 @@ describe Invite do
it 'marks the second invite as redeemed' do
another_invite.reload
another_invite.should be_redeemed
- end
+ end
end
end
- end
+ end
end
end
diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb
index 4070cc7ff..d884947d2 100644
--- a/spec/models/notification_spec.rb
+++ b/spec/models/notification_spec.rb
@@ -12,14 +12,14 @@ describe Notification do
let(:user) { Fabricate(:user) }
- context 'a regular notification' do
+ context 'a regular notification' do
it 'increases unread_notifications' do
lambda { Fabricate(:notification, user: user); user.reload }.should change(user, :unread_notifications)
end
it "doesn't increase unread_private_messages" do
lambda { Fabricate(:notification, user: user); user.reload }.should_not change(user, :unread_private_messages)
- end
+ end
end
context 'a private message' do
@@ -29,7 +29,7 @@ describe Notification do
it "increases unread_private_messages" do
lambda { Fabricate(:private_message_notification, user: user); user.reload }.should change(user, :unread_private_messages)
- end
+ end
end
end
@@ -46,8 +46,8 @@ describe Notification do
let!(:notification) { Fabricate(:notification) }
it 'updates the notification count on destroy' do
- MessageBusObserver.any_instance.expects(:refresh_notification_count).with(instance_of(Notification))
- notification.destroy
+ MessageBusObserver.any_instance.expects(:refresh_notification_count).with(instance_of(Notification))
+ notification.destroy
end
end
@@ -58,7 +58,7 @@ describe Notification do
it "calls email_user_mentioned on creating a notification" do
UserEmailObserver.any_instance.expects(:email_user_mentioned).with(instance_of(Notification))
Fabricate(:notification)
- end
+ end
end
@@ -66,11 +66,11 @@ describe Notification do
it "calls email_user_quoted on creating a quote notification" do
UserEmailObserver.any_instance.expects(:email_user_quoted).with(instance_of(Notification))
Fabricate(:quote_notification)
- end
+ end
end
- describe 'private message' do
- before do
+ describe 'private message' do
+ before do
@topic = Fabricate(:private_message_topic)
@post = Fabricate(:post, :topic => @topic, :user => @topic.user)
@target = @post.topic.topic_allowed_users.reject{|a| a.user_id == @post.user_id}[0].user
@@ -80,7 +80,7 @@ describe Notification do
@target.notifications.first.notification_type.should == Notification.Types[:private_message]
end
- it 'should not add a pm notification for the creator' do
+ it 'should not add a pm notification for the creator' do
@post.user.unread_notifications.should == 0
end
end
@@ -98,21 +98,21 @@ describe Notification do
describe 'data' do
let(:notification) { Fabricate.build(:notification) }
-
+
it 'should have a data hash' do
notification.data_hash.should be_present
end
-
+
it 'should have the data within the json' do
notification.data_hash[:poison].should == 'ivy'
end
end
- describe 'mark_posts_read' do
- it "marks multiple posts as read if needed" do
+ describe 'mark_posts_read' do
+ it "marks multiple posts as read if needed" do
user = Fabricate(:user)
- notifications = (1..3).map do |i|
+ notifications = (1..3).map do |i|
Notification.create!(read: false, user_id: user.id, topic_id: 2, post_number: i, data: '[]', notification_type: 1)
end
Notification.create!(read: true, user_id: user.id, topic_id: 2, post_number: 4, data: '[]', notification_type: 1)
diff --git a/spec/models/onebox_render_spec.rb b/spec/models/onebox_render_spec.rb
index 3b97423bc..637c20840 100644
--- a/spec/models/onebox_render_spec.rb
+++ b/spec/models/onebox_render_spec.rb
@@ -1,10 +1,10 @@
require 'spec_helper'
describe OneboxRender do
-
+
it { should validate_presence_of :url }
it { should validate_presence_of :cooked }
- it { should validate_presence_of :expires_at }
+ it { should validate_presence_of :expires_at }
it { should have_many :post_onebox_renders }
it { should have_many :posts }
diff --git a/spec/models/post_action_spec.rb b/spec/models/post_action_spec.rb
index 6eb782772..9b9482816 100644
--- a/spec/models/post_action_spec.rb
+++ b/spec/models/post_action_spec.rb
@@ -11,11 +11,11 @@ describe PostAction do
let(:post) { Fabricate(:post) }
let(:bookmark) { PostAction.new(user_id: post.user_id, post_action_type_id: PostActionType.Types[:bookmark] , post_id: post.id) }
- describe "flag counts" do
+ describe "flag counts" do
before do
PostAction.update_flagged_posts_count
- end
- it "starts of with 0 flag counts" do
+ end
+ it "starts of with 0 flag counts" do
PostAction.flagged_posts_count.should == 0
end
@@ -27,13 +27,13 @@ describe PostAction do
PostAction.flagged_posts_count.should == 0
end
- it "should reset counts when a topic is deleted" do
+ it "should reset counts when a topic is deleted" do
PostAction.act(codinghorror, post, PostActionType.Types[:off_topic])
post.topic.destroy
PostAction.flagged_posts_count.should == 0
end
-
- it "should reset counts when a post is deleted" do
+
+ it "should reset counts when a post is deleted" do
post2 = Fabricate(:post, topic_id: post.topic_id)
PostAction.act(codinghorror, post2, PostActionType.Types[:off_topic])
post2.destroy
@@ -50,16 +50,16 @@ describe PostAction do
lambda { bookmark.save; post.topic.reload }.should change(post.topic, :bookmark_count).by(1)
end
-
- describe 'when a user likes something' do
- it 'should increase the post counts when a user likes' do
+
+ describe 'when a user likes something' do
+ it 'should increase the post counts when a user likes' do
lambda {
PostAction.act(codinghorror, post, PostActionType.Types[:like])
post.reload
}.should change(post, :like_count).by(1)
end
-
- it 'should increase the forum topic like count when a user likes' do
+
+ it 'should increase the forum topic like count when a user likes' do
lambda {
PostAction.act(codinghorror, post, PostActionType.Types[:like])
post.topic.reload
@@ -69,15 +69,15 @@ describe PostAction do
end
- describe 'when a user votes for something' do
- it 'should increase the vote counts when a user likes' do
+ describe 'when a user votes for something' do
+ it 'should increase the vote counts when a user likes' do
lambda {
PostAction.act(codinghorror, post, PostActionType.Types[:vote])
post.reload
}.should change(post, :vote_count).by(1)
end
-
- it 'should increase the forum topic vote count when a user votes' do
+
+ it 'should increase the forum topic vote count when a user votes' do
lambda {
PostAction.act(codinghorror, post, PostActionType.Types[:vote])
post.topic.reload
@@ -97,13 +97,13 @@ describe PostAction do
end
it 'reduces the bookmark count of the post' do
- lambda {
+ lambda {
post.reload
}.should change(post, :bookmark_count).by(-1)
end
it 'reduces the bookmark count of the forum topic' do
- lambda {
+ lambda {
@topic.reload
}.should change(post.topic, :bookmark_count).by(-1)
end
@@ -118,7 +118,7 @@ describe PostAction do
lambda { PostAction.act(u1, post, PostActionType.Types[:off_topic]) }.should raise_error(PostAction::AlreadyFlagged)
end
- it 'should update counts when you clear flags' do
+ it 'should update counts when you clear flags' do
post = Fabricate(:post)
u1 = Fabricate(:evil_trout)
PostAction.act(u1, post, PostActionType.Types[:spam])
@@ -132,7 +132,7 @@ describe PostAction do
post.spam_count.should == 0
end
- it 'should follow the rules for automatic hiding workflow' do
+ it 'should follow the rules for automatic hiding workflow' do
post = Fabricate(:post)
u1 = Fabricate(:evil_trout)
@@ -141,7 +141,7 @@ describe PostAction do
# we need an admin for the messages
admin = Fabricate(:admin)
- SiteSetting.flags_required_to_hide_post = 2
+ SiteSetting.flags_required_to_hide_post = 2
PostAction.act(u1, post, PostActionType.Types[:spam])
PostAction.act(u2, post, PostActionType.Types[:spam])
@@ -149,7 +149,7 @@ describe PostAction do
post.reload
post.hidden.should.should be_true
- post.hidden_reason_id.should == Post::HiddenReason::FLAG_THRESHOLD_REACHED
+ post.hidden_reason_id.should == Post::HiddenReason::FLAG_THRESHOLD_REACHED
post.topic.visible.should be_false
post.revise(post.user, post.raw + " ha I edited it ")
@@ -165,14 +165,14 @@ describe PostAction do
post.reload
post.hidden.should be_true
- post.hidden_reason_id.should == Post::HiddenReason::FLAG_THRESHOLD_REACHED_AGAIN
+ post.hidden_reason_id.should == Post::HiddenReason::FLAG_THRESHOLD_REACHED_AGAIN
post.revise(post.user, post.raw + " ha I edited it again ")
-
+
post.reload
post.hidden.should be_true
- post.hidden_reason_id.should == Post::HiddenReason::FLAG_THRESHOLD_REACHED_AGAIN
+ post.hidden_reason_id.should == Post::HiddenReason::FLAG_THRESHOLD_REACHED_AGAIN
end
end
diff --git a/spec/models/post_alert_observer_spec.rb b/spec/models/post_alert_observer_spec.rb
index 5a8c1fa19..64b12a477 100644
--- a/spec/models/post_alert_observer_spec.rb
+++ b/spec/models/post_alert_observer_spec.rb
@@ -19,15 +19,15 @@ describe PostAlertObserver do
PostAction.act(evil_trout, post, PostActionType.Types[:like])
end
- it 'removes a notification' do
+ it 'removes a notification' do
lambda {
PostAction.remove_act(evil_trout, post, PostActionType.Types[:like])
}.should change(Notification, :count).by(-1)
end
- end
+ end
end
- context 'when editing a post' do
+ context 'when editing a post' do
it 'notifies a user of the revision' do
lambda {
post.revise(evil_trout, "world is the new body of the message")
@@ -41,21 +41,21 @@ describe PostAlertObserver do
lambda {
Fabricate(:post, raw: '[quote="EvilTrout, post:1"]whatup[/quote]')
}.should change(evil_trout.notifications, :count).by(1)
- end
+ end
it "won't notify the user a second time on revision" do
p1 = Fabricate(:post, raw: '[quote="Evil Trout, post:1"]whatup[/quote]')
- lambda {
+ lambda {
p1.revise(p1.user, '[quote="Evil Trout, post:1"]whatup now?[/quote]')
}.should_not change(evil_trout.notifications, :count)
- end
+ end
it "doesn't notify the poster" do
topic = post.topic
lambda {
new_post = Fabricate(:post, topic: topic, user: topic.user, raw: '[quote="Bruce Wayne, post:1"]whatup[/quote]')
}.should_not change(topic.user.notifications, :count).by(1)
- end
+ end
end
context '@mentions' do
@@ -72,7 +72,7 @@ describe PostAlertObserver do
it "won't notify the user a second time on revision" do
mention_post
- lambda {
+ lambda {
mention_post.revise(mention_post.user, "New raw content that still mentions @eviltrout")
}.should_not change(evil_trout.notifications, :count)
end
@@ -82,14 +82,14 @@ describe PostAlertObserver do
it "doesn't notify the user who created the topic in regular mode" do
topic.notify_regular!(user)
mention_post
- lambda {
+ lambda {
Fabricate(:post, user: user, raw: 'second post', topic: topic)
}.should_not change(user.notifications, :count).by(1)
end
it 'removes notifications' do
post = mention_post
- lambda {
+ lambda {
post.destroy
}.should change(evil_trout.notifications, :count).by(-1)
end
@@ -99,8 +99,8 @@ describe PostAlertObserver do
context 'private message' do
let(:user) { Fabricate(:user) }
let(:mention_post) { Fabricate(:post, user: user, raw: 'Hello @eviltrout')}
- let(:topic) { mention_post.topic }
- let(:post)
+ let(:topic) { mention_post.topic }
+ let(:post)
it "won't notify someone who can't see the post" do
lambda {
diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb
index 146a51599..daaa57ecc 100644
--- a/spec/models/post_spec.rb
+++ b/spec/models/post_spec.rb
@@ -18,7 +18,7 @@ describe Post do
let(:topic) { Fabricate(:topic) }
let(:post_args) do
- {user: topic.user, topic: topic}
+ {user: topic.user, topic: topic}
end
it_behaves_like "a versioned model"
@@ -59,17 +59,17 @@ describe Post do
end
- describe 'flagging helpers' do
- it 'isFlagged is accurate' do
+ describe 'flagging helpers' do
+ it 'isFlagged is accurate' do
post = Fabricate(:post)
user = Fabricate(:coding_horror)
PostAction.act(user, post, PostActionType.Types[:off_topic])
- post.reload
+ post.reload
post.is_flagged?.should == true
-
+
PostAction.remove_act(user, post, PostActionType.Types[:off_topic])
- post.reload
+ post.reload
post.is_flagged?.should == false
end
end
@@ -106,7 +106,7 @@ describe Post do
end
it "doesn't count whitelisted images" do
- Post.stubs(:white_listed_image_classes).returns(["classy"])
+ Post.stubs(:white_listed_image_classes).returns(["classy"])
post_with_two_classy_images.image_count.should == 0
end
@@ -209,12 +209,12 @@ describe Post do
it "ignores code" do
post = Fabricate.build(:post, post_args.merge(raw: "@Jake
@Finn
"))
post.raw_mentions.should == ['jake']
- end
+ end
it "ignores quotes" do
post = Fabricate.build(:post, post_args.merge(raw: "[quote=\"Evil Trout\"]@Jake[/quote] @Finn"))
post.raw_mentions.should == ['finn']
- end
+ end
end
@@ -238,7 +238,7 @@ describe Post do
let(:raw) { "this is our test post body"}
let(:post) { Fabricate.build(:post, raw: raw) }
-
+
it "returns a value" do
post.raw_hash.should be_present
end
@@ -340,11 +340,11 @@ describe Post do
end
it "doesn't create a new version if you do another" do
- post.cached_version.should == 2
+ post.cached_version.should == 2
end
it "doesn't change last_version_at" do
- post.last_version_at.to_i.should == revised_at.to_i
+ post.last_version_at.to_i.should == revised_at.to_i
end
context "after second window" do
@@ -357,7 +357,7 @@ describe Post do
end
it "does create a new version after the edit window" do
- post.cached_version.should == 3
+ post.cached_version.should == 3
end
it "does create a new version after the edit window" do
@@ -373,7 +373,7 @@ describe Post do
describe 'rate limiter' do
let(:changed_by) { Fabricate(:coding_horror) }
-
+
it "triggers a rate limiter" do
EditRateLimiter.any_instance.expects(:performed!)
post.revise(changed_by, 'updated body')
@@ -425,7 +425,7 @@ describe Post do
it 'is a ninja edit, because the second poster posted again quickly' do
post.all_versions.size.should == 2
- end
+ end
end
@@ -446,7 +446,7 @@ describe Post do
it 'passes the invalidate_oneboxes along to the job if present' do
Jobs.stubs(:enqueue).with(:feature_topic_users, has_key(:topic_id))
- Jobs.expects(:enqueue).with(:process_post, has_key(:invalidate_oneboxes))
+ Jobs.expects(:enqueue).with(:process_post, has_key(:invalidate_oneboxes))
post = Fabricate.build(:post, post_args)
post.invalidate_oneboxes = true
post.save
@@ -454,7 +454,7 @@ describe Post do
it 'passes the image_sizes along to the job if present' do
Jobs.stubs(:enqueue).with(:feature_topic_users, has_key(:topic_id))
- Jobs.expects(:enqueue).with(:process_post, has_key(:image_sizes))
+ Jobs.expects(:enqueue).with(:process_post, has_key(:image_sizes))
post = Fabricate.build(:post, post_args)
post.image_sizes = {'http://an.image.host/image.jpg' => {'width' => 17, 'height' => 31}}
post.save
@@ -467,7 +467,7 @@ describe Post do
describe 'replies' do
let(:post) { Fabricate(:post, post_args.merge(raw: "Hello @CodingHorror")) }
-
+
it 'notifies the poster on reply' do
lambda {
@reply = Fabricate(:basic_reply, user: coding_horror, topic: post.topic)
@@ -492,7 +492,7 @@ describe Post do
end
end
- describe 'muting' do
+ describe 'muting' do
it "does not notify users of new posts" do
post = Fabricate(:post, post_args)
user = post_args[:user]
@@ -530,7 +530,7 @@ describe Post do
it "creates a new version" do
post.version.should == 2
- end
+ end
end
@@ -538,7 +538,7 @@ describe Post do
before do
post.delete_by(post.user)
- post.reload
+ post.reload
end
it "deletes the post" do
@@ -578,14 +578,14 @@ describe Post do
}.should change(post.post_replies, :count).by(-1)
end
- it 'should increase the post_number when there are deletion gaps' do
+ it 'should increase the post_number when there are deletion gaps' do
reply.destroy
p = Fabricate(:post, user: post.user, topic: post.topic)
p.post_number.should == 3
end
end
-
+
end
@@ -612,14 +612,14 @@ describe Post do
it 'has no versions' do
post.versions.should be_blank
- end
+ end
it 'has cooked content' do
post.cooked.should be_present
end
it 'has an external id' do
- post.external_id.should be_present
+ post.external_id.should be_present
end
it 'has no quotes' do
diff --git a/spec/models/post_timing_spec.rb b/spec/models/post_timing_spec.rb
index 191820558..ffe7d483e 100644
--- a/spec/models/post_timing_spec.rb
+++ b/spec/models/post_timing_spec.rb
@@ -8,25 +8,25 @@ describe PostTiming do
it { should validate_presence_of :post_number }
it { should validate_presence_of :msecs }
- describe 'process_timings' do
-
+ describe 'process_timings' do
+
# integration test
- it 'processes timings correctly' do
+ it 'processes timings correctly' do
post = Fabricate(:post)
user2 = Fabricate(:coding_horror)
PostAction.act(user2, post, PostActionType.Types[:like])
post.user.unread_notifications.should == 1
-
+
post.user.unread_notifications_by_type.should == {Notification.Types[:liked] => 1}
-
+
PostTiming.process_timings(post.user, post.topic_id, 1, 100, [[post.post_number, 100]])
post.user.reload
post.user.unread_notifications_by_type.should == {}
post.user.unread_notifications.should == 0
-
+
end
end
@@ -65,14 +65,14 @@ describe PostTiming do
it 'sums the msecs together' do
@timing.msecs.should == 2468
end
- end
+ end
describe 'avg times' do
describe 'posts' do
it 'has no avg_time by default' do
@post.avg_time.should be_blank
- end
+ end
it "doesn't change when we calculate the avg time for the post because there's no timings" do
Post.calculate_avg_time
@@ -84,7 +84,7 @@ describe PostTiming do
describe 'topics' do
it 'has no avg_time by default' do
@topic.avg_time.should be_blank
- end
+ end
it "doesn't change when we calculate the avg time for the post because there's no timings" do
Topic.calculate_avg_time
diff --git a/spec/models/site_customization_spec.rb b/spec/models/site_customization_spec.rb
index 0b4b50a50..f602b1c76 100644
--- a/spec/models/site_customization_spec.rb
+++ b/spec/models/site_customization_spec.rb
@@ -6,37 +6,37 @@ describe SiteCustomization do
Fabricate(:user)
end
- let :customization do
+ let :customization do
SiteCustomization.create!(name: 'my name', user_id: user.id, header: "my awesome header", stylesheet: "my awesome css")
end
- it 'should set default key when creating a new customization' do
+ it 'should set default key when creating a new customization' do
s = SiteCustomization.create!(name: 'my name', user_id: user.id)
s.key.should_not == nil
end
context 'caching' do
-
- context 'enabled style' do
+
+ context 'enabled style' do
before do
@customization = customization
end
- it 'finds no style when none enabled' do
+ it 'finds no style when none enabled' do
SiteCustomization.enabled_style_key.should be_nil
end
- it 'finds the enabled style' do
- @customization.enabled = true
+ it 'finds the enabled style' do
+ @customization.enabled = true
@customization.save
SiteCustomization.enabled_style_key.should == @customization.key
end
- it 'finds no enabled style on other sites' do
- @customization.enabled = true
+ it 'finds no enabled style on other sites' do
+ @customization.enabled = true
@customization.save
-
+
RailsMultisite::ConnectionManagement.expects(:current_db).returns("foo").twice
# the mocking is tricky, lets remove the record so we can properly pretend we are on another db
# this bypasses the before / after stuff
@@ -46,7 +46,7 @@ describe SiteCustomization do
end
end
- it 'ensure stylesheet is on disk on first fetch' do
+ it 'ensure stylesheet is on disk on first fetch' do
c = customization
c.remove_from_cache!
File.delete(c.stylesheet_fullpath)
@@ -57,14 +57,14 @@ describe SiteCustomization do
end
it 'should allow me to lookup a filename containing my preview stylesheet' do
- SiteCustomization.custom_stylesheet(customization.key).should ==
- "
"
+ SiteCustomization.custom_stylesheet(customization.key).should ==
+ "
"
end
- it 'should fix stylesheet files after changing the stylesheet' do
- old_file = customization.stylesheet_fullpath
+ it 'should fix stylesheet files after changing the stylesheet' do
+ old_file = customization.stylesheet_fullpath
original = SiteCustomization.custom_stylesheet(customization.key)
-
+
File.exists?(old_file).should == true
customization.stylesheet = "div { clear:both; }"
customization.save
@@ -73,27 +73,27 @@ describe SiteCustomization do
end
it 'should delete old stylesheet files after deleting' do
- old_file = customization.stylesheet_fullpath
+ old_file = customization.stylesheet_fullpath
customization.ensure_stylesheet_on_disk!
customization.destroy
File.exists?(old_file).should == false
end
- it 'should nuke old revs out of the cache' do
+ it 'should nuke old revs out of the cache' do
old_style = SiteCustomization.custom_stylesheet(customization.key)
-
+
customization.stylesheet = "hello worldz"
customization.save
SiteCustomization.custom_stylesheet(customization.key).should_not == old_style
end
- it 'should compile scss' do
+ it 'should compile scss' do
c = SiteCustomization.create!(user_id: user.id, name: "test", stylesheet: '$black: #000; #a { color: $black; }', header: '')
c.stylesheet_baked.should == "#a {\n color: black; }\n"
end
- it 'should provide an awesome error on failure' do
+ it 'should provide an awesome error on failure' do
c = SiteCustomization.create!(user_id: user.id, name: "test", stylesheet: "$black: #000; #a { color: $black; }\n\n\nboom", header: '')
c.stylesheet_baked.should =~ /Syntax error/
diff --git a/spec/models/site_setting_spec.rb b/spec/models/site_setting_spec.rb
index 66c7d4849..e909866b9 100644
--- a/spec/models/site_setting_spec.rb
+++ b/spec/models/site_setting_spec.rb
@@ -2,8 +2,8 @@ require 'spec_helper'
describe SiteSetting do
- describe "int setting" do
- before :all do
+ describe "int setting" do
+ before :all do
SiteSetting.setting(:test_setting, 77)
SiteSetting.refresh!
end
@@ -12,65 +12,65 @@ describe SiteSetting do
SiteSetting.all_settings.detect {|s| s[:setting] == :test_setting }.should be_present
end
- it "should have the correct desc" do
+ it "should have the correct desc" do
I18n.expects(:t).with("site_settings.test_setting").returns("test description")
SiteSetting.description(:test_setting).should == "test description"
end
-
- it "should have the correct default" do
+
+ it "should have the correct default" do
SiteSetting.test_setting.should == 77
end
- describe "when overidden" do
- before :all do
+ describe "when overidden" do
+ before :all do
SiteSetting.test_setting = 100
end
- after :all do
+ after :all do
SiteSetting.remove_override!(:test_setting)
end
-
- it "should have the correct override" do
+
+ it "should have the correct override" do
SiteSetting.test_setting.should == 100
end
end
end
- describe "string setting" do
- before :all do
+ describe "string setting" do
+ before :all do
SiteSetting.setting(:test_str, "str")
SiteSetting.refresh!
end
- it "should have the correct default" do
+ it "should have the correct default" do
SiteSetting.test_str.should == "str"
end
- end
+ end
- describe "bool setting" do
- before :all do
- SiteSetting.setting(:test_hello?, false)
+ describe "bool setting" do
+ before :all do
+ SiteSetting.setting(:test_hello?, false)
SiteSetting.refresh!
end
- it "should have the correct default" do
+ it "should have the correct default" do
SiteSetting.test_hello?.should == false
end
-
+
it "should be overridable" do
SiteSetting.test_hello = true
SiteSetting.refresh!
SiteSetting.test_hello?.should == true
end
- it "should coerce true strings to true" do
+ it "should coerce true strings to true" do
SiteSetting.test_hello = "true"
SiteSetting.refresh!
SiteSetting.test_hello?.should == true
end
- it "should coerce all other strings to false" do
+ it "should coerce all other strings to false" do
SiteSetting.test_hello = "f"
SiteSetting.refresh!
SiteSetting.test_hello?.should == false
diff --git a/spec/models/topic_invite_spec.rb b/spec/models/topic_invite_spec.rb
index aa2544e05..620fd149d 100644
--- a/spec/models/topic_invite_spec.rb
+++ b/spec/models/topic_invite_spec.rb
@@ -1,10 +1,10 @@
require 'spec_helper'
describe TopicInvite do
-
+
it { should belong_to :topic }
it { should belong_to :invite }
it { should validate_presence_of :topic_id }
it { should validate_presence_of :invite_id }
-
+
end
diff --git a/spec/models/topic_link_click_spec.rb b/spec/models/topic_link_click_spec.rb
index 9841c9c60..853b75f6a 100644
--- a/spec/models/topic_link_click_spec.rb
+++ b/spec/models/topic_link_click_spec.rb
@@ -2,7 +2,7 @@ require 'discourse'
require 'spec_helper'
describe TopicLinkClick do
-
+
it { should belong_to :topic_link }
it { should belong_to :user }
@@ -18,11 +18,11 @@ describe TopicLinkClick do
context 'topic_links' do
before do
- @topic = Fabricate(:topic)
+ @topic = Fabricate(:topic)
@post = Fabricate(:post_with_external_links, user: @topic.user, topic: @topic)
- TopicLink.extract_from(@post)
+ TopicLink.extract_from(@post)
@topic_link = @topic.topic_links.first
- end
+ end
it 'has 0 clicks at first' do
@topic_link.clicks.should == 0
@@ -49,7 +49,7 @@ describe TopicLinkClick do
context 'counts for' do
before do
- @counts_for = TopicLinkClick.counts_for(@topic, [@post])
+ @counts_for = TopicLinkClick.counts_for(@topic, [@post])
end
it 'has a counts_for result' do
diff --git a/spec/models/topic_link_spec.rb b/spec/models/topic_link_spec.rb
index ba11abdf0..a4b2116c8 100644
--- a/spec/models/topic_link_spec.rb
+++ b/spec/models/topic_link_spec.rb
@@ -13,13 +13,13 @@ describe TopicLink do
end
before do
- @topic = Fabricate(:topic, title: 'unique topic name')
+ @topic = Fabricate(:topic, title: 'unique topic name')
@user = @topic.user
end
it "can't link to the same topic" do
- ftl = TopicLink.new(url: "/t/#{@topic.id}",
- topic_id: @topic.id,
+ ftl = TopicLink.new(url: "/t/#{@topic.id}",
+ topic_id: @topic.id,
link_topic_id: @topic.id)
ftl.valid?.should be_false
end
@@ -27,7 +27,7 @@ describe TopicLink do
describe 'external links' do
before do
@post = Fabricate(:post_with_external_links, user: @user, topic: @topic)
- TopicLink.extract_from(@post)
+ TopicLink.extract_from(@post)
end
it 'has the forum topic links' do
@@ -69,7 +69,7 @@ describe TopicLink do
it "should be the canonical URL" do
@link.url.should == @url
- end
+ end
end
@@ -167,7 +167,7 @@ describe TopicLink do
@reflection = @other_topic.topic_links.should be_blank
end
- end
+ end
end
@@ -177,7 +177,7 @@ describe TopicLink do
TopicLink.extract_from(post)
end
- it 'does not extract a link' do
+ it 'does not extract a link' do
@topic.topic_links.should be_blank
end
end
@@ -188,7 +188,7 @@ describe TopicLink do
TopicLink.extract_from(post)
end
- it 'does not extract a link' do
+ it 'does not extract a link' do
@topic.topic_links.should be_present
end
end
@@ -200,20 +200,20 @@ describe TopicLink do
TopicLink.extract_from(post)
end
- it 'does not extract a link' do
+ it 'does not extract a link' do
@topic.topic_links.should be_blank
end
- end
-
+ end
+
end
- describe 'internal link from pm' do
- before do
+ describe 'internal link from pm' do
+ before do
@pm = Fabricate(:topic, user: @user, archetype: 'private_message')
@other_post = @pm.posts.create(user: @user, raw: "some content")
-
+
@url = "http://#{test_uri.host}/t/topic-slug/#{@topic.id}"
-
+
@pm.posts.create(user: @user, raw: 'initial post')
@linked_post = @pm.posts.create(user: @user, raw: "Link to another topic: #{@url}")
@@ -225,7 +225,7 @@ describe TopicLink do
it 'should not create a reflection' do
@topic.topic_links.first.should be_nil
end
-
+
it 'should not create a normal link' do
@pm.topic_links.first.should_not be_nil
end
diff --git a/spec/models/topic_spec.rb b/spec/models/topic_spec.rb
index c99243b42..962d2873d 100644
--- a/spec/models/topic_spec.rb
+++ b/spec/models/topic_spec.rb
@@ -7,8 +7,8 @@ describe Topic do
it { should validate_presence_of :title }
it { should belong_to :category }
- it { should belong_to :user }
- it { should belong_to :last_poster }
+ it { should belong_to :user }
+ it { should belong_to :last_poster }
it { should belong_to :featured_user1 }
it { should belong_to :featured_user2 }
it { should belong_to :featured_user3 }
@@ -16,7 +16,7 @@ describe Topic do
it { should have_many :posts }
it { should have_many :topic_users }
- it { should have_many :topic_links }
+ it { should have_many :topic_links }
it { should have_many :topic_allowed_users }
it { should have_many :allowed_users }
it { should have_many :invites }
@@ -105,12 +105,12 @@ describe Topic do
it "won't allow another topic to be created with the same name" do
new_topic.should be_valid
end
- end
+ end
end
context 'html in title' do
- let(:topic) { Fabricate(:topic, title: " is my topic title" ) }
+ let(:topic) { Fabricate(:topic, title: " is my topic title" ) }
it "should escape the HTML" do
topic.title.should == "is my topic title"
@@ -119,7 +119,7 @@ describe Topic do
end
context 'fancy title' do
- let(:topic) { Fabricate(:topic, title: "\"this topic\" -- has ``fancy stuff''" ) }
+ let(:topic) { Fabricate(:topic, title: "\"this topic\" -- has ``fancy stuff''" ) }
context 'title_fancy_entities disabled' do
before do
@@ -172,7 +172,7 @@ describe Topic do
context 'move_posts' do
let(:user) { Fabricate(:user) }
let(:category) { Fabricate(:category, user: user) }
- let!(:topic) { Fabricate(:topic, user: user, category: category) }
+ let!(:topic) { Fabricate(:topic, user: user, category: category) }
let!(:p1) { Fabricate(:post, topic: topic, user: user) }
let!(:p2) { Fabricate(:post, topic: topic, user: user)}
let!(:p3) { Fabricate(:post, topic: topic, user: user)}
@@ -210,7 +210,7 @@ describe Topic do
topic.expects(:add_moderator_post)
TopicUser.update_last_read(user, topic.id, p4.post_number, 0)
end
-
+
let!(:new_topic) { topic.move_posts(user, "new topic name", [p2.id, p4.id]) }
@@ -238,7 +238,7 @@ describe Topic do
it "has renumbered the first post" do
p2.reload
- p2.post_number.should == 1
+ p2.post_number.should == 1
end
it "has changed the first post's sort order" do
@@ -254,7 +254,7 @@ describe Topic do
it "has changed the fourth post's sort order" do
p4.reload
p4.sort_order.should == 2
- end
+ end
it "has the correct highest_post_number" do
new_topic.reload
@@ -288,28 +288,28 @@ describe Topic do
end
- context 'private message' do
- let(:coding_horror) { User.where(username: 'CodingHorror').first }
+ context 'private message' do
+ let(:coding_horror) { User.where(username: 'CodingHorror').first }
let(:evil_trout) { Fabricate(:evil_trout) }
- let!(:topic) { Fabricate(:private_message_topic) }
+ let!(:topic) { Fabricate(:private_message_topic) }
it "should allow the allowed users to see the topic" do
Guardian.new(topic.user).can_see?(topic).should be_true
end
- it "should disallow anon to see the topic" do
+ it "should disallow anon to see the topic" do
Guardian.new.can_see?(topic).should be_false
end
- it "should disallow a different user to see the topic" do
+ it "should disallow a different user to see the topic" do
Guardian.new(evil_trout).can_see?(topic).should be_false
end
- it "should allow the recipient user to see the topic" do
+ it "should allow the recipient user to see the topic" do
Guardian.new(coding_horror).can_see?(topic).should be_true
- end
+ end
- it "should be excluded from the list view" do
+ it "should be excluded from the list view" do
TopicQuery.new(evil_trout).list_popular.topics.should_not include(topic)
end
@@ -355,23 +355,23 @@ describe Topic do
lambda { topic.invite(topic.user, walter.email) }.should change(Notification, :count)
end
- end
+ end
end
end
- context "user actions" do
+ context "user actions" do
let(:actions) { topic.user.user_actions }
- it "should not log a user action for the creation of the topic" do
+ it "should not log a user action for the creation of the topic" do
actions.map{|a| a.action_type}.should_not include(UserAction::NEW_TOPIC)
end
-
- it "should log a user action for the creation of a private message" do
+
+ it "should log a user action for the creation of a private message" do
actions.map{|a| a.action_type}.should include(UserAction::NEW_PRIVATE_MESSAGE)
end
- it "should log a user action for the recepient of the private message" do
+ it "should log a user action for the recepient of the private message" do
coding_horror.user_actions.map{|a| a.action_type}.should include(UserAction::GOT_PRIVATE_MESSAGE)
end
end
@@ -432,14 +432,14 @@ describe Topic do
@last_post.revise(Fabricate(:moderator), 'updated contents')
@topic.reload
}.should change(@topic, :bumped_at)
- end
+ end
it "doesn't bump the topic when a post that isn't the last post receives a new version" do
lambda {
@earlier_post.revise(Fabricate(:moderator), 'updated contents')
@topic.reload
}.should_not change(@topic, :bumped_at)
- end
+ end
end
@@ -454,7 +454,7 @@ describe Topic do
end
it 'creates a moderator post' do
- @mod_post.should be_present
+ @mod_post.should be_present
end
it 'has the moderator action type' do
@@ -472,7 +472,7 @@ describe Topic do
it "has the custom sort order we specified" do
@mod_post.sort_order.should == 999
- end
+ end
it 'creates a topic link' do
@topic.topic_links.count.should == 1
@@ -490,13 +490,13 @@ describe Topic do
context 'visibility' do
context 'disable' do
- before do
+ before do
@topic.update_status('visible', false, @user)
@topic.reload
end
it 'should not be visible' do
- @topic.should_not be_visible
+ @topic.should_not be_visible
end
it 'adds a moderator post' do
@@ -517,7 +517,7 @@ describe Topic do
end
it 'should be visible' do
- @topic.should be_visible
+ @topic.should be_visible
end
it 'adds a moderator post' do
@@ -526,8 +526,8 @@ describe Topic do
it "doesn't bump the topic" do
@topic.bumped_at.to_f.should == @original_bumped_at
- end
- end
+ end
+ end
end
context 'pinned' do
@@ -538,7 +538,7 @@ describe Topic do
end
it 'should not be pinned' do
- @topic.should_not be_pinned
+ @topic.should_not be_pinned
end
it 'adds a moderator post' do
@@ -547,7 +547,7 @@ describe Topic do
it "doesn't bump the topic" do
@topic.bumped_at.to_f.should == @original_bumped_at
- end
+ end
end
context 'enable' do
@@ -558,7 +558,7 @@ describe Topic do
end
it 'should be pinned' do
- @topic.should be_pinned
+ @topic.should be_pinned
end
it 'adds a moderator post' do
@@ -568,7 +568,7 @@ describe Topic do
it "doesn't bump the topic" do
@topic.bumped_at.to_f.should == @original_bumped_at
end
- end
+ end
end
context 'archived' do
@@ -579,7 +579,7 @@ describe Topic do
end
it 'should not be pinned' do
- @topic.should_not be_archived
+ @topic.should_not be_archived
end
it 'adds a moderator post' do
@@ -588,7 +588,7 @@ describe Topic do
it "doesn't bump the topic" do
@topic.bumped_at.to_f.should == @original_bumped_at
- end
+ end
end
context 'enable' do
@@ -599,7 +599,7 @@ describe Topic do
end
it 'should be archived' do
- @topic.should be_archived
+ @topic.should be_archived
end
it 'adds a moderator post' do
@@ -608,8 +608,8 @@ describe Topic do
it "doesn't bump the topic" do
@topic.bumped_at.to_f.should == @original_bumped_at
- end
- end
+ end
+ end
end
context 'closed' do
@@ -630,7 +630,7 @@ describe Topic do
# We bump the topic when a topic is re-opened
it "bumps the topic" do
@topic.bumped_at.to_f.should_not == @original_bumped_at
- end
+ end
end
@@ -642,7 +642,7 @@ describe Topic do
end
it 'should be closed' do
- @topic.should be_closed
+ @topic.should be_closed
end
it 'adds a moderator post' do
@@ -651,9 +651,9 @@ describe Topic do
it "doesn't bump the topic" do
@topic.bumped_at.to_f.should == @original_bumped_at
- end
-
- end
+ end
+
+ end
end
@@ -668,15 +668,15 @@ describe Topic do
it 'triggers a forum topic user change with true' do
# otherwise no chance the mock will work
- freeze_time do
+ freeze_time do
TopicUser.expects(:change).with(@user, @topic.id, starred: true, starred_at: DateTime.now)
@topic.toggle_star(@user, true)
end
end
it 'increases the star_count of the forum topic' do
- lambda {
- @topic.toggle_star(@user, true)
+ lambda {
+ @topic.toggle_star(@user, true)
@topic.reload
}.should change(@topic, :star_count).by(1)
end
@@ -688,8 +688,8 @@ describe Topic do
describe 'removing a star' do
before do
- @topic.toggle_star(@user, true)
- @topic.reload
+ @topic.toggle_star(@user, true)
+ @topic.reload
end
it 'rolls back the rate limiter' do
@@ -703,10 +703,10 @@ describe Topic do
end
it 'reduces the star_count' do
- lambda {
- @topic.toggle_star(@user, false)
+ lambda {
+ @topic.toggle_star(@user, false)
@topic.reload
- }.should change(@topic, :star_count).by(-1)
+ }.should change(@topic, :star_count).by(-1)
end
end
@@ -766,18 +766,18 @@ describe Topic do
@topic_user = @second_user.topic_users.where(topic_id: @topic.id).first
end
- it 'clears the posted flag for the second user' do
+ it 'clears the posted flag for the second user' do
@topic_user.posted?.should be_false
end
- it "sets the second user's last_read_post_number back to 1" do
+ it "sets the second user's last_read_post_number back to 1" do
@topic_user.last_read_post_number.should == 1
end
- it "sets the second user's last_read_post_number back to 1" do
+ it "sets the second user's last_read_post_number back to 1" do
@topic_user.seen_post_count.should == 1
end
-
+
end
@@ -849,7 +849,7 @@ describe Topic do
end
it 'is not a best_of' do
- topic.has_best_of.should be_false
+ topic.has_best_of.should be_false
end
it 'is not invisible' do
@@ -882,7 +882,7 @@ describe Topic do
end
end
end
-
+
describe 'versions' do
let(:topic) { Fabricate(:topic) }
@@ -941,8 +941,8 @@ describe Topic do
before do
@topic = Fabricate(:topic)
- @category = Fabricate(:category, user: @topic.user)
- @user = @topic.user
+ @category = Fabricate(:category, user: @topic.user)
+ @user = @topic.user
end
describe 'without a previous category' do
@@ -957,7 +957,7 @@ describe Topic do
@category.reload
end
- it 'changes the category' do
+ it 'changes the category' do
@topic.category.should == @category
end
@@ -1010,20 +1010,20 @@ describe Topic do
it "should lower the original category's topic count" do
@category.topic_count.should == 0
end
-
+
end
describe 'when the category exists' do
before do
@topic.change_category(nil)
- @category.reload
+ @category.reload
end
- it "resets the category" do
+ it "resets the category" do
@topic.category_id.should be_blank
end
- it "lowers the forum topic count" do
+ it "lowers the forum topic count" do
@category.topic_count.should == 0
end
diff --git a/spec/models/topic_user_spec.rb b/spec/models/topic_user_spec.rb
index 6376fa592..41daf770e 100644
--- a/spec/models/topic_user_spec.rb
+++ b/spec/models/topic_user_spec.rb
@@ -13,49 +13,49 @@ describe TopicUser do
@user = Fabricate(:coding_horror)
end
- describe 'notifications' do
+ describe 'notifications' 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.auto_track_topics_after_msecs = 0
@user.save
TopicUser.change(@user, @topic, {:starred_at => DateTime.now})
TopicUser.get(@topic,@user).notification_level.should == TopicUser::NotificationLevel::TRACKING
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 => DateTime.now})
@user.auto_track_topics_after_msecs = 0
@user.save
TopicUser.get(@topic,@user).notification_level.should == TopicUser::NotificationLevel::TRACKING
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 => DateTime.now})
TopicUser.get(@topic,@user).notification_level.should == TopicUser::NotificationLevel::REGULAR
end
- it 'reason should reset when changed' do
+ it 'reason should reset when changed' do
@topic.notify_muted!(@topic.user)
TopicUser.get(@topic,@topic.user).notifications_reason_id.should == TopicUser::NotificationReasons::USER_CHANGED
end
-
- it 'should have the correct reason for a user change when watched' do
+
+ it 'should have the correct reason for a user change when watched' do
@topic.notify_watch!(@user)
tu = TopicUser.get(@topic,@user)
tu.notification_level.should == TopicUser::NotificationLevel::WATCHING
tu.notifications_reason_id.should == TopicUser::NotificationReasons::USER_CHANGED
tu.notifications_changed_at.should_not be_nil
end
-
- it 'should have the correct reason for a user change when set to regular' do
+
+ it 'should have the correct reason for a user change when set to regular' do
@topic.notify_regular!(@user)
tu = TopicUser.get(@topic,@user)
tu.notification_level.should == TopicUser::NotificationLevel::REGULAR
tu.notifications_reason_id.should == TopicUser::NotificationReasons::USER_CHANGED
tu.notifications_changed_at.should_not be_nil
end
-
- it 'should have the correct reason for a user change when set to regular' do
+
+ it 'should have the correct reason for a user change when set to regular' do
@topic.notify_muted!(@user)
tu = TopicUser.get(@topic,@user)
tu.notification_level.should == TopicUser::NotificationLevel::MUTED
@@ -75,17 +75,17 @@ describe TopicUser do
TopicUser.track_visit!(@topic, @user)
@topic_user = TopicUser.get(@topic,@user)
- end
-
- it 'set upon initial visit' do
+ end
+
+ it 'set upon initial visit' do
@topic_user.first_visited_at.to_i.should == @now.to_i
@topic_user.last_visited_at.to_i.should == @now.to_i
end
- it 'updates upon repeat visit' do
+ it 'updates upon repeat visit' do
tomorrow = @now.tomorrow
DateTime.expects(:now).returns(tomorrow)
-
+
TopicUser.track_visit!(@topic,@user)
# reload is a no go
@topic_user = TopicUser.get(@topic,@user)
@@ -95,21 +95,21 @@ describe TopicUser do
end
- describe 'read tracking' do
- before do
- @post = Fabricate(:post, topic: @topic, user: @topic.user)
+ describe 'read tracking' do
+ before do
+ @post = Fabricate(:post, topic: @topic, user: @topic.user)
TopicUser.update_last_read(@user, @topic.id, 1, 0)
@topic_user = TopicUser.get(@topic,@user)
end
- it 'should create a new record for a visit' do
+ it 'should create a new record for a visit' do
@topic_user.last_read_post_number.should == 1
@topic_user.last_visited_at.to_i.should == @now.to_i
@topic_user.first_visited_at.to_i.should == @now.to_i
end
-
- it 'should update the record for repeat visit' do
- Fabricate(:post, topic: @topic, user: @user)
+
+ it 'should update the record for repeat visit' do
+ Fabricate(:post, topic: @topic, user: @user)
TopicUser.update_last_read(@user, @topic.id, 2, 0)
@topic_user = TopicUser.get(@topic,@user)
@topic_user.last_read_post_number.should == 2
@@ -117,21 +117,21 @@ describe TopicUser do
@topic_user.first_visited_at.to_i.should == @now.to_i
end
- context 'auto tracking' do
+ context 'auto tracking' do
before do
- Fabricate(:post, topic: @topic, user: @user)
+ Fabricate(:post, topic: @topic, user: @user)
@new_user = Fabricate(:user, auto_track_topics_after_msecs: 1000)
TopicUser.update_last_read(@new_user, @topic.id, 2, 0)
@topic_user = TopicUser.get(@topic,@new_user)
end
-
+
it 'should automatically track topics you reply to' do
post = Fabricate(:post, topic: @topic, user: @new_user)
@topic_user = TopicUser.get(@topic,@new_user)
@topic_user.notification_level.should == TopicUser::NotificationLevel::TRACKING
@topic_user.notifications_reason_id.should == TopicUser::NotificationReasons::CREATED_POST
end
-
+
it 'should not automatically track topics you reply to and have set state manually' do
Fabricate(:post, topic: @topic, user: @new_user)
TopicUser.change(@new_user, @topic, notification_level: TopicUser::NotificationLevel::REGULAR)
@@ -140,14 +140,14 @@ describe TopicUser do
@topic_user.notifications_reason_id.should == TopicUser::NotificationReasons::USER_CHANGED
end
- it 'should automatically track topics after they are read for long enough' do
+ it 'should automatically track topics after they are read for long enough' do
@topic_user.notification_level.should == TopicUser::NotificationLevel::REGULAR
TopicUser.update_last_read(@new_user, @topic.id, 2, 1001)
@topic_user = TopicUser.get(@topic,@new_user)
@topic_user.notification_level.should == TopicUser::NotificationLevel::TRACKING
end
-
- it 'should not automatically track topics after they are read for long enough if changed manually' do
+
+ it 'should not automatically track topics after they are read for long enough if changed manually' do
TopicUser.change(@new_user, @topic, notification_level: TopicUser::NotificationLevel::REGULAR)
@topic_user = TopicUser.get(@topic,@new_user)
@@ -173,7 +173,7 @@ describe TopicUser do
TopicUser.change(@user, @topic.id, starred: true)
}.should change(TopicUser, :count).by(1)
end
-
+
describe 'after creating a row' do
before do
TopicUser.change(@user, @topic.id, starred: true)
@@ -196,4 +196,4 @@ describe TopicUser do
end
-end
+end
diff --git a/spec/models/user_action_spec.rb b/spec/models/user_action_spec.rb
index c5162e25b..f01577669 100644
--- a/spec/models/user_action_spec.rb
+++ b/spec/models/user_action_spec.rb
@@ -6,70 +6,70 @@ describe UserAction do
it { should validate_presence_of :user_id }
- describe 'lists' do
+ describe 'lists' do
let(:public_post) { Fabricate(:post) }
let(:public_topic) { public_post.topic }
let(:user) { Fabricate(:user) }
let(:private_post) { Fabricate(:post) }
- let(:private_topic) do
+ let(:private_topic) do
topic = private_post.topic
- topic.update_column(:archetype, Archetype::private_message)
+ topic.update_column(:archetype, Archetype::private_message)
topic
end
def log_test_action(opts={})
UserAction.log_action!({
action_type: UserAction::NEW_PRIVATE_MESSAGE,
- user_id: user.id,
- acting_user_id: user.id,
+ user_id: user.id,
+ acting_user_id: user.id,
target_topic_id: private_topic.id,
- target_post_id: private_post.id,
+ target_post_id: private_post.id,
}.merge(opts))
end
- before do
+ before do
# Create some test data using a helper
log_test_action
log_test_action(action_type: UserAction::GOT_PRIVATE_MESSAGE)
log_test_action(action_type: UserAction::NEW_TOPIC, target_topic_id: public_topic.id, target_post_id: public_post.id)
- log_test_action(action_type: UserAction::BOOKMARK)
+ log_test_action(action_type: UserAction::BOOKMARK)
end
describe 'stats' do
- let :mystats do
+ let :mystats do
UserAction.stats(user.id, Guardian.new(user))
end
- it 'should include non private message events' do
+ it 'should include non private message events' do
mystats.map{|r| r["action_type"].to_i}.should include(UserAction::NEW_TOPIC)
end
- it 'should exclude private messages for non owners' do
+ it 'should exclude private messages for non owners' do
UserAction.stats(user.id,Guardian.new).map{|r| r["action_type"].to_i}.should_not include(UserAction::NEW_PRIVATE_MESSAGE)
end
- it 'should not include got private messages for owners' do
+ it 'should not include got private messages for owners' do
UserAction.stats(user.id,Guardian.new).map{|r| r["action_type"].to_i}.should_not include(UserAction::GOT_PRIVATE_MESSAGE)
end
-
- it 'should include private messages for owners' do
+
+ it 'should include private messages for owners' do
mystats.map{|r| r["action_type"].to_i}.should include(UserAction::NEW_PRIVATE_MESSAGE)
end
- it 'should include got private messages for owners' do
+ it 'should include got private messages for owners' do
mystats.map{|r| r["action_type"].to_i}.should include(UserAction::GOT_PRIVATE_MESSAGE)
end
end
- describe 'stream' do
+ describe 'stream' do
it 'should have 1 item for non owners' do
UserAction.stream(user_id: user.id, guardian: Guardian.new).count.should == 1
end
-
+
it 'should have bookmarks and pms for owners' do
UserAction.stream(user_id: user.id, guardian: user.guardian).count.should == 4
end
@@ -82,7 +82,7 @@ describe UserAction do
Fabricate(:user_action)
end
- describe 'when user likes' do
+ describe 'when user likes' do
let!(:post) { Fabricate(:post) }
let(:likee) { post.user }
@@ -96,24 +96,24 @@ describe UserAction do
@old_count = likee_stream.count
end
- it "creates a new stream entry" do
- PostAction.act(liker, post, PostActionType.Types[:like])
+ it "creates a new stream entry" do
+ PostAction.act(liker, post, PostActionType.Types[:like])
likee_stream.count.should == @old_count + 1
end
context "successful like" do
- before do
+ before do
PostAction.act(liker, post, PostActionType.Types[:like])
@liker_action = liker.user_actions.where(action_type: UserAction::LIKE).first
@likee_action = likee.user_actions.where(action_type: UserAction::WAS_LIKED).first
end
- it 'should create a like action on the liker' do
- @liker_action.should_not be_nil
+ it 'should create a like action on the liker' do
+ @liker_action.should_not be_nil
end
it 'should create a like action on the likee' do
- @likee_action.should_not be_nil
+ @likee_action.should_not be_nil
end
end
@@ -124,8 +124,8 @@ describe UserAction do
end
it "doesn't add the entry to the stream" do
- PostAction.act(liker, post, PostActionType.Types[:like])
- likee_stream.count.should_not == @old_count + 1
+ PostAction.act(liker, post, PostActionType.Types[:like])
+ likee_stream.count.should_not == @old_count + 1
end
end
@@ -133,53 +133,53 @@ describe UserAction do
end
describe 'when a user posts a new topic' do
- before do
+ before do
@post = Fabricate(:old_post)
end
- describe 'topic action' do
- before do
+ describe 'topic action' do
+ before do
@action = @post.user.user_actions.where(action_type: UserAction::NEW_TOPIC).first
end
- it 'should exist' do
+ it 'should exist' do
@action.should_not be_nil
end
- it 'shoule have the correct date' do
+ it 'shoule have the correct date' do
@action.created_at.should be_within(1).of(@post.topic.created_at)
end
end
- it 'should not log a post user action' do
+ it 'should not log a post user action' do
@post.user.user_actions.where(action_type: UserAction::POST).first.should be_nil
end
- describe 'when another user posts on the topic' do
- before do
+ describe 'when another user posts on the topic' do
+ before do
@other_user = Fabricate(:coding_horror)
@mentioned = Fabricate(:admin)
@response = Fabricate(:post, reply_to_post_number: 1, topic: @post.topic, user: @other_user, raw: "perhaps @#{@mentioned.username} knows how this works?")
end
-
- it 'should log a post action for the poster' do
+
+ it 'should log a post action for the poster' do
@response.user.user_actions.where(action_type: UserAction::POST).first.should_not be_nil
end
- it 'should log a post action for the original poster' do
+ it 'should log a post action for the original poster' do
@post.user.user_actions.where(action_type: UserAction::RESPONSE).first.should_not be_nil
end
- it 'should log a mention for the mentioned' do
+ it 'should log a mention for the mentioned' do
@mentioned.user_actions.where(action_type: UserAction::MENTION).first.should_not be_nil
end
it 'should not log a double notification for a post edit' do
@response.raw = "here it goes again"
- @response.save!
+ @response.save!
@response.user.user_actions.where(action_type: UserAction::POST).count.should == 1
end
- it 'should not log topic reply and reply for a single post' do
+ it 'should not log topic reply and reply for a single post' do
@post.user.user_actions.joins(:target_post).where('posts.post_number = 2').count.should == 1
end
@@ -188,26 +188,26 @@ describe UserAction do
end
describe 'when user bookmarks' do
- before do
+ before do
@post = Fabricate(:post)
@user = @post.user
PostAction.act(@user, @post, PostActionType.Types[:bookmark])
@action = @user.user_actions.where(action_type: UserAction::BOOKMARK).first
end
- it 'should create a bookmark action' do
+ it 'should create a bookmark action' do
@action.action_type.should == UserAction::BOOKMARK
end
it 'should point to the correct post' do
@action.target_post_id.should == @post.id
end
it 'should have the right acting_user' do
- @action.acting_user_id.should == @user.id
+ @action.acting_user_id.should == @user.id
end
- it 'should target the correct user' do
+ it 'should target the correct user' do
@action.user_id.should == @user.id
end
- it 'should nuke the action when unbookmarked' do
+ it 'should nuke the action when unbookmarked' do
PostAction.remove_act(@user, @post, PostActionType.Types[:bookmark])
@user.user_actions.where(action_type: UserAction::BOOKMARK).first.should be_nil
end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index c3faed2b1..ef56c1071 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -170,8 +170,8 @@ describe User do
end
- describe 'delete posts' do
- before do
+ describe 'delete posts' do
+ before do
@post1 = Fabricate(:post)
@user = @post1.user
@post2 = Fabricate(:post, topic: @post1.topic, user: @user)
@@ -180,7 +180,7 @@ describe User do
@guardian = Guardian.new(Fabricate(:admin))
end
- it 'allows moderator to delete all posts' do
+ it 'allows moderator to delete all posts' do
@user.delete_all_posts!(@guardian)
@posts.each do |p|
p.reload
@@ -689,24 +689,24 @@ describe User do
end
- describe 'update_time_read!' do
+ describe 'update_time_read!' do
let(:user) { Fabricate(:user) }
- it 'makes no changes if nothing is cached' do
+ it 'makes no changes if nothing is cached' do
$redis.expects(:get).with("user-last-seen:#{user.id}").returns(nil)
user.update_time_read!
user.reload
user.time_read.should == 0
end
- it 'makes a change if time read is below threshold' do
+ it 'makes a change if time read is below threshold' do
$redis.expects(:get).with("user-last-seen:#{user.id}").returns(Time.now - 10.0)
user.update_time_read!
user.reload
user.time_read.should == 10
end
- it 'makes no change if time read is above threshold' do
+ it 'makes no change if time read is above threshold' do
t = Time.now - 1 - User::MAX_TIME_READ_DIFF
$redis.expects(:get).with("user-last-seen:#{user.id}").returns(t)
user.update_time_read!
diff --git a/spec/requests/store_incoming_spec.rb b/spec/requests/store_incoming_spec.rb
index 83e800541..9e0bf3a9f 100644
--- a/spec/requests/store_incoming_spec.rb
+++ b/spec/requests/store_incoming_spec.rb
@@ -1,11 +1,11 @@
require "spec_helper"
describe "Stores incoming links" do
- before do
+ before do
TopicUser.stubs(:track_visit!)
end
- let :topic do
+ let :topic do
Fabricate(:post).topic
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index d0881b7eb..c0354cfd7 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -21,7 +21,7 @@ module Helpers
def log_in_user(user)
session[:current_user_id] = user.id
end
-
+
def fixture_file(filename)
return '' if filename == ''
file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename)
@@ -60,7 +60,7 @@ Spork.prefork do
config.infer_base_class_for_anonymous_controllers = true
config.before(:suite) do
- SeedFu.seed
+ SeedFu.seed
end
config.before(:all) do
@@ -71,7 +71,7 @@ Spork.prefork do
class DateTime
class << self
- alias_method :old_now, :now
+ alias_method :old_now, :now
def now
@now || old_now
end
@@ -95,7 +95,7 @@ end
Spork.each_run do
# This code will be run each time you run your specs.
- $redis.client.reconnect
+ $redis.client.reconnect
MessageBus.reliable_pub_sub.pub_redis.client.reconnect
Rails.cache.reconnect
end
diff --git a/spec/views/omniauth_callbacks/complete.html.erb_spec.rb b/spec/views/omniauth_callbacks/complete.html.erb_spec.rb
index 5b54f8d9c..6c8d48b5a 100644
--- a/spec/views/omniauth_callbacks/complete.html.erb_spec.rb
+++ b/spec/views/omniauth_callbacks/complete.html.erb_spec.rb
@@ -37,7 +37,7 @@ describe "users/omniauth_callbacks/complete.html.erb" do
rendered_data["auth_provider"].should eq("OpenId")
rendered_data["awaiting_activation"].should eq(true)
end
-
+
end
diff --git a/vendor/gems/discourse_emoji/Rakefile b/vendor/gems/discourse_emoji/Rakefile
index ecd0cbf92..56bb7292a 100644
--- a/vendor/gems/discourse_emoji/Rakefile
+++ b/vendor/gems/discourse_emoji/Rakefile
@@ -1,6 +1,6 @@
#!/usr/bin/env rake
require "bundler/gem_tasks"
-require "rspec/core/rake_task"
+require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:test) do |spec|
spec.pattern = 'spec/*_spec.rb'
diff --git a/vendor/gems/discourse_emoji/lib/discourse_emoji/engine.rb b/vendor/gems/discourse_emoji/lib/discourse_emoji/engine.rb
index 5caafd703..5ab5e030f 100644
--- a/vendor/gems/discourse_emoji/lib/discourse_emoji/engine.rb
+++ b/vendor/gems/discourse_emoji/lib/discourse_emoji/engine.rb
@@ -7,7 +7,7 @@ module DiscourseEmoji
initializer "discourse_emoji.configure_rails_initialization" do |app|
- app.config.after_initialize do
+ app.config.after_initialize do
DiscoursePluginRegistry.setup(DiscourseEmoji::Plugin)
Post.white_listed_image_classes << "emoji"
end
diff --git a/vendor/gems/discourse_emoji/lib/discourse_emoji/plugin.rb b/vendor/gems/discourse_emoji/lib/discourse_emoji/plugin.rb
index a9f89ac9d..177e2dfbd 100644
--- a/vendor/gems/discourse_emoji/lib/discourse_emoji/plugin.rb
+++ b/vendor/gems/discourse_emoji/lib/discourse_emoji/plugin.rb
@@ -3,10 +3,10 @@ require 'discourse_plugin'
module DiscourseEmoji
class Plugin < DiscoursePlugin
-
+
def setup
# Add our Assets
- register_js('discourse_emoji',
+ register_js('discourse_emoji',
server_side: File.expand_path('../../../vendor/assets/javascripts/discourse_emoji.js', __FILE__))
register_css('discourse_emoji')
end
diff --git a/vendor/gems/discourse_emoji/spec/plugin_spec.rb b/vendor/gems/discourse_emoji/spec/plugin_spec.rb
index bf926c85e..7a304c79c 100644
--- a/vendor/gems/discourse_emoji/spec/plugin_spec.rb
+++ b/vendor/gems/discourse_emoji/spec/plugin_spec.rb
@@ -9,15 +9,15 @@ describe DiscourseEmoji::Plugin do
context '.setup' do
- it 'registers its js' do
+ it 'registers its js' do
plugin.expects(:register_js).with('discourse_emoji', any_parameters)
plugin.setup
- end
+ end
- it 'registers its css' do
+ it 'registers its css' do
plugin.expects(:register_css).with('discourse_emoji')
plugin.setup
- end
+ end
end
diff --git a/vendor/gems/discourse_emoji/spec/spec_helper.rb b/vendor/gems/discourse_emoji/spec/spec_helper.rb
index 820326fdf..aaa32597f 100644
--- a/vendor/gems/discourse_emoji/spec/spec_helper.rb
+++ b/vendor/gems/discourse_emoji/spec/spec_helper.rb
@@ -7,7 +7,7 @@ RSpec.configure do |config|
config.mock_framework = :mocha
config.color_enabled = true
-
+
end
diff --git a/vendor/gems/discourse_emoji/vendor/assets/javascripts/discourse_emoji.js b/vendor/gems/discourse_emoji/vendor/assets/javascripts/discourse_emoji.js
index 28fdb1088..81176dd3b 100644
--- a/vendor/gems/discourse_emoji/vendor/assets/javascripts/discourse_emoji.js
+++ b/vendor/gems/discourse_emoji/vendor/assets/javascripts/discourse_emoji.js
@@ -10,9 +10,9 @@
style = ""
if (opts && opts.environment === "email") {
// Hard code sizes for email view
- style = 'width="20" height="20"';
+ style = 'width="20" height="20"';
}
-
+
this.textResult = text.replace(/\:([a-z\_\+\-0-9]+)\:/g, function (m1, m2) {
return (emoji.indexOf(m2) !== -1) ?
'
' :
@@ -23,7 +23,7 @@
if (Discourse && Discourse.ComposerView) {
Discourse.ComposerView.on("initWmdEditor", function(event){
-
+
template = Handlebars.compile("
" +
"
" +
"{{#each options}}" +
@@ -38,7 +38,7 @@
$('#wmd-input').autocomplete({
template: template,
- key: ":",
+ key: ":",
transformComplete: function(v){ return v + ":"; },
dataSource: function(term, callback){
@@ -50,14 +50,14 @@
}
var options = []
- var i;
+ var i;
for (i=0; i < emoji.length; i++) {
if (emoji[i].indexOf(term) == 0) {
options.push(emoji[i]);
if(options.length > 4) { break; }
}
}
-
+
if (options.length <= 4) {
for (i=0; i < emoji.length; i++) {
if (emoji[i].indexOf(term) > 0) {
@@ -66,7 +66,7 @@
}
}
}
-
+
callback(options)
}
});
diff --git a/vendor/gems/discourse_plugin/Rakefile b/vendor/gems/discourse_plugin/Rakefile
index ecd0cbf92..56bb7292a 100644
--- a/vendor/gems/discourse_plugin/Rakefile
+++ b/vendor/gems/discourse_plugin/Rakefile
@@ -1,6 +1,6 @@
#!/usr/bin/env rake
require "bundler/gem_tasks"
-require "rspec/core/rake_task"
+require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:test) do |spec|
spec.pattern = 'spec/*_spec.rb'
diff --git a/vendor/gems/discourse_plugin/spec/spec_helper.rb b/vendor/gems/discourse_plugin/spec/spec_helper.rb
index a79bca981..dc473379e 100644
--- a/vendor/gems/discourse_plugin/spec/spec_helper.rb
+++ b/vendor/gems/discourse_plugin/spec/spec_helper.rb
@@ -8,7 +8,7 @@ RSpec.configure do |config|
config.mock_framework = :mocha
config.color_enabled = true
-
+
config.before(:each) do
DiscourseEvent.clear
end
diff --git a/vendor/gems/discourse_poll/Rakefile b/vendor/gems/discourse_poll/Rakefile
index ecd0cbf92..56bb7292a 100644
--- a/vendor/gems/discourse_poll/Rakefile
+++ b/vendor/gems/discourse_poll/Rakefile
@@ -1,6 +1,6 @@
#!/usr/bin/env rake
require "bundler/gem_tasks"
-require "rspec/core/rake_task"
+require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:test) do |spec|
spec.pattern = 'spec/*_spec.rb'
diff --git a/vendor/gems/discourse_poll/lib/discourse_poll/engine.rb b/vendor/gems/discourse_poll/lib/discourse_poll/engine.rb
index c3036e0f6..c8cc053c6 100644
--- a/vendor/gems/discourse_poll/lib/discourse_poll/engine.rb
+++ b/vendor/gems/discourse_poll/lib/discourse_poll/engine.rb
@@ -7,7 +7,7 @@ module DiscoursePoll
initializer "discourse_poll.configure_rails_initialization" do |app|
- app.config.after_initialize do
+ app.config.after_initialize do
DiscoursePluginRegistry.setup(DiscoursePoll::Plugin)
end
@@ -18,4 +18,4 @@ module DiscoursePoll
end
end
-end
\ No newline at end of file
+end
diff --git a/vendor/gems/discourse_poll/lib/discourse_poll/locale/en.yml b/vendor/gems/discourse_poll/lib/discourse_poll/locale/en.yml
index 6f8a86754..a3611b374 100644
--- a/vendor/gems/discourse_poll/lib/discourse_poll/locale/en.yml
+++ b/vendor/gems/discourse_poll/lib/discourse_poll/locale/en.yml
@@ -36,12 +36,12 @@ en:
long_form: 'voted for this post'
archetypes:
- poll:
+ poll:
title: "Poll Topic"
options:
- single_vote:
+ single_vote:
title: "Only allow one vote"
description: "A user may only vote on one post."
- private_poll:
+ private_poll:
title: "Voting is Private"
- description: "Hide who voted for what choice."
\ No newline at end of file
+ description: "Hide who voted for what choice."
diff --git a/vendor/gems/discourse_poll/lib/discourse_poll/plugin.rb b/vendor/gems/discourse_poll/lib/discourse_poll/plugin.rb
index 8f907c7f5..efee17d7f 100644
--- a/vendor/gems/discourse_poll/lib/discourse_poll/plugin.rb
+++ b/vendor/gems/discourse_poll/lib/discourse_poll/plugin.rb
@@ -5,9 +5,9 @@ module DiscoursePoll
MAX_SORT_ORDER = 2147483647
POLL_OPTIONS = {private_poll: 1, single_vote: 1}
-
+
def setup
-
+
# Add our Assets
register_js('discourse_poll')
register_css('discourse_poll')
@@ -26,15 +26,15 @@ module DiscoursePoll
post.sort_order = 1
else
post.sort_order = DiscoursePoll::Plugin::MAX_SORT_ORDER
- end
+ end
end
module TopicViewSerializerMixin
def self.included(base)
- base.attributes :private_poll, :single_vote
+ base.attributes :private_poll, :single_vote
end
-
+
def private_poll
object.topic.has_meta_data_boolean?(:private_poll)
end
diff --git a/vendor/gems/discourse_poll/spec/plugin_spec.rb b/vendor/gems/discourse_poll/spec/plugin_spec.rb
index d93358f4a..d73cd9a71 100644
--- a/vendor/gems/discourse_poll/spec/plugin_spec.rb
+++ b/vendor/gems/discourse_poll/spec/plugin_spec.rb
@@ -9,22 +9,22 @@ describe DiscoursePoll::Plugin do
context '.setup' do
- it 'registers its js' do
+ it 'registers its js' do
plugin.expects(:register_js)
plugin.setup
- end
+ end
- it 'registers its css' do
+ it 'registers its css' do
plugin.expects(:register_css)
plugin.setup
- end
+ end
- it 'registers a poll archetype' do
+ it 'registers a poll archetype' do
plugin.expects(:register_archetype).with('poll', DiscoursePoll::Plugin::POLL_OPTIONS)
plugin.setup
- end
+ end
- it 'registers a handler on post_create' do
+ it 'registers a handler on post_create' do
plugin.expects(:listen_for).with(:before_create_post)
plugin.setup
end
@@ -38,7 +38,7 @@ describe DiscoursePoll::Plugin do
it "doesn't set the sort order" do
plugin.before_create_post(post)
- post.sort_order.should_not == DiscoursePoll::Plugin::MAX_SORT_ORDER
+ post.sort_order.should_not == DiscoursePoll::Plugin::MAX_SORT_ORDER
end
end
diff --git a/vendor/gems/discourse_poll/spec/spec_helper.rb b/vendor/gems/discourse_poll/spec/spec_helper.rb
index 820326fdf..aaa32597f 100644
--- a/vendor/gems/discourse_poll/spec/spec_helper.rb
+++ b/vendor/gems/discourse_poll/spec/spec_helper.rb
@@ -7,7 +7,7 @@ RSpec.configure do |config|
config.mock_framework = :mocha
config.color_enabled = true
-
+
end
diff --git a/vendor/gems/discourse_poll/vendor/assets/javascripts/discourse_poll/models/post.js b/vendor/gems/discourse_poll/vendor/assets/javascripts/discourse_poll/models/post.js
index d50ef8be8..dc44d7566 100644
--- a/vendor/gems/discourse_poll/vendor/assets/javascripts/discourse_poll/models/post.js
+++ b/vendor/gems/discourse_poll/vendor/assets/javascripts/discourse_poll/models/post.js
@@ -1,7 +1,7 @@
(function() {
window.Discourse.Post.reopen({
- voteAction: function () {
+ voteAction: function () {
return this.get('actionByName.vote');
}.property('actionByName.vote'),
@@ -12,12 +12,12 @@
}.property('replyBelowUrlComputed', 'topic.archetype'),
// Vote for this post
- vote: function() {
+ vote: function() {
voteType = Discourse.get('site.post_action_types').findProperty('name_key', 'vote');
this.get('voteAction').act();
Em.run.next(function () {
this.set('topic.voted_in_topic', true);
- }.bind(this));
+ }.bind(this));
return false;
},
@@ -37,7 +37,7 @@
this.get('voteAction').undo();
Em.run.next(function () {
this.set('topic.voted_in_topic', false);
- }.bind(this));
+ }.bind(this));
return false;
}
diff --git a/vendor/gems/discourse_poll/vendor/assets/javascripts/discourse_poll/models/post_action_type.js b/vendor/gems/discourse_poll/vendor/assets/javascripts/discourse_poll/models/post_action_type.js
index 1212dc903..f0d42dca6 100644
--- a/vendor/gems/discourse_poll/vendor/assets/javascripts/discourse_poll/models/post_action_type.js
+++ b/vendor/gems/discourse_poll/vendor/assets/javascripts/discourse_poll/models/post_action_type.js
@@ -1,9 +1,9 @@
(function() {
Discourse.PostActionType.reopen({
-
+
isVote: function() {
return (this.get('name_key') === 'vote');
}.property('name_key')
});
-}).call(this);
\ No newline at end of file
+}).call(this);
diff --git a/vendor/gems/discourse_poll/vendor/assets/javascripts/discourse_poll/views/post_view.js b/vendor/gems/discourse_poll/vendor/assets/javascripts/discourse_poll/views/post_view.js
index dda6d6366..b325fe265 100644
--- a/vendor/gems/discourse_poll/vendor/assets/javascripts/discourse_poll/views/post_view.js
+++ b/vendor/gems/discourse_poll/vendor/assets/javascripts/discourse_poll/views/post_view.js
@@ -1,13 +1,13 @@
(function() {
window.Discourse.PostView.reopen({
-
+
extraClass: function() {
if (this.get('showVotes')) return 'votes';
return null;
}.property('showVotes'),
showVotes: function() {
- var post = this.get('post');
+ var post = this.get('post');
if (post.get('post_number') === 1) return;
if (post.get('post_type') !== Discourse.Post.REGULAR_TYPE) return;
if (post.get('reply_to_post_number')) return;
@@ -15,4 +15,4 @@
}.property('post.post_number', 'post.post_type', 'post.reply_to_post_number')
})
-}).call(this);
\ No newline at end of file
+}).call(this);
diff --git a/vendor/gems/discourse_poll/vendor/assets/javascripts/discourse_poll/views/prepend_post_view.js b/vendor/gems/discourse_poll/vendor/assets/javascripts/discourse_poll/views/prepend_post_view.js
index e9349a5b6..4b17f200f 100644
--- a/vendor/gems/discourse_poll/vendor/assets/javascripts/discourse_poll/views/prepend_post_view.js
+++ b/vendor/gems/discourse_poll/vendor/assets/javascripts/discourse_poll/views/prepend_post_view.js
@@ -4,9 +4,9 @@
// Append our template for the poll controls
if (this.get('controller.content.archetype') == 'poll') {
- this.get('childViews').pushObject(Discourse.VoteControlsView.create());
+ this.get('childViews').pushObject(Discourse.VoteControlsView.create());
}
-
+
});
-}).call(this);
\ No newline at end of file
+}).call(this);
diff --git a/vendor/gems/discourse_poll/vendor/assets/javascripts/discourse_poll/views/topic_footer_buttons_view.js b/vendor/gems/discourse_poll/vendor/assets/javascripts/discourse_poll/views/topic_footer_buttons_view.js
index fc47b75e9..4a6094181 100644
--- a/vendor/gems/discourse_poll/vendor/assets/javascripts/discourse_poll/views/topic_footer_buttons_view.js
+++ b/vendor/gems/discourse_poll/vendor/assets/javascripts/discourse_poll/views/topic_footer_buttons_view.js
@@ -6,4 +6,4 @@
}.property()
});
-}).call(this);
\ No newline at end of file
+}).call(this);
diff --git a/vendor/gems/discourse_poll/vendor/assets/javascripts/discourse_poll/views/topic_information_view.js b/vendor/gems/discourse_poll/vendor/assets/javascripts/discourse_poll/views/topic_information_view.js
index 6be29a1ea..976341d84 100644
--- a/vendor/gems/discourse_poll/vendor/assets/javascripts/discourse_poll/views/topic_information_view.js
+++ b/vendor/gems/discourse_poll/vendor/assets/javascripts/discourse_poll/views/topic_information_view.js
@@ -11,4 +11,4 @@
}
});
-}).call(this);
\ No newline at end of file
+}).call(this);
diff --git a/vendor/gems/discourse_poll/vendor/assets/javascripts/discourse_poll/views/topic_status_view.js b/vendor/gems/discourse_poll/vendor/assets/javascripts/discourse_poll/views/topic_status_view.js
index a195ddcfb..0f00f58a0 100644
--- a/vendor/gems/discourse_poll/vendor/assets/javascripts/discourse_poll/views/topic_status_view.js
+++ b/vendor/gems/discourse_poll/vendor/assets/javascripts/discourse_poll/views/topic_status_view.js
@@ -6,7 +6,7 @@
if (this.get('topic.archetype') === 'poll') {
this.renderIcon(buffer, 'check-empty', 'poll');
}
-
+
});
-}).call(this);
\ No newline at end of file
+}).call(this);
diff --git a/vendor/gems/discourse_poll/vendor/assets/javascripts/discourse_poll/views/vote_controls_view.js b/vendor/gems/discourse_poll/vendor/assets/javascripts/discourse_poll/views/vote_controls_view.js
index 58b218881..374b77741 100644
--- a/vendor/gems/discourse_poll/vendor/assets/javascripts/discourse_poll/views/vote_controls_view.js
+++ b/vendor/gems/discourse_poll/vendor/assets/javascripts/discourse_poll/views/vote_controls_view.js
@@ -38,4 +38,4 @@
}.property('post.voteAction.can_act')
})
-}).call(this);
\ No newline at end of file
+}).call(this);
diff --git a/vendor/gems/discourse_task/Rakefile b/vendor/gems/discourse_task/Rakefile
index ecd0cbf92..56bb7292a 100644
--- a/vendor/gems/discourse_task/Rakefile
+++ b/vendor/gems/discourse_task/Rakefile
@@ -1,6 +1,6 @@
#!/usr/bin/env rake
require "bundler/gem_tasks"
-require "rspec/core/rake_task"
+require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:test) do |spec|
spec.pattern = 'spec/*_spec.rb'
diff --git a/vendor/gems/discourse_task/config/routes.rb b/vendor/gems/discourse_task/config/routes.rb
index 94c6aa8b1..35ef1b2c3 100644
--- a/vendor/gems/discourse_task/config/routes.rb
+++ b/vendor/gems/discourse_task/config/routes.rb
@@ -1,5 +1,5 @@
-Rails.application.routes.draw do
-
+Rails.application.routes.draw do
+
put 't/:slug/:topic_id/complete' => 'topics#complete', :constraints => {:topic_id => /\d+/}
-end
\ No newline at end of file
+end
diff --git a/vendor/gems/discourse_task/lib/discourse_task/engine.rb b/vendor/gems/discourse_task/lib/discourse_task/engine.rb
index 11b133ecd..7a3daaea2 100644
--- a/vendor/gems/discourse_task/lib/discourse_task/engine.rb
+++ b/vendor/gems/discourse_task/lib/discourse_task/engine.rb
@@ -7,7 +7,7 @@ module DiscourseTask
initializer "discourse_task.configure_rails_initialization" do |app|
- app.config.after_initialize do
+ app.config.after_initialize do
DiscoursePluginRegistry.setup(DiscourseTask::Plugin)
end
@@ -17,4 +17,4 @@ module DiscourseTask
end
end
-end
\ No newline at end of file
+end
diff --git a/vendor/gems/discourse_task/lib/discourse_task/plugin.rb b/vendor/gems/discourse_task/lib/discourse_task/plugin.rb
index 5ce2fd983..20aa668bb 100644
--- a/vendor/gems/discourse_task/lib/discourse_task/plugin.rb
+++ b/vendor/gems/discourse_task/lib/discourse_task/plugin.rb
@@ -20,7 +20,7 @@ module DiscourseTask
module TopicViewSerializerMixin
def self.included(base)
- base.attributes :can_complete_task, :complete, :completed_at
+ base.attributes :can_complete_task, :complete, :completed_at
end
def can_complete_task
@@ -73,7 +73,7 @@ module DiscourseTask
end
-
+
render nothing: true
end
diff --git a/vendor/gems/discourse_task/spec/plugin_spec.rb b/vendor/gems/discourse_task/spec/plugin_spec.rb
index 8dacd2cff..1e06099dc 100644
--- a/vendor/gems/discourse_task/spec/plugin_spec.rb
+++ b/vendor/gems/discourse_task/spec/plugin_spec.rb
@@ -8,20 +8,20 @@ describe DiscourseTask::Plugin do
context '.setup' do
- it 'registers its js' do
+ it 'registers its js' do
plugin.expects(:register_js).with('discourse_task')
plugin.setup
- end
+ end
- it 'registers its css' do
+ it 'registers its css' do
plugin.expects(:register_css).with('discourse_task')
plugin.setup
- end
+ end
- it 'registers a task archetype' do
+ it 'registers a task archetype' do
plugin.expects(:register_archetype).with('task')
plugin.setup
- end
+ end
end
diff --git a/vendor/gems/discourse_task/spec/spec_helper.rb b/vendor/gems/discourse_task/spec/spec_helper.rb
index 820326fdf..aaa32597f 100644
--- a/vendor/gems/discourse_task/spec/spec_helper.rb
+++ b/vendor/gems/discourse_task/spec/spec_helper.rb
@@ -7,7 +7,7 @@ RSpec.configure do |config|
config.mock_framework = :mocha
config.color_enabled = true
-
+
end
diff --git a/vendor/gems/discourse_task/vendor/assets/javascripts/discourse_task/controllers/topic_controller.js b/vendor/gems/discourse_task/vendor/assets/javascripts/discourse_task/controllers/topic_controller.js
index fe6929468..db588d4a2 100644
--- a/vendor/gems/discourse_task/vendor/assets/javascripts/discourse_task/controllers/topic_controller.js
+++ b/vendor/gems/discourse_task/vendor/assets/javascripts/discourse_task/controllers/topic_controller.js
@@ -1,5 +1,5 @@
(function() {
-
+
Discourse.TopicController.reopen({
// Allow the user to complete the task
@@ -10,6 +10,6 @@
})
-}).call(this);
+}).call(this);
diff --git a/vendor/gems/discourse_task/vendor/assets/javascripts/discourse_task/models/topic.js b/vendor/gems/discourse_task/vendor/assets/javascripts/discourse_task/models/topic.js
index fb018ecad..6e1920cbd 100644
--- a/vendor/gems/discourse_task/vendor/assets/javascripts/discourse_task/models/topic.js
+++ b/vendor/gems/discourse_task/vendor/assets/javascripts/discourse_task/models/topic.js
@@ -1,5 +1,5 @@
(function() {
-
+
Discourse.Topic.reopen({
// Allow the user to complete the task
@@ -10,14 +10,14 @@
jQuery.ajax(this.get('url') + "/complete", {
type: 'PUT',
data: {
- complete: this.get('complete') ? 'true' : 'false'
+ complete: this.get('complete') ? 'true' : 'false'
}
-
+
});
}
})
-}).call(this);
+}).call(this);
diff --git a/vendor/gems/discourse_task/vendor/assets/javascripts/discourse_task/views/topic_footer_buttons_view.js b/vendor/gems/discourse_task/vendor/assets/javascripts/discourse_task/views/topic_footer_buttons_view.js
index 37e0c83ea..5394316c3 100644
--- a/vendor/gems/discourse_task/vendor/assets/javascripts/discourse_task/views/topic_footer_buttons_view.js
+++ b/vendor/gems/discourse_task/vendor/assets/javascripts/discourse_task/views/topic_footer_buttons_view.js
@@ -1,5 +1,5 @@
(function() {
-
+
Discourse.TopicFooterButtonsView.prototype.on("additionalButtons", function(childViews) {
var topic = this.get('topic');
if (topic.get('archetype') == 'task' && topic.get('can_complete_task')) {
@@ -15,16 +15,16 @@
renderIcon: function (buffer) {
if (!this.get('complete')) {
- buffer.push(" ")
- }
- },
+ buffer.push(" ")
+ }
+ },
text: function () {
if (this.get('complete')) {
- return Em.String.i18n("task.reverse");
+ return Em.String.i18n("task.reverse");
} else {
return Em.String.i18n("task.complete_action");
- }
+ }
}.property('complete'),
click: function(e) {
@@ -35,6 +35,6 @@
}
});
-}).call(this);
+}).call(this);
diff --git a/vendor/gems/discourse_task/vendor/assets/javascripts/discourse_task/views/topic_status_view.js b/vendor/gems/discourse_task/vendor/assets/javascripts/discourse_task/views/topic_status_view.js
index eab020837..47e7daf7f 100644
--- a/vendor/gems/discourse_task/vendor/assets/javascripts/discourse_task/views/topic_status_view.js
+++ b/vendor/gems/discourse_task/vendor/assets/javascripts/discourse_task/views/topic_status_view.js
@@ -9,7 +9,7 @@
if (topic.get('complete')) icon = 'ok';
this.renderIcon(buffer, icon, 'task');
}
-
+
});
Discourse.TopicStatusView.reopen({
@@ -18,4 +18,4 @@
}.observes('topic.complete')
})
-}).call(this);
\ No newline at end of file
+}).call(this);
diff --git a/vendor/gems/discourse_task/vendor/assets/javascripts/discourse_task/views/topic_summary_view.js b/vendor/gems/discourse_task/vendor/assets/javascripts/discourse_task/views/topic_summary_view.js
index b1411ef81..27f5ecb44 100644
--- a/vendor/gems/discourse_task/vendor/assets/javascripts/discourse_task/views/topic_summary_view.js
+++ b/vendor/gems/discourse_task/vendor/assets/javascripts/discourse_task/views/topic_summary_view.js
@@ -11,4 +11,4 @@
}
});
-}).call(this);
\ No newline at end of file
+}).call(this);
diff --git a/vendor/gems/message_bus/assets/application.js b/vendor/gems/message_bus/assets/application.js
index 884cff24d..f2181e608 100644
--- a/vendor/gems/message_bus/assets/application.js
+++ b/vendor/gems/message_bus/assets/application.js
@@ -44,7 +44,7 @@ App.IndexModel = Ember.Object.extend({
processes = processes.sort(function(a,b){
return a.get('uniqueId') < b.get('uniqueId') ? -1 : 1;
});
- // somewhat odd ...
+ // somewhat odd ...
_this.set('processes', null);
_this.set('processes', processes);
});
@@ -55,7 +55,7 @@ App.IndexModel = Ember.Object.extend({
discover: function(){
var _this = this;
this.set('processes', Em.A());
-
+
this.ensureSubscribed();
this.set("discovering", true);
diff --git a/vendor/gems/message_bus/assets/ember.js b/vendor/gems/message_bus/assets/ember.js
index e566b10f9..417f382c2 100644
--- a/vendor/gems/message_bus/assets/ember.js
+++ b/vendor/gems/message_bus/assets/ember.js
@@ -1752,7 +1752,7 @@ var MapWithDefault = Ember.MapWithDefault = function(options) {
@static
@param [options]
@param {anything} [options.defaultValue]
- @return {Ember.MapWithDefault|Ember.Map} If options are passed, returns
+ @return {Ember.MapWithDefault|Ember.Map} If options are passed, returns
`Ember.MapWithDefault` otherwise returns `Ember.Map`
*/
MapWithDefault.create = function(options) {
@@ -1826,7 +1826,7 @@ var FIRST_KEY = /^([^\.\*]+)/;
If you plan to run on IE8 and older browsers then you should use this
method anytime you want to retrieve a property on an object that you don't
- know for sure is private. (Properties beginning with an underscore '_'
+ know for sure is private. (Properties beginning with an underscore '_'
are considered private.)
On all newer browsers, you only need to use this method to retrieve
@@ -1888,7 +1888,7 @@ get = function get(obj, keyName) {
If you plan to run on IE8 and older browsers then you should use this
method anytime you want to set a property on an object that you don't
- know for sure is private. (Properties beginning with an underscore '_'
+ know for sure is private. (Properties beginning with an underscore '_'
are considered private.)
On all newer browsers, you only need to use this method to set
@@ -4227,7 +4227,7 @@ Ember.RunLoop = RunLoop;
```javascript
Ember.run(function(){
- // code to be execute within a RunLoop
+ // code to be execute within a RunLoop
});
```
@@ -4266,7 +4266,7 @@ var run = Ember.run;
```javascript
Ember.run.begin();
- // code to be execute within a RunLoop
+ // code to be execute within a RunLoop
Ember.run.end();
```
@@ -4284,7 +4284,7 @@ Ember.run.begin = function() {
```javascript
Ember.run.begin();
- // code to be execute within a RunLoop
+ // code to be execute within a RunLoop
Ember.run.end();
```
@@ -6935,7 +6935,7 @@ Ember.String = {
'action_name'.classify(); // 'ActionName'
'css-class-name'.classify(); // 'CssClassName'
'my favorite items'.classify(); // 'MyFavoriteItems'
- ```
+ ```
@method classify
@param {String} str the string to classify
@@ -7357,7 +7357,7 @@ Ember.Enumerable = Ember.Mixin.create(
@method nextObject
@param {Number} index the current index of the iteration
- @param {Object} previousObject the value returned by the last call to
+ @param {Object} previousObject the value returned by the last call to
`nextObject`.
@param {Object} context a context object you can use to maintain state.
@return {Object} the next object in the iteration or undefined
@@ -8422,9 +8422,9 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot
@method arrayContentWillChange
@param {Number} startIdx The starting index in the array that will change.
- @param {Number} removeAmt The number of items that will be removed. If you
+ @param {Number} removeAmt The number of items that will be removed. If you
pass `null` assumes 0
- @param {Number} addAmt The number of items that will be added If you
+ @param {Number} addAmt The number of items that will be added If you
pass `null` assumes 0.
@return {Ember.Array} receiver
*/
@@ -8898,11 +8898,11 @@ Ember.MutableArray = Ember.Mixin.create(Ember.Array, Ember.MutableEnumerable,
passed array. You should also call `this.enumerableContentDidChange()`
@method replace
- @param {Number} idx Starting index in the array to replace. If
+ @param {Number} idx Starting index in the array to replace. If
idx >= length, then append to the end of the array.
- @param {Number} amt Number of elements that should be removed from
+ @param {Number} amt Number of elements that should be removed from
the array, starting at *idx*.
- @param {Array} objects An array of zero or more objects that should be
+ @param {Array} objects An array of zero or more objects that should be
inserted into the array at *idx*
*/
replace: Ember.required(),
@@ -10157,14 +10157,14 @@ CoreObject.PrototypeMixin = Mixin.create({
view.get('classNames'); // ['ember-view', 'bar', 'foo', 'baz']
```
Adding a single property that is not an array will just add it in the array:
-
+
```javascript
var view = App.FooBarView.create({
classNames: 'baz'
})
view.get('classNames'); // ['ember-view', 'bar', 'foo', 'baz']
```
-
+
Using the `concatenatedProperties` property, we can tell to Ember that mix
the content of the properties.
@@ -14249,7 +14249,7 @@ class:
* `mouseEnter`
* `mouseLeave`
- Form events:
+ Form events:
* `submit`
* `change`
@@ -14257,7 +14257,7 @@ class:
* `focusOut`
* `input`
- HTML5 drag and drop events:
+ HTML5 drag and drop events:
* `dragStart`
* `drag`
@@ -15794,14 +15794,14 @@ Ember.View.reopenClass({
`className` and optional `falsyClassName`.
- if a `className` or `falsyClassName` has been specified:
- - if the value is truthy and `className` has been specified,
+ - if the value is truthy and `className` has been specified,
`className` is returned
- - if the value is falsy and `falsyClassName` has been specified,
+ - if the value is falsy and `falsyClassName` has been specified,
`falsyClassName` is returned
- otherwise `null` is returned
- - if the value is `true`, the dasherized last part of the supplied path
+ - if the value is `true`, the dasherized last part of the supplied path
is returned
- - if the value is not `false`, `undefined` or `null`, the `value`
+ - if the value is not `false`, `undefined` or `null`, the `value`
is returned
- if none of the above rules apply, `null` is returned
@@ -16651,7 +16651,7 @@ var get = Ember.get, set = Ember.set, fmt = Ember.String.fmt;
Given an empty `` and the following code:
- ```javascript
+ ```javascript
someItemsView = Ember.CollectionView.create({
classNames: ['a-collection'],
content: ['A','B','C'],
@@ -17823,7 +17823,7 @@ Ember.Handlebars.registerHelper('helperMissing', function(path, options) {
## Example with bound options
- Bound hash options are also supported. Example:
+ Bound hash options are also supported. Example:
```handlebars
{{repeat text countBinding="numRepeats"}}
@@ -17861,15 +17861,15 @@ Ember.Handlebars.registerHelper('helperMissing', function(path, options) {
{{concatenate prop1 prop2 prop3}}. If any of the properties change,
the helpr will re-render. Note that dependency keys cannot be
using in conjunction with multi-property helpers, since it is ambiguous
- which property the dependent keys would belong to.
-
+ which property the dependent keys would belong to.
+
## Use with unbound helper
- The {{unbound}} helper can be used with bound helper invocations
+ The {{unbound}} helper can be used with bound helper invocations
to render them in their unbound form, e.g.
```handlebars
- {{unbound capitalize name}}
+ {{unbound capitalize name}}
```
In this example, if the name property changes, the helper
@@ -17895,7 +17895,7 @@ Ember.Handlebars.registerBoundHelper = function(name, fn) {
view = data.view,
currentContext = (options.contexts && options.contexts[0]) || this,
normalized,
- pathRoot, path,
+ pathRoot, path,
loc, hashOption;
// Detect bound options (e.g. countBinding="otherCount")
@@ -18001,7 +18001,7 @@ function evaluateMultiPropertyBoundHelper(context, fn, normalizedProperties, opt
// Assemble liast of watched properties that'll re-render this helper.
watchedProperties = [];
for (boundOption in boundOptions) {
- if (boundOptions.hasOwnProperty(boundOption)) {
+ if (boundOptions.hasOwnProperty(boundOption)) {
watchedProperties.push(normalizePath(context, boundOptions[boundOption], data));
}
}
@@ -18936,14 +18936,14 @@ EmberHandlebars.registerHelper('unless', function(context, options) {
Result in the following rendered output:
- ```html
+ ```html
```
A boolean return value will insert a specified class name if the property
returns `true` and remove the class name if the property returns `false`.
- A class name is provided via the syntax
+ A class name is provided via the syntax
`somePropertyName:class-name-if-true`.
```javascript
@@ -19100,9 +19100,9 @@ EmberHandlebars.registerHelper('bindAttr', function(options) {
@method bindClasses
@for Ember.Handlebars
@param {Ember.Object} context The context from which to lookup properties
- @param {String} classBindings A string, space-separated, of class bindings
+ @param {String} classBindings A string, space-separated, of class bindings
to use
- @param {Ember.View} view The view in which observers should look for the
+ @param {Ember.View} view The view in which observers should look for the
element to update
@param {Srting} bindAttrId Optional bindAttr id used to lookup elements
@return {Array} An array of class names to add
@@ -19792,7 +19792,7 @@ Ember.Handlebars.registerHelper('unbound', function(property, fn) {
// Unbound helper call.
options.data.isUnbound = true;
helper = Ember.Handlebars.helpers[arguments[0]] || Ember.Handlebars.helperMissing;
- out = helper.apply(this, Array.prototype.slice.call(arguments, 1));
+ out = helper.apply(this, Array.prototype.slice.call(arguments, 1));
delete options.data.isUnbound;
return out;
}
@@ -20087,7 +20087,7 @@ GroupedEach.prototype = {
```handlebars
{{#view App.MyView }}
- {{each view.items itemViewClass="App.AnItemView"}}
+ {{each view.items itemViewClass="App.AnItemView"}}
{{/view}}
```
@@ -20118,7 +20118,7 @@ GroupedEach.prototype = {
Greetings Sara
```
-
+
### Representing each item with a Controller.
By default the controller lookup within an `{{#each}}` block will be
the controller of the template where the `{{#each}}` was used. If each
@@ -20126,10 +20126,10 @@ GroupedEach.prototype = {
`itemController` option which references a controller by lookup name.
Each item in the loop will be wrapped in an instance of this controller
and the item itself will be set to the `content` property of that controller.
-
+
This is useful in cases where properties of model objects need transformation
or synthesis for display:
-
+
```javascript
App.DeveloperController = Ember.ObjectController.extend({
isAvailableForHire: function(){
@@ -20137,13 +20137,13 @@ GroupedEach.prototype = {
}.property('isEmployed', 'isSeekingWork')
})
```
-
+
```handlebars
{{#each person in Developers itemController="developer"}}
{{person.name}} {{#if person.isAvailableForHire}}Hire me!{{/if}}
{{/each}}
```
-
+
@method each
@for Ember.Handlebars.helpers
@param [name] {String} name for item (used with `in`)
@@ -21082,7 +21082,7 @@ helpers = helpers || Ember.Handlebars.helpers; data = data || {};
var buffer = '', stack1, hashTypes, escapeExpression=this.escapeExpression, self=this;
function program1(depth0,data) {
-
+
var buffer = '', hashTypes;
data.buffer.push("
");
hashTypes = {};
@@ -21092,7 +21092,7 @@ function program1(depth0,data) {
}
function program3(depth0,data) {
-
+
var hashTypes;
hashTypes = {'contentBinding': "STRING"};
data.buffer.push(escapeExpression(helpers.view.call(depth0, "Ember.SelectOption", {hash:{
@@ -21107,7 +21107,7 @@ function program3(depth0,data) {
stack1 = helpers.each.call(depth0, "view.content", {hash:{},inverse:self.noop,fn:self.program(3, program3, data),contexts:[depth0],types:["ID"],hashTypes:hashTypes,data:data});
if(stack1 || stack1 === 0) { data.buffer.push(stack1); }
return buffer;
-
+
}),
attributeBindings: ['multiple', 'disabled', 'tabindex'],
diff --git a/vendor/gems/message_bus/assets/handlebars.js b/vendor/gems/message_bus/assets/handlebars.js
index 9c653ee72..9e66e9267 100644
--- a/vendor/gems/message_bus/assets/handlebars.js
+++ b/vendor/gems/message_bus/assets/handlebars.js
@@ -184,99 +184,99 @@ performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) {
var $0 = $$.length - 1;
switch (yystate) {
-case 1: return $$[$0-1];
+case 1: return $$[$0-1];
break;
-case 2: this.$ = new yy.ProgramNode([], $$[$0]);
+case 2: this.$ = new yy.ProgramNode([], $$[$0]);
break;
-case 3: this.$ = new yy.ProgramNode($$[$0-2], $$[$0]);
+case 3: this.$ = new yy.ProgramNode($$[$0-2], $$[$0]);
break;
-case 4: this.$ = new yy.ProgramNode($$[$0-1], []);
+case 4: this.$ = new yy.ProgramNode($$[$0-1], []);
break;
-case 5: this.$ = new yy.ProgramNode($$[$0]);
+case 5: this.$ = new yy.ProgramNode($$[$0]);
break;
-case 6: this.$ = new yy.ProgramNode([], []);
+case 6: this.$ = new yy.ProgramNode([], []);
break;
-case 7: this.$ = new yy.ProgramNode([]);
+case 7: this.$ = new yy.ProgramNode([]);
break;
-case 8: this.$ = [$$[$0]];
+case 8: this.$ = [$$[$0]];
break;
-case 9: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
+case 9: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
break;
-case 10: this.$ = new yy.BlockNode($$[$0-2], $$[$0-1].inverse, $$[$0-1], $$[$0]);
+case 10: this.$ = new yy.BlockNode($$[$0-2], $$[$0-1].inverse, $$[$0-1], $$[$0]);
break;
-case 11: this.$ = new yy.BlockNode($$[$0-2], $$[$0-1], $$[$0-1].inverse, $$[$0]);
+case 11: this.$ = new yy.BlockNode($$[$0-2], $$[$0-1], $$[$0-1].inverse, $$[$0]);
break;
-case 12: this.$ = $$[$0];
+case 12: this.$ = $$[$0];
break;
-case 13: this.$ = $$[$0];
+case 13: this.$ = $$[$0];
break;
-case 14: this.$ = new yy.ContentNode($$[$0]);
+case 14: this.$ = new yy.ContentNode($$[$0]);
break;
-case 15: this.$ = new yy.CommentNode($$[$0]);
+case 15: this.$ = new yy.CommentNode($$[$0]);
break;
-case 16: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]);
+case 16: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]);
break;
-case 17: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]);
+case 17: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]);
break;
-case 18: this.$ = $$[$0-1];
+case 18: this.$ = $$[$0-1];
break;
-case 19: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]);
+case 19: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]);
break;
-case 20: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1], true);
+case 20: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1], true);
break;
-case 21: this.$ = new yy.PartialNode($$[$0-1]);
+case 21: this.$ = new yy.PartialNode($$[$0-1]);
break;
-case 22: this.$ = new yy.PartialNode($$[$0-2], $$[$0-1]);
+case 22: this.$ = new yy.PartialNode($$[$0-2], $$[$0-1]);
break;
-case 23:
+case 23:
break;
-case 24: this.$ = [[$$[$0-2]].concat($$[$0-1]), $$[$0]];
+case 24: this.$ = [[$$[$0-2]].concat($$[$0-1]), $$[$0]];
break;
-case 25: this.$ = [[$$[$0-1]].concat($$[$0]), null];
+case 25: this.$ = [[$$[$0-1]].concat($$[$0]), null];
break;
-case 26: this.$ = [[$$[$0-1]], $$[$0]];
+case 26: this.$ = [[$$[$0-1]], $$[$0]];
break;
-case 27: this.$ = [[$$[$0]], null];
+case 27: this.$ = [[$$[$0]], null];
break;
-case 28: this.$ = [[new yy.DataNode($$[$0])], null];
+case 28: this.$ = [[new yy.DataNode($$[$0])], null];
break;
-case 29: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
+case 29: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
break;
-case 30: this.$ = [$$[$0]];
+case 30: this.$ = [$$[$0]];
break;
-case 31: this.$ = $$[$0];
+case 31: this.$ = $$[$0];
break;
-case 32: this.$ = new yy.StringNode($$[$0]);
+case 32: this.$ = new yy.StringNode($$[$0]);
break;
-case 33: this.$ = new yy.IntegerNode($$[$0]);
+case 33: this.$ = new yy.IntegerNode($$[$0]);
break;
-case 34: this.$ = new yy.BooleanNode($$[$0]);
+case 34: this.$ = new yy.BooleanNode($$[$0]);
break;
-case 35: this.$ = new yy.DataNode($$[$0]);
+case 35: this.$ = new yy.DataNode($$[$0]);
break;
-case 36: this.$ = new yy.HashNode($$[$0]);
+case 36: this.$ = new yy.HashNode($$[$0]);
break;
-case 37: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
+case 37: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
break;
-case 38: this.$ = [$$[$0]];
+case 38: this.$ = [$$[$0]];
break;
-case 39: this.$ = [$$[$0-2], $$[$0]];
+case 39: this.$ = [$$[$0-2], $$[$0]];
break;
-case 40: this.$ = [$$[$0-2], new yy.StringNode($$[$0])];
+case 40: this.$ = [$$[$0-2], new yy.StringNode($$[$0])];
break;
-case 41: this.$ = [$$[$0-2], new yy.IntegerNode($$[$0])];
+case 41: this.$ = [$$[$0-2], new yy.IntegerNode($$[$0])];
break;
-case 42: this.$ = [$$[$0-2], new yy.BooleanNode($$[$0])];
+case 42: this.$ = [$$[$0-2], new yy.BooleanNode($$[$0])];
break;
-case 43: this.$ = [$$[$0-2], new yy.DataNode($$[$0])];
+case 43: this.$ = [$$[$0-2], new yy.DataNode($$[$0])];
break;
-case 44: this.$ = new yy.PartialNameNode($$[$0]);
+case 44: this.$ = new yy.PartialNameNode($$[$0]);
break;
-case 45: this.$ = new yy.IdNode($$[$0]);
+case 45: this.$ = new yy.IdNode($$[$0]);
break;
-case 46: $$[$0-2].push($$[$0]); this.$ = $$[$0-2];
+case 46: $$[$0-2].push($$[$0]); this.$ = $$[$0-2];
break;
-case 47: this.$ = [$$[$0]];
+case 47: this.$ = [$$[$0]];
break;
}
},
@@ -566,75 +566,75 @@ case 0:
if(yy_.yytext.slice(-1) !== "\\") this.begin("mu");
if(yy_.yytext.slice(-1) === "\\") yy_.yytext = yy_.yytext.substr(0,yy_.yyleng-1), this.begin("emu");
if(yy_.yytext) return 14;
-
+
break;
-case 1: return 14;
+case 1: return 14;
break;
case 2:
if(yy_.yytext.slice(-1) !== "\\") this.popState();
if(yy_.yytext.slice(-1) === "\\") yy_.yytext = yy_.yytext.substr(0,yy_.yyleng-1);
return 14;
-
+
break;
-case 3: yy_.yytext = yy_.yytext.substr(0, yy_.yyleng-4); this.popState(); return 15;
+case 3: yy_.yytext = yy_.yytext.substr(0, yy_.yyleng-4); this.popState(); return 15;
break;
-case 4: this.begin("par"); return 24;
+case 4: this.begin("par"); return 24;
break;
-case 5: return 16;
+case 5: return 16;
break;
-case 6: return 20;
+case 6: return 20;
break;
-case 7: return 19;
+case 7: return 19;
break;
-case 8: return 19;
+case 8: return 19;
break;
-case 9: return 23;
+case 9: return 23;
break;
-case 10: return 23;
+case 10: return 23;
break;
-case 11: this.popState(); this.begin('com');
+case 11: this.popState(); this.begin('com');
break;
-case 12: yy_.yytext = yy_.yytext.substr(3,yy_.yyleng-5); this.popState(); return 15;
+case 12: yy_.yytext = yy_.yytext.substr(3,yy_.yyleng-5); this.popState(); return 15;
break;
-case 13: return 22;
+case 13: return 22;
break;
-case 14: return 36;
+case 14: return 36;
break;
-case 15: return 35;
+case 15: return 35;
break;
-case 16: return 35;
+case 16: return 35;
break;
-case 17: return 39;
+case 17: return 39;
break;
-case 18: /*ignore whitespace*/
+case 18: /*ignore whitespace*/
break;
-case 19: this.popState(); return 18;
+case 19: this.popState(); return 18;
break;
-case 20: this.popState(); return 18;
+case 20: this.popState(); return 18;
break;
-case 21: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\"/g,'"'); return 30;
+case 21: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\"/g,'"'); return 30;
break;
-case 22: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\'/g,"'"); return 30;
+case 22: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\'/g,"'"); return 30;
break;
-case 23: yy_.yytext = yy_.yytext.substr(1); return 28;
+case 23: yy_.yytext = yy_.yytext.substr(1); return 28;
break;
-case 24: return 32;
+case 24: return 32;
break;
-case 25: return 32;
+case 25: return 32;
break;
-case 26: return 31;
+case 26: return 31;
break;
-case 27: return 35;
+case 27: return 35;
break;
-case 28: yy_.yytext = yy_.yytext.substr(1, yy_.yyleng-2); return 35;
+case 28: yy_.yytext = yy_.yytext.substr(1, yy_.yyleng-2); return 35;
break;
-case 29: return 'INVALID';
+case 29: return 'INVALID';
break;
-case 30: /*ignore whitespace*/
+case 30: /*ignore whitespace*/
break;
-case 31: this.popState(); return 37;
+case 31: this.popState(); return 37;
break;
-case 32: return 5;
+case 32: return 5;
break;
}
};
diff --git a/vendor/gems/message_bus/assets/message-bus.js b/vendor/gems/message_bus/assets/message-bus.js
index 1a19d1577..ede6f9842 100644
--- a/vendor/gems/message_bus/assets/message-bus.js
+++ b/vendor/gems/message_bus/assets/message-bus.js
@@ -56,7 +56,7 @@ window.MessageBus = (function() {
callbacks: callbacks,
clientId: clientId,
stop: false,
-
+
start: function(opts) {
var poll,
_this = this;
diff --git a/vendor/gems/message_bus/lib/message_bus.rb b/vendor/gems/message_bus/lib/message_bus.rb
index 3d144892a..1ba6260be 100644
--- a/vendor/gems/message_bus/lib/message_bus.rb
+++ b/vendor/gems/message_bus/lib/message_bus.rb
@@ -40,11 +40,11 @@ module MessageBus::Implementation
def logger
return @logger if @logger
require 'logger'
- @logger = Logger.new(STDOUT)
+ @logger = Logger.new(STDOUT)
end
def sockets_enabled?
- @sockets_enabled == false ? false : true
+ @sockets_enabled == false ? false : true
end
def sockets_enabled=(val)
@@ -68,13 +68,13 @@ module MessageBus::Implementation
end
def off
- @off = true
+ @off = true
end
- def on
- @off = false
+ def on
+ @off = false
end
-
+
# Allow us to inject a redis db
def redis_config=(config)
@redis_config = config
@@ -114,10 +114,10 @@ module MessageBus::Implementation
end
def allow_broadcast?
- @allow_broadcast ||=
+ @allow_broadcast ||=
if defined? ::Rails
::Rails.env.test? || ::Rails.env.development?
- else
+ else
false
end
end
@@ -130,9 +130,9 @@ module MessageBus::Implementation
MessageBus::Diagnostics.enable
end
- def publish(channel, data, opts = nil)
- return if @off
-
+ def publish(channel, data, opts = nil)
+ return if @off
+
user_ids = nil
if opts
user_ids = opts[:user_ids] if opts
@@ -142,14 +142,14 @@ module MessageBus::Implementation
data: data,
user_ids: user_ids
})
-
+
reliable_pub_sub.publish(encode_channel_name(channel), encoded_data)
end
def blocking_subscribe(channel=nil, &blk)
if channel
reliable_pub_sub.subscribe(encode_channel_name(channel), &blk)
- else
+ else
reliable_pub_sub.global_subscribe(&blk)
end
end
@@ -173,7 +173,7 @@ module MessageBus::Implementation
def subscribe(channel=nil, &blk)
subscribe_impl(channel, nil, &blk)
end
-
+
# subscribe only on current site
def local_subscribe(channel=nil, &blk)
site_id = MessageBus.site_id_lookup.call if MessageBus.site_id_lookup
@@ -181,15 +181,15 @@ module MessageBus::Implementation
end
def backlog(channel=nil, last_id)
- old =
+ old =
if channel
reliable_pub_sub.backlog(encode_channel_name(channel), last_id)
- else
+ else
reliable_pub_sub.global_backlog(encode_channel_name(channel), last_id)
end
old.each{ |m|
- decode_message!(m)
+ decode_message!(m)
}
old
end
@@ -199,32 +199,32 @@ module MessageBus::Implementation
reliable_pub_sub.last_id(encode_channel_name(channel))
end
- protected
+ protected
def decode_message!(msg)
channel, site_id = decode_channel_name(msg.channel)
- msg.channel = channel
+ msg.channel = channel
msg.site_id = site_id
- parsed = JSON.parse(msg.data)
+ parsed = JSON.parse(msg.data)
msg.data = parsed["data"]
msg.user_ids = parsed["user_ids"]
end
def subscribe_impl(channel, site_id, &blk)
- @subscriptions ||= {}
+ @subscriptions ||= {}
@subscriptions[site_id] ||= {}
- @subscriptions[site_id][channel] ||= []
- @subscriptions[site_id][channel] << blk
+ @subscriptions[site_id][channel] ||= []
+ @subscriptions[site_id][channel] << blk
ensure_subscriber_thread
end
def ensure_subscriber_thread
@mutex ||= Mutex.new
- @mutex.synchronize do
+ @mutex.synchronize do
return if @subscriber_thread
@subscriber_thread = Thread.new do
reliable_pub_sub.global_subscribe do |msg|
- begin
+ begin
decode_message!(msg)
globals = @subscriptions[nil]
@@ -232,7 +232,7 @@ module MessageBus::Implementation
global_globals = globals[nil] if globals
local_globals = locals[nil] if locals
-
+
globals = globals[msg.channel] if globals
locals = locals[msg.channel] if locals
@@ -243,7 +243,7 @@ module MessageBus::Implementation
rescue => e
MessageBus.logger.warn "failed to process message #{msg.inspect}\n ex: #{e} backtrace: #{e.backtrace}"
end
-
+
end
end
end
diff --git a/vendor/gems/message_bus/lib/message_bus/client.rb b/vendor/gems/message_bus/lib/message_bus/client.rb
index c8556c91a..7d48b4df8 100644
--- a/vendor/gems/message_bus/lib/message_bus/client.rb
+++ b/vendor/gems/message_bus/lib/message_bus/client.rb
@@ -8,7 +8,7 @@ class MessageBus::Client
@subscriptions = {}
end
- def close
+ def close
return unless @async_response
write_and_close "[]"
end
@@ -31,12 +31,12 @@ class MessageBus::Client
end
def subscriptions
- @subscriptions
+ @subscriptions
end
def backlog
r = []
- @subscriptions.each do |k,v|
+ @subscriptions.each do |k,v|
next if v.to_i < 0
messages = MessageBus.backlog(k,v)
messages.each do |msg|
@@ -46,8 +46,8 @@ class MessageBus::Client
end
# stats message for all newly subscribed
status_message = nil
- @subscriptions.each do |k,v|
- if v.to_i == -1
+ @subscriptions.each do |k,v|
+ if v.to_i == -1
status_message ||= {}
status_message[k] = MessageBus.last_id(k)
end
diff --git a/vendor/gems/message_bus/lib/message_bus/connection_manager.rb b/vendor/gems/message_bus/lib/message_bus/connection_manager.rb
index 446104ad6..6f15e28a9 100644
--- a/vendor/gems/message_bus/lib/message_bus/connection_manager.rb
+++ b/vendor/gems/message_bus/lib/message_bus/connection_manager.rb
@@ -4,23 +4,23 @@ class MessageBus::ConnectionManager
def initialize
@clients = {}
- @subscriptions = {}
+ @subscriptions = {}
end
def notify_clients(msg)
- begin
- site_subs = @subscriptions[msg.site_id]
+ begin
+ site_subs = @subscriptions[msg.site_id]
subscription = site_subs[msg.channel] if site_subs
return unless subscription
-
+
subscription.each do |client_id|
client = @clients[client_id]
if client
allowed = !msg.user_ids || msg.user_ids.include?(client.user_id)
- if allowed
+ if allowed
client << msg
- # turns out you can delete from a set while itereating
+ # turns out you can delete from a set while itereating
remove_client(client)
end
end
@@ -29,7 +29,7 @@ class MessageBus::ConnectionManager
MessageBus.logger.error "notify clients crash #{e} : #{e.backtrace}"
end
end
-
+
def add_client(client)
@clients[client.client_id] = client
@subscriptions[client.site_id] ||= {}
@@ -51,8 +51,8 @@ class MessageBus::ConnectionManager
end
def subscribe_client(client,channel)
- set = @subscriptions[client.site_id][channel]
- unless set
+ set = @subscriptions[client.site_id][channel]
+ unless set
set = Set.new
@subscriptions[client.site_id][channel] = set
end
@@ -65,5 +65,5 @@ class MessageBus::ConnectionManager
subscriptions: @subscriptions
}
end
-
+
end
diff --git a/vendor/gems/message_bus/lib/message_bus/diagnostics.rb b/vendor/gems/message_bus/lib/message_bus/diagnostics.rb
index 97883c8a1..ed1a954df 100644
--- a/vendor/gems/message_bus/lib/message_bus/diagnostics.rb
+++ b/vendor/gems/message_bus/lib/message_bus/diagnostics.rb
@@ -1,15 +1,15 @@
class MessageBus::Diagnostics
def self.full_process_path
- begin
- info = `ps -eo "%p|$|%a" | grep '^\\s*#{Process.pid}'`
+ begin
+ info = `ps -eo "%p|$|%a" | grep '^\\s*#{Process.pid}'`
info.strip.split('|$|')[1]
rescue
# skip it ... not linux or something weird
end
end
-
+
def self.hostname
- begin
+ begin
`hostname`.strip
rescue
# skip it
@@ -21,8 +21,8 @@ class MessageBus::Diagnostics
start_time = Time.now.to_f
hostname = self.hostname
- # it may make sense to add a channel per machine/host to streamline
- # process to process comms
+ # it may make sense to add a channel per machine/host to streamline
+ # process to process comms
MessageBus.subscribe('/_diagnostics/hup') do |msg|
if Process.pid == msg.data["pid"] && hostname == msg.data["hostname"]
$shutdown = true
@@ -33,7 +33,7 @@ class MessageBus::Diagnostics
MessageBus.subscribe('/_diagnostics/discover') do |msg|
MessageBus.on_connect.call msg.site_id if MessageBus.on_connect
- MessageBus.publish '/_diagnostics/process-discovery', {
+ MessageBus.publish '/_diagnostics/process-discovery', {
pid: Process.pid,
process_name: $0,
full_path: full_path,
diff --git a/vendor/gems/message_bus/lib/message_bus/message.rb b/vendor/gems/message_bus/lib/message_bus/message.rb
index 681302e8e..030df8bdc 100644
--- a/vendor/gems/message_bus/lib/message_bus/message.rb
+++ b/vendor/gems/message_bus/lib/message_bus/message.rb
@@ -1,5 +1,5 @@
class MessageBus::Message < Struct.new(:global_id, :message_id, :channel , :data)
-
+
attr_accessor :site_id, :user_ids
def self.decode(encoded)
@@ -10,7 +10,7 @@ class MessageBus::Message < Struct.new(:global_id, :message_id, :channel , :data
MessageBus::Message.new encoded[0..s1].to_i, encoded[s1+1..s2].to_i, encoded[s2+1..s3-1].gsub("$$123$$", "|"), encoded[s3+1..-1]
end
- # only tricky thing to encode is pipes in a channel name ... do a straight replace
+ # only tricky thing to encode is pipes in a channel name ... do a straight replace
def encode
global_id.to_s << "|" << message_id.to_s << "|" << channel.gsub("|","$$123$$") << "|" << data
end
diff --git a/vendor/gems/message_bus/lib/message_bus/message_handler.rb b/vendor/gems/message_bus/lib/message_bus/message_handler.rb
index c370d6c24..2edd1150e 100644
--- a/vendor/gems/message_bus/lib/message_bus/message_handler.rb
+++ b/vendor/gems/message_bus/lib/message_bus/message_handler.rb
@@ -8,13 +8,13 @@ class MessageBus::MessageHandler
def self.handle(name,&blk)
raise ArgumentError.new("expecting block") unless block_given?
raise ArgumentError.new("name") unless name
-
+
@@handlers ||= {}
@@handlers[name] = blk
end
def self.call(site_id, name, data, current_user_id)
- begin
+ begin
MessageBus.on_connect.call(site_id) if MessageBus.on_connect
@@handlers[name].call(data,current_user_id)
ensure
diff --git a/vendor/gems/message_bus/lib/message_bus/rack/diagnostics.rb b/vendor/gems/message_bus/lib/message_bus/rack/diagnostics.rb
index 85f7fbeeb..8a4d405be 100644
--- a/vendor/gems/message_bus/lib/message_bus/rack/diagnostics.rb
+++ b/vendor/gems/message_bus/lib/message_bus/rack/diagnostics.rb
@@ -57,14 +57,14 @@ HTML
# from ember-rails
def indent(string)
string.gsub(/$(.)/m, "\\1 ").strip
- end
+ end
def call(env)
return @app.call(env) unless env['PATH_INFO'].start_with? '/message-bus/_diagnostics'
route = env['PATH_INFO'].split('/message-bus/_diagnostics')[1]
-
+
if MessageBus.is_admin_lookup.nil? || !MessageBus.is_admin_lookup.call(env)
return [403, {}, ['not allowed']]
end
@@ -85,14 +85,14 @@ HTML
asset = route.split('/assets/')[1]
if asset && !asset !~ /\//
- content = asset_contents(asset)
+ content = asset_contents(asset)
split = asset.split('.')
if split[1] == 'handlebars'
content = translate_handlebars(split[0],content)
end
return [200, {'content-type' => 'text/javascript;'}, [content]]
end
-
+
return [404, {}, ['not found']]
end
end
diff --git a/vendor/gems/message_bus/lib/message_bus/rack/middleware.rb b/vendor/gems/message_bus/lib/message_bus/rack/middleware.rb
index f240266a4..ec16a3d61 100644
--- a/vendor/gems/message_bus/lib/message_bus/rack/middleware.rb
+++ b/vendor/gems/message_bus/lib/message_bus/rack/middleware.rb
@@ -9,7 +9,7 @@ class MessageBus::Rack::Middleware
def self.start_listener
unless @started_listener
MessageBus.subscribe do |msg|
- EM.next_tick do
+ EM.next_tick do
@@connection_manager.notify_clients(msg) if @@connection_manager
end
end
@@ -25,9 +25,9 @@ class MessageBus::Rack::Middleware
def self.backlog_to_json(backlog)
m = backlog.map do |msg|
- {
+ {
:global_id => msg.global_id,
- :message_id => msg.message_id,
+ :message_id => msg.message_id,
:channel => msg.channel,
:data => msg.data
}
@@ -36,7 +36,7 @@ class MessageBus::Rack::Middleware
end
def call(env)
-
+
return @app.call(env) unless env['PATH_INFO'] =~ /^\/message-bus/
# special debug/test route
@@ -46,7 +46,7 @@ class MessageBus::Rack::Middleware
return [200,{"Content-Type" => "text/html"},["sent"]]
end
- if env['PATH_INFO'].start_with? '/message-bus/_diagnostics'
+ if env['PATH_INFO'].start_with? '/message-bus/_diagnostics'
diags = MessageBus::Rack::Diagnostics.new(@app)
return diags.call(env)
end
@@ -54,9 +54,9 @@ class MessageBus::Rack::Middleware
client_id = env['PATH_INFO'].split("/")[2]
return [404, {}, ["not found"]] unless client_id
- user_id = MessageBus.user_id_lookup.call(env) if MessageBus.user_id_lookup
- site_id = MessageBus.site_id_lookup.call(env) if MessageBus.site_id_lookup
-
+ user_id = MessageBus.user_id_lookup.call(env) if MessageBus.user_id_lookup
+ site_id = MessageBus.site_id_lookup.call(env) if MessageBus.site_id_lookup
+
client = MessageBus::Client.new(client_id: client_id, user_id: user_id, site_id: site_id)
connection = env['em.connection']
@@ -65,20 +65,20 @@ class MessageBus::Rack::Middleware
request.POST.each do |k,v|
client.subscribe(k, v)
end
-
+
backlog = client.backlog
headers = {}
headers["Cache-Control"] = "must-revalidate, private, max-age=0"
headers["Content-Type"] ="application/json; charset=utf-8"
- if backlog.length > 0
+ if backlog.length > 0
[200, headers, [self.class.backlog_to_json(backlog)] ]
elsif MessageBus.long_polling_enabled? && env['QUERY_STRING'] !~ /dlp=t/
response = Thin::AsyncResponse.new(env)
response.headers["Cache-Control"] = "must-revalidate, private, max-age=0"
response.headers["Content-Type"] ="application/json; charset=utf-8"
response.status = 200
- client.async_response = response
+ client.async_response = response
@@connection_manager.add_client(client)
@@ -86,16 +86,16 @@ class MessageBus::Rack::Middleware
client.close
@@connection_manager.remove_client(client)
}
-
+
throw :async
- else
+ else
[200, headers, ["[]"]]
end
end
end
-# there is also another in cramp this is from https://github.com/macournoyer/thin_async/blob/master/lib/thin/async.rb
+# there is also another in cramp this is from https://github.com/macournoyer/thin_async/blob/master/lib/thin/async.rb
module Thin
unless defined?(DeferrableBody)
# Based on version from James Tucker
@@ -115,7 +115,7 @@ module Thin
@body_callback = blk
schedule_dequeue
end
-
+
private
def schedule_dequeue
return unless @body_callback
@@ -129,14 +129,14 @@ module Thin
end
end
end
-
+
# Response whos body is sent asynchronously.
class AsyncResponse
include Rack::Response::Helpers
-
+
attr_reader :headers, :callback, :closed
attr_accessor :status
-
+
def initialize(env, status=200, headers={})
@callback = env['async.callback']
@body = DeferrableBody.new
@@ -144,25 +144,25 @@ module Thin
@headers = headers
@headers_sent = false
end
-
+
def send_headers
return if @headers_sent
@callback.call [@status, @headers, @body]
@headers_sent = true
end
-
+
def write(body)
send_headers
@body.call(body.respond_to?(:each) ? body : [body])
end
alias :<< :write
-
+
# Tell Thin the response is complete and the connection can be closed.
def done
@closed = true
send_headers
::EM.next_tick { @body.succeed }
end
-
+
end
end
diff --git a/vendor/gems/message_bus/lib/message_bus/reliable_pub_sub.rb b/vendor/gems/message_bus/lib/message_bus/reliable_pub_sub.rb
index 5f4b715d1..a92e22c62 100644
--- a/vendor/gems/message_bus/lib/message_bus/reliable_pub_sub.rb
+++ b/vendor/gems/message_bus/lib/message_bus/reliable_pub_sub.rb
@@ -1,17 +1,17 @@
require 'redis'
-# the heart of the message bus, it acts as 2 things
+# the heart of the message bus, it acts as 2 things
#
# 1. A channel multiplexer
-# 2. Backlog storage per-multiplexed channel.
+# 2. Backlog storage per-multiplexed channel.
#
-# ids are all sequencially increasing numbers starting at 0
+# ids are all sequencially increasing numbers starting at 0
#
class MessageBus::ReliablePubSub
class NoMoreRetries < StandardError; end
- class BackLogOutOfOrder < StandardError
+ class BackLogOutOfOrder < StandardError
attr_accessor :highest_id
def initialize(highest_id)
@@ -26,7 +26,7 @@ class MessageBus::ReliablePubSub
def max_publish_retries
@max_publish_retries ||= 10
end
-
+
def max_publish_wait=(ms)
@max_publish_wait = ms
end
@@ -35,11 +35,11 @@ class MessageBus::ReliablePubSub
@max_publish_wait ||= 500
end
- # max_backlog_size is per multiplexed channel
+ # max_backlog_size is per multiplexed channel
def initialize(redis_config = {}, max_backlog_size = 1000)
@redis_config = redis_config
@max_backlog_size = 1000
- # we can store a ton here ...
+ # we can store a ton here ...
@max_global_backlog_size = 100000
end
@@ -47,7 +47,7 @@ class MessageBus::ReliablePubSub
def max_global_backlog_size=(val)
@max_global_backlog_size = val
end
-
+
# per channel backlog size
def max_backlog_size=(val)
@max_backlog_size = val
@@ -62,7 +62,7 @@ class MessageBus::ReliablePubSub
"discourse_#{db}"
end
- # redis connection used for publishing messages
+ # redis connection used for publishing messages
def pub_redis
@pub_redis ||= new_redis_connection
end
@@ -84,14 +84,14 @@ class MessageBus::ReliablePubSub
end
# use with extreme care, will nuke all of the data
- def reset!
+ def reset!
pub_redis.keys("__mb_*").each do |k|
pub_redis.del k
end
end
def publish(channel, data)
- redis = pub_redis
+ redis = pub_redis
backlog_id_key = backlog_id_key(channel)
backlog_key = backlog_key(channel)
@@ -126,13 +126,13 @@ class MessageBus::ReliablePubSub
end
def last_id(channel)
- redis = pub_redis
+ redis = pub_redis
backlog_id_key = backlog_id_key(channel)
redis.get(backlog_id_key).to_i
end
def backlog(channel, last_id = nil)
- redis = pub_redis
+ redis = pub_redis
backlog_key = backlog_key(channel)
items = redis.zrangebyscore backlog_key, last_id.to_i + 1, "+inf"
@@ -150,7 +150,7 @@ class MessageBus::ReliablePubSub
items.map! do |i|
pipe = i.index "|"
message_id = i[0..pipe].to_i
- channel = i[pipe+1..-1]
+ channel = i[pipe+1..-1]
m = get_message(channel, message_id)
m
end
@@ -160,11 +160,11 @@ class MessageBus::ReliablePubSub
end
def get_message(channel, message_id)
- redis = pub_redis
+ redis = pub_redis
backlog_key = backlog_key(channel)
items = redis.zrangebyscore backlog_key, message_id, message_id
- if items && items[0]
+ if items && items[0]
MessageBus::Message.decode(items[0])
else
nil
@@ -172,8 +172,8 @@ class MessageBus::ReliablePubSub
end
def subscribe(channel, last_id = nil)
- # trivial implementation for now,
- # can cut down on connections if we only have one global subscriber
+ # trivial implementation for now,
+ # can cut down on connections if we only have one global subscriber
raise ArgumentError unless block_given?
if last_id
@@ -212,7 +212,7 @@ class MessageBus::ReliablePubSub
clear_backlog = lambda do
retries = 4
- begin
+ begin
highest_id = process_global_backlog(highest_id, retries > 0, &blk)
rescue BackLogOutOfOrder => e
highest_id = e.highest_id
@@ -231,7 +231,7 @@ class MessageBus::ReliablePubSub
end
redis.subscribe(redis_channel_name) do |on|
- on.subscribe do
+ on.subscribe do
if highest_id
clear_backlog.call(&blk)
end
@@ -242,12 +242,12 @@ class MessageBus::ReliablePubSub
# we have 2 options
#
# 1. message came in the correct order GREAT, just deal with it
- # 2. message came in the incorrect order COMPLICATED, wait a tiny bit and clear backlog
-
+ # 2. message came in the incorrect order COMPLICATED, wait a tiny bit and clear backlog
+
if highest_id.nil? || m.global_id == highest_id + 1
- highest_id = m.global_id
+ highest_id = m.global_id
yield m
- else
+ else
clear_backlog.call(&blk)
end
end
diff --git a/vendor/gems/message_bus/spec/lib/client_spec.rb b/vendor/gems/message_bus/spec/lib/client_spec.rb
index 448146d28..fdb8be924 100644
--- a/vendor/gems/message_bus/spec/lib/client_spec.rb
+++ b/vendor/gems/message_bus/spec/lib/client_spec.rb
@@ -1,23 +1,23 @@
require 'spec_helper'
require 'message_bus'
-describe MessageBus::Client do
-
+describe MessageBus::Client do
+
describe "subscriptions" do
-
+
before do
@client = MessageBus::Client.new :client_id => 'abc'
end
- it "should provide a list of subscriptions" do
+ it "should provide a list of subscriptions" do
@client.subscribe('/hello', nil)
- @client.subscriptions['/hello'].should_not be_nil
+ @client.subscriptions['/hello'].should_not be_nil
end
- it "should provide backlog for subscribed channel" do
+ it "should provide backlog for subscribed channel" do
@client.subscribe('/hello', nil)
MessageBus.publish '/hello', 'world'
- log = @client.backlog
+ log = @client.backlog
log.length.should == 1
log[0].channel.should == '/hello'
log[0].data.should == 'world'
diff --git a/vendor/gems/message_bus/spec/lib/connection_manager_spec.rb b/vendor/gems/message_bus/spec/lib/connection_manager_spec.rb
index 27c74ee26..8d1c89835 100644
--- a/vendor/gems/message_bus/spec/lib/connection_manager_spec.rb
+++ b/vendor/gems/message_bus/spec/lib/connection_manager_spec.rb
@@ -2,7 +2,7 @@ require 'spec_helper'
require 'message_bus'
class FakeAsync
-
+
attr_accessor :cleanup_timer
def <<(val)
@@ -20,58 +20,58 @@ class FakeTimer
def cancel; @cancelled = true; end
end
-describe MessageBus::ConnectionManager do
+describe MessageBus::ConnectionManager do
- before do
+ before do
@manager = MessageBus::ConnectionManager.new
@client = MessageBus::Client.new(client_id: "xyz", user_id: 1, site_id: 10)
@resp = FakeAsync.new
@client.async_response = @resp
@client.subscribe('test', -1)
- @manager.add_client(@client)
+ @manager.add_client(@client)
@client.cleanup_timer = FakeTimer.new
end
- it "should cancel the timer after its responds" do
+ it "should cancel the timer after its responds" do
m = MessageBus::Message.new(1,1,"test","data")
m.site_id = 10
@manager.notify_clients(m)
@client.cleanup_timer.cancelled.should == true
end
- it "should be able to lookup an identical client" do
+ it "should be able to lookup an identical client" do
@manager.lookup_client(@client.client_id).should == @client
end
- it "should be subscribed to a channel" do
+ it "should be subscribed to a channel" do
@manager.stats[:subscriptions][10]["test"].length == 1
end
- it "should not notify clients on incorrect site" do
+ it "should not notify clients on incorrect site" do
m = MessageBus::Message.new(1,1,"test","data")
m.site_id = 9
@manager.notify_clients(m)
@resp.sent.should == nil
end
- it "should notify clients on the correct site" do
+ it "should notify clients on the correct site" do
m = MessageBus::Message.new(1,1,"test","data")
m.site_id = 10
@manager.notify_clients(m)
@resp.sent.should_not == nil
end
- it "should strip site id and user id from the payload delivered" do
+ it "should strip site id and user id from the payload delivered" do
m = MessageBus::Message.new(1,1,"test","data")
m.user_ids = [1]
m.site_id = 10
@manager.notify_clients(m)
- parsed = JSON.parse(@resp.sent)
+ parsed = JSON.parse(@resp.sent)
parsed[0]["site_id"].should == nil
parsed[0]["user_id"].should == nil
end
- it "should not deliver unselected" do
+ it "should not deliver unselected" do
m = MessageBus::Message.new(1,1,"test","data")
m.user_ids = [5]
m.site_id = 10
diff --git a/vendor/gems/message_bus/spec/lib/message_bus_spec.rb b/vendor/gems/message_bus/spec/lib/message_bus_spec.rb
index de33fddb3..5729e77ab 100644
--- a/vendor/gems/message_bus/spec/lib/message_bus_spec.rb
+++ b/vendor/gems/message_bus/spec/lib/message_bus_spec.rb
@@ -5,17 +5,17 @@ require 'redis'
describe MessageBus do
- before do
- MessageBus.site_id_lookup do
+ before do
+ MessageBus.site_id_lookup do
"magic"
end
MessageBus.redis_config = {}
end
- it "should automatically decode hashed messages" do
+ it "should automatically decode hashed messages" do
data = nil
- MessageBus.subscribe("/chuck") do |msg|
- data = msg.data
+ MessageBus.subscribe("/chuck") do |msg|
+ data = msg.data
end
MessageBus.publish("/chuck", {:norris => true})
wait_for(1000){ data }
@@ -23,10 +23,10 @@ describe MessageBus do
data["norris"].should == true
end
- it "should get a message if it subscribes to it" do
+ it "should get a message if it subscribes to it" do
@data,@site_id,@channel = nil
-
- MessageBus.subscribe("/chuck") do |msg|
+
+ MessageBus.subscribe("/chuck") do |msg|
@data = msg.data
@site_id = msg.site_id
@channel = msg.channel
@@ -36,7 +36,7 @@ describe MessageBus do
MessageBus.publish("/chuck", "norris", user_ids: [1,2,3])
wait_for(1000){@data}
-
+
@data.should == 'norris'
@site_id.should == 'magic'
@channel.should == '/chuck'
@@ -45,10 +45,10 @@ describe MessageBus do
end
- it "should get global messages if it subscribes to them" do
+ it "should get global messages if it subscribes to them" do
@data,@site_id,@channel = nil
-
- MessageBus.subscribe do |msg|
+
+ MessageBus.subscribe do |msg|
@data = msg.data
@site_id = msg.site_id
@channel = msg.channel
@@ -57,7 +57,7 @@ describe MessageBus do
MessageBus.publish("/chuck", "norris")
wait_for(1000){@data}
-
+
@data.should == 'norris'
@site_id.should == 'magic'
@channel.should == '/chuck'
diff --git a/vendor/gems/message_bus/spec/lib/message_handler_spec.rb b/vendor/gems/message_bus/spec/lib/message_handler_spec.rb
index 740710224..dc3e52842 100644
--- a/vendor/gems/message_bus/spec/lib/message_handler_spec.rb
+++ b/vendor/gems/message_bus/spec/lib/message_handler_spec.rb
@@ -3,14 +3,14 @@ require 'message_bus'
describe MessageBus::MessageHandler do
- it "should properly register message handlers" do
+ it "should properly register message handlers" do
MessageBus::MessageHandler.handle "/hello" do |m|
m
end
MessageBus::MessageHandler.call("site","/hello", "world", 1).should == "world"
end
- it "should correctly load message handlers" do
+ it "should correctly load message handlers" do
MessageBus::MessageHandler.load_handlers("#{File.dirname(__FILE__)}/handlers")
MessageBus::MessageHandler.call("site","/dupe", "1", 1).should == "11"
end
@@ -19,7 +19,7 @@ describe MessageBus::MessageHandler do
MessageBus::MessageHandler.handle "/channel" do |m|
m
end
-
+
connected = false
disconnected = false
@@ -31,9 +31,9 @@ describe MessageBus::MessageHandler do
end
MessageBus::MessageHandler.call("site_id", "/channel", "data", 1)
-
+
connected.should == true
disconnected.should == true
-
+
end
end
diff --git a/vendor/gems/message_bus/spec/lib/middleware_spec.rb b/vendor/gems/message_bus/spec/lib/middleware_spec.rb
index 7e1422843..d5fd89ce8 100644
--- a/vendor/gems/message_bus/spec/lib/middleware_spec.rb
+++ b/vendor/gems/message_bus/spec/lib/middleware_spec.rb
@@ -7,7 +7,7 @@ describe MessageBus::Rack::Middleware do
class FakeAsyncMiddleware
- def self.in_async?
+ def self.in_async?
@@in_async if defined? @@in_async
end
@@ -20,7 +20,7 @@ describe MessageBus::Rack::Middleware do
EM.run {
env['async.callback'] = lambda { |r|
# more judo with deferrable body, at this point we just have headers
- r[2].callback do
+ r[2].callback do
# even more judo cause rack test does not call each like the spec says
body = ""
r[2].each do |m|
@@ -35,7 +35,7 @@ describe MessageBus::Rack::Middleware do
}
EM::Timer.new(1) { EM.stop }
-
+
defer = lambda {
if !result
@@in_async = true
@@ -63,7 +63,7 @@ describe MessageBus::Rack::Middleware do
end
describe "long polling" do
- before do
+ before do
MessageBus.sockets_enabled = false
MessageBus.long_polling_enabled = true
end
@@ -83,7 +83,7 @@ describe MessageBus::Rack::Middleware do
parsed[0]["data"]["/foo"].should == MessageBus.last_id("/foo")
end
- it "should respond to long polls when data is available" do
+ it "should respond to long polls when data is available" do
Thread.new do
wait_for(2000) { FakeAsyncMiddleware.in_async? }
@@ -98,7 +98,7 @@ describe MessageBus::Rack::Middleware do
parsed[0]["data"].should == "bar"
end
- it "should timeout within its alloted slot" do
+ it "should timeout within its alloted slot" do
begin
MessageBus.long_polling_interval = 10
s = Time.now.to_f * 1000
@@ -110,9 +110,9 @@ describe MessageBus::Rack::Middleware do
end
end
- describe "diagnostics" do
+ describe "diagnostics" do
- it "should return a 403 if a user attempts to get at the _diagnostics path" do
+ it "should return a 403 if a user attempts to get at the _diagnostics path" do
get "/message-bus/_diagnostics"
last_response.status.should == 403
end
@@ -131,9 +131,9 @@ describe MessageBus::Rack::Middleware do
end
end
-
+
describe "polling" do
- before do
+ before do
MessageBus.sockets_enabled = false
MessageBus.long_polling_enabled = false
end
@@ -149,8 +149,8 @@ describe MessageBus::Rack::Middleware do
last_response.should be_ok
end
- it "should correctly understand that -1 means stuff from now onwards" do
-
+ it "should correctly understand that -1 means stuff from now onwards" do
+
MessageBus.publish('foo', 'bar')
post "/message-bus/ABCD", {
@@ -164,7 +164,7 @@ describe MessageBus::Rack::Middleware do
end
- it "should respond with the data if messages exist in the backlog" do
+ it "should respond with the data if messages exist in the backlog" do
id = MessageBus.last_id('/foo')
MessageBus.publish("/foo", "barbs")
@@ -182,10 +182,10 @@ describe MessageBus::Rack::Middleware do
parsed[1]["data"].should == "borbs"
end
- it "should not get consumed messages" do
+ it "should not get consumed messages" do
MessageBus.publish("/foo", "barbs")
id = MessageBus.last_id('/foo')
-
+
client_id = "ABCD"
post "/message-bus/#{client_id}", {
'/foo' => id
diff --git a/vendor/gems/message_bus/spec/lib/multi_process_spec.rb b/vendor/gems/message_bus/spec/lib/multi_process_spec.rb
index 89cdef42e..db6a5fde2 100644
--- a/vendor/gems/message_bus/spec/lib/multi_process_spec.rb
+++ b/vendor/gems/message_bus/spec/lib/multi_process_spec.rb
@@ -28,12 +28,12 @@ describe MessageBus::ReliablePubSub do
end
end
- it 'gets every response from child processes' do
+ it 'gets every response from child processes' do
pid = nil
Redis.new(:db => 10).flushall
begin
- pids = (1..10).map{spawn_child}
- responses = []
+ pids = (1..10).map{spawn_child}
+ responses = []
bus = MessageBus::ReliablePubSub.new(:db => 10)
Thread.new do
bus.subscribe("/response", 0) do |msg|
@@ -41,7 +41,7 @@ describe MessageBus::ReliablePubSub do
end
end
10.times{bus.publish("/echo", Process.pid.to_s)}
- wait_for 4000 do
+ wait_for 4000 do
responses.count == 100
end
@@ -50,7 +50,7 @@ describe MessageBus::ReliablePubSub do
responses.count.should == 100
ensure
if pids
- pids.each do |pid|
+ pids.each do |pid|
Process.kill("HUP", pid)
Process.wait(pid)
end
diff --git a/vendor/gems/message_bus/spec/lib/reliable_pub_sub_spec.rb b/vendor/gems/message_bus/spec/lib/reliable_pub_sub_spec.rb
index 5b7fbf6d7..8fd3ed2ed 100644
--- a/vendor/gems/message_bus/spec/lib/reliable_pub_sub_spec.rb
+++ b/vendor/gems/message_bus/spec/lib/reliable_pub_sub_spec.rb
@@ -7,22 +7,22 @@ describe MessageBus::ReliablePubSub do
MessageBus::ReliablePubSub.new(:db => 10)
end
- before do
+ before do
@bus = new_test_bus
@bus.reset!
end
- it "should be able to access the backlog" do
+ it "should be able to access the backlog" do
@bus.publish "/foo", "bar"
@bus.publish "/foo", "baz"
- @bus.backlog("/foo", 0).to_a.should == [
+ @bus.backlog("/foo", 0).to_a.should == [
MessageBus::Message.new(1,1,'/foo','bar'),
MessageBus::Message.new(2,2,'/foo','baz')
]
end
- it "should truncate channels correctly" do
+ it "should truncate channels correctly" do
@bus.max_backlog_size = 2
4.times do |t|
@bus.publish "/foo", t.to_s
@@ -34,18 +34,18 @@ describe MessageBus::ReliablePubSub do
]
end
- it "should be able to grab a message by id" do
+ it "should be able to grab a message by id" do
id1 = @bus.publish "/foo", "bar"
id2 = @bus.publish "/foo", "baz"
@bus.get_message("/foo", id2).should == MessageBus::Message.new(2, 2, "/foo", "baz")
@bus.get_message("/foo", id1).should == MessageBus::Message.new(1, 1, "/foo", "bar")
end
- it "should be able to access the global backlog" do
+ it "should be able to access the global backlog" do
@bus.publish "/foo", "bar"
- @bus.publish "/hello", "world"
+ @bus.publish "/hello", "world"
@bus.publish "/foo", "baz"
- @bus.publish "/hello", "planet"
+ @bus.publish "/hello", "planet"
@bus.global_backlog.to_a.should == [
MessageBus::Message.new(1, 1, "/foo", "bar"),
@@ -55,7 +55,7 @@ describe MessageBus::ReliablePubSub do
]
end
- it "should correctly omit dropped messages from the global backlog" do
+ it "should correctly omit dropped messages from the global backlog" do
@bus.max_backlog_size = 1
@bus.publish "/foo", "a"
@bus.publish "/foo", "b"
@@ -68,12 +68,12 @@ describe MessageBus::ReliablePubSub do
]
end
- it "should have the correct number of messages for multi threaded access" do
+ it "should have the correct number of messages for multi threaded access" do
threads = []
- 4.times do
- threads << Thread.new do
- bus = new_test_bus
- 25.times {
+ 4.times do
+ threads << Thread.new do
+ bus = new_test_bus
+ 25.times {
bus.publish "/foo", "."
}
end
@@ -86,14 +86,14 @@ describe MessageBus::ReliablePubSub do
it "should be able to subscribe globally with recovery" do
@bus.publish("/foo", "1")
@bus.publish("/bar", "2")
- got = []
+ got = []
- t = Thread.new do
- new_test_bus.global_subscribe(0) do |msg|
+ t = Thread.new do
+ new_test_bus.global_subscribe(0) do |msg|
got << msg
end
end
-
+
@bus.publish("/bar", "3")
wait_for(100) do
@@ -101,29 +101,29 @@ describe MessageBus::ReliablePubSub do
end
t.kill
-
+
got.length.should == 3
got.map{|m| m.data}.should == ["1","2","3"]
end
- it "should be able to encode and decode messages properly" do
+ it "should be able to encode and decode messages properly" do
m = MessageBus::Message.new 1,2,'||','||'
MessageBus::Message.decode(m.encode).should == m
end
- it "should handle subscribe on single channel, with recovery" do
+ it "should handle subscribe on single channel, with recovery" do
@bus.publish("/foo", "1")
@bus.publish("/bar", "2")
- got = []
+ got = []
- t = Thread.new do
- new_test_bus.subscribe("/foo",0) do |msg|
+ t = Thread.new do
+ new_test_bus.subscribe("/foo",0) do |msg|
got << msg
end
end
-
+
@bus.publish("/foo", "3")
-
+
wait_for(100) do
got.length == 2
end
@@ -133,22 +133,22 @@ describe MessageBus::ReliablePubSub do
got.map{|m| m.data}.should == ["1","3"]
end
- it "should not get backlog if subscribe is called without params" do
+ it "should not get backlog if subscribe is called without params" do
@bus.publish("/foo", "1")
- got = []
+ got = []
- t = Thread.new do
- new_test_bus.subscribe("/foo") do |msg|
+ t = Thread.new do
+ new_test_bus.subscribe("/foo") do |msg|
got << msg
end
end
- # sleep 50ms to allow the bus to correctly subscribe,
+ # sleep 50ms to allow the bus to correctly subscribe,
# I thought about adding a subscribed callback, but outside of testing it matters less
sleep 0.05
@bus.publish("/foo", "2")
-
+
wait_for(100) do
got.length == 1
end
@@ -158,7 +158,7 @@ describe MessageBus::ReliablePubSub do
got.map{|m| m.data}.should == ["2"]
end
- it "should allow us to get last id on a channel" do
+ it "should allow us to get last id on a channel" do
@bus.last_id("/foo").should == 0
@bus.publish("/foo", "1")
@bus.last_id("/foo").should == 1
diff --git a/vendor/gems/rails_multisite/Rakefile b/vendor/gems/rails_multisite/Rakefile
index ecd0cbf92..56bb7292a 100644
--- a/vendor/gems/rails_multisite/Rakefile
+++ b/vendor/gems/rails_multisite/Rakefile
@@ -1,6 +1,6 @@
#!/usr/bin/env rake
require "bundler/gem_tasks"
-require "rspec/core/rake_task"
+require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:test) do |spec|
spec.pattern = 'spec/*_spec.rb'
diff --git a/vendor/gems/rails_multisite/lib/rails_multisite/connection_management.rb b/vendor/gems/rails_multisite/lib/rails_multisite/connection_management.rb
index 41a1452c1..218073d90 100644
--- a/vendor/gems/rails_multisite/lib/rails_multisite/connection_management.rb
+++ b/vendor/gems/rails_multisite/lib/rails_multisite/connection_management.rb
@@ -14,7 +14,7 @@ module RailsMultisite
handler = ActiveRecord::ConnectionAdapters::ConnectionHandler.new
@@connection_handlers[spec] = handler
end
- else
+ else
handler = @@default_connection_handler
end
ActiveRecord::Base.connection_handler = handler
@@ -30,25 +30,25 @@ module RailsMultisite
yield db
ActiveRecord::Base.connection_handler.clear_active_connections!
end
- establish_connection(:db => old)
+ establish_connection(:db => old)
ActiveRecord::Base.connection_handler.clear_active_connections! unless connected
end
def self.all_dbs
- ["default"] +
+ ["default"] +
if defined?(@@db_spec_cache) && @@db_spec_cache
@@db_spec_cache.keys.to_a
- else
+ else
[]
end
end
def self.current_db
- db = ActiveRecord::Base.connection_pool.spec.config[:db_key] || "default"
+ db = ActiveRecord::Base.connection_pool.spec.config[:db_key] || "default"
end
def self.config_filename=(config_filename)
- @@config_filename = config_filename
+ @@config_filename = config_filename
end
def self.config_filename
@@ -90,8 +90,8 @@ module RailsMultisite
@@host_spec_cache[host] = @@default_spec
end
- # inject our connection_handler pool
- # WARNING MONKEY PATCH
+ # inject our connection_handler pool
+ # WARNING MONKEY PATCH
#
# see: https://github.com/rails/rails/issues/8344#issuecomment-10800848
#
@@ -103,7 +103,7 @@ module RailsMultisite
module NewConnectionHandler
def self.included(klass)
- klass.class_eval do
+ klass.class_eval do
define_singleton_method :connection_handler do
Thread.current[:connection_handler] || @connection_handler
end
@@ -122,7 +122,7 @@ module RailsMultisite
def call(env)
request = Rack::Request.new(env)
- begin
+ begin
#TODO: add a callback so users can simply go to a domain to register it, or something
return [404, {}, ["not found"]] unless @@host_spec_cache[request.host]
@@ -139,9 +139,9 @@ module RailsMultisite
if opts[:host]
@@host_spec_cache[opts[:host]]
else
- @@db_spec_cache[opts[:db]]
+ @@db_spec_cache[opts[:db]]
end
end
-
+
end
end
diff --git a/vendor/gems/rails_multisite/lib/rails_multisite/railtie.rb b/vendor/gems/rails_multisite/lib/rails_multisite/railtie.rb
index 6594a4fad..ad95ba2ae 100644
--- a/vendor/gems/rails_multisite/lib/rails_multisite/railtie.rb
+++ b/vendor/gems/rails_multisite/lib/rails_multisite/railtie.rb
@@ -16,6 +16,6 @@ module RailsMultisite
end
- end
+ end
end
diff --git a/vendor/gems/rails_multisite/lib/tasks/generators.rake b/vendor/gems/rails_multisite/lib/tasks/generators.rake
index 95e901623..2e019185d 100644
--- a/vendor/gems/rails_multisite/lib/tasks/generators.rake
+++ b/vendor/gems/rails_multisite/lib/tasks/generators.rake
@@ -4,17 +4,17 @@ task "multisite:generate:config" => :environment do
if File.exists?(filename)
puts "Config is already generated at #{RailsMultisite::ConnectionManagement::CONFIG_FILE}"
- else
+ else
puts "Generated config file at #{RailsMultisite::ConnectionManagement::CONFIG_FILE}"
- File.open(filename, 'w') do |f|
+ File.open(filename, 'w') do |f|
f.write <<-CONFIG
-# site_name:
+# site_name:
# adapter: postgresql
# database: db_name
# host: localhost
# pool: 5
# timeout: 5000
-# db_id: 1 # optionally include other settings you need
+# db_id: 1 # optionally include other settings you need
# host_names:
# - www.mysite.com
# - www.anothersite.com
diff --git a/vendor/gems/rails_multisite/spec/connection_management_rack_spec.rb b/vendor/gems/rails_multisite/spec/connection_management_rack_spec.rb
index 8931c7ac6..f683a3d47 100644
--- a/vendor/gems/rails_multisite/spec/connection_management_rack_spec.rb
+++ b/vendor/gems/rails_multisite/spec/connection_management_rack_spec.rb
@@ -6,7 +6,7 @@ describe RailsMultisite::ConnectionManagement do
include Rack::Test::Methods
def app
-
+
RailsMultisite::ConnectionManagement.config_filename = 'spec/fixtures/two_dbs.yml'
RailsMultisite::ConnectionManagement.load_settings!
@@ -18,7 +18,7 @@ describe RailsMultisite::ConnectionManagement do
}.to_app
end
- after do
+ after do
RailsMultisite::ConnectionManagement.clear_settings!
end
@@ -31,12 +31,12 @@ describe RailsMultisite::ConnectionManagement do
get 'http://second.localhost/html'
last_response.should be_ok
end
-
+
it 'returns 200 for valid main site' do
get 'http://default.localhost/html'
last_response.should be_ok
end
-
+
it 'returns 404 for invalid site' do
get '/html'
last_response.should be_not_found
diff --git a/vendor/gems/rails_multisite/spec/connection_management_spec.rb b/vendor/gems/rails_multisite/spec/connection_management_spec.rb
index 690dffcf5..aca9e2c4b 100644
--- a/vendor/gems/rails_multisite/spec/connection_management_spec.rb
+++ b/vendor/gems/rails_multisite/spec/connection_management_spec.rb
@@ -24,7 +24,7 @@ describe RailsMultisite::ConnectionManagement do
before do
subject.config_filename = "spec/fixtures/two_dbs.yml"
subject.load_settings!
- end
+ end
its(:all_dbs) { should == ['default', 'second']}
context 'second db' do
diff --git a/vendor/gems/rails_multisite/spec/fixtures/two_dbs.yml b/vendor/gems/rails_multisite/spec/fixtures/two_dbs.yml
index ab1049b96..ca9cf0a45 100644
--- a/vendor/gems/rails_multisite/spec/fixtures/two_dbs.yml
+++ b/vendor/gems/rails_multisite/spec/fixtures/two_dbs.yml
@@ -1,9 +1,9 @@
-second:
+second:
adapter: sqlite3
database: second_db
username: username
password: password
- db_id: 1
+ db_id: 1
host_names:
- second.localhost
- - 2nd.localhost
\ No newline at end of file
+ - 2nd.localhost
diff --git a/vendor/gems/rails_multisite/spec/spec_helper.rb b/vendor/gems/rails_multisite/spec/spec_helper.rb
index 19b054548..51b8e0bd7 100644
--- a/vendor/gems/rails_multisite/spec/spec_helper.rb
+++ b/vendor/gems/rails_multisite/spec/spec_helper.rb
@@ -7,7 +7,7 @@ ENV["RAILS_ENV"] ||= 'test'
RSpec.configure do |config|
config.color_enabled = true
-
+
config.before(:suite) do
ActiveRecord::Base.configurations['test'] = (YAML::load(File.open("spec/fixtures/database.yml"))['test'])
end