mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 15:48:43 -05:00
Rails 4 updates
This commit is contained in:
parent
0a7bbb08e1
commit
f99acebdaa
10 changed files with 41 additions and 37 deletions
5
Gemfile
5
Gemfile
|
@ -36,7 +36,6 @@ if rails4?
|
||||||
gem 'rails', '4.0.0'
|
gem 'rails', '4.0.0'
|
||||||
gem 'redis-rails', :git => 'git://github.com/SamSaffron/redis-store.git'
|
gem 'redis-rails', :git => 'git://github.com/SamSaffron/redis-store.git'
|
||||||
gem 'rails-observers'
|
gem 'rails-observers'
|
||||||
gem 'protected_attributes'
|
|
||||||
gem 'actionpack-action_caching'
|
gem 'actionpack-action_caching'
|
||||||
gem 'seed-fu' , github: 'mbleigh/seed-fu'
|
gem 'seed-fu' , github: 'mbleigh/seed-fu'
|
||||||
gem 'spork-rails', :github => 'sporkrb/spork-rails'
|
gem 'spork-rails', :github => 'sporkrb/spork-rails'
|
||||||
|
@ -62,7 +61,7 @@ gem 'redis'
|
||||||
gem 'hiredis'
|
gem 'hiredis'
|
||||||
gem 'em-redis'
|
gem 'em-redis'
|
||||||
|
|
||||||
gem 'active_model_serializers', git: 'https://github.com/rails-api/active_model_serializers.git'
|
gem 'active_model_serializers'
|
||||||
|
|
||||||
# we had issues with latest, stick to the rev till we figure this out
|
# we had issues with latest, stick to the rev till we figure this out
|
||||||
# PR that makes it all hang together welcome
|
# PR that makes it all hang together welcome
|
||||||
|
@ -120,7 +119,7 @@ gem 'sinatra', require: nil
|
||||||
gem 'slim' # required for sidekiq-web
|
gem 'slim' # required for sidekiq-web
|
||||||
gem 'therubyracer', require: 'v8'
|
gem 'therubyracer', require: 'v8'
|
||||||
gem 'thin', require: false
|
gem 'thin', require: false
|
||||||
gem 'diffy', require: false
|
gem 'diffy', '>= 3.0', require: false
|
||||||
gem 'highline', require: false
|
gem 'highline', require: false
|
||||||
|
|
||||||
# Gem that enables support for plugins. It is required.
|
# Gem that enables support for plugins. It is required.
|
||||||
|
|
15
Gemfile.lock
15
Gemfile.lock
|
@ -59,13 +59,6 @@ GIT
|
||||||
specs:
|
specs:
|
||||||
email_reply_parser (0.6)
|
email_reply_parser (0.6)
|
||||||
|
|
||||||
GIT
|
|
||||||
remote: https://github.com/rails-api/active_model_serializers.git
|
|
||||||
revision: fe84e0ad5268f1439123fd9a1f9fd12e25a54cd3
|
|
||||||
specs:
|
|
||||||
active_model_serializers (0.8.1)
|
|
||||||
activemodel (>= 3.0)
|
|
||||||
|
|
||||||
GIT
|
GIT
|
||||||
remote: https://github.com/zhangyuan/vestal_versions
|
remote: https://github.com/zhangyuan/vestal_versions
|
||||||
revision: 0ea75ec4e269b5a9e609639919ade0f36381a446
|
revision: 0ea75ec4e269b5a9e609639919ade0f36381a446
|
||||||
|
@ -114,6 +107,8 @@ GEM
|
||||||
active_attr (0.7.0)
|
active_attr (0.7.0)
|
||||||
activemodel (>= 3.0.2, < 4.1)
|
activemodel (>= 3.0.2, < 4.1)
|
||||||
activesupport (>= 3.0.2, < 4.1)
|
activesupport (>= 3.0.2, < 4.1)
|
||||||
|
active_model_serializers (0.8.1)
|
||||||
|
activemodel (>= 3.0)
|
||||||
activemodel (3.2.12)
|
activemodel (3.2.12)
|
||||||
activesupport (= 3.2.12)
|
activesupport (= 3.2.12)
|
||||||
builder (~> 3.0.0)
|
builder (~> 3.0.0)
|
||||||
|
@ -161,7 +156,7 @@ GEM
|
||||||
daemons (1.1.9)
|
daemons (1.1.9)
|
||||||
debug_inspector (0.0.2)
|
debug_inspector (0.0.2)
|
||||||
diff-lcs (1.2.4)
|
diff-lcs (1.2.4)
|
||||||
diffy (2.1.4)
|
diffy (3.0.1)
|
||||||
em-redis (0.3.0)
|
em-redis (0.3.0)
|
||||||
eventmachine
|
eventmachine
|
||||||
ember-rails (0.10.0)
|
ember-rails (0.10.0)
|
||||||
|
@ -467,7 +462,7 @@ PLATFORMS
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
active_attr
|
active_attr
|
||||||
active_model_serializers!
|
active_model_serializers
|
||||||
activerecord-postgres-hstore
|
activerecord-postgres-hstore
|
||||||
airbrake (= 3.1.2)
|
airbrake (= 3.1.2)
|
||||||
annotate!
|
annotate!
|
||||||
|
@ -476,7 +471,7 @@ DEPENDENCIES
|
||||||
binding_of_caller
|
binding_of_caller
|
||||||
certified
|
certified
|
||||||
clockwork
|
clockwork
|
||||||
diffy
|
diffy (>= 3.0)
|
||||||
discourse_emoji!
|
discourse_emoji!
|
||||||
discourse_plugin!
|
discourse_plugin!
|
||||||
em-redis
|
em-redis
|
||||||
|
|
|
@ -89,13 +89,6 @@ GIT
|
||||||
specs:
|
specs:
|
||||||
email_reply_parser (0.6)
|
email_reply_parser (0.6)
|
||||||
|
|
||||||
GIT
|
|
||||||
remote: https://github.com/rails-api/active_model_serializers.git
|
|
||||||
revision: 8ac4bf90067eef442a6208848f86e55892d724f1
|
|
||||||
specs:
|
|
||||||
active_model_serializers (0.8.1)
|
|
||||||
activemodel (>= 3.2)
|
|
||||||
|
|
||||||
GIT
|
GIT
|
||||||
remote: https://github.com/zhangyuan/vestal_versions
|
remote: https://github.com/zhangyuan/vestal_versions
|
||||||
revision: 0ea75ec4e269b5a9e609639919ade0f36381a446
|
revision: 0ea75ec4e269b5a9e609639919ade0f36381a446
|
||||||
|
@ -139,6 +132,8 @@ GEM
|
||||||
rack-test (~> 0.6.2)
|
rack-test (~> 0.6.2)
|
||||||
actionpack-action_caching (1.0.0)
|
actionpack-action_caching (1.0.0)
|
||||||
actionpack (>= 4.0.0.beta, < 5.0)
|
actionpack (>= 4.0.0.beta, < 5.0)
|
||||||
|
active_model_serializers (0.8.1)
|
||||||
|
activemodel (>= 3.0)
|
||||||
activemodel (4.0.0)
|
activemodel (4.0.0)
|
||||||
activesupport (= 4.0.0)
|
activesupport (= 4.0.0)
|
||||||
builder (~> 3.1.0)
|
builder (~> 3.1.0)
|
||||||
|
@ -318,8 +313,6 @@ GEM
|
||||||
pg (0.15.1)
|
pg (0.15.1)
|
||||||
polyglot (0.3.3)
|
polyglot (0.3.3)
|
||||||
progress (2.4.0)
|
progress (2.4.0)
|
||||||
protected_attributes (1.0.3)
|
|
||||||
activemodel (>= 4.0.0, < 5.0)
|
|
||||||
pry (0.9.12.2)
|
pry (0.9.12.2)
|
||||||
coderay (~> 1.0.5)
|
coderay (~> 1.0.5)
|
||||||
method_source (~> 0.8)
|
method_source (~> 0.8)
|
||||||
|
@ -477,7 +470,7 @@ PLATFORMS
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
actionpack-action_caching
|
actionpack-action_caching
|
||||||
active_model_serializers!
|
active_model_serializers
|
||||||
airbrake (= 3.1.2)
|
airbrake (= 3.1.2)
|
||||||
annotate!
|
annotate!
|
||||||
barber
|
barber
|
||||||
|
@ -485,7 +478,7 @@ DEPENDENCIES
|
||||||
binding_of_caller
|
binding_of_caller
|
||||||
certified
|
certified
|
||||||
clockwork
|
clockwork
|
||||||
diffy
|
diffy (>= 3.0)
|
||||||
discourse_emoji!
|
discourse_emoji!
|
||||||
discourse_plugin!
|
discourse_plugin!
|
||||||
em-redis
|
em-redis
|
||||||
|
@ -525,7 +518,6 @@ DEPENDENCIES
|
||||||
omniauth-twitter
|
omniauth-twitter
|
||||||
openid-redis-store
|
openid-redis-store
|
||||||
pg
|
pg
|
||||||
protected_attributes
|
|
||||||
pry-nav
|
pry-nav
|
||||||
pry-rails
|
pry-rails
|
||||||
qunit-rails
|
qunit-rails
|
||||||
|
|
|
@ -9,8 +9,9 @@ class DiscourseVersionCheck
|
||||||
|
|
||||||
attr_accessor :latest_version, :critical_updates, :installed_version, :installed_sha, :missing_versions_count, :updated_at
|
attr_accessor :latest_version, :critical_updates, :installed_version, :installed_sha, :missing_versions_count, :updated_at
|
||||||
|
|
||||||
def active_model_serializer
|
unless rails4?
|
||||||
DiscourseVersionCheckSerializer
|
def active_model_serializer
|
||||||
|
DiscourseVersionCheckSerializer
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
|
@ -468,7 +468,7 @@ class Topic < ActiveRecord::Base
|
||||||
|
|
||||||
# Chooses which topic users to feature
|
# Chooses which topic users to feature
|
||||||
def feature_topic_users(args={})
|
def feature_topic_users(args={})
|
||||||
reload
|
reload unless rails4?
|
||||||
|
|
||||||
# Don't include the OP or the last poster
|
# Don't include the OP or the last poster
|
||||||
to_feature = posts.where('user_id NOT IN (?, ?)', user_id, last_post_user_id)
|
to_feature = posts.where('user_id NOT IN (?, ?)', user_id, last_post_user_id)
|
||||||
|
|
|
@ -13,7 +13,7 @@ class DiffEngine
|
||||||
#
|
#
|
||||||
# returns: html containing decorations indicating the changes
|
# returns: html containing decorations indicating the changes
|
||||||
def self.html_diff(html_before, html_after)
|
def self.html_diff(html_before, html_after)
|
||||||
Diffy::Diff.new(html_before, html_after).to_s(:html)
|
Diffy::Diff.new(html_before, html_after, {allow_empty_diff: false}).to_s(:html)
|
||||||
end
|
end
|
||||||
|
|
||||||
# same as html diff, except that it operates on markdown
|
# same as html diff, except that it operates on markdown
|
||||||
|
|
|
@ -15,13 +15,21 @@ module Trashable
|
||||||
#
|
#
|
||||||
# with this in place Post.limit(10).with_deleted, will work as expected
|
# with this in place Post.limit(10).with_deleted, will work as expected
|
||||||
#
|
#
|
||||||
scope = self.scoped.with_default_scope
|
if rails4?
|
||||||
|
scope = self.all.with_default_scope
|
||||||
|
else
|
||||||
|
scope = self.scoped.with_default_scope
|
||||||
|
end
|
||||||
scope.where_values.delete(with_deleted_scope_sql)
|
scope.where_values.delete(with_deleted_scope_sql)
|
||||||
scope
|
scope
|
||||||
end
|
end
|
||||||
|
|
||||||
def with_deleted_scope_sql
|
def with_deleted_scope_sql
|
||||||
scoped.table[:deleted_at].eq(nil).to_sql
|
if rails4?
|
||||||
|
all.table[:deleted_at].eq(nil).to_sql
|
||||||
|
else
|
||||||
|
scoped.table[:deleted_at].eq(nil).to_sql
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,11 @@ describe StaticController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "renders the file" do
|
it "renders the file" do
|
||||||
response.should render_template('faq')
|
if rails4?
|
||||||
|
response.should render_template('static/faq.en')
|
||||||
|
else
|
||||||
|
response.should render_template('faq')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -23,7 +27,11 @@ describe StaticController do
|
||||||
|
|
||||||
context "when #{setting_name} site setting is NOT set" do
|
context "when #{setting_name} site setting is NOT set" do
|
||||||
it "renders the #{id} page" do
|
it "renders the #{id} page" do
|
||||||
expect(subject).to render_template(id)
|
if rails4?
|
||||||
|
expect(subject).to render_template("static/#{id}.en")
|
||||||
|
else
|
||||||
|
expect(subject).to render_template(id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -147,6 +147,7 @@ describe PostMover do
|
||||||
|
|
||||||
it "copies the OP, doesn't delete it" do
|
it "copies the OP, doesn't delete it" do
|
||||||
new_topic.should be_present
|
new_topic.should be_present
|
||||||
|
new_topic.posts.reload
|
||||||
new_topic.posts.first.raw.should == p1.raw
|
new_topic.posts.first.raw.should == p1.raw
|
||||||
|
|
||||||
new_topic.reload
|
new_topic.reload
|
||||||
|
|
|
@ -661,7 +661,7 @@ describe Topic do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'meta data' do
|
describe 'meta data' do
|
||||||
let(:topic) { Fabricate(:topic, meta_data: {hello: 'world'}) }
|
let(:topic) { Fabricate(:topic, meta_data: {'hello' => 'world'}) }
|
||||||
|
|
||||||
it 'allows us to create a topic with meta data' do
|
it 'allows us to create a topic with meta data' do
|
||||||
topic.meta_data['hello'].should == 'world'
|
topic.meta_data['hello'].should == 'world'
|
||||||
|
@ -671,7 +671,7 @@ describe Topic do
|
||||||
|
|
||||||
context 'existing key' do
|
context 'existing key' do
|
||||||
before do
|
before do
|
||||||
topic.update_meta_data(hello: 'bane')
|
topic.update_meta_data('hello' => 'bane')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'updates the key' do
|
it 'updates the key' do
|
||||||
|
@ -681,7 +681,7 @@ describe Topic do
|
||||||
|
|
||||||
context 'new key' do
|
context 'new key' do
|
||||||
before do
|
before do
|
||||||
topic.update_meta_data(city: 'gotham')
|
topic.update_meta_data('city' => 'gotham')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'adds the new key' do
|
it 'adds the new key' do
|
||||||
|
|
Loading…
Reference in a new issue