mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 15:48:43 -05:00
Convert specs to RSpec 2.99.2 syntax with Transpec
This conversion is done by Transpec 3.1.0 with the following command: transpec * 424 conversions from: obj.should to: expect(obj).to * 325 conversions from: == expected to: eq(expected) * 38 conversions from: obj.should_not to: expect(obj).not_to * 15 conversions from: =~ /pattern/ to: match(/pattern/) * 9 conversions from: it { should ... } to: it { is_expected.to ... } * 5 conversions from: lambda { }.should_not to: expect { }.not_to * 4 conversions from: lambda { }.should to: expect { }.to * 2 conversions from: -> { }.should to: expect { }.to * 2 conversions from: -> { }.should_not to: expect { }.not_to * 1 conversion from: === expected to: be === expected * 1 conversion from: =~ [1, 2] to: match_array([1, 2]) For more details: https://github.com/yujinakayama/transpec#supported-conversions
This commit is contained in:
parent
84c65aeb60
commit
b8cbe51026
43 changed files with 492 additions and 492 deletions
|
@ -1609,11 +1609,11 @@ describe Guardian do
|
|||
end
|
||||
|
||||
it "is true for admin anonymizing a regular user" do
|
||||
Guardian.new(admin).can_anonymize_user?(user).should == true
|
||||
expect(Guardian.new(admin).can_anonymize_user?(user)).to eq(true)
|
||||
end
|
||||
|
||||
it "is true for moderator anonymizing a regular user" do
|
||||
Guardian.new(moderator).can_anonymize_user?(user).should == true
|
||||
expect(Guardian.new(moderator).can_anonymize_user?(user)).to eq(true)
|
||||
end
|
||||
|
||||
it "is false for admin anonymizing an admin" do
|
||||
|
|
|
@ -3,14 +3,14 @@ require_dependency 'highlight_js/highlight_js'
|
|||
|
||||
describe HighlightJs do
|
||||
it 'can list languages' do
|
||||
HighlightJs.languages.should include('thrift')
|
||||
expect(HighlightJs.languages).to include('thrift')
|
||||
end
|
||||
|
||||
it 'can generate a packed bundle' do
|
||||
bundle = HighlightJs.bundle(["thrift", "http"])
|
||||
bundle.should =~ /thrift/
|
||||
bundle.should =~ /http/
|
||||
bundle.should_not =~ /applescript/
|
||||
expect(bundle).to match(/thrift/)
|
||||
expect(bundle).to match(/http/)
|
||||
expect(bundle).not_to match(/applescript/)
|
||||
end
|
||||
|
||||
|
||||
|
@ -18,6 +18,6 @@ describe HighlightJs do
|
|||
version1 = HighlightJs.version("http|cpp")
|
||||
version2 = HighlightJs.version("rust|cpp|fake")
|
||||
|
||||
version1.should_not == version2
|
||||
expect(version1).not_to eq(version2)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,6 +10,6 @@ describe LetterAvatar do
|
|||
|
||||
LetterAvatar.cleanup_old
|
||||
|
||||
Dir.entries(File.dirname(path)).length.should == 3
|
||||
expect(Dir.entries(File.dirname(path)).length).to eq(3)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -33,7 +33,7 @@ describe Middleware::RequestTracker do
|
|||
log_tracked_view("0")
|
||||
ApplicationRequest.write_cache!
|
||||
|
||||
ApplicationRequest.page_view_anon.first.count.should == 2
|
||||
expect(ApplicationRequest.page_view_anon.first.count).to eq(2)
|
||||
end
|
||||
|
||||
it "can log requests correctly" do
|
||||
|
@ -52,11 +52,11 @@ describe Middleware::RequestTracker do
|
|||
|
||||
ApplicationRequest.write_cache!
|
||||
|
||||
ApplicationRequest.http_total.first.count.should == 2
|
||||
ApplicationRequest.http_2xx.first.count.should == 2
|
||||
expect(ApplicationRequest.http_total.first.count).to eq(2)
|
||||
expect(ApplicationRequest.http_2xx.first.count).to eq(2)
|
||||
|
||||
ApplicationRequest.page_view_anon.first.count.should == 1
|
||||
ApplicationRequest.page_view_crawler.first.count.should == 1
|
||||
expect(ApplicationRequest.page_view_anon.first.count).to eq(1)
|
||||
expect(ApplicationRequest.page_view_crawler.first.count).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,26 +15,26 @@ describe PostRevisor do
|
|||
}
|
||||
|
||||
it 'provides a guardian' do
|
||||
tc.guardian.should be_an_instance_of Guardian
|
||||
expect(tc.guardian).to be_an_instance_of Guardian
|
||||
end
|
||||
|
||||
it 'tracks changes properly' do
|
||||
tc.diff.should == {}
|
||||
expect(tc.diff).to eq({})
|
||||
|
||||
# it remembers changes we tell it to
|
||||
tc.record_change('height', '180cm', '170cm')
|
||||
tc.diff['height'].should == ['180cm', '170cm']
|
||||
expect(tc.diff['height']).to eq(['180cm', '170cm'])
|
||||
|
||||
# it works with arrays of values
|
||||
tc.record_change('colors', nil, ['red', 'blue'])
|
||||
tc.diff['colors'].should == [nil, ['red', 'blue']]
|
||||
expect(tc.diff['colors']).to eq([nil, ['red', 'blue']])
|
||||
|
||||
# it does not record changes to the same val
|
||||
tc.record_change('wat', 'js', 'js')
|
||||
tc.diff['wat'].should be_nil
|
||||
expect(tc.diff['wat']).to be_nil
|
||||
|
||||
tc.record_change('tags', ['a', 'b'], ['a', 'b'])
|
||||
tc.diff['tags'].should be_nil
|
||||
expect(tc.diff['tags']).to be_nil
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -51,9 +51,9 @@ describe PostRevisor do
|
|||
it 'allows the user to change it to a wiki' do
|
||||
pc = PostCreator.new(newuser, topic_id: topic.id, raw: 'this is a post that will become a wiki')
|
||||
post = pc.create
|
||||
post.revise(post.user, wiki: true).should be_truthy
|
||||
expect(post.revise(post.user, wiki: true)).to be_truthy
|
||||
post.reload
|
||||
post.wiki.should be_truthy
|
||||
expect(post.wiki).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -22,9 +22,9 @@ describe Search do
|
|||
end
|
||||
|
||||
it "should index correctly" do
|
||||
@indexed.should =~ /fun/
|
||||
@indexed.should =~ /sam/
|
||||
@indexed.should =~ /america/
|
||||
expect(@indexed).to match(/fun/)
|
||||
expect(@indexed).to match(/sam/)
|
||||
expect(@indexed).to match(/america/)
|
||||
|
||||
@topic.title = "harpi is the new title"
|
||||
@topic.save!
|
||||
|
@ -32,7 +32,7 @@ describe Search do
|
|||
|
||||
@indexed = @post.post_search_data.search_data
|
||||
|
||||
@indexed.should =~ /harpi/
|
||||
expect(@indexed).to match(/harpi/)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -43,8 +43,8 @@ describe Search do
|
|||
end
|
||||
|
||||
it "should pick up on data" do
|
||||
@indexed.should =~ /fred/
|
||||
@indexed.should =~ /jone/
|
||||
expect(@indexed).to match(/fred/)
|
||||
expect(@indexed).to match(/jone/)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -55,7 +55,7 @@ describe Search do
|
|||
end
|
||||
|
||||
it "should pick up on name" do
|
||||
@indexed.should =~ /america/
|
||||
expect(@indexed).to match(/america/)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -66,15 +66,15 @@ describe Search do
|
|||
end
|
||||
|
||||
it 'escapes non alphanumeric characters' do
|
||||
Search.execute('foo :!$);}]>@\#\"\'').posts.length.should == 0 # There are at least three levels of sanitation for Search.query!
|
||||
expect(Search.execute('foo :!$);}]>@\#\"\'').posts.length).to eq(0) # There are at least three levels of sanitation for Search.query!
|
||||
end
|
||||
|
||||
it "doesn't raise an error when single quotes are present" do
|
||||
Search.execute("'hello' world").posts.length.should == 0 # There are at least three levels of sanitation for Search.query!
|
||||
expect(Search.execute("'hello' world").posts.length).to eq(0) # There are at least three levels of sanitation for Search.query!
|
||||
end
|
||||
|
||||
it 'works when given two terms with spaces' do
|
||||
lambda { Search.execute('evil trout') }.should_not raise_error
|
||||
expect { Search.execute('evil trout') }.not_to raise_error
|
||||
end
|
||||
|
||||
context 'users' do
|
||||
|
@ -82,8 +82,8 @@ describe Search do
|
|||
let(:result) { Search.execute('bruce', type_filter: 'user') }
|
||||
|
||||
it 'returns a result' do
|
||||
result.users.length.should == 1
|
||||
result.users[0].id.should == user.id
|
||||
expect(result.users.length).to eq(1)
|
||||
expect(result.users[0].id).to eq(user.id)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -92,7 +92,7 @@ describe Search do
|
|||
let(:result) { Search.execute('bruce') }
|
||||
|
||||
it 'does not return a result' do
|
||||
result.users.length.should == 0
|
||||
expect(result.users.length).to eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -124,21 +124,21 @@ describe Search do
|
|||
type_filter: 'private_messages',
|
||||
guardian: Guardian.new(reply.user))
|
||||
|
||||
results.posts.length.should == 1
|
||||
expect(results.posts.length).to eq(1)
|
||||
|
||||
|
||||
results = Search.execute('mars',
|
||||
search_context: topic,
|
||||
guardian: Guardian.new(reply.user))
|
||||
|
||||
results.posts.length.should == 1
|
||||
expect(results.posts.length).to eq(1)
|
||||
|
||||
# does not leak out
|
||||
results = Search.execute('mars',
|
||||
type_filter: 'private_messages',
|
||||
guardian: Guardian.new(Fabricate(:user)))
|
||||
|
||||
results.posts.length.should == 0
|
||||
expect(results.posts.length).to eq(0)
|
||||
|
||||
Fabricate(:topic, category_id: nil, archetype: 'private_message')
|
||||
Fabricate(:post, topic: topic, raw: 'another secret pm from mars, testing')
|
||||
|
@ -150,7 +150,7 @@ describe Search do
|
|||
search_context: post.user,
|
||||
guardian: Guardian.new(Fabricate(:admin)))
|
||||
|
||||
results.posts.length.should == 1
|
||||
expect(results.posts.length).to eq(1)
|
||||
|
||||
end
|
||||
|
||||
|
@ -185,11 +185,11 @@ describe Search do
|
|||
topic.reload
|
||||
|
||||
results = Search.execute('posting', search_context: post1.topic)
|
||||
results.posts.map(&:id).should == [post1.id, post2.id, post3.id, post4.id]
|
||||
expect(results.posts.map(&:id)).to eq([post1.id, post2.id, post3.id, post4.id])
|
||||
|
||||
# stop words should work
|
||||
results = Search.execute('this', search_context: post1.topic)
|
||||
results.posts.length.should == 4
|
||||
expect(results.posts.length).to eq(4)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -198,8 +198,8 @@ describe Search do
|
|||
let(:result) { Search.execute('hundred', type_filter: 'topic', include_blurbs: true) }
|
||||
|
||||
it 'returns a result correctly' do
|
||||
result.posts.length.should == 1
|
||||
result.posts[0].id.should == post.id
|
||||
expect(result.posts.length).to eq(1)
|
||||
expect(result.posts[0].id).to eq(post.id)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -208,12 +208,12 @@ describe Search do
|
|||
let(:result) { Search.execute('quotes', type_filter: 'topic', include_blurbs: true) }
|
||||
|
||||
it 'returns the post' do
|
||||
result.should be_present
|
||||
result.posts.length.should == 1
|
||||
expect(result).to be_present
|
||||
expect(result.posts.length).to eq(1)
|
||||
p = result.posts[0]
|
||||
p.topic.id.should == topic.id
|
||||
p.id.should == reply.id
|
||||
result.blurb(p).should == "this reply has no quotes"
|
||||
expect(p.topic.id).to eq(topic.id)
|
||||
expect(p.id).to eq(reply.id)
|
||||
expect(result.blurb(p)).to eq("this reply has no quotes")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -221,8 +221,8 @@ describe Search do
|
|||
let(:result) { Search.execute(topic.id, type_filter: 'topic', search_for_id: true, min_search_term_length: 1) }
|
||||
|
||||
it 'returns the topic' do
|
||||
result.posts.length.should == 1
|
||||
result.posts.first.id.should == post.id
|
||||
expect(result.posts.length).to eq(1)
|
||||
expect(result.posts.first.id).to eq(post.id)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -230,8 +230,8 @@ describe Search do
|
|||
let(:result) { Search.execute(topic.relative_url, search_for_id: true, type_filter: 'topic')}
|
||||
|
||||
it 'returns the topic' do
|
||||
result.posts.length.should == 1
|
||||
result.posts.first.id.should == post.id
|
||||
expect(result.posts.length).to eq(1)
|
||||
expect(result.posts.first.id).to eq(post.id)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -250,9 +250,9 @@ describe Search do
|
|||
category.set_permissions(:staff => :full)
|
||||
category.save
|
||||
|
||||
result(nil).posts.should_not be_present
|
||||
result(Fabricate(:user)).posts.should_not be_present
|
||||
result(Fabricate(:admin)).posts.should be_present
|
||||
expect(result(nil).posts).not_to be_present
|
||||
expect(result(Fabricate(:user)).posts).not_to be_present
|
||||
expect(result(Fabricate(:admin)).posts).to be_present
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -269,7 +269,7 @@ describe Search do
|
|||
let(:result) { Search.execute('запись') }
|
||||
|
||||
it 'finds something when given cyrillic query' do
|
||||
result.posts.should be_present
|
||||
expect(result.posts).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -281,12 +281,12 @@ describe Search do
|
|||
end
|
||||
|
||||
it 'returns the correct result' do
|
||||
search.categories.should be_present
|
||||
expect(search.categories).to be_present
|
||||
|
||||
category.set_permissions({})
|
||||
category.save
|
||||
|
||||
search.categories.should_not be_present
|
||||
expect(search.categories).not_to be_present
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -302,9 +302,9 @@ describe Search do
|
|||
let(:results) { Search.execute('amazing', type_filter: 'user') }
|
||||
|
||||
it "returns a user result" do
|
||||
results.categories.length.should == 0
|
||||
results.posts.length.should == 0
|
||||
results.users.length.should == 1
|
||||
expect(results.categories.length).to eq(0)
|
||||
expect(results.posts.length).to eq(0)
|
||||
expect(results.users.length).to eq(1)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -313,9 +313,9 @@ describe Search do
|
|||
let(:results) { Search.execute('amazing', type_filter: 'category') }
|
||||
|
||||
it "returns a category result" do
|
||||
results.categories.length.should == 1
|
||||
results.posts.length.should == 0
|
||||
results.users.length.should == 0
|
||||
expect(results.categories.length).to eq(1)
|
||||
expect(results.posts.length).to eq(0)
|
||||
expect(results.users.length).to eq(0)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -334,7 +334,7 @@ describe Search do
|
|||
result = Search.execute('hello', search_context: post.user)
|
||||
|
||||
result.posts.first.topic_id = post.topic_id
|
||||
result.posts.length.should == 1
|
||||
expect(result.posts.length).to eq(1)
|
||||
end
|
||||
|
||||
it 'can use category as a search context' do
|
||||
|
@ -346,8 +346,8 @@ describe Search do
|
|||
_another_post = Fabricate(:post, topic: topic_no_cat, user: topic.user )
|
||||
|
||||
search = Search.execute('hello', search_context: category)
|
||||
search.posts.length.should == 1
|
||||
search.posts.first.id.should == post.id
|
||||
expect(search.posts.length).to eq(1)
|
||||
expect(search.posts.first.id).to eq(post.id)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -356,7 +356,7 @@ describe Search do
|
|||
it 'splits English / Chinese' do
|
||||
SiteSetting.default_locale = 'zh_CN'
|
||||
data = Search.prepare_data('Discourse社区指南').split(' ')
|
||||
data.should == ['Discourse', '社区','指南']
|
||||
expect(data).to eq(['Discourse', '社区','指南'])
|
||||
end
|
||||
|
||||
it 'finds chinese topic based on title' do
|
||||
|
@ -366,8 +366,8 @@ describe Search do
|
|||
topic = Fabricate(:topic, title: 'My Title Discourse社區指南')
|
||||
post = Fabricate(:post, topic: topic)
|
||||
|
||||
Search.execute('社區指南').posts.first.id.should == post.id
|
||||
Search.execute('指南').posts.first.id.should == post.id
|
||||
expect(Search.execute('社區指南').posts.first.id).to eq(post.id)
|
||||
expect(Search.execute('指南').posts.first.id).to eq(post.id)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -376,31 +376,31 @@ describe Search do
|
|||
post = Fabricate(:post, raw: 'hi this is a test 123 123')
|
||||
topic = post.topic
|
||||
|
||||
Search.execute('test status:closed').posts.length.should == 0
|
||||
Search.execute('test status:open').posts.length.should == 1
|
||||
expect(Search.execute('test status:closed').posts.length).to eq(0)
|
||||
expect(Search.execute('test status:open').posts.length).to eq(1)
|
||||
|
||||
topic.closed = true
|
||||
topic.save
|
||||
|
||||
Search.execute('test status:closed').posts.length.should == 1
|
||||
Search.execute('test status:open').posts.length.should == 0
|
||||
expect(Search.execute('test status:closed').posts.length).to eq(1)
|
||||
expect(Search.execute('test status:open').posts.length).to eq(0)
|
||||
|
||||
topic.archived = true
|
||||
topic.closed = false
|
||||
topic.save
|
||||
|
||||
Search.execute('test status:archived').posts.length.should == 1
|
||||
Search.execute('test status:open').posts.length.should == 0
|
||||
expect(Search.execute('test status:archived').posts.length).to eq(1)
|
||||
expect(Search.execute('test status:open').posts.length).to eq(0)
|
||||
|
||||
Search.execute('test status:noreplies').posts.length.should == 1
|
||||
expect(Search.execute('test status:noreplies').posts.length).to eq(1)
|
||||
|
||||
Search.execute('test in:likes', guardian: Guardian.new(topic.user)).posts.length.should == 0
|
||||
expect(Search.execute('test in:likes', guardian: Guardian.new(topic.user)).posts.length).to eq(0)
|
||||
|
||||
Search.execute('test in:posted', guardian: Guardian.new(topic.user)).posts.length.should == 1
|
||||
expect(Search.execute('test in:posted', guardian: Guardian.new(topic.user)).posts.length).to eq(1)
|
||||
|
||||
TopicUser.change(topic.user.id, topic.id, notification_level: TopicUser.notification_levels[:tracking])
|
||||
Search.execute('test in:watching', guardian: Guardian.new(topic.user)).posts.length.should == 0
|
||||
Search.execute('test in:tracking', guardian: Guardian.new(topic.user)).posts.length.should == 1
|
||||
expect(Search.execute('test in:watching', guardian: Guardian.new(topic.user)).posts.length).to eq(0)
|
||||
expect(Search.execute('test in:tracking', guardian: Guardian.new(topic.user)).posts.length).to eq(1)
|
||||
|
||||
end
|
||||
|
||||
|
@ -410,8 +410,8 @@ describe Search do
|
|||
|
||||
post2 = Fabricate(:post, raw: 'that Sam I am, that Sam I am')
|
||||
|
||||
Search.execute('sam').posts.map(&:id).should == [post1.id, post2.id]
|
||||
Search.execute('sam order:latest').posts.map(&:id).should == [post2.id, post1.id]
|
||||
expect(Search.execute('sam').posts.map(&:id)).to eq([post1.id, post2.id])
|
||||
expect(Search.execute('sam order:latest').posts.map(&:id)).to eq([post2.id, post1.id])
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -33,24 +33,24 @@ describe SiteSettingExtension do
|
|||
it "will reset to default if provider vanishes" do
|
||||
settings.setting(:hello, 1)
|
||||
settings.hello = 100
|
||||
settings.hello.should == 100
|
||||
expect(settings.hello).to eq(100)
|
||||
|
||||
settings.provider.clear
|
||||
settings.refresh!
|
||||
|
||||
settings.hello.should == 1
|
||||
expect(settings.hello).to eq(1)
|
||||
end
|
||||
|
||||
it "will set to new value if provider changes" do
|
||||
|
||||
settings.setting(:hello, 1)
|
||||
settings.hello = 100
|
||||
settings.hello.should == 100
|
||||
expect(settings.hello).to eq(100)
|
||||
|
||||
settings.provider.save(:hello, 99, SiteSetting.types[:fixnum] )
|
||||
settings.refresh!
|
||||
|
||||
settings.hello.should == 99
|
||||
expect(settings.hello).to eq(99)
|
||||
end
|
||||
|
||||
it "Publishes changes cross sites" do
|
||||
|
@ -60,12 +60,12 @@ describe SiteSettingExtension do
|
|||
settings.hello = 100
|
||||
|
||||
settings2.refresh!
|
||||
settings2.hello.should == 100
|
||||
expect(settings2.hello).to eq(100)
|
||||
|
||||
settings.hello = 99
|
||||
|
||||
settings2.refresh!
|
||||
settings2.hello.should == 99
|
||||
expect(settings2.hello).to eq(99)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -75,7 +75,7 @@ describe SiteSettingExtension do
|
|||
settings.setting(:hello, 1)
|
||||
settings.hello = 100
|
||||
settings.provider.current_site = "boom"
|
||||
settings.hello.should == 1
|
||||
expect(settings.hello).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -86,16 +86,16 @@ describe SiteSettingExtension do
|
|||
end
|
||||
|
||||
it "should have a key in all_settings" do
|
||||
settings.all_settings.detect {|s| s[:setting] == :test_setting }.should be_present
|
||||
expect(settings.all_settings.detect {|s| s[:setting] == :test_setting }).to be_present
|
||||
end
|
||||
|
||||
it "should have the correct desc" do
|
||||
I18n.expects(:t).with("site_settings.test_setting").returns("test description")
|
||||
settings.description(:test_setting).should == "test description"
|
||||
expect(settings.description(:test_setting)).to eq("test description")
|
||||
end
|
||||
|
||||
it "should have the correct default" do
|
||||
settings.test_setting.should == 77
|
||||
expect(settings.test_setting).to eq(77)
|
||||
end
|
||||
|
||||
context "when overidden" do
|
||||
|
@ -105,29 +105,29 @@ describe SiteSettingExtension do
|
|||
|
||||
it "should have the correct override" do
|
||||
settings.test_setting = 100
|
||||
settings.test_setting.should == 100
|
||||
expect(settings.test_setting).to eq(100)
|
||||
end
|
||||
|
||||
it "should coerce correct string to int" do
|
||||
settings.test_setting = "101"
|
||||
settings.test_setting.should.eql? 101
|
||||
expect(settings.test_setting).to.eql? 101
|
||||
end
|
||||
|
||||
it "should coerce incorrect string to 0" do
|
||||
settings.test_setting = "pie"
|
||||
settings.test_setting.should.eql? 0
|
||||
expect(settings.test_setting).to.eql? 0
|
||||
end
|
||||
|
||||
it "should not set default when reset" do
|
||||
settings.test_setting = 100
|
||||
settings.setting(:test_setting, 77)
|
||||
settings.refresh!
|
||||
settings.test_setting.should_not == 77
|
||||
expect(settings.test_setting).not_to eq(77)
|
||||
end
|
||||
|
||||
it "can be overridden with set" do
|
||||
settings.set("test_setting", 12)
|
||||
settings.test_setting.should == 12
|
||||
expect(settings.test_setting).to eq(12)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -148,7 +148,7 @@ describe SiteSettingExtension do
|
|||
end
|
||||
|
||||
it "should have the correct default" do
|
||||
settings.test_str.should == "str"
|
||||
expect(settings.test_str).to eq("str")
|
||||
end
|
||||
|
||||
context "when overridden" do
|
||||
|
@ -158,12 +158,12 @@ describe SiteSettingExtension do
|
|||
|
||||
it "should coerce int to string" do
|
||||
settings.test_str = 100
|
||||
settings.test_str.should.eql? "100"
|
||||
expect(settings.test_str).to.eql? "100"
|
||||
end
|
||||
|
||||
it "can be overridden with set" do
|
||||
settings.set("test_str", "hi")
|
||||
settings.test_str.should == "hi"
|
||||
expect(settings.test_str).to eq("hi")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -180,7 +180,7 @@ describe SiteSettingExtension do
|
|||
message = e.message
|
||||
end
|
||||
|
||||
message.should =~ /oops/
|
||||
expect(message).to match(/oops/)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -191,7 +191,7 @@ describe SiteSettingExtension do
|
|||
end
|
||||
|
||||
it "should have the correct default" do
|
||||
settings.test_hello?.should == false
|
||||
expect(settings.test_hello?).to eq(false)
|
||||
end
|
||||
|
||||
context "when overridden" do
|
||||
|
@ -201,29 +201,29 @@ describe SiteSettingExtension do
|
|||
|
||||
it "should have the correct override" do
|
||||
settings.test_hello = true
|
||||
settings.test_hello?.should == true
|
||||
expect(settings.test_hello?).to eq(true)
|
||||
end
|
||||
|
||||
it "should coerce true strings to true" do
|
||||
settings.test_hello = "true"
|
||||
settings.test_hello?.should.eql? true
|
||||
expect(settings.test_hello?).to.eql? true
|
||||
end
|
||||
|
||||
it "should coerce all other strings to false" do
|
||||
settings.test_hello = "f"
|
||||
settings.test_hello?.should.eql? false
|
||||
expect(settings.test_hello?).to.eql? false
|
||||
end
|
||||
|
||||
it "should not set default when reset" do
|
||||
settings.test_hello = true
|
||||
settings.setting(:test_hello?, false)
|
||||
settings.refresh!
|
||||
settings.test_hello?.should_not == false
|
||||
expect(settings.test_hello?).not_to eq(false)
|
||||
end
|
||||
|
||||
it "can be overridden with set" do
|
||||
settings.set("test_hello", true)
|
||||
settings.test_hello?.should == true
|
||||
expect(settings.test_hello?).to eq(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -256,7 +256,7 @@ describe SiteSettingExtension do
|
|||
end
|
||||
|
||||
it 'should not hose all_settings' do
|
||||
settings.all_settings.detect {|s| s[:setting] == :test_enum }.should be_present
|
||||
expect(settings.all_settings.detect {|s| s[:setting] == :test_enum }).to be_present
|
||||
end
|
||||
|
||||
context 'when overridden' do
|
||||
|
@ -284,7 +284,7 @@ describe SiteSettingExtension do
|
|||
end
|
||||
|
||||
it "should return the category in all_settings" do
|
||||
settings.all_settings.find {|s| s[:setting] == :test_setting }[:category].should == :tests
|
||||
expect(settings.all_settings.find {|s| s[:setting] == :test_setting }[:category]).to eq(:tests)
|
||||
end
|
||||
|
||||
context "when overidden" do
|
||||
|
@ -294,12 +294,12 @@ describe SiteSettingExtension do
|
|||
|
||||
it "should have the correct override" do
|
||||
settings.test_setting = 101
|
||||
settings.test_setting.should == 101
|
||||
expect(settings.test_setting).to eq(101)
|
||||
end
|
||||
|
||||
it "should still have the correct category" do
|
||||
settings.test_setting = 102
|
||||
settings.all_settings.find {|s| s[:setting] == :test_setting }[:category].should == :tests
|
||||
expect(settings.all_settings.find {|s| s[:setting] == :test_setting }[:category]).to eq(:tests)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -317,7 +317,7 @@ describe SiteSettingExtension do
|
|||
it "stores valid values" do
|
||||
EmailSettingValidator.any_instance.expects(:valid_value?).returns(true)
|
||||
settings.validated_setting = 'success@example.com'
|
||||
settings.validated_setting.should == 'success@example.com'
|
||||
expect(settings.validated_setting).to eq('success@example.com')
|
||||
end
|
||||
|
||||
it "rejects invalid values" do
|
||||
|
@ -325,12 +325,12 @@ describe SiteSettingExtension do
|
|||
EmailSettingValidator.any_instance.expects(:valid_value?).returns(false)
|
||||
settings.validated_setting = 'nope'
|
||||
}.to raise_error(Discourse::InvalidParameters)
|
||||
settings.validated_setting.should == "info@example.com"
|
||||
expect(settings.validated_setting).to eq("info@example.com")
|
||||
end
|
||||
|
||||
it "allows blank values" do
|
||||
settings.validated_setting = ''
|
||||
settings.validated_setting.should == ''
|
||||
expect(settings.validated_setting).to eq('')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -362,12 +362,12 @@ describe SiteSettingExtension do
|
|||
|
||||
it "filters domain" do
|
||||
settings.set("white_listed_spam_host_domains", "http://www.discourse.org/")
|
||||
settings.white_listed_spam_host_domains.should == "www.discourse.org"
|
||||
expect(settings.white_listed_spam_host_domains).to eq("www.discourse.org")
|
||||
end
|
||||
|
||||
it "returns invalid domain as is, without throwing exception" do
|
||||
settings.set("white_listed_spam_host_domains", "test!url")
|
||||
settings.white_listed_spam_host_domains.should == "test!url"
|
||||
expect(settings.white_listed_spam_host_domains).to eq("test!url")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -378,19 +378,19 @@ describe SiteSettingExtension do
|
|||
end
|
||||
|
||||
it "is in the `hidden_settings` collection" do
|
||||
settings.hidden_settings.include?(:superman_identity).should == true
|
||||
expect(settings.hidden_settings.include?(:superman_identity)).to eq(true)
|
||||
end
|
||||
|
||||
it "can be retrieved" do
|
||||
settings.superman_identity.should == "Clark Kent"
|
||||
expect(settings.superman_identity).to eq("Clark Kent")
|
||||
end
|
||||
|
||||
it "is not present in all_settings by default" do
|
||||
settings.all_settings.find {|s| s[:setting] == :superman_identity }.should be_blank
|
||||
expect(settings.all_settings.find {|s| s[:setting] == :superman_identity }).to be_blank
|
||||
end
|
||||
|
||||
it "is present in all_settings when we ask for hidden" do
|
||||
settings.all_settings(true).find {|s| s[:setting] == :superman_identity }.should be_present
|
||||
expect(settings.all_settings(true).find {|s| s[:setting] == :superman_identity }).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -402,17 +402,17 @@ describe SiteSettingExtension do
|
|||
end
|
||||
|
||||
it "should not add the key to the shadowed_settings collection" do
|
||||
settings.shadowed_settings.include?(:trout_api_key).should == false
|
||||
expect(settings.shadowed_settings.include?(:trout_api_key)).to eq(false)
|
||||
end
|
||||
|
||||
it "can return the default value" do
|
||||
settings.trout_api_key.should == 'evil'
|
||||
expect(settings.trout_api_key).to eq('evil')
|
||||
end
|
||||
|
||||
it "can overwrite the default" do
|
||||
settings.trout_api_key = 'tophat'
|
||||
settings.refresh!
|
||||
settings.trout_api_key.should == 'tophat'
|
||||
expect(settings.trout_api_key).to eq('tophat')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -424,16 +424,16 @@ describe SiteSettingExtension do
|
|||
end
|
||||
|
||||
it "should return the global setting instead of default" do
|
||||
settings.trout_api_key.should == 'purringcat'
|
||||
expect(settings.trout_api_key).to eq('purringcat')
|
||||
end
|
||||
|
||||
it "should return the global setting after a refresh" do
|
||||
settings.refresh!
|
||||
settings.trout_api_key.should == 'purringcat'
|
||||
expect(settings.trout_api_key).to eq('purringcat')
|
||||
end
|
||||
|
||||
it "should add the key to the shadowed_settings collection" do
|
||||
settings.shadowed_settings.include?(:trout_api_key).should == true
|
||||
expect(settings.shadowed_settings.include?(:trout_api_key)).to eq(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,8 +11,8 @@ describe Admin::PluginsController do
|
|||
|
||||
it 'should return JSON' do
|
||||
xhr :get, :index
|
||||
response.should be_success
|
||||
::JSON.parse(response.body).has_key?('plugins').should == true
|
||||
expect(response).to be_success
|
||||
expect(::JSON.parse(response.body).has_key?('plugins')).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -3,12 +3,12 @@ require 'spec_helper'
|
|||
describe DirectoryItemsController do
|
||||
|
||||
it "requires a `period` param" do
|
||||
->{ xhr :get, :index }.should raise_error
|
||||
expect{ xhr :get, :index }.to raise_error
|
||||
end
|
||||
|
||||
it "requires a proper `period` param" do
|
||||
xhr :get, :index, period: 'eviltrout'
|
||||
response.should_not be_success
|
||||
expect(response).not_to be_success
|
||||
end
|
||||
|
||||
|
||||
|
@ -19,7 +19,7 @@ describe DirectoryItemsController do
|
|||
|
||||
it "succeeds" do
|
||||
xhr :get, :index, period: 'all'
|
||||
response.should be_success
|
||||
expect(response).to be_success
|
||||
json = ::JSON.parse(response.body)
|
||||
end
|
||||
end
|
||||
|
@ -35,20 +35,20 @@ describe DirectoryItemsController do
|
|||
|
||||
it "succeeds with a valid value" do
|
||||
xhr :get, :index, period: 'all'
|
||||
response.should be_success
|
||||
expect(response).to be_success
|
||||
json = ::JSON.parse(response.body)
|
||||
|
||||
json.should be_present
|
||||
json['directory_items'].should be_present
|
||||
json['total_rows_directory_items'].should be_present
|
||||
json['load_more_directory_items'].should be_present
|
||||
expect(json).to be_present
|
||||
expect(json['directory_items']).to be_present
|
||||
expect(json['total_rows_directory_items']).to be_present
|
||||
expect(json['load_more_directory_items']).to be_present
|
||||
end
|
||||
|
||||
it "fails when the directory is disabled" do
|
||||
SiteSetting.enable_user_directory = false
|
||||
|
||||
xhr :get, :index, period: 'all'
|
||||
response.should_not be_success
|
||||
expect(response).not_to be_success
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -91,10 +91,10 @@ describe GroupsController do
|
|||
Guardian.any_instance.stubs(:can_edit?).with(group).returns(false)
|
||||
|
||||
xhr :put, :add_members, group_id: group.name, usernames: "bob"
|
||||
response.should be_forbidden
|
||||
expect(response).to be_forbidden
|
||||
|
||||
xhr :delete, :remove_member, group_id: group.name, username: "bob"
|
||||
response.should be_forbidden
|
||||
expect(response).to be_forbidden
|
||||
end
|
||||
|
||||
it "cannot add members to automatic groups" do
|
||||
|
@ -102,7 +102,7 @@ describe GroupsController do
|
|||
auto_group = Fabricate(:group, name: "auto_group", automatic: true)
|
||||
|
||||
xhr :put, :add_members, group_id: group.name, usernames: "bob"
|
||||
response.should be_forbidden
|
||||
expect(response).to be_forbidden
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -119,42 +119,42 @@ describe GroupsController do
|
|||
user2 = Fabricate(:user)
|
||||
xhr :put, :add_members, group_id: group.name, usernames: user2.username
|
||||
|
||||
response.should be_success
|
||||
expect(response).to be_success
|
||||
group.reload
|
||||
group.users.count.should eq(2)
|
||||
expect(group.users.count).to eq(2)
|
||||
end
|
||||
|
||||
it "succeeds silently when adding non-existent users" do
|
||||
xhr :put, :add_members, group_id: group.name, usernames: "nosuchperson"
|
||||
|
||||
response.should be_success
|
||||
expect(response).to be_success
|
||||
group.reload
|
||||
group.users.count.should eq(1)
|
||||
expect(group.users.count).to eq(1)
|
||||
end
|
||||
|
||||
it "succeeds silently when adding duplicate users" do
|
||||
xhr :put, :add_members, group_id: group.name, usernames: @user1.username
|
||||
|
||||
response.should be_success
|
||||
expect(response).to be_success
|
||||
group.reload
|
||||
group.users.should eq([@user1])
|
||||
expect(group.users).to eq([@user1])
|
||||
end
|
||||
|
||||
it "can make incremental deletes" do
|
||||
xhr :delete, :remove_member, group_id: group.name, username: @user1.username
|
||||
|
||||
response.should be_success
|
||||
expect(response).to be_success
|
||||
group.reload
|
||||
group.users.count.should eq(0)
|
||||
expect(group.users.count).to eq(0)
|
||||
end
|
||||
|
||||
it "succeeds silently when removing non-members" do
|
||||
user2 = Fabricate(:user)
|
||||
xhr :delete, :remove_member, group_id: group.name, username: user2.username
|
||||
|
||||
response.should be_success
|
||||
expect(response).to be_success
|
||||
group.reload
|
||||
group.users.count.should eq(1)
|
||||
expect(group.users.count).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -851,8 +851,8 @@ describe PostsController do
|
|||
it "can be viewed by anonymous" do
|
||||
post = Fabricate(:post, raw: "123456789")
|
||||
xhr :get, :markdown_id, id: post.id
|
||||
response.should be_success
|
||||
response.body.should == "123456789"
|
||||
expect(response).to be_success
|
||||
expect(response.body).to eq("123456789")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -862,8 +862,8 @@ describe PostsController do
|
|||
post = Fabricate(:post, topic: topic, post_number: 1, raw: "123456789")
|
||||
post.save
|
||||
xhr :get, :markdown_num, topic_id: topic.id, post_number: 1
|
||||
response.should be_success
|
||||
response.body.should == "123456789"
|
||||
expect(response).to be_success
|
||||
expect(response.body).to eq("123456789")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -874,13 +874,13 @@ describe PostsController do
|
|||
|
||||
it "redirects to the topic" do
|
||||
xhr :get, :short_link, post_id: post.id
|
||||
response.should be_redirect
|
||||
expect(response).to be_redirect
|
||||
end
|
||||
|
||||
it "returns a 403 when access is denied" do
|
||||
Guardian.any_instance.stubs(:can_see?).returns(false)
|
||||
xhr :get, :short_link, post_id: post.id
|
||||
response.should be_forbidden
|
||||
expect(response).to be_forbidden
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -967,10 +967,10 @@ describe TopicsController do
|
|||
PostAction.act(user, post2, bookmark)
|
||||
|
||||
xhr :put, :bookmark, topic_id: post.topic_id
|
||||
PostAction.where(user_id: user.id, post_action_type: bookmark).count.should == 2
|
||||
expect(PostAction.where(user_id: user.id, post_action_type: bookmark).count).to eq(2)
|
||||
|
||||
xhr :put, :remove_bookmarks, topic_id: post.topic_id
|
||||
PostAction.where(user_id: user.id, post_action_type: bookmark).count.should == 0
|
||||
expect(PostAction.where(user_id: user.id, post_action_type: bookmark).count).to eq(0)
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -674,48 +674,48 @@ describe UsersController do
|
|||
|
||||
it 'raises an error without a new_username param' do
|
||||
expect { xhr :put, :username, username: user.username }.to raise_error(ActionController::ParameterMissing)
|
||||
user.reload.username.should == old_username
|
||||
expect(user.reload.username).to eq(old_username)
|
||||
end
|
||||
|
||||
it 'raises an error when you don\'t have permission to change the username' do
|
||||
Guardian.any_instance.expects(:can_edit_username?).with(user).returns(false)
|
||||
xhr :put, :username, username: user.username, new_username: new_username
|
||||
expect(response).to be_forbidden
|
||||
user.reload.username.should == old_username
|
||||
expect(user.reload.username).to eq(old_username)
|
||||
end
|
||||
|
||||
# Bad behavior, this should give a real JSON error, not an InvalidParameters
|
||||
it 'raises an error when change_username fails' do
|
||||
User.any_instance.expects(:save).returns(false)
|
||||
expect { xhr :put, :username, username: user.username, new_username: new_username }.to raise_error(Discourse::InvalidParameters)
|
||||
user.reload.username.should == old_username
|
||||
expect(user.reload.username).to eq(old_username)
|
||||
end
|
||||
|
||||
it 'should succeed in normal circumstances' do
|
||||
xhr :put, :username, username: user.username, new_username: new_username
|
||||
response.should be_success
|
||||
user.reload.username.should == new_username
|
||||
expect(response).to be_success
|
||||
expect(user.reload.username).to eq(new_username)
|
||||
end
|
||||
|
||||
skip 'should fail if the user is old', 'ensure_can_edit_username! is not throwing' do
|
||||
# Older than the change period and >1 post
|
||||
user.created_at = Time.now - (SiteSetting.username_change_period + 1).days
|
||||
user.stubs(:post_count).returns(200)
|
||||
Guardian.new(user).can_edit_username?(user).should == false
|
||||
expect(Guardian.new(user).can_edit_username?(user)).to eq(false)
|
||||
|
||||
xhr :put, :username, username: user.username, new_username: new_username
|
||||
|
||||
response.should be_forbidden
|
||||
user.reload.username.should == old_username
|
||||
expect(response).to be_forbidden
|
||||
expect(user.reload.username).to eq(old_username)
|
||||
end
|
||||
|
||||
it 'should create a staff action log when a staff member changes the username' do
|
||||
acting_user = Fabricate(:admin)
|
||||
log_in_user(acting_user)
|
||||
xhr :put, :username, username: user.username, new_username: new_username
|
||||
response.should be_success
|
||||
UserHistory.where(action: UserHistory.actions[:change_username], target_user_id: user.id, acting_user_id: acting_user.id).should be_present
|
||||
user.reload.username.should == new_username
|
||||
expect(response).to be_success
|
||||
expect(UserHistory.where(action: UserHistory.actions[:change_username], target_user_id: user.id, acting_user_id: acting_user.id)).to be_present
|
||||
expect(user.reload.username).to eq(new_username)
|
||||
end
|
||||
|
||||
it 'should return a JSON response with the updated username' do
|
||||
|
|
|
@ -21,7 +21,7 @@ describe 'invite only' do
|
|||
api_username: admin.username
|
||||
|
||||
user_id = JSON.parse(response.body)["user_id"]
|
||||
user_id.should be > 0
|
||||
expect(user_id).to be > 0
|
||||
|
||||
# activate and approve
|
||||
xhr :put, "/admin/users/#{user_id}/activate",
|
||||
|
@ -33,8 +33,8 @@ describe 'invite only' do
|
|||
api_username: admin.username
|
||||
|
||||
u = User.find(user_id)
|
||||
u.active.should == true
|
||||
u.approved.should == true
|
||||
expect(u.active).to eq(true)
|
||||
expect(u.approved).to eq(true)
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,8 +14,8 @@ describe SpamRulesEnforcer do
|
|||
Given!(:first_post) { create_post(user: spammer1) }
|
||||
Given!(:second_post) { create_post(user: spammer2, topic: first_post.topic) }
|
||||
|
||||
Then { first_post.reload.spam_count.should == 0 }
|
||||
And { second_post.reload.spam_count.should == 0 }
|
||||
Then { expect(first_post.reload.spam_count).to eq(0) }
|
||||
And { expect(second_post.reload.spam_count).to eq(0) }
|
||||
end
|
||||
|
||||
context 'flag_sockpuppets is enabled' do
|
||||
|
@ -27,15 +27,15 @@ describe SpamRulesEnforcer do
|
|||
context 'second spammer replies' do
|
||||
Given!(:second_post) { create_post(user: spammer2, topic: first_post.topic) }
|
||||
|
||||
Then { first_post.reload.spam_count.should == 1 }
|
||||
And { second_post.reload.spam_count.should == 1 }
|
||||
Then { expect(first_post.reload.spam_count).to eq(1) }
|
||||
And { expect(second_post.reload.spam_count).to eq(1) }
|
||||
|
||||
context 'third spam post' do
|
||||
Given!(:third_post) { create_post(user: spammer3, topic: first_post.topic) }
|
||||
|
||||
Then { first_post.reload.spam_count.should == 1 }
|
||||
And { second_post.reload.spam_count.should == 1 }
|
||||
And { third_post.reload.spam_count.should == 1 }
|
||||
Then { expect(first_post.reload.spam_count).to eq(1) }
|
||||
And { expect(second_post.reload.spam_count).to eq(1) }
|
||||
And { expect(third_post.reload.spam_count).to eq(1) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -49,8 +49,8 @@ describe SpamRulesEnforcer do
|
|||
context 'a reply by a new user at the same IP address' do
|
||||
Given!(:second_post) { create_post(user: spammer2, topic: first_post.topic) }
|
||||
|
||||
Then { first_post.reload.spam_count.should == 0 }
|
||||
And { second_post.reload.spam_count.should == 1 }
|
||||
Then { expect(first_post.reload.spam_count).to eq(0) }
|
||||
And { expect(second_post.reload.spam_count).to eq(1) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -41,7 +41,7 @@ describe SpamRulesEnforcer do
|
|||
|
||||
Invariant { expect(Guardian.new(spammer).can_create_topic?(nil)).to be false }
|
||||
Invariant { expect{PostCreator.create(spammer, {title: 'limited time offer for you', raw: 'better buy this stuff ok', archetype_id: 1})}.to raise_error(Discourse::InvalidAccess) }
|
||||
Invariant { PostCreator.create(spammer, {topic_id: another_topic.id, raw: 'my reply is spam in your topic', archetype_id: 1}).should == nil }
|
||||
Invariant { expect(PostCreator.create(spammer, {topic_id: another_topic.id, raw: 'my reply is spam in your topic', archetype_id: 1})).to eq(nil) }
|
||||
|
||||
Then { expect(spammer.reload).to be_blocked }
|
||||
And { expect(spam_post.reload).to be_hidden }
|
||||
|
|
|
@ -29,14 +29,14 @@ describe Topic do
|
|||
|
||||
context 'uncategorized' do
|
||||
Given(:category) { nil }
|
||||
Then { topic.auto_close_at.should == nil }
|
||||
And { scheduled_jobs_for(:close_topic).should be_empty }
|
||||
Then { expect(topic.auto_close_at).to eq(nil) }
|
||||
And { expect(scheduled_jobs_for(:close_topic)).to be_empty }
|
||||
end
|
||||
|
||||
context 'category without default auto-close' do
|
||||
Given(:category) { Fabricate(:category, auto_close_hours: nil) }
|
||||
Then { topic.auto_close_at.should == nil }
|
||||
And { scheduled_jobs_for(:close_topic).should be_empty }
|
||||
Then { expect(topic.auto_close_at).to eq(nil) }
|
||||
And { expect(scheduled_jobs_for(:close_topic)).to be_empty }
|
||||
end
|
||||
|
||||
context 'jobs may be queued' do
|
||||
|
@ -51,20 +51,20 @@ describe Topic do
|
|||
|
||||
context 'category has a default auto-close' do
|
||||
Given(:category) { Fabricate(:category, auto_close_hours: 2.0) }
|
||||
Then { topic.auto_close_at.should be_within_one_second_of(2.hours.from_now) }
|
||||
And { topic.auto_close_started_at.should == Time.zone.now }
|
||||
And { scheduled_jobs_for(:close_topic, {topic_id: topic.id}).size.should == 1 }
|
||||
And { scheduled_jobs_for(:close_topic, {topic_id: category.topic.id}).should be_empty }
|
||||
Then { expect(topic.auto_close_at).to be_within_one_second_of(2.hours.from_now) }
|
||||
And { expect(topic.auto_close_started_at).to eq(Time.zone.now) }
|
||||
And { expect(scheduled_jobs_for(:close_topic, {topic_id: topic.id}).size).to eq(1) }
|
||||
And { expect(scheduled_jobs_for(:close_topic, {topic_id: category.topic.id})).to be_empty }
|
||||
|
||||
context 'topic was created by staff user' do
|
||||
Given(:admin) { Fabricate(:admin) }
|
||||
Given(:staff_topic) { Fabricate(:topic, user: admin, category: category) }
|
||||
Then { scheduled_jobs_for(:close_topic, {topic_id: staff_topic.id, user_id: admin.id}).size.should == 1 }
|
||||
Then { expect(scheduled_jobs_for(:close_topic, {topic_id: staff_topic.id, user_id: admin.id}).size).to eq(1) }
|
||||
|
||||
context 'topic is closed manually' do
|
||||
When { staff_topic.update_status('closed', true, admin) }
|
||||
Then { staff_topic.reload.auto_close_at.should == nil }
|
||||
And { staff_topic.auto_close_started_at.should == nil }
|
||||
Then { expect(staff_topic.reload.auto_close_at).to eq(nil) }
|
||||
And { expect(staff_topic.auto_close_started_at).to eq(nil) }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -73,18 +73,18 @@ describe Topic do
|
|||
Given { Discourse.stubs(:system_user).returns(system_user) }
|
||||
Given(:regular_user) { Fabricate(:user) }
|
||||
Given(:regular_user_topic) { Fabricate(:topic, user: regular_user, category: category) }
|
||||
Then { scheduled_jobs_for(:close_topic, {topic_id: regular_user_topic.id, user_id: system_user.id}).size.should == 1 }
|
||||
Then { expect(scheduled_jobs_for(:close_topic, {topic_id: regular_user_topic.id, user_id: system_user.id}).size).to eq(1) }
|
||||
end
|
||||
|
||||
context 'auto_close_hours of topic was set to 0' do
|
||||
Given(:dont_close_topic) { Fabricate(:topic, auto_close_hours: 0, category: category) }
|
||||
Then { scheduled_jobs_for(:close_topic).should be_empty }
|
||||
Then { expect(scheduled_jobs_for(:close_topic)).to be_empty }
|
||||
end
|
||||
|
||||
context 'two topics in the category' do
|
||||
Given!(:other_topic) { Fabricate(:topic, category: category) }
|
||||
When { topic } # create the second topic
|
||||
Then { scheduled_jobs_for(:close_topic).size.should == 2 }
|
||||
Then { expect(scheduled_jobs_for(:close_topic).size).to eq(2) }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -92,8 +92,8 @@ describe Topic do
|
|||
Given(:admin) { Fabricate(:admin) }
|
||||
Given!(:auto_closed_topic) { Fabricate(:topic, user: admin, closed: true, auto_close_at: 1.day.ago, auto_close_user_id: admin.id, auto_close_started_at: 6.days.ago) }
|
||||
When { auto_closed_topic.update_status('closed', false, admin) }
|
||||
Then { auto_closed_topic.reload.auto_close_at.should == nil }
|
||||
And { auto_closed_topic.auto_close_started_at.should == nil }
|
||||
Then { expect(auto_closed_topic.reload.auto_close_at).to eq(nil) }
|
||||
And { expect(auto_closed_topic.auto_close_started_at).to eq(nil) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,20 +4,20 @@ describe "i18n integrity checks" do
|
|||
|
||||
it 'should have an i18n key for all trust levels' do
|
||||
TrustLevel.all.each do |ts|
|
||||
ts.name.should_not =~ /translation missing/
|
||||
expect(ts.name).not_to match(/translation missing/)
|
||||
end
|
||||
end
|
||||
|
||||
it "needs an i18n key (description) for each Site Setting" do
|
||||
SiteSetting.all_settings.each do |s|
|
||||
next if s[:setting] =~ /^test/
|
||||
s[:description].should_not =~ /translation missing/
|
||||
expect(s[:description]).not_to match(/translation missing/)
|
||||
end
|
||||
end
|
||||
|
||||
it "needs an i18n key (notification_types) for each Notification type" do
|
||||
Notification.types.each_key do |type|
|
||||
I18n.t("notification_types.#{type}").should_not =~ /translation missing/
|
||||
expect(I18n.t("notification_types.#{type}")).not_to match(/translation missing/)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -25,11 +25,11 @@ describe "i18n integrity checks" do
|
|||
Dir["#{Rails.root}/config/locales/client.*.yml"].each do |f|
|
||||
locale = /.*\.([^.]{2,})\.yml$/.match(f)[1]
|
||||
client = YAML.load_file("#{Rails.root}/config/locales/client.#{locale}.yml")
|
||||
client.count.should == 1
|
||||
client[locale].should_not == nil
|
||||
client[locale].count.should == 2
|
||||
client[locale]["js"].should_not == nil
|
||||
client[locale]["admin_js"].should_not == nil
|
||||
expect(client.count).to eq(1)
|
||||
expect(client[locale]).not_to eq(nil)
|
||||
expect(client[locale].count).to eq(2)
|
||||
expect(client[locale]["js"]).not_to eq(nil)
|
||||
expect(client[locale]["admin_js"]).not_to eq(nil)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -37,8 +37,8 @@ describe "i18n integrity checks" do
|
|||
Dir["#{Rails.root}/config/locales/server.*.yml"].each do |f|
|
||||
locale = /.*\.([^.]{2,})\.yml$/.match(f)[1]
|
||||
server = YAML.load_file("#{Rails.root}/config/locales/server.#{locale}.yml")
|
||||
server.count.should == 1
|
||||
server[locale].should_not == nil
|
||||
expect(server.count).to eq(1)
|
||||
expect(server[locale]).not_to eq(nil)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -50,7 +50,7 @@ describe "i18n integrity checks" do
|
|||
next if line.start_with? "#"
|
||||
next if line.start_with? "---"
|
||||
next if line.blank?
|
||||
line.should eq locale
|
||||
expect(line).to eq locale
|
||||
break
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@ describe ApplicationRequest do
|
|||
|
||||
it 'logs nothing for an unflushed increment' do
|
||||
ApplicationRequest.increment!(:anon)
|
||||
ApplicationRequest.count.should == 0
|
||||
expect(ApplicationRequest.count).to eq(0)
|
||||
end
|
||||
|
||||
it 'can automatically flush' do
|
||||
|
@ -22,7 +22,7 @@ describe ApplicationRequest do
|
|||
inc(:http_total)
|
||||
inc(:http_total, autoflush: 3)
|
||||
|
||||
ApplicationRequest.http_total.first.count.should == 3
|
||||
expect(ApplicationRequest.http_total.first.count).to eq(3)
|
||||
end
|
||||
|
||||
it 'can flush based on time' do
|
||||
|
@ -30,12 +30,12 @@ describe ApplicationRequest do
|
|||
freeze_time(t1)
|
||||
ApplicationRequest.write_cache!
|
||||
inc(:http_total)
|
||||
ApplicationRequest.count.should == 0
|
||||
expect(ApplicationRequest.count).to eq(0)
|
||||
|
||||
freeze_time(t1 + ApplicationRequest.autoflush_seconds + 1)
|
||||
inc(:http_total)
|
||||
|
||||
ApplicationRequest.count.should == 1
|
||||
expect(ApplicationRequest.count).to eq(1)
|
||||
end
|
||||
|
||||
it 'flushes yesterdays results' do
|
||||
|
@ -46,7 +46,7 @@ describe ApplicationRequest do
|
|||
inc(:http_total)
|
||||
|
||||
ApplicationRequest.write_cache!
|
||||
ApplicationRequest.count.should == 2
|
||||
expect(ApplicationRequest.count).to eq(2)
|
||||
end
|
||||
|
||||
it 'clears cache correctly' do
|
||||
|
@ -55,7 +55,7 @@ describe ApplicationRequest do
|
|||
ApplicationRequest.clear_cache!
|
||||
ApplicationRequest.write_cache!
|
||||
|
||||
ApplicationRequest.count.should == 0
|
||||
expect(ApplicationRequest.count).to eq(0)
|
||||
end
|
||||
|
||||
it 'logs a few counts once flushed' do
|
||||
|
@ -68,9 +68,9 @@ describe ApplicationRequest do
|
|||
|
||||
ApplicationRequest.write_cache!
|
||||
|
||||
ApplicationRequest.http_total.first.count.should == 3
|
||||
ApplicationRequest.http_2xx.first.count.should == 2
|
||||
ApplicationRequest.http_3xx.first.count.should == 4
|
||||
expect(ApplicationRequest.http_total.first.count).to eq(3)
|
||||
expect(ApplicationRequest.http_2xx.first.count).to eq(2)
|
||||
expect(ApplicationRequest.http_3xx.first.count).to eq(4)
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -200,7 +200,7 @@ describe Category do
|
|||
|
||||
it 'and be sanitized' do
|
||||
c = Fabricate(:category, name: 'Cats', slug: ' invalid slug')
|
||||
c.slug.should == 'invalid-slug'
|
||||
expect(c.slug).to eq('invalid-slug')
|
||||
end
|
||||
|
||||
it 'fails if custom slug is duplicate with existing' do
|
||||
|
|
|
@ -57,7 +57,7 @@ describe CategoryUser do
|
|||
CategoryUser.create!(user: user, category: watched_category, notification_level: CategoryUser.notification_levels[:watching])
|
||||
|
||||
post = create_post
|
||||
TopicUser.get(post.topic, user).should be_blank
|
||||
expect(TopicUser.get(post.topic, user)).to be_blank
|
||||
|
||||
# Now, change the topic's category
|
||||
post.topic.change_category_to_id(watched_category.id)
|
||||
|
|
|
@ -292,7 +292,7 @@ describe Group do
|
|||
let(:group) {Fabricate(:group)}
|
||||
|
||||
it "by default has no managers" do
|
||||
group.managers.should be_empty
|
||||
expect(group.managers).to be_empty
|
||||
end
|
||||
|
||||
it "multiple managers can be appointed" do
|
||||
|
|
|
@ -202,7 +202,7 @@ describe PostAction do
|
|||
it 'should generate notifications correctly' do
|
||||
ActiveRecord::Base.observers.enable :all
|
||||
PostAction.act(codinghorror, post, PostActionType.types[:like])
|
||||
Notification.count.should == 1
|
||||
expect(Notification.count).to eq(1)
|
||||
|
||||
mutee = Fabricate(:user)
|
||||
|
||||
|
@ -210,13 +210,13 @@ describe PostAction do
|
|||
MutedUser.create!(user_id: post.user.id, muted_user_id: mutee.id)
|
||||
PostAction.act(mutee, post, PostActionType.types[:like])
|
||||
|
||||
Notification.count.should == 1
|
||||
expect(Notification.count).to eq(1)
|
||||
|
||||
# you can not mute admin, sorry
|
||||
MutedUser.create!(user_id: post.user.id, muted_user_id: admin.id)
|
||||
PostAction.act(admin, post, PostActionType.types[:like])
|
||||
|
||||
Notification.count.should == 2
|
||||
expect(Notification.count).to eq(2)
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'spec_helper'
|
|||
|
||||
describe TopTopic do
|
||||
|
||||
it { should belong_to :topic }
|
||||
it { is_expected.to belong_to :topic }
|
||||
|
||||
context "refresh!" do
|
||||
|
||||
|
@ -10,7 +10,7 @@ describe TopTopic do
|
|||
let!(:t2) { Fabricate(:topic) }
|
||||
|
||||
it "begins blank" do
|
||||
TopTopic.all.should be_blank
|
||||
expect(TopTopic.all).to be_blank
|
||||
end
|
||||
|
||||
context "after calculating" do
|
||||
|
@ -20,7 +20,7 @@ describe TopTopic do
|
|||
end
|
||||
|
||||
it "should have top topics" do
|
||||
TopTopic.pluck(:topic_id).should =~ [t1.id, t2.id]
|
||||
expect(TopTopic.pluck(:topic_id)).to match_array([t1.id, t2.id])
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -2,8 +2,8 @@ require 'spec_helper'
|
|||
|
||||
describe TopicUser do
|
||||
|
||||
it { should belong_to :user }
|
||||
it { should belong_to :topic }
|
||||
it { is_expected.to belong_to :user }
|
||||
it { is_expected.to belong_to :topic }
|
||||
|
||||
let(:user) { Fabricate(:user) }
|
||||
|
||||
|
@ -28,7 +28,7 @@ describe TopicUser do
|
|||
|
||||
it "defaults to blank" do
|
||||
ensure_topic_user
|
||||
topic_user.cleared_pinned_at.should be_blank
|
||||
expect(topic_user.cleared_pinned_at).to be_blank
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -38,50 +38,50 @@ describe TopicUser do
|
|||
it 'should be set to tracking if auto_track_topics is enabled' do
|
||||
user.update_column(:auto_track_topics_after_msecs, 0)
|
||||
ensure_topic_user
|
||||
TopicUser.get(topic, user).notification_level.should == TopicUser.notification_levels[:tracking]
|
||||
expect(TopicUser.get(topic, user).notification_level).to eq(TopicUser.notification_levels[:tracking])
|
||||
end
|
||||
|
||||
it 'should reset regular topics to tracking topics if auto track is changed' do
|
||||
ensure_topic_user
|
||||
user.auto_track_topics_after_msecs = 0
|
||||
user.save
|
||||
topic_user.notification_level.should == TopicUser.notification_levels[:tracking]
|
||||
expect(topic_user.notification_level).to eq(TopicUser.notification_levels[:tracking])
|
||||
end
|
||||
|
||||
it 'should be set to "regular" notifications, by default on non creators' do
|
||||
ensure_topic_user
|
||||
TopicUser.get(topic,user).notification_level.should == TopicUser.notification_levels[:regular]
|
||||
expect(TopicUser.get(topic,user).notification_level).to eq(TopicUser.notification_levels[:regular])
|
||||
end
|
||||
|
||||
it 'reason should reset when changed' do
|
||||
topic.notify_muted!(topic.user)
|
||||
TopicUser.get(topic,topic.user).notifications_reason_id.should == TopicUser.notification_reasons[:user_changed]
|
||||
expect(TopicUser.get(topic,topic.user).notifications_reason_id).to eq(TopicUser.notification_reasons[:user_changed])
|
||||
end
|
||||
|
||||
it 'should have the correct reason for a user change when watched' do
|
||||
topic.notify_watch!(user)
|
||||
topic_user.notification_level.should == TopicUser.notification_levels[:watching]
|
||||
topic_user.notifications_reason_id.should == TopicUser.notification_reasons[:user_changed]
|
||||
topic_user.notifications_changed_at.should_not == nil
|
||||
expect(topic_user.notification_level).to eq(TopicUser.notification_levels[:watching])
|
||||
expect(topic_user.notifications_reason_id).to eq(TopicUser.notification_reasons[:user_changed])
|
||||
expect(topic_user.notifications_changed_at).not_to eq(nil)
|
||||
end
|
||||
|
||||
it 'should have the correct reason for a user change when set to regular' do
|
||||
topic.notify_regular!(user)
|
||||
topic_user.notification_level.should == TopicUser.notification_levels[:regular]
|
||||
topic_user.notifications_reason_id.should == TopicUser.notification_reasons[:user_changed]
|
||||
topic_user.notifications_changed_at.should_not == nil
|
||||
expect(topic_user.notification_level).to eq(TopicUser.notification_levels[:regular])
|
||||
expect(topic_user.notifications_reason_id).to eq(TopicUser.notification_reasons[:user_changed])
|
||||
expect(topic_user.notifications_changed_at).not_to eq(nil)
|
||||
end
|
||||
|
||||
it 'should have the correct reason for a user change when set to regular' do
|
||||
topic.notify_muted!(user)
|
||||
topic_user.notification_level.should == TopicUser.notification_levels[:muted]
|
||||
topic_user.notifications_reason_id.should == TopicUser.notification_reasons[:user_changed]
|
||||
topic_user.notifications_changed_at.should_not == nil
|
||||
expect(topic_user.notification_level).to eq(TopicUser.notification_levels[:muted])
|
||||
expect(topic_user.notifications_reason_id).to eq(TopicUser.notification_reasons[:user_changed])
|
||||
expect(topic_user.notifications_changed_at).not_to eq(nil)
|
||||
end
|
||||
|
||||
it 'should watch topics a user created' do
|
||||
topic_creator_user.notification_level.should == TopicUser.notification_levels[:watching]
|
||||
topic_creator_user.notifications_reason_id.should == TopicUser.notification_reasons[:created_topic]
|
||||
expect(topic_creator_user.notification_level).to eq(TopicUser.notification_levels[:watching])
|
||||
expect(topic_creator_user.notifications_reason_id).to eq(TopicUser.notification_reasons[:created_topic])
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -93,8 +93,8 @@ describe TopicUser do
|
|||
|
||||
it 'set upon initial visit' do
|
||||
freeze_time yesterday do
|
||||
topic_user.first_visited_at.to_i.should == yesterday.to_i
|
||||
topic_user.last_visited_at.to_i.should == yesterday.to_i
|
||||
expect(topic_user.first_visited_at.to_i).to eq(yesterday.to_i)
|
||||
expect(topic_user.last_visited_at.to_i).to eq(yesterday.to_i)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -105,8 +105,8 @@ describe TopicUser do
|
|||
TopicUser.track_visit!(topic,user)
|
||||
# reload is a no go
|
||||
topic_user = TopicUser.get(topic,user)
|
||||
topic_user.first_visited_at.to_i.should == yesterday.to_i
|
||||
topic_user.last_visited_at.to_i.should == today.to_i
|
||||
expect(topic_user.first_visited_at.to_i).to eq(yesterday.to_i)
|
||||
expect(topic_user.last_visited_at.to_i).to eq(today.to_i)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -128,9 +128,9 @@ describe TopicUser do
|
|||
|
||||
it 'should create a new record for a visit' do
|
||||
freeze_time yesterday do
|
||||
topic_user.last_read_post_number.should == 1
|
||||
topic_user.last_visited_at.to_i.should == yesterday.to_i
|
||||
topic_user.first_visited_at.to_i.should == yesterday.to_i
|
||||
expect(topic_user.last_read_post_number).to eq(1)
|
||||
expect(topic_user.last_visited_at.to_i).to eq(yesterday.to_i)
|
||||
expect(topic_user.first_visited_at.to_i).to eq(yesterday.to_i)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -139,9 +139,9 @@ describe TopicUser 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
|
||||
topic_user.last_visited_at.to_i.should == yesterday.to_i
|
||||
topic_user.first_visited_at.to_i.should == yesterday.to_i
|
||||
expect(topic_user.last_read_post_number).to eq(2)
|
||||
expect(topic_user.last_visited_at.to_i).to eq(yesterday.to_i)
|
||||
expect(topic_user.first_visited_at.to_i).to eq(yesterday.to_i)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -153,8 +153,8 @@ describe TopicUser do
|
|||
target_user = Fabricate(:user)
|
||||
post = create_post(archetype: Archetype.private_message, target_usernames: target_user.username);
|
||||
|
||||
TopicUser.get(post.topic, post.user).notification_level.should == TopicUser.notification_levels[:watching]
|
||||
TopicUser.get(post.topic, target_user).notification_level.should == TopicUser.notification_levels[:watching]
|
||||
expect(TopicUser.get(post.topic, post.user).notification_level).to eq(TopicUser.notification_levels[:watching])
|
||||
expect(TopicUser.get(post.topic, target_user).notification_level).to eq(TopicUser.notification_levels[:watching])
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -168,27 +168,27 @@ describe TopicUser do
|
|||
|
||||
it 'should automatically track topics you reply to' do
|
||||
post_creator.create
|
||||
topic_new_user.notification_level.should == TopicUser.notification_levels[:tracking]
|
||||
topic_new_user.notifications_reason_id.should == TopicUser.notification_reasons[:created_post]
|
||||
expect(topic_new_user.notification_level).to eq(TopicUser.notification_levels[:tracking])
|
||||
expect(topic_new_user.notifications_reason_id).to eq(TopicUser.notification_reasons[:created_post])
|
||||
end
|
||||
|
||||
it 'should not automatically track topics you reply to and have set state manually' do
|
||||
post_creator.create
|
||||
TopicUser.change(new_user, topic, notification_level: TopicUser.notification_levels[:regular])
|
||||
topic_new_user.notification_level.should == TopicUser.notification_levels[:regular]
|
||||
topic_new_user.notifications_reason_id.should == TopicUser.notification_reasons[:user_changed]
|
||||
expect(topic_new_user.notification_level).to eq(TopicUser.notification_levels[:regular])
|
||||
expect(topic_new_user.notifications_reason_id).to eq(TopicUser.notification_reasons[:user_changed])
|
||||
end
|
||||
|
||||
it 'should automatically track topics after they are read for long enough' do
|
||||
topic_new_user.notification_level.should ==TopicUser.notification_levels[:regular]
|
||||
expect(topic_new_user.notification_level).to eq(TopicUser.notification_levels[:regular])
|
||||
TopicUser.update_last_read(new_user, topic.id, 2, 1001)
|
||||
TopicUser.get(topic, new_user).notification_level.should == TopicUser.notification_levels[:tracking]
|
||||
expect(TopicUser.get(topic, new_user).notification_level).to eq(TopicUser.notification_levels[:tracking])
|
||||
end
|
||||
|
||||
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.notification_levels[:regular])
|
||||
TopicUser.update_last_read(new_user, topic, 2, 1001)
|
||||
topic_new_user.notification_level.should == TopicUser.notification_levels[:regular]
|
||||
expect(topic_new_user.notification_level).to eq(TopicUser.notification_levels[:regular])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -199,11 +199,11 @@ describe TopicUser do
|
|||
|
||||
topic; user
|
||||
|
||||
lambda {
|
||||
expect {
|
||||
TopicUser.change(user, topic.id, total_msecs_viewed: 1)
|
||||
TopicUser.change(user, topic.id, total_msecs_viewed: 2)
|
||||
TopicUser.change(user, topic.id, total_msecs_viewed: 3)
|
||||
}.should change(TopicUser, :count).by(1)
|
||||
}.to change(TopicUser, :count).by(1)
|
||||
end
|
||||
|
||||
describe 'after creating a row' do
|
||||
|
@ -212,11 +212,11 @@ describe TopicUser do
|
|||
end
|
||||
|
||||
it 'has a lookup' do
|
||||
TopicUser.lookup_for(user, [topic]).should be_present
|
||||
expect(TopicUser.lookup_for(user, [topic])).to be_present
|
||||
end
|
||||
|
||||
it 'has a key in the lookup for this forum topic' do
|
||||
TopicUser.lookup_for(user, [topic]).has_key?(topic.id).should == true
|
||||
expect(TopicUser.lookup_for(user, [topic]).has_key?(topic.id)).to eq(true)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -228,8 +228,8 @@ describe TopicUser do
|
|||
TopicUser.create!(user_id: 2, topic_id: 1, notification_level: TopicUser.notification_levels[:watching])
|
||||
TopicUser.create!(user_id: 3, topic_id: 1, notification_level: TopicUser.notification_levels[:regular])
|
||||
|
||||
TopicUser.tracking(1).count.should == 2
|
||||
TopicUser.tracking(10).count.should == 0
|
||||
expect(TopicUser.tracking(1).count).to eq(2)
|
||||
expect(TopicUser.tracking(10).count).to eq(0)
|
||||
end
|
||||
|
||||
it "is able to self heal" do
|
||||
|
@ -247,8 +247,8 @@ describe TopicUser do
|
|||
TopicUser.ensure_consistency!
|
||||
|
||||
tu = TopicUser.find_by(user_id: p1.user_id, topic_id: p1.topic_id)
|
||||
tu.last_read_post_number.should == p2.post_number
|
||||
tu.highest_seen_post_number.should == 2
|
||||
expect(tu.last_read_post_number).to eq(p2.post_number)
|
||||
expect(tu.highest_seen_post_number).to eq(2)
|
||||
|
||||
end
|
||||
|
||||
|
@ -263,15 +263,15 @@ describe TopicUser do
|
|||
|
||||
# mails posts from earlier topics
|
||||
tu = TopicUser.find_by(user_id: user3.id, topic_id: post.topic_id)
|
||||
tu.last_emailed_post_number.should == 2
|
||||
expect(tu.last_emailed_post_number).to eq(2)
|
||||
|
||||
# mails nothing to random users
|
||||
tu = TopicUser.find_by(user_id: user1.id, topic_id: post.topic_id)
|
||||
tu.should == nil
|
||||
expect(tu).to eq(nil)
|
||||
|
||||
# mails other user
|
||||
tu = TopicUser.find_by(user_id: user2.id, topic_id: post.topic_id)
|
||||
tu.last_emailed_post_number.should == 2
|
||||
expect(tu.last_emailed_post_number).to eq(2)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -6,11 +6,11 @@ describe UserBadge do
|
|||
context 'validations' do
|
||||
before(:each) { BadgeGranter.grant(Fabricate(:badge), Fabricate(:user)) }
|
||||
|
||||
it { should validate_presence_of(:badge_id) }
|
||||
it { should validate_presence_of(:user_id) }
|
||||
it { should validate_presence_of(:granted_at) }
|
||||
it { should validate_presence_of(:granted_by) }
|
||||
it { should validate_uniqueness_of(:badge_id).scoped_to(:user_id) }
|
||||
it { is_expected.to validate_presence_of(:badge_id) }
|
||||
it { is_expected.to validate_presence_of(:user_id) }
|
||||
it { is_expected.to validate_presence_of(:granted_at) }
|
||||
it { is_expected.to validate_presence_of(:granted_by) }
|
||||
it { is_expected.to validate_uniqueness_of(:badge_id).scoped_to(:user_id) }
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -3,12 +3,12 @@ require 'spec_helper'
|
|||
describe AnonymousShadowCreator do
|
||||
|
||||
it "returns no shadow by default" do
|
||||
AnonymousShadowCreator.get(Fabricate.build(:user)).should == nil
|
||||
expect(AnonymousShadowCreator.get(Fabricate.build(:user))).to eq(nil)
|
||||
end
|
||||
|
||||
it "returns no shadow if trust level is not met" do
|
||||
SiteSetting.allow_anonymous_posting = true
|
||||
AnonymousShadowCreator.get(Fabricate.build(:user, trust_level: 0)).should == nil
|
||||
expect(AnonymousShadowCreator.get(Fabricate.build(:user, trust_level: 0))).to eq(nil)
|
||||
end
|
||||
|
||||
it "returns a new shadow once time expires" do
|
||||
|
@ -21,13 +21,13 @@ describe AnonymousShadowCreator do
|
|||
freeze_time 2.minutes.from_now
|
||||
shadow2 = AnonymousShadowCreator.get(user)
|
||||
|
||||
shadow.id.should == shadow2.id
|
||||
expect(shadow.id).to eq(shadow2.id)
|
||||
create_post(user: shadow)
|
||||
|
||||
freeze_time 4.minutes.from_now
|
||||
shadow3 = AnonymousShadowCreator.get(user)
|
||||
|
||||
shadow2.id.should_not == shadow3.id
|
||||
expect(shadow2.id).not_to eq(shadow3.id)
|
||||
|
||||
end
|
||||
|
||||
|
@ -38,20 +38,20 @@ describe AnonymousShadowCreator do
|
|||
shadow = AnonymousShadowCreator.get(user)
|
||||
shadow2 = AnonymousShadowCreator.get(user)
|
||||
|
||||
shadow.id.should == shadow2.id
|
||||
expect(shadow.id).to eq(shadow2.id)
|
||||
|
||||
shadow.trust_level.should == 1
|
||||
shadow.username.should == "anonymous"
|
||||
expect(shadow.trust_level).to eq(1)
|
||||
expect(shadow.username).to eq("anonymous")
|
||||
|
||||
shadow.created_at.should_not == user.created_at
|
||||
expect(shadow.created_at).not_to eq(user.created_at)
|
||||
|
||||
|
||||
p = create_post
|
||||
Guardian.new(shadow).post_can_act?(p, :like).should == false
|
||||
Guardian.new(user).post_can_act?(p, :like).should == true
|
||||
expect(Guardian.new(shadow).post_can_act?(p, :like)).to eq(false)
|
||||
expect(Guardian.new(user).post_can_act?(p, :like)).to eq(true)
|
||||
|
||||
user.anonymous?.should == false
|
||||
shadow.anonymous?.should == true
|
||||
expect(user.anonymous?).to eq(false)
|
||||
expect(shadow.anonymous?).to eq(true)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -144,7 +144,7 @@ describe SpamRule::AutoBlock do
|
|||
enforcer = described_class.new(user)
|
||||
enforcer.expects(:num_spam_flags_against_user).never
|
||||
enforcer.expects(:num_users_who_flagged_spam_against_user).never
|
||||
enforcer.block?.should eq(false)
|
||||
expect(enforcer.block?).to eq(false)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -17,13 +17,13 @@ describe BadgeGranter do
|
|||
BadgeGranter.revoke_ungranted_titles!
|
||||
|
||||
user.reload
|
||||
user.title.should == badge.name
|
||||
expect(user.title).to eq(badge.name)
|
||||
|
||||
badge.update_column(:allow_title, false)
|
||||
BadgeGranter.revoke_ungranted_titles!
|
||||
|
||||
user.reload
|
||||
user.title.should == ''
|
||||
expect(user.title).to eq('')
|
||||
|
||||
user.title = "CEO"
|
||||
user.save
|
||||
|
@ -31,7 +31,7 @@ describe BadgeGranter do
|
|||
BadgeGranter.revoke_ungranted_titles!
|
||||
|
||||
user.reload
|
||||
user.title.should == "CEO"
|
||||
expect(user.title).to eq("CEO")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -39,7 +39,7 @@ describe BadgeGranter do
|
|||
it 'can correctly preview' do
|
||||
Fabricate(:user, email: 'sam@gmail.com')
|
||||
result = BadgeGranter.preview('select id user_id, null post_id, created_at granted_at from users where email like \'%gmail.com\'')
|
||||
result[:grant_count].should == 1
|
||||
expect(result[:grant_count]).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -61,11 +61,11 @@ describe BadgeGranter do
|
|||
BadgeGranter.backfill(Badge.find(Badge::FirstLike))
|
||||
|
||||
b = UserBadge.find_by(user_id: post.user_id)
|
||||
b.post_id.should == post.id
|
||||
expect(b.post_id).to eq(post.id)
|
||||
b.badge_id = Badge::Welcome
|
||||
|
||||
b = UserBadge.find_by(user_id: user2.id)
|
||||
b.post_id.should == post.id
|
||||
expect(b.post_id).to eq(post.id)
|
||||
b.badge_id = Badge::FirstLike
|
||||
end
|
||||
|
||||
|
@ -77,12 +77,12 @@ describe BadgeGranter do
|
|||
}
|
||||
|
||||
# TODO add welcome
|
||||
post.user.user_badges.pluck(:badge_id).sort.should == [Badge::NiceTopic,Badge::GoodTopic]
|
||||
expect(post.user.user_badges.pluck(:badge_id).sort).to eq([Badge::NiceTopic,Badge::GoodTopic])
|
||||
|
||||
post.user.notifications.count.should == 2
|
||||
expect(post.user.notifications.count).to eq(2)
|
||||
|
||||
Badge.find(Badge::NiceTopic).grant_count.should == 1
|
||||
Badge.find(Badge::GoodTopic).grant_count.should == 1
|
||||
expect(Badge.find(Badge::NiceTopic).grant_count).to eq(1)
|
||||
expect(Badge.find(Badge::GoodTopic).grant_count).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -92,9 +92,9 @@ describe BadgeGranter do
|
|||
badge = Fabricate(:badge, multiple_grant: true)
|
||||
user_badge = BadgeGranter.grant(badge, user)
|
||||
user_badge = BadgeGranter.grant(badge, user)
|
||||
user_badge.should be_present
|
||||
expect(user_badge).to be_present
|
||||
|
||||
UserBadge.where(user_id: user.id).count.should == 2
|
||||
expect(UserBadge.where(user_id: user.id).count).to eq(2)
|
||||
end
|
||||
|
||||
it 'sets granted_at' do
|
||||
|
@ -102,7 +102,7 @@ describe BadgeGranter do
|
|||
Timecop.freeze time
|
||||
|
||||
user_badge = BadgeGranter.grant(badge, user)
|
||||
user_badge.granted_at.should eq(time)
|
||||
expect(user_badge.granted_at).to eq(time)
|
||||
|
||||
Timecop.return
|
||||
end
|
||||
|
@ -111,24 +111,24 @@ describe BadgeGranter do
|
|||
admin = Fabricate(:admin)
|
||||
StaffActionLogger.any_instance.expects(:log_badge_grant).once
|
||||
user_badge = BadgeGranter.grant(badge, user, granted_by: admin)
|
||||
user_badge.granted_by.should eq(admin)
|
||||
expect(user_badge.granted_by).to eq(admin)
|
||||
end
|
||||
|
||||
it 'defaults granted_by to the system user' do
|
||||
StaffActionLogger.any_instance.expects(:log_badge_grant).never
|
||||
user_badge = BadgeGranter.grant(badge, user)
|
||||
user_badge.granted_by_id.should eq(Discourse.system_user.id)
|
||||
expect(user_badge.granted_by_id).to eq(Discourse.system_user.id)
|
||||
end
|
||||
|
||||
it 'does not allow a regular user to grant badges' do
|
||||
user_badge = BadgeGranter.grant(badge, user, granted_by: Fabricate(:user))
|
||||
user_badge.should_not be_present
|
||||
expect(user_badge).not_to be_present
|
||||
end
|
||||
|
||||
it 'increments grant_count on the badge and creates a notification' do
|
||||
BadgeGranter.grant(badge, user)
|
||||
badge.reload.grant_count.should eq(1)
|
||||
user.notifications.find_by(notification_type: Notification.types[:granted_badge]).data_hash["badge_id"].should == badge.id
|
||||
expect(badge.reload.grant_count).to eq(1)
|
||||
expect(user.notifications.find_by(notification_type: Notification.types[:granted_badge]).data_hash["badge_id"]).to eq(badge.id)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -140,13 +140,13 @@ describe BadgeGranter do
|
|||
|
||||
it 'revokes the badge and does necessary cleanup' do
|
||||
user.title = badge.name; user.save!
|
||||
badge.reload.grant_count.should eq(1)
|
||||
expect(badge.reload.grant_count).to eq(1)
|
||||
StaffActionLogger.any_instance.expects(:log_badge_revoke).with(user_badge)
|
||||
BadgeGranter.revoke(user_badge, revoked_by: admin)
|
||||
UserBadge.find_by(user: user, badge: badge).should_not be_present
|
||||
badge.reload.grant_count.should eq(0)
|
||||
user.notifications.where(notification_type: Notification.types[:granted_badge]).should be_empty
|
||||
user.reload.title.should == nil
|
||||
expect(UserBadge.find_by(user: user, badge: badge)).not_to be_present
|
||||
expect(badge.reload.grant_count).to eq(0)
|
||||
expect(user.notifications.where(notification_type: Notification.types[:granted_badge])).to be_empty
|
||||
expect(user.reload.title).to eq(nil)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -166,7 +166,7 @@ describe BadgeGranter do
|
|||
user.save
|
||||
|
||||
BadgeGranter.process_queue!
|
||||
UserBadge.where(user_id: user.id, badge_id: Badge::Autobiographer).count.should eq(1)
|
||||
expect(UserBadge.where(user_id: user.id, badge_id: Badge::Autobiographer).count).to eq(1)
|
||||
end
|
||||
|
||||
it "grants read guidlines" do
|
||||
|
@ -174,7 +174,7 @@ describe BadgeGranter do
|
|||
user.user_stat.save
|
||||
|
||||
BadgeGranter.process_queue!
|
||||
UserBadge.where(user_id: user.id, badge_id: Badge::ReadGuidelines).count.should eq(1)
|
||||
expect(UserBadge.where(user_id: user.id, badge_id: Badge::ReadGuidelines).count).to eq(1)
|
||||
end
|
||||
|
||||
it "grants first link" do
|
||||
|
@ -182,7 +182,7 @@ describe BadgeGranter do
|
|||
post2 = create_post(raw: "#{Discourse.base_url}/t/slug/#{post.topic_id}")
|
||||
|
||||
BadgeGranter.process_queue!
|
||||
UserBadge.where(user_id: post2.user.id, badge_id: Badge::FirstLink).count.should eq(1)
|
||||
expect(UserBadge.where(user_id: post2.user.id, badge_id: Badge::FirstLink).count).to eq(1)
|
||||
end
|
||||
|
||||
it "grants first edit" do
|
||||
|
@ -190,24 +190,24 @@ describe BadgeGranter do
|
|||
post = create_post
|
||||
user = post.user
|
||||
|
||||
UserBadge.where(user_id: user.id, badge_id: Badge::Editor).count.should eq(0)
|
||||
expect(UserBadge.where(user_id: user.id, badge_id: Badge::Editor).count).to eq(0)
|
||||
|
||||
PostRevisor.new(post).revise!(user, { raw: "This is my new test 1235 123" })
|
||||
BadgeGranter.process_queue!
|
||||
|
||||
UserBadge.where(user_id: user.id, badge_id: Badge::Editor).count.should eq(1)
|
||||
expect(UserBadge.where(user_id: user.id, badge_id: Badge::Editor).count).to eq(1)
|
||||
end
|
||||
|
||||
it "grants and revokes trust level badges" do
|
||||
user.change_trust_level!(TrustLevel[4])
|
||||
BadgeGranter.process_queue!
|
||||
UserBadge.where(user_id: user.id, badge_id: Badge.trust_level_badge_ids).count.should eq(4)
|
||||
expect(UserBadge.where(user_id: user.id, badge_id: Badge.trust_level_badge_ids).count).to eq(4)
|
||||
|
||||
user.change_trust_level!(TrustLevel[1])
|
||||
BadgeGranter.backfill(Badge.find(1))
|
||||
BadgeGranter.backfill(Badge.find(2))
|
||||
UserBadge.where(user_id: user.id, badge_id: 1).first.should_not == nil
|
||||
UserBadge.where(user_id: user.id, badge_id: 2).first.should == nil
|
||||
expect(UserBadge.where(user_id: user.id, badge_id: 1).first).not_to eq(nil)
|
||||
expect(UserBadge.where(user_id: user.id, badge_id: 2).first).to eq(nil)
|
||||
end
|
||||
|
||||
it "grants system like badges" do
|
||||
|
@ -215,7 +215,7 @@ describe BadgeGranter do
|
|||
# Welcome badge
|
||||
action = PostAction.act(liker, post, PostActionType.types[:like])
|
||||
BadgeGranter.process_queue!
|
||||
UserBadge.find_by(user_id: user.id, badge_id: 5).should_not == nil
|
||||
expect(UserBadge.find_by(user_id: user.id, badge_id: 5)).not_to eq(nil)
|
||||
|
||||
post = create_post(topic: post.topic, user: user)
|
||||
action = PostAction.act(liker, post, PostActionType.types[:like])
|
||||
|
@ -226,25 +226,25 @@ describe BadgeGranter do
|
|||
BadgeGranter.queue_badge_grant(Badge::Trigger::PostAction, post_action: action)
|
||||
BadgeGranter.process_queue!
|
||||
|
||||
UserBadge.find_by(user_id: user.id, badge_id: Badge::NicePost).should_not == nil
|
||||
UserBadge.where(user_id: user.id, badge_id: Badge::NicePost).count.should == 1
|
||||
expect(UserBadge.find_by(user_id: user.id, badge_id: Badge::NicePost)).not_to eq(nil)
|
||||
expect(UserBadge.where(user_id: user.id, badge_id: Badge::NicePost).count).to eq(1)
|
||||
|
||||
# Good post badge
|
||||
post.update_attributes like_count: 25
|
||||
BadgeGranter.queue_badge_grant(Badge::Trigger::PostAction, post_action: action)
|
||||
BadgeGranter.process_queue!
|
||||
UserBadge.find_by(user_id: user.id, badge_id: Badge::GoodPost).should_not == nil
|
||||
expect(UserBadge.find_by(user_id: user.id, badge_id: Badge::GoodPost)).not_to eq(nil)
|
||||
|
||||
# Great post badge
|
||||
post.update_attributes like_count: 50
|
||||
BadgeGranter.queue_badge_grant(Badge::Trigger::PostAction, post_action: action)
|
||||
BadgeGranter.process_queue!
|
||||
UserBadge.find_by(user_id: user.id, badge_id: Badge::GreatPost).should_not == nil
|
||||
expect(UserBadge.find_by(user_id: user.id, badge_id: Badge::GreatPost)).not_to eq(nil)
|
||||
|
||||
# Revoke badges on unlike
|
||||
post.update_attributes like_count: 49
|
||||
BadgeGranter.backfill(Badge.find(Badge::GreatPost))
|
||||
UserBadge.find_by(user_id: user.id, badge_id: Badge::GreatPost).should == nil
|
||||
expect(UserBadge.find_by(user_id: user.id, badge_id: Badge::GreatPost)).to eq(nil)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -15,14 +15,14 @@ describe ColorSchemeRevisor do
|
|||
|
||||
it "can change the name" do
|
||||
described_class.revise(color_scheme, valid_params.merge(name: "Changed Name"))
|
||||
color_scheme.reload.name.should == "Changed Name"
|
||||
expect(color_scheme.reload.name).to eq("Changed Name")
|
||||
end
|
||||
|
||||
it "can enable and disable" do
|
||||
described_class.revise(color_scheme, valid_params.merge(enabled: true))
|
||||
color_scheme.reload.should be_enabled
|
||||
expect(color_scheme.reload).to be_enabled
|
||||
described_class.revise(color_scheme, valid_params.merge(enabled: false))
|
||||
color_scheme.reload.should_not be_enabled
|
||||
expect(color_scheme.reload).not_to be_enabled
|
||||
end
|
||||
|
||||
def test_color_change(color_scheme_arg, expected_enabled)
|
||||
|
@ -30,9 +30,9 @@ describe ColorSchemeRevisor do
|
|||
{name: color.name, hex: 'BEEF99'}
|
||||
]))
|
||||
color_scheme_arg.reload
|
||||
color_scheme_arg.enabled.should == expected_enabled
|
||||
color_scheme_arg.colors.size.should == 1
|
||||
color_scheme_arg.colors.first.hex.should == 'BEEF99'
|
||||
expect(color_scheme_arg.enabled).to eq(expected_enabled)
|
||||
expect(color_scheme_arg.colors.size).to eq(1)
|
||||
expect(color_scheme_arg.colors.first.hex).to eq('BEEF99')
|
||||
end
|
||||
|
||||
it "can change colors of a color scheme that's not enabled" do
|
||||
|
@ -47,8 +47,8 @@ describe ColorSchemeRevisor do
|
|||
it "disables other color scheme before enabling" do
|
||||
prev_enabled = Fabricate(:color_scheme, enabled: true)
|
||||
described_class.revise(color_scheme, valid_params.merge(enabled: true))
|
||||
prev_enabled.reload.enabled.should == false
|
||||
color_scheme.reload.enabled.should == true
|
||||
expect(prev_enabled.reload.enabled).to eq(false)
|
||||
expect(color_scheme.reload.enabled).to eq(true)
|
||||
end
|
||||
|
||||
it "doesn't make changes when a color is invalid" do
|
||||
|
@ -56,10 +56,10 @@ describe ColorSchemeRevisor do
|
|||
cs = described_class.revise(color_scheme, valid_params.merge(colors: [
|
||||
{name: color.name, hex: 'OOPS'}
|
||||
]))
|
||||
cs.should_not be_valid
|
||||
cs.errors.should be_present
|
||||
expect(cs).not_to be_valid
|
||||
expect(cs.errors).to be_present
|
||||
}.to_not change { color_scheme.reload.version }
|
||||
color_scheme.colors.first.hex.should == color.hex
|
||||
expect(color_scheme.colors.first.hex).to eq(color.hex)
|
||||
end
|
||||
|
||||
describe "versions" do
|
||||
|
@ -77,10 +77,10 @@ describe ColorSchemeRevisor do
|
|||
]))
|
||||
}.to change { color_scheme.reload.version }.by(1)
|
||||
old_version = ColorScheme.find_by(versioned_id: color_scheme.id, version: (color_scheme.version - 1))
|
||||
old_version.should_not == nil
|
||||
old_version.colors.count.should == color_scheme.colors.count
|
||||
old_version.colors_by_name[color.name].hex.should == old_hex
|
||||
color_scheme.colors_by_name[color.name].hex.should == 'BEEF99'
|
||||
expect(old_version).not_to eq(nil)
|
||||
expect(old_version.colors.count).to eq(color_scheme.colors.count)
|
||||
expect(old_version.colors_by_name[color.name].hex).to eq(old_hex)
|
||||
expect(color_scheme.colors_by_name[color.name].hex).to eq('BEEF99')
|
||||
end
|
||||
|
||||
it "doesn't create a new version if colors have not changed" do
|
||||
|
@ -97,7 +97,7 @@ describe ColorSchemeRevisor do
|
|||
context "when there are no previous versions" do
|
||||
it "does nothing" do
|
||||
expect {
|
||||
described_class.revert(color_scheme).should == color_scheme
|
||||
expect(described_class.revert(color_scheme)).to eq(color_scheme)
|
||||
}.to_not change { color_scheme.reload.version }
|
||||
end
|
||||
end
|
||||
|
@ -111,20 +111,20 @@ describe ColorSchemeRevisor do
|
|||
end
|
||||
|
||||
it "reverts the colors to the previous version" do
|
||||
color_scheme.colors_by_name[new_color_params[:name]].hex.should == new_color_params[:hex]
|
||||
expect(color_scheme.colors_by_name[new_color_params[:name]].hex).to eq(new_color_params[:hex])
|
||||
expect {
|
||||
described_class.revert(color_scheme)
|
||||
}.to change { color_scheme.reload.version }.by(-1)
|
||||
color_scheme.colors.size.should == 1
|
||||
color_scheme.colors.first.hex.should == @prev_hex
|
||||
color_scheme.colors_by_name[new_color_params[:name]].hex.should == @prev_hex
|
||||
expect(color_scheme.colors.size).to eq(1)
|
||||
expect(color_scheme.colors.first.hex).to eq(@prev_hex)
|
||||
expect(color_scheme.colors_by_name[new_color_params[:name]].hex).to eq(@prev_hex)
|
||||
end
|
||||
|
||||
it "destroys the old version's record" do
|
||||
expect {
|
||||
described_class.revert(color_scheme)
|
||||
}.to change { ColorScheme.count }.by(-1)
|
||||
color_scheme.reload.previous_version.should == nil
|
||||
expect(color_scheme.reload.previous_version).to eq(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,7 +13,7 @@ describe SpamRule::FlagSockpuppets do
|
|||
SiteSetting.stubs(:flag_sockpuppets).returns(false)
|
||||
rule.expects(:reply_is_from_sockpuppet?).never
|
||||
rule.expects(:flag_sockpuppet_users).never
|
||||
perform.should eq(false)
|
||||
expect(perform).to eq(false)
|
||||
end
|
||||
|
||||
context 'flag_sockpuppets is enabled' do
|
||||
|
@ -22,91 +22,91 @@ describe SpamRule::FlagSockpuppets do
|
|||
it 'flags posts when it should' do
|
||||
rule.expects(:reply_is_from_sockpuppet?).returns(:true)
|
||||
rule.expects(:flag_sockpuppet_users).once
|
||||
perform.should eq(true)
|
||||
expect(perform).to eq(true)
|
||||
end
|
||||
|
||||
it "doesn't flag posts when it shouldn't" do
|
||||
rule.expects(:reply_is_from_sockpuppet?).returns(false)
|
||||
rule.expects(:flag_sockpuppet_users).never
|
||||
perform.should eq(false)
|
||||
expect(perform).to eq(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'reply_is_from_sockpuppet?' do
|
||||
it 'is false for the first post in a topic' do
|
||||
described_class.new(post1).reply_is_from_sockpuppet?.should eq(false)
|
||||
expect(described_class.new(post1).reply_is_from_sockpuppet?).to eq(false)
|
||||
end
|
||||
|
||||
it 'is false if users have different IP addresses' do
|
||||
post2 = Fabricate(:post, user: Fabricate(:user, ip_address: '182.189.199.199'), topic: post1.topic)
|
||||
described_class.new(post2).reply_is_from_sockpuppet?.should eq(false)
|
||||
expect(described_class.new(post2).reply_is_from_sockpuppet?).to eq(false)
|
||||
end
|
||||
|
||||
it 'is true if users have the same IP address and are new' do
|
||||
post2 = Fabricate(:post, user: Fabricate(:user, ip_address: user1.ip_address), topic: post1.topic)
|
||||
described_class.new(post2).reply_is_from_sockpuppet?.should eq(true)
|
||||
expect(described_class.new(post2).reply_is_from_sockpuppet?).to eq(true)
|
||||
end
|
||||
|
||||
it 'is false if the ip address is whitelisted' do
|
||||
ScreenedIpAddress.stubs(:is_whitelisted?).with(user1.ip_address).returns(true)
|
||||
post2 = Fabricate(:post, user: Fabricate(:user, ip_address: user1.ip_address), topic: post1.topic)
|
||||
described_class.new(post2).reply_is_from_sockpuppet?.should eq(false)
|
||||
expect(described_class.new(post2).reply_is_from_sockpuppet?).to eq(false)
|
||||
end
|
||||
|
||||
it 'is false if reply and first post are from the same user' do
|
||||
post2 = Fabricate(:post, user: user1, topic: post1.topic)
|
||||
described_class.new(post2).reply_is_from_sockpuppet?.should eq(false)
|
||||
expect(described_class.new(post2).reply_is_from_sockpuppet?).to eq(false)
|
||||
end
|
||||
|
||||
it 'is false if first post user is staff' do
|
||||
staff1 = Fabricate(:admin, ip_address: '182.189.119.174')
|
||||
staff_post1 = Fabricate(:post, user: staff1, topic: Fabricate(:topic, user: staff1))
|
||||
post2 = Fabricate(:post, user: Fabricate(:user, ip_address: staff1.ip_address), topic: staff_post1.topic)
|
||||
described_class.new(post2).reply_is_from_sockpuppet?.should eq(false)
|
||||
expect(described_class.new(post2).reply_is_from_sockpuppet?).to eq(false)
|
||||
end
|
||||
|
||||
it 'is false if second post user is staff' do
|
||||
post2 = Fabricate(:post, user: Fabricate(:moderator, ip_address: user1.ip_address), topic: post1.topic)
|
||||
described_class.new(post2).reply_is_from_sockpuppet?.should eq(false)
|
||||
expect(described_class.new(post2).reply_is_from_sockpuppet?).to eq(false)
|
||||
end
|
||||
|
||||
it 'is false if both users are staff' do
|
||||
staff1 = Fabricate(:moderator, ip_address: '182.189.119.174')
|
||||
staff_post1 = Fabricate(:post, user: staff1, topic: Fabricate(:topic, user: staff1))
|
||||
post2 = Fabricate(:post, user: Fabricate(:admin, ip_address: staff1.ip_address), topic: staff_post1.topic)
|
||||
described_class.new(post2).reply_is_from_sockpuppet?.should eq(false)
|
||||
expect(described_class.new(post2).reply_is_from_sockpuppet?).to eq(false)
|
||||
end
|
||||
|
||||
it 'is true if first post user was created over 24 hours ago and has trust level higher than 0' do
|
||||
old_user = Fabricate(:user, ip_address: '182.189.119.174', created_at: 25.hours.ago, trust_level: TrustLevel[1])
|
||||
first_post = Fabricate(:post, user: old_user, topic: Fabricate(:topic, user: old_user))
|
||||
post2 = Fabricate(:post, user: Fabricate(:user, ip_address: old_user.ip_address), topic: first_post.topic)
|
||||
described_class.new(post2).reply_is_from_sockpuppet?.should eq(true)
|
||||
expect(described_class.new(post2).reply_is_from_sockpuppet?).to eq(true)
|
||||
end
|
||||
|
||||
it 'is false if second post user was created over 24 hours ago and has trust level higher than 0' do
|
||||
post2 = Fabricate(:post, user: Fabricate(:user, ip_address: user1.ip_address, created_at: 25.hours.ago, trust_level: TrustLevel[1]), topic: post1.topic)
|
||||
described_class.new(post2).reply_is_from_sockpuppet?.should eq(false)
|
||||
expect(described_class.new(post2).reply_is_from_sockpuppet?).to eq(false)
|
||||
end
|
||||
|
||||
it 'is true if first post user was created less that 24 hours ago and has trust level higher than 0' do
|
||||
new_user = Fabricate(:user, ip_address: '182.189.119.174', created_at: 1.hour.ago, trust_level: TrustLevel[1])
|
||||
first_post = Fabricate(:post, user: new_user, topic: Fabricate(:topic, user: new_user))
|
||||
post2 = Fabricate(:post, user: Fabricate(:user, ip_address: new_user.ip_address), topic: first_post.topic)
|
||||
described_class.new(post2).reply_is_from_sockpuppet?.should eq(true)
|
||||
expect(described_class.new(post2).reply_is_from_sockpuppet?).to eq(true)
|
||||
end
|
||||
|
||||
it 'is true if second user was created less that 24 hours ago and has trust level higher than 0' do
|
||||
post2 = Fabricate(:post, user: Fabricate(:user, ip_address: user1.ip_address, created_at: 23.hours.ago, trust_level: TrustLevel[1]), topic: post1.topic)
|
||||
described_class.new(post2).reply_is_from_sockpuppet?.should eq(true)
|
||||
expect(described_class.new(post2).reply_is_from_sockpuppet?).to eq(true)
|
||||
end
|
||||
|
||||
# A weird case
|
||||
it 'is false when user is nil on first post' do
|
||||
post1.user = nil; post1.save!
|
||||
post2 = Fabricate(:post, user: Fabricate(:user), topic: post1.topic)
|
||||
described_class.new(post2).reply_is_from_sockpuppet?.should eq(false)
|
||||
expect(described_class.new(post2).reply_is_from_sockpuppet?).to eq(false)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ describe GroupMessage do
|
|||
before { GroupMessage.any_instance.stubs(:sent_recently?).returns(true) }
|
||||
subject { GroupMessage.create(moderators_group, :user_automatically_blocked, {user: user}) }
|
||||
|
||||
it { should eq(false) }
|
||||
it { is_expected.to eq(false) }
|
||||
|
||||
it 'should not send the same notification again' do
|
||||
PostCreator.expects(:create).never
|
||||
|
|
|
@ -15,29 +15,29 @@ describe PostAlerter do
|
|||
post = Fabricate(:post, raw: '[quote="EvilTrout, post:1"]whatup[/quote]')
|
||||
MutedUser.create!(user_id: evil_trout.id, muted_user_id: post.user_id)
|
||||
|
||||
lambda {
|
||||
expect {
|
||||
PostAlerter.post_created(post)
|
||||
}.should change(evil_trout.notifications, :count).by(0)
|
||||
}.to change(evil_trout.notifications, :count).by(0)
|
||||
end
|
||||
|
||||
it 'notifies a user by username' do
|
||||
lambda {
|
||||
expect {
|
||||
create_post_with_alerts(raw: '[quote="EvilTrout, post:1"]whatup[/quote]')
|
||||
}.should change(evil_trout.notifications, :count).by(1)
|
||||
}.to change(evil_trout.notifications, :count).by(1)
|
||||
end
|
||||
|
||||
it "won't notify the user a second time on revision" do
|
||||
p1 = create_post_with_alerts(raw: '[quote="Evil Trout, post:1"]whatup[/quote]')
|
||||
lambda {
|
||||
expect {
|
||||
p1.revise(p1.user, { raw: '[quote="Evil Trout, post:1"]whatup now?[/quote]' })
|
||||
}.should_not change(evil_trout.notifications, :count)
|
||||
}.not_to change(evil_trout.notifications, :count)
|
||||
end
|
||||
|
||||
it "doesn't notify the poster" do
|
||||
topic = create_post_with_alerts.topic
|
||||
lambda {
|
||||
expect {
|
||||
Fabricate(:post, topic: topic, user: topic.user, raw: '[quote="Bruce Wayne, post:1"]whatup[/quote]')
|
||||
}.should_not change(topic.user.notifications, :count)
|
||||
}.not_to change(topic.user.notifications, :count)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -47,16 +47,16 @@ describe PostAlerter do
|
|||
user = post1.user
|
||||
create_post(raw: "my magic topic\n##{Discourse.base_url}#{post1.url}")
|
||||
|
||||
user.notifications.count.should == 1
|
||||
expect(user.notifications.count).to eq(1)
|
||||
|
||||
create_post(user: user, raw: "my magic topic\n##{Discourse.base_url}#{post1.url}")
|
||||
|
||||
user.reload
|
||||
user.notifications.count.should == 1
|
||||
expect(user.notifications.count).to eq(1)
|
||||
|
||||
# don't notify on reflection
|
||||
post1.reload
|
||||
PostAlerter.new.extract_linked_users(post1).length.should == 0
|
||||
expect(PostAlerter.new.extract_linked_users(post1).length).to eq(0)
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -68,24 +68,24 @@ describe PostAlerter do
|
|||
let(:topic) { mention_post.topic }
|
||||
|
||||
it 'notifies a user' do
|
||||
lambda {
|
||||
expect {
|
||||
mention_post
|
||||
}.should change(evil_trout.notifications, :count).by(1)
|
||||
}.to change(evil_trout.notifications, :count).by(1)
|
||||
end
|
||||
|
||||
it "won't notify the user a second time on revision" do
|
||||
mention_post
|
||||
lambda {
|
||||
expect {
|
||||
mention_post.revise(mention_post.user, { raw: "New raw content that still mentions @eviltrout" })
|
||||
}.should_not change(evil_trout.notifications, :count)
|
||||
}.not_to change(evil_trout.notifications, :count)
|
||||
end
|
||||
|
||||
it "doesn't notify the user who created the topic in regular mode" do
|
||||
topic.notify_regular!(user)
|
||||
mention_post
|
||||
lambda {
|
||||
expect {
|
||||
create_post_with_alerts(user: user, raw: 'second post', topic: topic)
|
||||
}.should_not change(user.notifications, :count)
|
||||
}.not_to change(user.notifications, :count)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -60,33 +60,33 @@ describe PostOwnerChanger do
|
|||
change_owners
|
||||
|
||||
p1user.reload; p2user.reload; user_a.reload
|
||||
p1user.topic_count.should == 0
|
||||
p1user.post_count.should == 0
|
||||
p2user.topic_count.should == 0
|
||||
p2user.post_count.should == 0
|
||||
user_a.topic_count.should == 1
|
||||
user_a.post_count.should == 2
|
||||
p1user.user_stat.first_post_created_at.should == nil
|
||||
p2user.user_stat.first_post_created_at.should == nil
|
||||
p1user.user_stat.topic_reply_count.should == 0
|
||||
p2user.user_stat.topic_reply_count.should == 0
|
||||
user_a.user_stat.first_post_created_at.should be_present
|
||||
expect(p1user.topic_count).to eq(0)
|
||||
expect(p1user.post_count).to eq(0)
|
||||
expect(p2user.topic_count).to eq(0)
|
||||
expect(p2user.post_count).to eq(0)
|
||||
expect(user_a.topic_count).to eq(1)
|
||||
expect(user_a.post_count).to eq(2)
|
||||
expect(p1user.user_stat.first_post_created_at).to eq(nil)
|
||||
expect(p2user.user_stat.first_post_created_at).to eq(nil)
|
||||
expect(p1user.user_stat.topic_reply_count).to eq(0)
|
||||
expect(p2user.user_stat.topic_reply_count).to eq(0)
|
||||
expect(user_a.user_stat.first_post_created_at).to be_present
|
||||
end
|
||||
|
||||
it "updates UserAction records" do
|
||||
g = Guardian.new(editor)
|
||||
UserAction.stats(user_a.id, g).should == []
|
||||
expect(UserAction.stats(user_a.id, g)).to eq([])
|
||||
|
||||
change_owners
|
||||
|
||||
UserAction.stats(p1user.id, g).should == []
|
||||
UserAction.stats(p2user.id, g).should == []
|
||||
expect(UserAction.stats(p1user.id, g)).to eq([])
|
||||
expect(UserAction.stats(p2user.id, g)).to eq([])
|
||||
stats = UserAction.stats(user_a.id, g)
|
||||
stats.size.should == 2
|
||||
stats[0].action_type.should == UserAction::NEW_TOPIC
|
||||
stats[0].count.should == 1
|
||||
stats[1].action_type.should == UserAction::REPLY
|
||||
stats[1].count.should == 1
|
||||
expect(stats.size).to eq(2)
|
||||
expect(stats[0].action_type).to eq(UserAction::NEW_TOPIC)
|
||||
expect(stats[0].count).to eq(1)
|
||||
expect(stats[1].action_type).to eq(UserAction::REPLY)
|
||||
expect(stats[1].count).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,8 +11,8 @@ describe RandomTopicSelector do
|
|||
$redis.rpush key, t
|
||||
end
|
||||
|
||||
RandomTopicSelector.next(2).should == [0,1]
|
||||
RandomTopicSelector.next(2).should == [2,3]
|
||||
expect(RandomTopicSelector.next(2)).to eq([0,1])
|
||||
expect(RandomTopicSelector.next(2)).to eq([2,3])
|
||||
end
|
||||
|
||||
it 'can correctly backfill' do
|
||||
|
@ -22,6 +22,6 @@ describe RandomTopicSelector do
|
|||
_t3 = Fabricate(:topic, category_id: category.id, deleted_at: 1.minute.ago)
|
||||
t4 = Fabricate(:topic, category_id: category.id)
|
||||
|
||||
RandomTopicSelector.next(5, category).sort.should == [t1.id,t4.id].sort
|
||||
expect(RandomTopicSelector.next(5, category).sort).to eq([t1.id,t4.id].sort)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -35,15 +35,15 @@ describe StaffActionLogger do
|
|||
|
||||
describe "log_show_emails" do
|
||||
it "logs the user history" do
|
||||
-> { logger.log_show_emails([admin]) }.should change(UserHistory, :count).by(1)
|
||||
expect { logger.log_show_emails([admin]) }.to change(UserHistory, :count).by(1)
|
||||
end
|
||||
|
||||
it "doesn't raise an exception with nothing to log" do
|
||||
-> { logger.log_show_emails([]) }.should_not raise_error
|
||||
expect { logger.log_show_emails([]) }.not_to raise_error
|
||||
end
|
||||
|
||||
it "doesn't raise an exception with nil input" do
|
||||
-> { logger.log_show_emails(nil) }.should_not raise_error
|
||||
expect { logger.log_show_emails(nil) }.not_to raise_error
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -107,7 +107,7 @@ describe StaffActionLogger do
|
|||
|
||||
it 'creates a new UserHistory record' do
|
||||
expect { log_trust_level_change }.to change { UserHistory.count }.by(1)
|
||||
UserHistory.last.details.should include "new trust level: #{new_trust_level}"
|
||||
expect(UserHistory.last.details).to include "new trust level: #{new_trust_level}"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -132,21 +132,21 @@ describe StaffActionLogger do
|
|||
|
||||
it "logs new site customizations" do
|
||||
log_record = logger.log_site_customization_change(nil, valid_params)
|
||||
log_record.subject.should == valid_params[:name]
|
||||
log_record.previous_value.should == nil
|
||||
log_record.new_value.should be_present
|
||||
expect(log_record.subject).to eq(valid_params[:name])
|
||||
expect(log_record.previous_value).to eq(nil)
|
||||
expect(log_record.new_value).to be_present
|
||||
json = ::JSON.parse(log_record.new_value)
|
||||
json['stylesheet'].should be_present
|
||||
json['header'].should be_present
|
||||
expect(json['stylesheet']).to be_present
|
||||
expect(json['header']).to be_present
|
||||
end
|
||||
|
||||
it "logs updated site customizations" do
|
||||
existing = SiteCustomization.new(name: 'Banana', stylesheet: "body {color: yellow;}", header: "h1 {color: brown;}")
|
||||
log_record = logger.log_site_customization_change(existing, valid_params)
|
||||
log_record.previous_value.should be_present
|
||||
expect(log_record.previous_value).to be_present
|
||||
json = ::JSON.parse(log_record.previous_value)
|
||||
json['stylesheet'].should == existing.stylesheet
|
||||
json['header'].should == existing.header
|
||||
expect(json['stylesheet']).to eq(existing.stylesheet)
|
||||
expect(json['header']).to eq(existing.header)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -158,11 +158,11 @@ describe StaffActionLogger do
|
|||
it "creates a new UserHistory record" do
|
||||
site_customization = SiteCustomization.new(name: 'Banana', stylesheet: "body {color: yellow;}", header: "h1 {color: brown;}")
|
||||
log_record = logger.log_site_customization_destroy(site_customization)
|
||||
log_record.previous_value.should be_present
|
||||
log_record.new_value.should == nil
|
||||
expect(log_record.previous_value).to be_present
|
||||
expect(log_record.new_value).to eq(nil)
|
||||
json = ::JSON.parse(log_record.previous_value)
|
||||
json['stylesheet'].should == site_customization.stylesheet
|
||||
json['header'].should == site_customization.header
|
||||
expect(json['stylesheet']).to eq(site_customization.stylesheet)
|
||||
expect(json['header']).to eq(site_customization.header)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -181,9 +181,9 @@ describe StaffActionLogger do
|
|||
it "creates a new UserHistory record" do
|
||||
reason = "He was a big meanie."
|
||||
log_record = logger.log_user_suspend(user, reason)
|
||||
log_record.should be_valid
|
||||
log_record.details.should == reason
|
||||
log_record.target_user.should == user
|
||||
expect(log_record).to be_valid
|
||||
expect(log_record.details).to eq(reason)
|
||||
expect(log_record.target_user).to eq(user)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -196,8 +196,8 @@ describe StaffActionLogger do
|
|||
|
||||
it "creates a new UserHistory record" do
|
||||
log_record = logger.log_user_unsuspend(user)
|
||||
log_record.should be_valid
|
||||
log_record.target_user.should == user
|
||||
expect(log_record).to be_valid
|
||||
expect(log_record.target_user).to eq(user)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -212,9 +212,9 @@ describe StaffActionLogger do
|
|||
|
||||
it "creates a new UserHistory record" do
|
||||
log_record = logger.log_badge_grant(user_badge)
|
||||
log_record.should be_valid
|
||||
log_record.target_user.should == user
|
||||
log_record.details.should == badge.name
|
||||
expect(log_record).to be_valid
|
||||
expect(log_record.target_user).to eq(user)
|
||||
expect(log_record.details).to eq(badge.name)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -229,9 +229,9 @@ describe StaffActionLogger do
|
|||
|
||||
it "creates a new UserHistory record" do
|
||||
log_record = logger.log_badge_revoke(user_badge)
|
||||
log_record.should be_valid
|
||||
log_record.target_user.should == user
|
||||
log_record.details.should == badge.name
|
||||
expect(log_record).to be_valid
|
||||
expect(log_record.target_user).to eq(user)
|
||||
expect(log_record.details).to eq(badge.name)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -241,8 +241,8 @@ describe StaffActionLogger do
|
|||
|
||||
it 'creates a new UserHistory record' do
|
||||
log_record = logger.log_roll_up(subnets)
|
||||
log_record.should be_valid
|
||||
log_record.details.should == subnets.join(", ")
|
||||
expect(log_record).to be_valid
|
||||
expect(log_record.details).to eq(subnets.join(", "))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -257,11 +257,11 @@ describe StaffActionLogger do
|
|||
clicked_on: 'thing',
|
||||
topic_id: 1234
|
||||
})
|
||||
logged.should be_valid
|
||||
logged.details.should == "evil: trout\nclicked_on: thing"
|
||||
logged.action.should == UserHistory.actions[:custom_staff]
|
||||
logged.custom_type.should == 'clicked_something'
|
||||
logged.topic_id.should === 1234
|
||||
expect(logged).to be_valid
|
||||
expect(logged.details).to eq("evil: trout\nclicked_on: thing")
|
||||
expect(logged.action).to eq(UserHistory.actions[:custom_staff])
|
||||
expect(logged.custom_type).to eq('clicked_something')
|
||||
expect(logged.topic_id).to be === 1234
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,22 +10,22 @@ describe UserAnonymizer do
|
|||
|
||||
it "changes username" do
|
||||
make_anonymous
|
||||
user.reload.username.should =~ /^anon\d{3,}$/
|
||||
expect(user.reload.username).to match(/^anon\d{3,}$/)
|
||||
end
|
||||
|
||||
it "changes email address" do
|
||||
make_anonymous
|
||||
user.reload.email.should == "#{user.username}@example.com"
|
||||
expect(user.reload.email).to eq("#{user.username}@example.com")
|
||||
end
|
||||
|
||||
it "turns off all notifications" do
|
||||
make_anonymous
|
||||
user.reload
|
||||
user.email_digests.should == false
|
||||
user.email_private_messages.should == false
|
||||
user.email_direct.should == false
|
||||
user.email_always.should == false
|
||||
user.mailing_list_mode.should == false
|
||||
expect(user.email_digests).to eq(false)
|
||||
expect(user.email_private_messages).to eq(false)
|
||||
expect(user.email_direct).to eq(false)
|
||||
expect(user.email_always).to eq(false)
|
||||
expect(user.mailing_list_mode).to eq(false)
|
||||
end
|
||||
|
||||
it "resets profile to default values" do
|
||||
|
@ -42,17 +42,17 @@ describe UserAnonymizer do
|
|||
make_anonymous
|
||||
user.reload
|
||||
|
||||
user.name.should_not be_present
|
||||
user.date_of_birth.should == nil
|
||||
user.title.should_not be_present
|
||||
expect(user.name).not_to be_present
|
||||
expect(user.date_of_birth).to eq(nil)
|
||||
expect(user.title).not_to be_present
|
||||
|
||||
profile = user.user_profile(true)
|
||||
profile.location.should == nil
|
||||
profile.website.should == nil
|
||||
profile.bio_cooked.should == nil
|
||||
profile.profile_background.should == nil
|
||||
profile.bio_cooked_version.should == nil
|
||||
profile.card_background.should == nil
|
||||
expect(profile.location).to eq(nil)
|
||||
expect(profile.website).to eq(nil)
|
||||
expect(profile.bio_cooked).to eq(nil)
|
||||
expect(profile.profile_background).to eq(nil)
|
||||
expect(profile.bio_cooked_version).to eq(nil)
|
||||
expect(profile.card_background).to eq(nil)
|
||||
end
|
||||
|
||||
it "removes the avatar" do
|
||||
|
@ -61,7 +61,7 @@ describe UserAnonymizer do
|
|||
user.save!
|
||||
expect { make_anonymous }.to change { Upload.count }.by(-1)
|
||||
user.reload
|
||||
user.user_avatar.should == nil
|
||||
expect(user.user_avatar).to eq(nil)
|
||||
end
|
||||
|
||||
it "logs the action" do
|
||||
|
@ -78,20 +78,20 @@ describe UserAnonymizer do
|
|||
UserOpenId.create(user_id: user.id, email: user.email, url: "http://example.com/openid", active: true)
|
||||
make_anonymous
|
||||
user.reload
|
||||
user.twitter_user_info.should == nil
|
||||
user.google_user_info.should == nil
|
||||
user.github_user_info.should == nil
|
||||
user.facebook_user_info.should == nil
|
||||
user.single_sign_on_record.should == nil
|
||||
user.oauth2_user_info.should == nil
|
||||
user.user_open_ids.count.should == 0
|
||||
expect(user.twitter_user_info).to eq(nil)
|
||||
expect(user.google_user_info).to eq(nil)
|
||||
expect(user.github_user_info).to eq(nil)
|
||||
expect(user.facebook_user_info).to eq(nil)
|
||||
expect(user.single_sign_on_record).to eq(nil)
|
||||
expect(user.oauth2_user_info).to eq(nil)
|
||||
expect(user.user_open_ids.count).to eq(0)
|
||||
end
|
||||
|
||||
it "removes api key" do
|
||||
ApiKey.create(user_id: user.id, key: "123123123")
|
||||
expect { make_anonymous }.to change { ApiKey.count }.by(-1)
|
||||
user.reload
|
||||
user.api_key.should == nil
|
||||
expect(user.api_key).to eq(nil)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -58,7 +58,7 @@ describe UserBlocker do
|
|||
user.stubs(:blocked?).returns(true)
|
||||
SystemMessage.unstub(:create)
|
||||
SystemMessage.expects(:create).never
|
||||
block_user.should == false
|
||||
expect(block_user).to eq(false)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -42,8 +42,8 @@ describe UserDestroyer do
|
|||
|
||||
it 'should return the deleted user record' do
|
||||
return_value = destroy
|
||||
return_value.should == @user
|
||||
return_value.should be_destroyed
|
||||
expect(return_value).to eq(@user)
|
||||
expect(return_value).to be_destroyed
|
||||
end
|
||||
|
||||
it 'should log the action' do
|
||||
|
@ -123,22 +123,22 @@ describe UserDestroyer do
|
|||
|
||||
it "deletes the posts" do
|
||||
destroy
|
||||
post.reload.deleted_at.should_not == nil
|
||||
post.user_id.should == nil
|
||||
expect(post.reload.deleted_at).not_to eq(nil)
|
||||
expect(post.user_id).to eq(nil)
|
||||
end
|
||||
|
||||
it "does not delete topics started by others in which the user has replies" do
|
||||
destroy
|
||||
topic.reload.deleted_at.should == nil
|
||||
topic.user_id.should_not == nil
|
||||
expect(topic.reload.deleted_at).to eq(nil)
|
||||
expect(topic.user_id).not_to eq(nil)
|
||||
end
|
||||
|
||||
it "deletes topics started by the deleted user" do
|
||||
spammer_topic = Fabricate(:topic, user: @user)
|
||||
spammer_post = Fabricate(:post, user: @user, topic: spammer_topic)
|
||||
destroy
|
||||
spammer_topic.reload.deleted_at.should_not == nil
|
||||
spammer_topic.user_id.should == nil
|
||||
expect(spammer_topic.reload.deleted_at).not_to eq(nil)
|
||||
expect(spammer_topic.user_id).to eq(nil)
|
||||
end
|
||||
|
||||
context "delete_as_spammer is true" do
|
||||
|
@ -148,12 +148,12 @@ describe UserDestroyer do
|
|||
it "agrees with flags on user's posts" do
|
||||
spammer_post = Fabricate(:post, user: @user)
|
||||
flag = PostAction.act(@admin, spammer_post, PostActionType.types[:inappropriate])
|
||||
flag.agreed_at.should == nil
|
||||
expect(flag.agreed_at).to eq(nil)
|
||||
|
||||
destroy
|
||||
|
||||
flag.reload
|
||||
flag.agreed_at.should_not == nil
|
||||
expect(flag.agreed_at).not_to eq(nil)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -167,8 +167,8 @@ describe UserDestroyer do
|
|||
|
||||
it "deletes the posts" do
|
||||
destroy
|
||||
post.reload.deleted_at.should_not == nil
|
||||
post.user_id.should == nil
|
||||
expect(post.reload.deleted_at).not_to eq(nil)
|
||||
expect(post.user_id).to eq(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -188,7 +188,7 @@ describe UserDestroyer do
|
|||
let!(:deleted_post) { Fabricate(:post, user: @user, deleted_at: 1.hour.ago) }
|
||||
it "should mark the user's deleted posts as belonging to a nuked user" do
|
||||
expect { UserDestroyer.new(@admin).destroy(@user) }.to change { User.count }.by(-1)
|
||||
deleted_post.reload.user_id.should == nil
|
||||
expect(deleted_post.reload.user_id).to eq(nil)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -209,7 +209,7 @@ describe UserDestroyer do
|
|||
end
|
||||
|
||||
it 'should return false' do
|
||||
destroy.should == false
|
||||
expect(destroy).to eq(false)
|
||||
end
|
||||
|
||||
it 'should not log the action' do
|
||||
|
@ -289,9 +289,9 @@ describe UserDestroyer do
|
|||
|
||||
it "assigns the system user to the categories" do
|
||||
UserDestroyer.new(@admin).destroy(@user, {delete_posts: true})
|
||||
category.reload.user_id.should == Discourse.system_user.id
|
||||
category.topic.should be_present
|
||||
category.topic.user_id.should == Discourse.system_user.id
|
||||
expect(category.reload.user_id).to eq(Discourse.system_user.id)
|
||||
expect(category.topic).to be_present
|
||||
expect(category.topic.user_id).to eq(Discourse.system_user.id)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -317,7 +317,7 @@ describe UserDestroyer do
|
|||
expect {
|
||||
UserDestroyer.new(@admin).destroy(@user, {delete_posts: true})
|
||||
}.to change { PostAction.count }.by(-1)
|
||||
@post.reload.like_count.should == 0
|
||||
expect(@post.reload.like_count).to eq(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -125,7 +125,7 @@ describe UserUpdater do
|
|||
updater = described_class.new(acting_user, user)
|
||||
|
||||
updater.update(website: 'example.com', custom_fields: '')
|
||||
user.reload.custom_fields.should == {'import_username' => 'my_old_username'}
|
||||
expect(user.reload.custom_fields).to eq({'import_username' => 'my_old_username'})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -35,14 +35,14 @@ describe UsernameCheckerService do
|
|||
User.stubs(:username_available?).returns(false)
|
||||
UserNameSuggester.stubs(:suggest).returns('einar-j')
|
||||
result = @service.check_username('vincent', @nil_email)
|
||||
result[:available].should == false
|
||||
result[:suggestion].should eq('einar-j')
|
||||
expect(result[:available]).to eq(false)
|
||||
expect(result[:suggestion]).to eq('einar-j')
|
||||
end
|
||||
|
||||
it 'username available locally' do
|
||||
User.stubs(:username_available?).returns(true)
|
||||
result = @service.check_username('vincent', @nil_email)
|
||||
result[:available].should == true
|
||||
expect(result[:available]).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ module Helpers
|
|||
sleep 0.001
|
||||
end
|
||||
|
||||
result.should == true
|
||||
expect(result).to eq(true)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@ shared_examples_for "a versioned model" do
|
|||
let(:model) { Fabricate(described_class.to_s.downcase) }
|
||||
|
||||
it 'should be versioned' do
|
||||
model.should respond_to(:version)
|
||||
model.version.should == 1
|
||||
expect(model).to respond_to(:version)
|
||||
expect(model.version).to eq(1)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue