Merge pull request #1709 from chancancode/boot_to_master

Make Discourse work on Rails master (4.1)
This commit is contained in:
Sam 2013-12-30 15:52:29 -08:00
commit 530b67aabd
5 changed files with 526 additions and 5 deletions

17
Gemfile
View file

@ -14,10 +14,16 @@ module ::Kernel
def rails4?
!ENV["RAILS3"]
end
def rails_master?
rails4? && ENV["RAILS_MASTER"]
end
end
if rails4?
Bundler::SharedHelpers.default_lockfile = Pathname.new("#{Bundler::SharedHelpers.default_gemfile}_rails4.lock")
rails_version = rails_master? ? 'rails_master' : 'rails4'
Bundler::SharedHelpers.default_lockfile = Pathname.new("#{Bundler::SharedHelpers.default_gemfile}_#{rails_version}.lock")
# Bundler::Dsl.evaluate already called with an incorrect lockfile ... fix it
class Bundler::Dsl
@ -39,9 +45,14 @@ end
gem 'seed-fu-discourse', require: 'seed-fu'
if rails4?
gem 'rails'
if rails_master?
gem 'rails', git: 'https://github.com/rails/rails.git'
gem 'actionpack-action_caching', git: 'https://github.com/rails/actionpack-action_caching.git'
else
gem 'rails'
gem 'actionpack-action_caching'
end
gem 'rails-observers'
gem 'actionpack-action_caching'
else
# we had pain with the 3.2.13 upgrade so monkey patch the security fix
# next time around we hope to upgrade

501
Gemfile_rails_master.lock Normal file
View file

