mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 13:09:18 +08:00
Support Ruby 2.4.
This commit is contained in:
parent
86efc57390
commit
04016f0dec
|
@ -24,6 +24,7 @@ matrix:
|
||||||
fast_finish: true
|
fast_finish: true
|
||||||
|
|
||||||
rvm:
|
rvm:
|
||||||
|
- 2.4.1
|
||||||
- 2.3.3
|
- 2.3.3
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
|
1
Gemfile
1
Gemfile
|
@ -112,6 +112,7 @@ group :assets do
|
||||||
end
|
end
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
|
gem 'webmock', require: false
|
||||||
gem 'fakeweb', '~> 1.3.0', require: false
|
gem 'fakeweb', '~> 1.3.0', require: false
|
||||||
gem 'minitest', require: false
|
gem 'minitest', require: false
|
||||||
gem 'timecop'
|
gem 'timecop'
|
||||||
|
|
12
Gemfile.lock
12
Gemfile.lock
|
@ -37,6 +37,8 @@ GEM
|
||||||
minitest (~> 5.1)
|
minitest (~> 5.1)
|
||||||
thread_safe (~> 0.3, >= 0.3.4)
|
thread_safe (~> 0.3, >= 0.3.4)
|
||||||
tzinfo (~> 1.1)
|
tzinfo (~> 1.1)
|
||||||
|
addressable (2.5.1)
|
||||||
|
public_suffix (~> 2.0, >= 2.0.2)
|
||||||
annotate (2.7.1)
|
annotate (2.7.1)
|
||||||
activerecord (>= 3.2, < 6.0)
|
activerecord (>= 3.2, < 6.0)
|
||||||
rake (>= 10.4, < 12.0)
|
rake (>= 10.4, < 12.0)
|
||||||
|
@ -69,6 +71,8 @@ GEM
|
||||||
coderay (1.1.1)
|
coderay (1.1.1)
|
||||||
concurrent-ruby (1.0.5)
|
concurrent-ruby (1.0.5)
|
||||||
connection_pool (2.2.0)
|
connection_pool (2.2.0)
|
||||||
|
crack (0.4.3)
|
||||||
|
safe_yaml (~> 1.0.0)
|
||||||
crass (1.0.2)
|
crass (1.0.2)
|
||||||
debug_inspector (0.0.2)
|
debug_inspector (0.0.2)
|
||||||
diff-lcs (1.2.5)
|
diff-lcs (1.2.5)
|
||||||
|
@ -113,6 +117,7 @@ GEM
|
||||||
globalid (0.3.7)
|
globalid (0.3.7)
|
||||||
activesupport (>= 4.1.0)
|
activesupport (>= 4.1.0)
|
||||||
guess_html_encoding (0.0.11)
|
guess_html_encoding (0.0.11)
|
||||||
|
hashdiff (0.3.2)
|
||||||
hashie (3.5.5)
|
hashie (3.5.5)
|
||||||
highline (1.7.8)
|
highline (1.7.8)
|
||||||
hiredis (0.6.1)
|
hiredis (0.6.1)
|
||||||
|
@ -228,6 +233,7 @@ GEM
|
||||||
pry (>= 0.9.10, < 0.11.0)
|
pry (>= 0.9.10, < 0.11.0)
|
||||||
pry-rails (0.3.4)
|
pry-rails (0.3.4)
|
||||||
pry (>= 0.9.10)
|
pry (>= 0.9.10)
|
||||||
|
public_suffix (2.0.5)
|
||||||
puma (3.6.0)
|
puma (3.6.0)
|
||||||
r2 (0.2.6)
|
r2 (0.2.6)
|
||||||
rack (1.6.5)
|
rack (1.6.5)
|
||||||
|
@ -316,6 +322,7 @@ GEM
|
||||||
guess_html_encoding (>= 0.0.4)
|
guess_html_encoding (>= 0.0.4)
|
||||||
nokogiri (>= 1.6.0)
|
nokogiri (>= 1.6.0)
|
||||||
ruby_dep (1.5.0)
|
ruby_dep (1.5.0)
|
||||||
|
safe_yaml (1.0.4)
|
||||||
sanitize (4.4.0)
|
sanitize (4.4.0)
|
||||||
crass (~> 1.0.2)
|
crass (~> 1.0.2)
|
||||||
nokogiri (>= 1.4.4)
|
nokogiri (>= 1.4.4)
|
||||||
|
@ -377,6 +384,10 @@ GEM
|
||||||
kgio (~> 2.6)
|
kgio (~> 2.6)
|
||||||
raindrops (~> 0.7)
|
raindrops (~> 0.7)
|
||||||
uniform_notifier (1.10.0)
|
uniform_notifier (1.10.0)
|
||||||
|
webmock (3.0.1)
|
||||||
|
addressable (>= 2.3.6)
|
||||||
|
crack (>= 0.3.2)
|
||||||
|
hashdiff
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
ruby
|
ruby
|
||||||
|
@ -477,6 +488,7 @@ DEPENDENCIES
|
||||||
uglifier
|
uglifier
|
||||||
unf
|
unf
|
||||||
unicorn
|
unicorn
|
||||||
|
webmock
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
1.14.6
|
1.14.6
|
||||||
|
|
|
@ -24,8 +24,8 @@
|
||||||
{{#if model.number_of_suspensions}}
|
{{#if model.number_of_suspensions}}
|
||||||
<div><span class="suspensions">{{model.number_of_suspensions}}</span> {{i18n 'user.staff_counters.suspensions'}}</div>
|
<div><span class="suspensions">{{model.number_of_suspensions}}</span> {{i18n 'user.staff_counters.suspensions'}}</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if model.number_of_warnings}}
|
{{#if model.warnings_received_count}}
|
||||||
<div><span class="warnings-received">{{model.number_of_warnings}}</span> {{i18n 'user.staff_counters.warnings_received'}}</div>
|
<div><span class="warnings-received">{{model.warnings_received_count}}</span> {{i18n 'user.staff_counters.warnings_received'}}</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
|
|
|
@ -465,7 +465,7 @@ class ApplicationController < ActionController::Base
|
||||||
# type - a machine-readable description of the error
|
# type - a machine-readable description of the error
|
||||||
# status - HTTP status code to return
|
# status - HTTP status code to return
|
||||||
def render_json_error(obj, opts={})
|
def render_json_error(obj, opts={})
|
||||||
opts = { status: opts } if opts.is_a?(Fixnum)
|
opts = { status: opts } if opts.is_a?(Integer)
|
||||||
render json: MultiJson.dump(create_errors_json(obj, opts[:type])), status: opts[:status] || 422
|
render json: MultiJson.dump(create_errors_json(obj, opts[:type])), status: opts[:status] || 422
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -744,7 +744,7 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
result = {}
|
result = {}
|
||||||
|
|
||||||
%W{number_of_deleted_posts number_of_flagged_posts number_of_flags_given number_of_suspensions number_of_warnings}.each do |info|
|
%W{number_of_deleted_posts number_of_flagged_posts number_of_flags_given number_of_suspensions warnings_received_count}.each do |info|
|
||||||
result[info] = @user.send(info)
|
result[info] = @user.send(info)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -388,8 +388,8 @@ SQL
|
||||||
group = group.id if group.is_a?(Group)
|
group = group.id if group.is_a?(Group)
|
||||||
|
|
||||||
# subtle, using Group[] ensures the group exists in the DB
|
# subtle, using Group[] ensures the group exists in the DB
|
||||||
group = Group[group.to_sym].id unless group.is_a?(Fixnum)
|
group = Group[group.to_sym].id unless group.is_a?(Integer)
|
||||||
permission = CategoryGroup.permission_types[permission] unless permission.is_a?(Fixnum)
|
permission = CategoryGroup.permission_types[permission] unless permission.is_a?(Integer)
|
||||||
|
|
||||||
[group, permission]
|
[group, permission]
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,7 @@ class CategoryFeaturedUser < ActiveRecord::Base
|
||||||
|
|
||||||
def self.feature_users_in(category_or_category_id)
|
def self.feature_users_in(category_or_category_id)
|
||||||
category_id =
|
category_id =
|
||||||
if category_or_category_id.is_a?(Fixnum)
|
if category_or_category_id.is_a?(Integer)
|
||||||
category_or_category_id
|
category_or_category_id
|
||||||
else
|
else
|
||||||
category_or_category_id.id
|
category_or_category_id.id
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class DraftSequence < ActiveRecord::Base
|
class DraftSequence < ActiveRecord::Base
|
||||||
def self.next!(user,key)
|
def self.next!(user,key)
|
||||||
user_id = user
|
user_id = user
|
||||||
user_id = user.id unless user.class == Fixnum
|
user_id = user.id unless user.is_a?(Integer)
|
||||||
|
|
||||||
return 0 if user_id < 0
|
return 0 if user_id < 0
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ class DraftSequence < ActiveRecord::Base
|
||||||
return nil unless user
|
return nil unless user
|
||||||
|
|
||||||
user_id = user
|
user_id = user
|
||||||
user_id = user.id unless user.class == Fixnum
|
user_id = user.id unless user.is_a?(Integer)
|
||||||
|
|
||||||
# perf critical path
|
# perf critical path
|
||||||
r = exec_sql('select sequence from draft_sequences where user_id = ? and draft_key = ?', user_id, key).values
|
r = exec_sql('select sequence from draft_sequences where user_id = ? and draft_key = ?', user_id, key).values
|
||||||
|
|
|
@ -42,7 +42,7 @@ class PluginStore
|
||||||
|
|
||||||
def self.cast_value(type, value)
|
def self.cast_value(type, value)
|
||||||
case type
|
case type
|
||||||
when "Fixnum" then value.to_i
|
when "Integer", "Fixnum" then value.to_i
|
||||||
when "TrueClass", "FalseClass" then value == "true"
|
when "TrueClass", "FalseClass" then value == "true"
|
||||||
when "JSON" then map_json(::JSON.parse(value))
|
when "JSON" then map_json(::JSON.parse(value))
|
||||||
else value
|
else value
|
||||||
|
|
|
@ -118,7 +118,7 @@ class Topic < ActiveRecord::Base
|
||||||
has_many :invites, through: :topic_invites, source: :invite
|
has_many :invites, through: :topic_invites, source: :invite
|
||||||
has_many :topic_status_updates, dependent: :destroy
|
has_many :topic_status_updates, dependent: :destroy
|
||||||
|
|
||||||
has_one :warning
|
has_one :user_warning
|
||||||
has_one :first_post, -> {where post_number: 1}, class_name: Post
|
has_one :first_post, -> {where post_number: 1}, class_name: Post
|
||||||
|
|
||||||
# When we want to temporarily attach some data to a forum topic (usually before serialization)
|
# When we want to temporarily attach some data to a forum topic (usually before serialization)
|
||||||
|
|
|
@ -37,7 +37,7 @@ class User < ActiveRecord::Base
|
||||||
has_many :invites, dependent: :destroy
|
has_many :invites, dependent: :destroy
|
||||||
has_many :topic_links, dependent: :destroy
|
has_many :topic_links, dependent: :destroy
|
||||||
has_many :uploads
|
has_many :uploads
|
||||||
has_many :warnings
|
has_many :user_warnings
|
||||||
has_many :user_archived_messages, dependent: :destroy
|
has_many :user_archived_messages, dependent: :destroy
|
||||||
has_many :email_change_requests, dependent: :destroy
|
has_many :email_change_requests, dependent: :destroy
|
||||||
has_many :directory_items, dependent: :delete_all
|
has_many :directory_items, dependent: :delete_all
|
||||||
|
@ -276,7 +276,7 @@ class User < ActiveRecord::Base
|
||||||
def approve(approved_by, send_mail=true)
|
def approve(approved_by, send_mail=true)
|
||||||
self.approved = true
|
self.approved = true
|
||||||
|
|
||||||
if approved_by.is_a?(Fixnum)
|
if approved_by.is_a?(Integer)
|
||||||
self.approved_by_id = approved_by
|
self.approved_by_id = approved_by
|
||||||
else
|
else
|
||||||
self.approved_by = approved_by
|
self.approved_by = approved_by
|
||||||
|
@ -614,7 +614,7 @@ class User < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def warnings_received_count
|
def warnings_received_count
|
||||||
warnings.count
|
user_warnings.count
|
||||||
end
|
end
|
||||||
|
|
||||||
def flags_received_count
|
def flags_received_count
|
||||||
|
@ -889,10 +889,6 @@ class User < ActiveRecord::Base
|
||||||
.count
|
.count
|
||||||
end
|
end
|
||||||
|
|
||||||
def number_of_warnings
|
|
||||||
self.warnings.count
|
|
||||||
end
|
|
||||||
|
|
||||||
def number_of_suspensions
|
def number_of_suspensions
|
||||||
UserHistory.for(self, :suspend_user).count
|
UserHistory.for(self, :suspend_user).count
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class Warning < ActiveRecord::Base
|
class UserWarning < ActiveRecord::Base
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
belongs_to :topic
|
belongs_to :topic
|
||||||
belongs_to :created_by, class_name: 'User'
|
belongs_to :created_by, class_name: 'User'
|
9
db/migrate/20170413043152_rename_warnings.rb
Normal file
9
db/migrate/20170413043152_rename_warnings.rb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
class RenameWarnings < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
rename_table :warnings, :user_warnings
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
rename_table :user_warnings, :warnings
|
||||||
|
end
|
||||||
|
end
|
|
@ -45,7 +45,7 @@ module PrettyText
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_topic_info(topic_id)
|
def get_topic_info(topic_id)
|
||||||
return unless Fixnum === topic_id
|
return unless topic_id.is_a?(Integer)
|
||||||
# TODO this only handles public topics, secured one do not get this
|
# TODO this only handles public topics, secured one do not get this
|
||||||
topic = Topic.find_by(id: topic_id)
|
topic = Topic.find_by(id: topic_id)
|
||||||
if topic && Guardian.new.can_see?(topic)
|
if topic && Guardian.new.can_see?(topic)
|
||||||
|
@ -76,4 +76,3 @@ module PrettyText
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ module SiteSettingExtension
|
||||||
def types
|
def types
|
||||||
@types ||= Enum.new(string: 1,
|
@types ||= Enum.new(string: 1,
|
||||||
time: 2,
|
time: 2,
|
||||||
fixnum: 3,
|
integer: 3,
|
||||||
float: 4,
|
float: 4,
|
||||||
bool: 5,
|
bool: 5,
|
||||||
null: 6,
|
null: 6,
|
||||||
|
@ -286,7 +286,7 @@ module SiteSettingExtension
|
||||||
val = (val == "t" || val == "true") ? 't' : 'f'
|
val = (val == "t" || val == "true") ? 't' : 'f'
|
||||||
end
|
end
|
||||||
|
|
||||||
if type == types[:fixnum] && !val.is_a?(Fixnum)
|
if type == types[:integer] && !val.is_a?(Integer)
|
||||||
val = val.to_i
|
val = val.to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -295,7 +295,7 @@ module SiteSettingExtension
|
||||||
end
|
end
|
||||||
|
|
||||||
if type == types[:enum]
|
if type == types[:enum]
|
||||||
val = val.to_i if defaults[name.to_sym].is_a?(Fixnum)
|
val = val.to_i if defaults[name.to_sym].is_a?(Integer)
|
||||||
if enum_class(name)
|
if enum_class(name)
|
||||||
raise Discourse::InvalidParameters.new(:value) unless enum_class(name).valid_value?(val)
|
raise Discourse::InvalidParameters.new(:value) unless enum_class(name).valid_value?(val)
|
||||||
else
|
else
|
||||||
|
@ -340,9 +340,9 @@ module SiteSettingExtension
|
||||||
valid = true
|
valid = true
|
||||||
type = get_data_type(name, defaults[name.to_sym])
|
type = get_data_type(name, defaults[name.to_sym])
|
||||||
|
|
||||||
if type == types[:fixnum]
|
if type == types[:integer]
|
||||||
# validate fixnum
|
# validate integer
|
||||||
valid = false unless value.to_i.is_a?(Fixnum)
|
valid = false unless value.to_i.is_a?(Integer)
|
||||||
end
|
end
|
||||||
|
|
||||||
valid
|
valid
|
||||||
|
@ -407,8 +407,8 @@ module SiteSettingExtension
|
||||||
case val
|
case val
|
||||||
when String
|
when String
|
||||||
types[:string]
|
types[:string]
|
||||||
when Fixnum
|
when Integer
|
||||||
types[:fixnum]
|
types[:integer]
|
||||||
when Float
|
when Float
|
||||||
types[:float]
|
types[:float]
|
||||||
when TrueClass, FalseClass
|
when TrueClass, FalseClass
|
||||||
|
@ -422,14 +422,14 @@ module SiteSettingExtension
|
||||||
case type
|
case type
|
||||||
when types[:float]
|
when types[:float]
|
||||||
value.to_f
|
value.to_f
|
||||||
when types[:fixnum]
|
when types[:integer]
|
||||||
value.to_i
|
value.to_i
|
||||||
when types[:bool]
|
when types[:bool]
|
||||||
value == true || value == "t" || value == "true"
|
value == true || value == "t" || value == "true"
|
||||||
when types[:null]
|
when types[:null]
|
||||||
nil
|
nil
|
||||||
when types[:enum]
|
when types[:enum]
|
||||||
defaults[name.to_sym].is_a?(Fixnum) ? value.to_i : value
|
defaults[name.to_sym].is_a?(Integer) ? value.to_i : value
|
||||||
else
|
else
|
||||||
return value if types[type]
|
return value if types[type]
|
||||||
# Otherwise it's a type error
|
# Otherwise it's a type error
|
||||||
|
@ -441,7 +441,7 @@ module SiteSettingExtension
|
||||||
@validator_mapping ||= {
|
@validator_mapping ||= {
|
||||||
'email' => EmailSettingValidator,
|
'email' => EmailSettingValidator,
|
||||||
'username' => UsernameSettingValidator,
|
'username' => UsernameSettingValidator,
|
||||||
types[:fixnum] => IntegerSettingValidator,
|
types[:integer] => IntegerSettingValidator,
|
||||||
types[:string] => StringSettingValidator,
|
types[:string] => StringSettingValidator,
|
||||||
'list' => StringSettingValidator,
|
'list' => StringSettingValidator,
|
||||||
'enum' => StringSettingValidator,
|
'enum' => StringSettingValidator,
|
||||||
|
|
|
@ -64,7 +64,7 @@ class TopicCreator
|
||||||
rollback_with!(topic, :too_many_users) if @added_users.size != 1
|
rollback_with!(topic, :too_many_users) if @added_users.size != 1
|
||||||
|
|
||||||
# Create a warning record
|
# Create a warning record
|
||||||
Warning.create(topic: topic, user: @added_users.first, created_by: @user)
|
UserWarning.create(topic: topic, user: @added_users.first, created_by: @user)
|
||||||
end
|
end
|
||||||
|
|
||||||
def watch_topic(topic)
|
def watch_topic(topic)
|
||||||
|
|
|
@ -297,6 +297,8 @@ describe Email::Receiver do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "supports attached images" do
|
it "supports attached images" do
|
||||||
|
SiteSetting.queue_jobs = true
|
||||||
|
|
||||||
expect { process(:no_body_with_image) }.to change { topic.posts.count }
|
expect { process(:no_body_with_image) }.to change { topic.posts.count }
|
||||||
expect(topic.posts.last.raw).to match(/<img/)
|
expect(topic.posts.last.raw).to match(/<img/)
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ LONG_COOKED
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'autolinks' do
|
it 'autolinks' do
|
||||||
|
stub_request(:get, "https://www.eviltrout.com").to_return(body: "")
|
||||||
expect(EmailCook.new("https://www.eviltrout.com").cook).to eq("<a href='https://www.eviltrout.com'>https://www.eviltrout.com</a><br>")
|
expect(EmailCook.new("https://www.eviltrout.com").cook).to eq("<a href='https://www.eviltrout.com'>https://www.eviltrout.com</a><br>")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ describe Onebox::Engine::DiscourseLocalOnebox do
|
||||||
|
|
||||||
it "returns nil if file type is not audio or video" do
|
it "returns nil if file type is not audio or video" do
|
||||||
url = "#{Discourse.base_url}#{path}.pdf"
|
url = "#{Discourse.base_url}#{path}.pdf"
|
||||||
FakeWeb.register_uri(:get, url, body: "")
|
stub_request(:get, url).to_return(body: '')
|
||||||
expect(Onebox.preview(url).to_s).to eq("")
|
expect(Onebox.preview(url).to_s).to eq("")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,10 @@ require_dependency 'oneboxer'
|
||||||
describe Oneboxer do
|
describe Oneboxer do
|
||||||
|
|
||||||
it "returns blank string for an invalid onebox" do
|
it "returns blank string for an invalid onebox" do
|
||||||
|
stub_request(:get, "http://boom.com").to_return(body: "")
|
||||||
|
|
||||||
expect(Oneboxer.preview("http://boom.com")).to eq("")
|
expect(Oneboxer.preview("http://boom.com")).to eq("")
|
||||||
expect(Oneboxer.onebox("http://boom.com")).to eq("")
|
expect(Oneboxer.onebox("http://boom.com")).to eq("")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -255,6 +255,8 @@ describe PostCreator do
|
||||||
it 'creates a post with featured link' do
|
it 'creates a post with featured link' do
|
||||||
SiteSetting.topic_featured_link_enabled = true
|
SiteSetting.topic_featured_link_enabled = true
|
||||||
SiteSetting.min_first_post_length = 100
|
SiteSetting.min_first_post_length = 100
|
||||||
|
SiteSetting.queue_jobs = true
|
||||||
|
|
||||||
post = creator_with_featured_link.create
|
post = creator_with_featured_link.create
|
||||||
expect(post.topic.featured_link).to eq('http://www.discourse.org')
|
expect(post.topic.featured_link).to eq('http://www.discourse.org')
|
||||||
expect(post.valid?).to eq(true)
|
expect(post.valid?).to eq(true)
|
||||||
|
@ -585,7 +587,7 @@ describe PostCreator do
|
||||||
|
|
||||||
it 'acts correctly' do
|
it 'acts correctly' do
|
||||||
# It's not a warning
|
# It's not a warning
|
||||||
expect(post.topic.warning).to be_blank
|
expect(post.topic.user_warning).to be_blank
|
||||||
|
|
||||||
expect(post.topic.archetype).to eq(Archetype.private_message)
|
expect(post.topic.archetype).to eq(Archetype.private_message)
|
||||||
expect(post.topic.subtype).to eq(TopicSubtype.user_to_user)
|
expect(post.topic.subtype).to eq(TopicSubtype.user_to_user)
|
||||||
|
@ -657,11 +659,11 @@ describe PostCreator do
|
||||||
|
|
||||||
topic = post.topic
|
topic = post.topic
|
||||||
expect(topic).to be_present
|
expect(topic).to be_present
|
||||||
expect(topic.warning).to be_present
|
expect(topic.user_warning).to be_present
|
||||||
expect(topic.subtype).to eq(TopicSubtype.moderator_warning)
|
expect(topic.subtype).to eq(TopicSubtype.moderator_warning)
|
||||||
expect(topic.warning.user).to eq(target_user1)
|
expect(topic.user_warning.user).to eq(target_user1)
|
||||||
expect(topic.warning.created_by).to eq(user)
|
expect(topic.user_warning.created_by).to eq(user)
|
||||||
expect(target_user1.warnings.count).to eq(1)
|
expect(target_user1.user_warnings.count).to eq(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ describe SiteSettingExtension do
|
||||||
settings.hello = 100
|
settings.hello = 100
|
||||||
expect(settings.hello).to eq(100)
|
expect(settings.hello).to eq(100)
|
||||||
|
|
||||||
settings.provider.save(:hello, 99, SiteSetting.types[:fixnum] )
|
settings.provider.save(:hello, 99, SiteSetting.types[:integer] )
|
||||||
settings.refresh!
|
settings.refresh!
|
||||||
|
|
||||||
expect(settings.hello).to eq(99)
|
expect(settings.hello).to eq(99)
|
||||||
|
@ -386,16 +386,6 @@ describe SiteSettingExtension do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "set for an invalid fixnum value" do
|
|
||||||
it "raises an error" do
|
|
||||||
settings.setting(:test_setting, 80)
|
|
||||||
settings.refresh!
|
|
||||||
expect {
|
|
||||||
settings.set("test_setting", 9999999999999999999)
|
|
||||||
}.to raise_error(ArgumentError)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "filter domain name" do
|
describe "filter domain name" do
|
||||||
before do
|
before do
|
||||||
settings.setting(:white_listed_spam_host_domains, "www.example.com")
|
settings.setting(:white_listed_spam_host_domains, "www.example.com")
|
||||||
|
|
|
@ -75,12 +75,12 @@ describe UploadsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is successful with synchronous api' do
|
it 'is successful with synchronous api' do
|
||||||
SiteSetting.stubs(:authorized_extensions).returns("*")
|
SiteSetting.authorized_extensions = "*"
|
||||||
controller.stubs(:is_api?).returns(true)
|
controller.stubs(:is_api?).returns(true)
|
||||||
|
|
||||||
Jobs.expects(:enqueue).with(:create_thumbnails, anything)
|
Jobs.expects(:enqueue).with(:create_thumbnails, anything)
|
||||||
|
|
||||||
FakeWeb.register_uri(:get, "http://example.com/image.png", :body => File.read('spec/fixtures/images/logo.png'))
|
stub_request(:get, "http://example.com/image.png").to_return(body: File.read('spec/fixtures/images/logo.png'))
|
||||||
|
|
||||||
xhr :post, :create, url: 'http://example.com/image.png', type: "avatar", synchronous: true
|
xhr :post, :create, url: 'http://example.com/image.png', type: "avatar", synchronous: true
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ describe UserAvatarsController do
|
||||||
SiteSetting.s3_upload_bucket = "test"
|
SiteSetting.s3_upload_bucket = "test"
|
||||||
SiteSetting.s3_cdn_url = "http://cdn.com"
|
SiteSetting.s3_cdn_url = "http://cdn.com"
|
||||||
|
|
||||||
FakeWeb.register_uri(:get, "http://cdn.com/something/else", :body => 'image')
|
stub_request(:get, "http://cdn.com/something/else").to_return(body: 'image')
|
||||||
|
|
||||||
GlobalSetting.expects(:cdn_url).returns("http://awesome.com/boom")
|
GlobalSetting.expects(:cdn_url).returns("http://awesome.com/boom")
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,9 @@ describe Jobs::PullHotlinkedImages do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
png = Base64.decode64("R0lGODlhAQABALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A/wD//wBiZCH5BAEAAA8ALAAAAAABAAEAAAQC8EUAOw==")
|
png = Base64.decode64("R0lGODlhAQABALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A/wD//wBiZCH5BAEAAA8ALAAAAAABAAEAAAQC8EUAOw==")
|
||||||
FakeWeb.register_uri(:get, "http://wiki.mozilla.org/images/2/2e/Longcat1.png", body: png)
|
stub_request(:get, "http://wiki.mozilla.org/images/2/2e/Longcat1.png").to_return(body: png)
|
||||||
SiteSetting.download_remote_images_to_local = true
|
SiteSetting.download_remote_images_to_local = true
|
||||||
|
FastImage.expects(:size).returns([100, 100]).at_least_once
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'replaces image src' do
|
it 'replaces image src' do
|
||||||
|
|
|
@ -8,7 +8,7 @@ describe Jobs::UpdateGravatar do
|
||||||
expect(user.user_avatar.gravatar_upload_id).to eq(nil)
|
expect(user.user_avatar.gravatar_upload_id).to eq(nil)
|
||||||
|
|
||||||
png = Base64.decode64("R0lGODlhAQABALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A/wD//wBiZCH5BAEAAA8ALAAAAAABAAEAAAQC8EUAOw==")
|
png = Base64.decode64("R0lGODlhAQABALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A/wD//wBiZCH5BAEAAA8ALAAAAAABAAEAAAQC8EUAOw==")
|
||||||
FakeWeb.register_uri(:get, "http://www.gravatar.com/avatar/d10ca8d11301c2f4993ac2279ce4b930.png?s=500&d=404", body: png)
|
stub_request(:get, "http://www.gravatar.com/avatar/d10ca8d11301c2f4993ac2279ce4b930.png?s=360&d=404").to_return(body: png)
|
||||||
|
|
||||||
SiteSetting.automatically_download_gravatars = true
|
SiteSetting.automatically_download_gravatars = true
|
||||||
|
|
||||||
|
|
|
@ -1155,6 +1155,7 @@ describe User do
|
||||||
describe "refresh_avatar" do
|
describe "refresh_avatar" do
|
||||||
it "enqueues the update_gravatar job when automatically downloading gravatars" do
|
it "enqueues the update_gravatar job when automatically downloading gravatars" do
|
||||||
SiteSetting.automatically_download_gravatars = true
|
SiteSetting.automatically_download_gravatars = true
|
||||||
|
SiteSetting.queue_jobs = true
|
||||||
|
|
||||||
user = Fabricate(:user)
|
user = Fabricate(:user)
|
||||||
|
|
||||||
|
|
|
@ -9,17 +9,14 @@ require 'rbtrace'
|
||||||
#uncomment the following line to use spork with the debugger
|
#uncomment the following line to use spork with the debugger
|
||||||
#require 'spork/ext/ruby-debug'
|
#require 'spork/ext/ruby-debug'
|
||||||
|
|
||||||
require 'fakeweb'
|
|
||||||
FakeWeb.allow_net_connect = false
|
|
||||||
|
|
||||||
Spork.prefork do
|
Spork.prefork do
|
||||||
# Loading more in this block will cause your tests to run faster. However,
|
# Loading more in this block will cause your tests to run faster. However,
|
||||||
# if you change any configuration or code from libraries loaded here, you'll
|
# if you change any configuration or code from libraries loaded here, you'll
|
||||||
# need to restart spork for it take effect.
|
# need to restart spork for it take effect.
|
||||||
require 'fabrication'
|
require 'fabrication'
|
||||||
require 'mocha/api'
|
require 'mocha/api'
|
||||||
require 'fakeweb'
|
|
||||||
require 'certified'
|
require 'certified'
|
||||||
|
require 'webmock/rspec'
|
||||||
|
|
||||||
ENV["RAILS_ENV"] ||= 'test'
|
ENV["RAILS_ENV"] ||= 'test'
|
||||||
require File.expand_path("../../config/environment", __FILE__)
|
require File.expand_path("../../config/environment", __FILE__)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user