@ -0,0 +1,501 @@
GIT
remote: https://github.com/rails/actionpack-action_caching.git
revision: a45e97298f6a77a4d74662521715d5656b821f24
specs:
actionpack-action_caching (1.1.0)
actionpack (>= 4.0.0, < 5.0)
GIT
remote: https://github.com/rails/rails.git
revision: 4aae538d9ffff3a00a81f3da52fa70f7fd79ac74
specs:
actionmailer (4.1.0.beta)
actionpack (= 4.1.0.beta)
actionview (= 4.1.0.beta)
mail (~> 2.5.4)
actionpack (4.1.0.beta)
actionview (= 4.1.0.beta)
activesupport (= 4.1.0.beta)
rack (~> 1.5.2)
rack-test (~> 0.6.2)
actionview (4.1.0.beta)
activesupport (= 4.1.0.beta)
builder (~> 3.1.0)
erubis (~> 2.7.0)
activemodel (4.1.0.beta)
activesupport (= 4.1.0.beta)
builder (~> 3.1.0)
activerecord (4.1.0.beta)
activemodel (= 4.1.0.beta)
activesupport (= 4.1.0.beta)
arel (~> 5.0.0)
activesupport (4.1.0.beta)
i18n (~> 0.6, >= 0.6.4)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.1)
tzinfo (~> 1.1)
rails (4.1.0.beta)
actionmailer (= 4.1.0.beta)
actionpack (= 4.1.0.beta)
actionview (= 4.1.0.beta)
activemodel (= 4.1.0.beta)
activerecord (= 4.1.0.beta)
activesupport (= 4.1.0.beta)
bundler (>= 1.3.0, < 2.0)
railties (= 4.1.0.beta)
sprockets-rails (~> 2.0.0)
railties (4.1.0.beta)
actionpack (= 4.1.0.beta)
activesupport (= 4.1.0.beta)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
PATH
remote: vendor/gems/discourse_plugin
specs:
discourse_plugin (0.0.1)
PATH
remote: vendor/gems/rails_multisite
specs:
rails_multisite (0.0.1)
GEM
remote: https://rubygems.org/
specs:
active_model_serializers (0.8.1)
activemodel (>= 3.0)
addressable (2.3.5)
airbrake (3.1.2)
activesupport
builder
annotate (2.6.0)
activerecord (>= 2.3.0)
rake (>= 0.8.7)
arel (5.0.0)
atomic (1.1.14)
barber (0.4.2)
ember-source
execjs
handlebars-source
better_errors (1.0.1)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
builder (3.1.4)
celluloid (0.15.2)
timers (~> 1.1.0)
certified (0.1.1)
coderay (1.1.0)
connection_pool (1.2.0)
daemons (1.1.9)
debug_inspector (0.0.2)
diff-lcs (1.2.4)
email_reply_parser-discourse (0.6)
ember-data-source (0.14)
ember-source
ember-rails (0.14.1)
active_model_serializers
barber (>= 0.4.1)
ember-data-source
ember-source
execjs (>= 1.2)
handlebars-source
jquery-rails (>= 1.0.17)
railties (>= 3.1)
ember-source (1.2.0.1)
handlebars-source (~> 1.1.2)
erubis (2.7.0)
eventmachine (1.0.3)
excon (0.28.0)
execjs (2.0.2)
exifr (1.1.3)
fabrication (2.8.1)
fakeweb (1.3.0)
faraday (0.8.8)
multipart-post (~> 1.2.0)
fast_blank (0.0.1)
rake
rake-compiler
fast_stack (0.1.0)
rake
rake-compiler
fast_xor (1.1.2)
rake
rake-compiler
fast_xs (0.8.0)
fastimage (1.5.2)
ffi (1.9.3)
flamegraph (0.0.5)
fast_stack
fog (1.18.0)
builder
excon (~> 0.28.0)
formatador (~> 0.2.0)
mime-types
multi_json (~> 1.0)
net-scp (~> 1.1)
net-ssh (>= 2.1.3)
nokogiri (~> 1.5)
ruby-hmac
formatador (0.2.4)
fspath (2.0.5)
given_core (3.1.1)
sorcerer (>= 0.3.7)
handlebars-source (1.1.2)
hashie (2.0.5)
highline (1.6.20)
hike (1.2.3)
hiredis (0.4.5)
html_truncator (0.3.1)
nokogiri (~> 1.5)
httpauth (0.2.0)
i18n (0.6.9)
ice_cube (0.11.1)
image_optim (0.9.1)
exifr (~> 1.1.3)
fspath (~> 2.0.5)
image_size (~> 1.1.2)
in_threads (~> 1.2.0)
progress (~> 3.0.0)
image_size (1.1.3)
image_sorcery (1.1.0)
in_threads (1.2.0)
jquery-rails (3.0.4)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
json (1.8.1)
jwt (0.1.8)
multi_json (>= 1.5)
kgio (2.8.1)
librarian (0.1.1)
highline
thor (~> 0.15)
libv8 (3.16.14.3)
listen (0.7.3)
lru_redux (0.8.1)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
message_bus (0.9.3.2)
eventmachine
rack (>= 1.1.3)
redis
metaclass (0.0.1)
method_source (0.8.2)
mime-types (1.25.1)
mini_portile (0.5.1)
minitest (5.1.0)
mocha (0.14.0)
metaclass (~> 0.0.1)
mock_redis (0.9.0)
msgpack (0.5.7)
multi_json (1.8.2)
multipart-post (1.2.0)
mustache (0.99.4)
net-scp (1.1.2)
net-ssh (>= 2.6.5)
net-ssh (2.7.0)
nokogiri (1.6.0)
mini_portile (~> 0.5.0)
oauth (0.4.7)
oauth2 (0.8.1)
faraday (~> 0.8)
httpauth (~> 0.1)
jwt (~> 0.1.4)
multi_json (~> 1.0)
rack (~> 1.2)
oj (2.2.3)
omniauth (1.1.4)
hashie (>= 1.2, < 3)
rack
omniauth-browserid-discourse (0.0.2)
faraday
multi_json
omniauth (~> 1.0)
omniauth-cas (1.0.4)
addressable (~> 2.3)
nokogiri (~> 1.6)
omniauth (~> 1.1.0)
omniauth-facebook (1.4.1)
omniauth-oauth2 (~> 1.1.0)
omniauth-github (1.1.1)
omniauth (~> 1.0)
omniauth-oauth2 (~> 1.1)
omniauth-oauth (1.0.1)
oauth
omniauth (~> 1.0)
omniauth-oauth2 (1.1.1)
oauth2 (~> 0.8.0)
omniauth (~> 1.0)
omniauth-openid (1.0.1)
omniauth (~> 1.0)
rack-openid (~> 1.3.1)
omniauth-twitter (1.0.1)
multi_json (~> 1.3)
omniauth-oauth (~> 1.0)
openid-redis-store (0.0.2)
redis
ruby-openid
pg (0.15.1)
polyglot (0.3.3)
progress (3.0.0)
pry (0.9.12.4)
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
pry-nav (0.2.3)
pry (~> 0.9.10)
pry-rails (0.3.2)
pry (>= 0.9.10)
puma (2.6.0)
rack (>= 1.1, < 2.0)
qunit-rails (0.0.4)
railties (>= 3.2.3)
rack (1.5.2)
rack-cors (0.2.8)
rack
rack-mini-profiler (0.9.0.pre)
rack (>= 1.1.3)
rack-openid (1.3.1)
rack (>= 1.1.0)
ruby-openid (>= 2.1.8)
rack-protection (1.5.1)
rack
rack-test (0.6.2)
rack (>= 1.0)
rails-observers (0.1.2)
activemodel (~> 4.0)
raindrops (0.12.0)
rake (10.1.0)
rake-compiler (0.9.2)
rake
rb-fsevent (0.9.3)
rb-inotify (0.9.2)
ffi (>= 0.5.0)
rbtrace (0.4.1)
ffi (>= 1.0.6)
msgpack (>= 0.4.3)
trollop (>= 1.16.2)
redcarpet (3.0.0)
redis (3.0.6)
redis-actionpack (4.0.0)
actionpack (~> 4)
redis-rack (~> 1.5.0)
redis-store (~> 1.1.0)
redis-activesupport (4.0.0)
activesupport (~> 4)
redis-store (~> 1.1.0)
redis-namespace (1.3.2)
redis (~> 3.0.4)
redis-rack (1.5.0)
rack (~> 1.5)
redis-store (~> 1.1.0)
redis-rails (4.0.0)
redis-actionpack (~> 4)
redis-activesupport (~> 4)
redis-store (~> 1.1.0)
redis-store (1.1.4)
redis (>= 2.2)
ref (1.0.5)
rest-client (1.6.7)
mime-types (>= 1.16)
rinku (1.7.3)
rspec (2.14.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec-core (2.14.6)
rspec-expectations (2.14.3)
diff-lcs (>= 1.1.3, < 2.0)
rspec-given (3.1.1)
given_core (= 3.1.1)
rspec (>= 2.12)
rspec-mocks (2.14.4)
rspec-rails (2.14.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
ruby-hmac (0.4.0)
ruby-openid (2.3.0)
sanitize (2.0.6)
nokogiri (>= 1.4.4)
sass (3.2.12)
sass-rails (4.0.1)
railties (>= 4.0.0, < 5.0)
sass (>= 3.1.10)
sprockets-rails (~> 2.0.0)
seed-fu-discourse (2.2.0)
activerecord (>= 3.1, < 4.1)
activesupport (>= 3.1, < 4.1)
shoulda (3.5.0)
shoulda-context (~> 1.0, >= 1.0.1)
shoulda-matchers (>= 1.4.1, < 3.0)
shoulda-context (1.1.5)
shoulda-matchers (2.4.0)
activesupport (>= 3.0.0)
sidekiq (2.15.1)
celluloid (>= 0.15.1)
connection_pool (>= 1.0.0)
json
redis (>= 3.0.4)
redis-namespace (>= 1.3.1)
sidekiq-failures (0.2.2)
sidekiq (>= 2.9.0)
sidetiq (0.4.3)
celluloid (>= 0.14.1)
ice_cube (~> 0.11.0)
sidekiq (~> 2.15.0)
simplecov (0.7.1)
multi_json (~> 1.0)
simplecov-html (~> 0.7.1)
simplecov-html (0.7.1)
sinatra (1.4.4)
rack (~> 1.4)
rack-protection (~> 1.4)
tilt (~> 1.3, >= 1.3.4)
slim (2.0.1)
temple (~> 0.6.6)
tilt (>= 1.3.3, < 2.1)
slop (3.4.7)
sorcerer (1.0.2)
spork (1.0.0rc4)
spork-rails (4.0.0)
rails (>= 3.0.0, < 5)
spork (>= 1.0rc0)
sprockets (2.10.1)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.0.1)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (~> 2.8)
temple (0.6.7)
therubyracer-discourse (0.12.0)
libv8 (~> 3.16.14.0)
ref
thin (1.6.1)
daemons (>= 1.0.9)
eventmachine (>= 1.0.0)
rack (>= 1.0.0)
thor (0.18.1)
thread_safe (0.1.3)
atomic
tilt (1.4.1)
timecop (0.6.3)
timers (1.1.0)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
trollop (2.0)
tzinfo (1.1.0)
thread_safe (~> 0.1)
uglifier (2.3.1)
execjs (>= 0.3.0)
json (>= 1.8.0)
unf (0.1.3)
unf_ext
unf_ext (0.0.6)
unicorn (4.7.0)
kgio (~> 2.6)
rack
raindrops (~> 0.7)
PLATFORMS
ruby
DEPENDENCIES
actionpack-action_caching!
active_model_serializers
airbrake (= 3.1.2)
annotate
barber
better_errors
binding_of_caller
certified
discourse_plugin!
email_reply_parser-discourse
ember-rails
ember-source (~> 1.2.0.1)
eventmachine
fabrication
fakeweb (~> 1.3.0)
fast_blank
fast_xor
fast_xs
fastimage
flamegraph
fog (= 1.18.0)
handlebars-source (~> 1.1.2)
highline
hiredis
html_truncator
image_optim
image_sorcery
librarian (>= 0.0.25)
listen (= 0.7.3)
lru_redux
message_bus
minitest
mocha
mock_redis
multi_json
mustache
nokogiri
oj
omniauth
omniauth-browserid-discourse
omniauth-cas
omniauth-facebook
omniauth-github
omniauth-oauth2
omniauth-openid
omniauth-twitter
openid-redis-store
pg (= 0.15.1)
pry-nav
pry-rails
puma
qunit-rails
rack-cors
rack-mini-profiler (= 0.9.0.pre)
rack-protection
rails!
rails-observers
rails_multisite!
rake
rb-fsevent
rb-inotify (~> 0.9)
rbtrace
redcarpet
redis
redis-rails
rest-client
rinku
rspec-given
rspec-rails
sanitize
sass
sass-rails
seed-fu-discourse
shoulda
sidekiq (= 2.15.1)
sidekiq-failures
sidetiq (>= 0.3.6)
simplecov
sinatra
slim
spork-rails
therubyracer-discourse
thin
timecop
uglifier
unf
unicorn

View file

@ -45,7 +45,9 @@ unless rails4?
class Relation
def where_values_hash
equalities = with_default_scope.where_values.grep(Arel::Nodes::Equality).find_all { |node|
values = rails_master? ? where_values : with_default_scope.where_values
equalities = values.grep(Arel::Nodes::Equality).find_all { |node|
node.left.relation.name == table_name
}

View file

@ -15,7 +15,13 @@ module Trashable
#
# with this in place Post.limit(10).with_deleted, will work as expected
#
scope = rails4? ? self.all.with_default_scope : self.scoped.with_default_scope
scope = if rails_master?
self.all
elsif rails4?
self.all.with_default_scope
else
self.scoped.with_default_scope
end
scope.where_values.delete(with_deleted_scope_sql)
scope

View file

@ -267,6 +267,7 @@ describe Category do
category.latest_post_id.should == post3.id
category.latest_topic_id.should == post2.topic_id
post3.reload
destroyer = PostDestroyer.new(Fabricate(:admin), post3)
destroyer.destroy