diff --git a/app/models/screened_email.rb b/app/models/screened_email.rb
index 5a3a0e08040..8f8de3fd118 100644
--- a/app/models/screened_email.rb
+++ b/app/models/screened_email.rb
@@ -35,7 +35,7 @@ class ScreenedEmail < ActiveRecord::Base
screened_email.record_match! if screened_email
- screened_email && screened_email.action_type == actions[:block]
+ screened_email.try(:action_type) == actions[:block]
end
def self.levenshtein(first, second)
diff --git a/app/models/topic.rb b/app/models/topic.rb
index 1ec59f19868..7069e95770a 100644
--- a/app/models/topic.rb
+++ b/app/models/topic.rb
@@ -528,15 +528,15 @@ class Topic < ActiveRecord::Base
end
def remove_allowed_user(username)
- user = User.find_by(username: username)
- if user
+ if user = User.find_by(username: username)
topic_user = topic_allowed_users.find_by(user_id: user.id)
if topic_user
topic_user.destroy
- else
- false
+ return true
end
end
+
+ false
end
# Invite a user to the topic by username or email. Returns success/failure
diff --git a/app/serializers/post_serializer.rb b/app/serializers/post_serializer.rb
index 582d5e06025..10012e357cf 100644
--- a/app/serializers/post_serializer.rb
+++ b/app/serializers/post_serializer.rb
@@ -54,15 +54,15 @@ class PostSerializer < BasicPostSerializer
:via_email
def moderator?
- !!(object.user && object.user.moderator?)
+ !!(object.try(:user).try(:moderator?))
end
def admin?
- !!(object.user && object.user.admin?)
+ !!(object.try(:user).try(:admin?))
end
def staff?
- !!(object.user && object.user.staff?)
+ !!(object.try(:user).try(:staff?))
end
def yours
@@ -119,11 +119,11 @@ class PostSerializer < BasicPostSerializer
end
def user_title
- object.user.try(:title)
+ object.try(:user).try(:title)
end
def trust_level
- object.user.try(:trust_level)
+ object.try(:user).try(:trust_level)
end
def reply_to_user
diff --git a/lib/scheduler/schedule_info.rb b/lib/scheduler/schedule_info.rb
index 7be6da36fe1..9416ffa3bd0 100644
--- a/lib/scheduler/schedule_info.rb
+++ b/lib/scheduler/schedule_info.rb
@@ -35,14 +35,16 @@ module Scheduler
def valid_every?
return false unless @klass.every
- @prev_run &&
+ !!@prev_run &&
@prev_run <= Time.now.to_i &&
@next_run < @prev_run + @klass.every * (1 + @manager.random_ratio)
end
def valid_daily?
return false unless @klass.daily
- @prev_run && @prev_run <= Time.now.to_i && @next_run < @prev_run + 1.day
+ !!@prev_run &&
+ @prev_run <= Time.now.to_i &&
+ @next_run < @prev_run + 1.day
end
def schedule_every!
diff --git a/lib/url_helper.rb b/lib/url_helper.rb
index 7c913d1bc2d..19d2fc23df1 100644
--- a/lib/url_helper.rb
+++ b/lib/url_helper.rb
@@ -3,8 +3,8 @@ module UrlHelper
def is_local(url)
url.present? && (
Discourse.store.has_been_uploaded?(url) ||
- url =~ /^\/assets\// ||
- url =~ /^\/plugins\// ||
+ !!(url =~ /^\/assets\//) ||
+ !!(url =~ /^\/plugins\//) ||
url.start_with?(Discourse.asset_host || Discourse.base_url_no_prefix)
)
end
diff --git a/plugins/poll/spec/poll_plugin/poll_spec.rb b/plugins/poll/spec/poll_plugin/poll_spec.rb
index caa1c45236a..816738ea9f7 100644
--- a/plugins/poll/spec/poll_plugin/poll_spec.rb
+++ b/plugins/poll/spec/poll_plugin/poll_spec.rb
@@ -7,20 +7,20 @@ describe PollPlugin::Poll do
let(:user) { Fabricate(:user) }
it "should detect poll post correctly" do
- expect(poll.is_poll?).to be_true
+ expect(poll.is_poll?).should == true
post2 = create_post(topic: topic, raw: "This is a generic reply.")
- expect(PollPlugin::Poll.new(post2).is_poll?).to be_false
+ expect(PollPlugin::Poll.new(post2).is_poll?).should == false
post.topic.title = "Not a poll"
- expect(poll.is_poll?).to be_false
+ expect(poll.is_poll?).should == false
end
it "strips whitespace from the prefix translation" do
topic.title = "Polll: This might be a poll"
topic.save
- expect(PollPlugin::Poll.new(post).is_poll?).to be_false
+ expect(PollPlugin::Poll.new(post).is_poll?).should == false
I18n.expects(:t).with('poll.prefix').returns("Polll ")
I18n.expects(:t).with('poll.closed_prefix').returns("Closed Poll ")
- expect(PollPlugin::Poll.new(post).is_poll?).to be_true
+ expect(PollPlugin::Poll.new(post).is_poll?).should == true
end
it "should get options correctly" do
diff --git a/plugins/poll/spec/post_creator_spec.rb b/plugins/poll/spec/post_creator_spec.rb
index 7e2c78d2a85..d409bc8731a 100644
--- a/plugins/poll/spec/post_creator_spec.rb
+++ b/plugins/poll/spec/post_creator_spec.rb
@@ -15,11 +15,11 @@ describe PostCreator do
it "cannot have options changed after 5 minutes" do
poll_post.raw = "[poll]\n* option 1\n* option 2\n* option 3\n[/poll]"
- poll_post.valid?.should be_true
+ poll_post.valid?.should == true
poll_post.save
Timecop.freeze(Time.now + 6.minutes) do
poll_post.raw = "[poll]\n* option 1\n* option 2\n* option 3\n* option 4\n[/poll]"
- poll_post.valid?.should be_false
+ poll_post.valid?.should == false
poll_post.errors[:poll_options].should be_present
end
end
@@ -28,9 +28,9 @@ describe PostCreator do
poll_post.last_editor_id = admin.id
Timecop.freeze(Time.now + 6.minutes) do
poll_post.raw = "[poll]\n* option 1\n* option 2\n* option 3\n* option 4.1\n[/poll]"
- poll_post.valid?.should be_true
+ poll_post.valid?.should == true
poll_post.raw = "[poll]\n* option 1\n* option 2\n* option 3\n[/poll]"
- poll_post.valid?.should be_false
+ poll_post.valid?.should == false
end
end
end
diff --git a/spec/components/auth/facebook_authenticator_spec.rb b/spec/components/auth/facebook_authenticator_spec.rb
index 8ace4391005..9ee4d303c47 100644
--- a/spec/components/auth/facebook_authenticator_spec.rb
+++ b/spec/components/auth/facebook_authenticator_spec.rb
@@ -49,7 +49,7 @@ describe Auth::FacebookAuthenticator do
result = authenticator.after_authenticate(hash)
- result.user.should be_nil
+ result.user.should == nil
result.extra_data[:name].should == "bob bob"
end
end
diff --git a/spec/components/auth/google_oauth2_authenticator_spec.rb b/spec/components/auth/google_oauth2_authenticator_spec.rb
index adab781c2fa..bb481658c22 100644
--- a/spec/components/auth/google_oauth2_authenticator_spec.rb
+++ b/spec/components/auth/google_oauth2_authenticator_spec.rb
@@ -50,7 +50,7 @@ describe Auth::GoogleOAuth2Authenticator do
authenticator = described_class.new
result = authenticator.after_authenticate(hash)
- result.user.should be_nil
+ result.user.should == nil
result.extra_data[:name].should == "Jane Doe"
end
end
diff --git a/spec/components/avatar_lookup_spec.rb b/spec/components/avatar_lookup_spec.rb
index 4fae74dccaf..163e4a7124f 100644
--- a/spec/components/avatar_lookup_spec.rb
+++ b/spec/components/avatar_lookup_spec.rb
@@ -12,15 +12,15 @@ describe AvatarLookup do
end
it 'returns nil if user_id does not exists' do
- @avatar_lookup[0].should be_nil
+ @avatar_lookup[0].should == nil
end
it 'returns nil if user_id is nil' do
- @avatar_lookup[nil].should be_nil
+ @avatar_lookup[nil].should == nil
end
it 'returns user if user_id exists' do
@avatar_lookup[user.id].should eq(user)
end
end
-end
\ No newline at end of file
+end
diff --git a/spec/components/cache_spec.rb b/spec/components/cache_spec.rb
index 0c9b14c5460..bbc1e842670 100644
--- a/spec/components/cache_spec.rb
+++ b/spec/components/cache_spec.rb
@@ -23,7 +23,7 @@ describe Cache do
cache.write("hello1", "world")
cache.clear
- cache.read("hello0").should be_nil
+ cache.read("hello0").should == nil
end
it "can delete by family" do
@@ -32,8 +32,8 @@ describe Cache do
cache.delete_by_family("my_family")
- cache.fetch("key").should be_nil
- cache.fetch("key2").should be_nil
+ cache.fetch("key").should == nil
+ cache.fetch("key2").should == nil
end
@@ -43,7 +43,7 @@ describe Cache do
end
cache.delete("key")
- cache.fetch("key").should be_nil
+ cache.fetch("key").should == nil
end
#TODO yuck on this mock
diff --git a/spec/components/category_list_spec.rb b/spec/components/category_list_spec.rb
index b508c1b9697..51b1b44ec2b 100644
--- a/spec/components/category_list_spec.rb
+++ b/spec/components/category_list_spec.rb
@@ -40,10 +40,10 @@ describe CategoryList do
CategoryList.new(Guardian.new(admin)).categories.find { |x| x.name == private_cat.name }.displayable_topics.count.should == 1
CategoryList.new(Guardian.new(user)).categories.find { |x| x.name == public_cat.name }.displayable_topics.count.should == 1
- CategoryList.new(Guardian.new(user)).categories.find { |x| x.name == private_cat.name }.should be_nil
+ CategoryList.new(Guardian.new(user)).categories.find { |x| x.name == private_cat.name }.should == nil
CategoryList.new(Guardian.new(nil)).categories.find { |x| x.name == public_cat.name }.displayable_topics.count.should == 1
- CategoryList.new(Guardian.new(nil)).categories.find { |x| x.name == private_cat.name }.should be_nil
+ CategoryList.new(Guardian.new(nil)).categories.find { |x| x.name == private_cat.name }.should == nil
end
end
@@ -98,7 +98,7 @@ describe CategoryList do
end
it "should contain our topic" do
- category.featured_topics.include?(topic).should be_true
+ category.featured_topics.include?(topic).should == true
end
end
diff --git a/spec/components/composer_messages_finder_spec.rb b/spec/components/composer_messages_finder_spec.rb
index 1321013a99d..f119bf4dafd 100644
--- a/spec/components/composer_messages_finder_spec.rb
+++ b/spec/components/composer_messages_finder_spec.rb
@@ -102,7 +102,7 @@ describe ComposerMessagesFinder do
end
it "creates a notified_about_avatar log" do
- UserHistory.exists_for_user?(user, :notified_about_avatar).should be_true
+ UserHistory.exists_for_user?(user, :notified_about_avatar).should == true
end
end
@@ -185,7 +185,7 @@ describe ComposerMessagesFinder do
end
it "creates a notified_about_sequential_replies log" do
- UserHistory.exists_for_user?(user, :notified_about_sequential_replies).should be_true
+ UserHistory.exists_for_user?(user, :notified_about_sequential_replies).should == true
end
end
@@ -270,7 +270,7 @@ describe ComposerMessagesFinder do
end
it "creates a notified_about_dominating_topic log" do
- UserHistory.exists_for_user?(user, :notified_about_dominating_topic).should be_true
+ UserHistory.exists_for_user?(user, :notified_about_dominating_topic).should == true
end
end
diff --git a/spec/components/cooked_post_processor_spec.rb b/spec/components/cooked_post_processor_spec.rb
index db768190052..53f1501b307 100644
--- a/spec/components/cooked_post_processor_spec.rb
+++ b/spec/components/cooked_post_processor_spec.rb
@@ -106,7 +106,7 @@ describe CookedPostProcessor do
it "adds a topic image if there's one in the post" do
FastImage.stubs(:size)
- post.topic.image_url.should be_nil
+ post.topic.image_url.should == nil
cpp.post_process_images
post.topic.reload
post.topic.image_url.should be_present
@@ -364,12 +364,12 @@ describe CookedPostProcessor do
it "is true when the image is inside a link" do
img = doc.css("img#linked_image").first
- cpp.is_a_hyperlink?(img).should be_true
+ cpp.is_a_hyperlink?(img).should == true
end
it "is false when the image is not inside a link" do
img = doc.css("img#standard_image").first
- cpp.is_a_hyperlink?(img).should be_false
+ cpp.is_a_hyperlink?(img).should == false
end
end
diff --git a/spec/components/discourse_plugin_registry_spec.rb b/spec/components/discourse_plugin_registry_spec.rb
index 650d8648de6..f3942e91228 100644
--- a/spec/components/discourse_plugin_registry_spec.rb
+++ b/spec/components/discourse_plugin_registry_spec.rb
@@ -53,7 +53,7 @@ describe DiscoursePluginRegistry do
end
it 'is returned by DiscoursePluginRegistry.stylesheets' do
- registry_instance.stylesheets.include?('hello.css').should be_true
+ registry_instance.stylesheets.include?('hello.css').should == true
end
it "won't add the same file twice" do
@@ -67,7 +67,7 @@ describe DiscoursePluginRegistry do
end
it 'is returned by DiscoursePluginRegistry.javascripts' do
- registry_instance.javascripts.include?('hello.js').should be_true
+ registry_instance.javascripts.include?('hello.js').should == true
end
it "won't add the same file twice" do
diff --git a/spec/components/email/email_spec.rb b/spec/components/email/email_spec.rb
index 47c2e050e44..3773e7df51c 100644
--- a/spec/components/email/email_spec.rb
+++ b/spec/components/email/email_spec.rb
@@ -6,19 +6,19 @@ describe Email do
describe "is_valid?" do
it 'treats a good email as valid' do
- Email.is_valid?('sam@sam.com').should be_true
+ Email.is_valid?('sam@sam.com').should == true
end
it 'treats a bad email as invalid' do
- Email.is_valid?('sam@sam').should be_false
+ Email.is_valid?('sam@sam').should == false
end
it 'allows museum tld' do
- Email.is_valid?('sam@nic.museum').should be_true
+ Email.is_valid?('sam@nic.museum').should == true
end
it 'does not think a word is an email' do
- Email.is_valid?('sam').should be_false
+ Email.is_valid?('sam').should == false
end
end
diff --git a/spec/components/email/receiver_spec.rb b/spec/components/email/receiver_spec.rb
index cf5f6a2f5ec..32babee208c 100644
--- a/spec/components/email/receiver_spec.rb
+++ b/spec/components/email/receiver_spec.rb
@@ -28,7 +28,7 @@ describe Email::Receiver do
expect { test_parse_body(fixture_file("emails/no_content_reply.eml")) }.to raise_error(Email::Receiver::EmptyEmailError)
end
- pending "raises EmailUnparsableError if the headers are corrupted" do
+ skip "raises EmailUnparsableError if the headers are corrupted" do
expect { ; }.to raise_error(Email::Receiver::EmailUnparsableError)
end
@@ -130,7 +130,7 @@ Thanks for listening."
topic.posts.count.should == (start_count + 1)
created_post = topic.posts.last
- created_post.via_email.should be_true
+ created_post.via_email.should == true
created_post.cooked.strip.should == fixture_file("emails/valid_reply.cooked").strip
end
end
@@ -168,7 +168,7 @@ Thanks for listening."
topic.posts.count.should == (start_count + 1)
topic.posts.last.cooked.should match /
/
- Upload.find_by(sha1: upload_sha).should_not be_nil
+ Upload.find_by(sha1: upload_sha).should_not == nil
end
end
diff --git a/spec/components/enum_spec.rb b/spec/components/enum_spec.rb
index 9a5f1f793ef..f0c6ca95b95 100644
--- a/spec/components/enum_spec.rb
+++ b/spec/components/enum_spec.rb
@@ -16,11 +16,11 @@ describe Enum do
describe ".valid?" do
it "returns true if a key exists" do
- enum.valid?(:finn).should be_true
+ enum.valid?(:finn).should == true
end
it "returns false if a key does not exist" do
- enum.valid?(:obama).should be_false
+ enum.valid?(:obama).should == false
end
end
diff --git a/spec/components/guardian_spec.rb b/spec/components/guardian_spec.rb
index 8ebd05af11a..d5ec6ccf450 100644
--- a/spec/components/guardian_spec.rb
+++ b/spec/components/guardian_spec.rb
@@ -28,59 +28,59 @@ describe Guardian do
let(:user) { build(:user) }
it "returns false when the user is nil" do
- Guardian.new(nil).post_can_act?(post, :like).should be_false
+ Guardian.new(nil).post_can_act?(post, :like).should be_falsey
end
it "returns false when the post is nil" do
- Guardian.new(user).post_can_act?(nil, :like).should be_false
+ Guardian.new(user).post_can_act?(nil, :like).should be_falsey
end
it "returns false when the topic is archived" do
post.topic.archived = true
- Guardian.new(user).post_can_act?(post, :like).should be_false
+ Guardian.new(user).post_can_act?(post, :like).should be_falsey
end
it "returns false when the post is deleted" do
post.deleted_at = Time.now
- Guardian.new(user).post_can_act?(post, :like).should be_false
+ Guardian.new(user).post_can_act?(post, :like).should be_falsey
end
it "always allows flagging" do
post.topic.archived = true
- Guardian.new(user).post_can_act?(post, :spam).should be_true
+ Guardian.new(user).post_can_act?(post, :spam).should be_truthy
end
it "returns false when liking yourself" do
- Guardian.new(post.user).post_can_act?(post, :like).should be_false
+ Guardian.new(post.user).post_can_act?(post, :like).should be_falsey
end
it "returns false when you've already done it" do
- Guardian.new(user).post_can_act?(post, :like, taken_actions: {PostActionType.types[:like] => 1}).should be_false
+ Guardian.new(user).post_can_act?(post, :like, taken_actions: {PostActionType.types[:like] => 1}).should be_falsey
end
it "returns false when you already flagged a post" do
- Guardian.new(user).post_can_act?(post, :off_topic, taken_actions: {PostActionType.types[:spam] => 1}).should be_false
+ Guardian.new(user).post_can_act?(post, :off_topic, taken_actions: {PostActionType.types[:spam] => 1}).should be_falsey
end
describe "trust levels" do
it "returns true for a new user liking something" do
user.trust_level = TrustLevel[0]
- Guardian.new(user).post_can_act?(post, :like).should be_true
+ Guardian.new(user).post_can_act?(post, :like).should be_truthy
end
it "returns false for a new user flagging something as spam" do
user.trust_level = TrustLevel[0]
- Guardian.new(user).post_can_act?(post, :spam).should be_false
+ Guardian.new(user).post_can_act?(post, :spam).should be_falsey
end
it "returns false for a new user flagging something as off topic" do
user.trust_level = TrustLevel[0]
- Guardian.new(user).post_can_act?(post, :off_topic).should be_false
+ Guardian.new(user).post_can_act?(post, :off_topic).should be_falsey
end
it "returns false for a new user flagging with notify_user" do
user.trust_level = TrustLevel[0]
- Guardian.new(user).post_can_act?(post, :notify_user).should be_false # because new users can't send private messages
+ Guardian.new(user).post_can_act?(post, :notify_user).should be_falsey # because new users can't send private messages
end
end
end
@@ -92,19 +92,19 @@ describe Guardian do
let(:moderator) { Fabricate(:moderator) }
it "returns false when the user is nil" do
- Guardian.new(nil).can_defer_flags?(post).should be_false
+ Guardian.new(nil).can_defer_flags?(post).should be_falsey
end
it "returns false when the post is nil" do
- Guardian.new(moderator).can_defer_flags?(nil).should be_false
+ Guardian.new(moderator).can_defer_flags?(nil).should be_falsey
end
it "returns false when the user is not a moderator" do
- Guardian.new(user).can_defer_flags?(post).should be_false
+ Guardian.new(user).can_defer_flags?(post).should be_falsey
end
it "returns true when the user is a moderator" do
- Guardian.new(moderator).can_defer_flags?(post).should be_true
+ Guardian.new(moderator).can_defer_flags?(post).should be_truthy
end
end
@@ -115,48 +115,48 @@ describe Guardian do
let(:suspended_user) { Fabricate(:user, suspended_till: 1.week.from_now, suspended_at: 1.day.ago) }
it "returns false when the user is nil" do
- Guardian.new(nil).can_send_private_message?(user).should be_false
+ Guardian.new(nil).can_send_private_message?(user).should be_falsey
end
it "returns false when the target user is nil" do
- Guardian.new(user).can_send_private_message?(nil).should be_false
+ Guardian.new(user).can_send_private_message?(nil).should be_falsey
end
it "returns false when the target is the same as the user" do
- Guardian.new(user).can_send_private_message?(user).should be_false
+ Guardian.new(user).can_send_private_message?(user).should be_falsey
end
it "returns false when you are untrusted" do
user.trust_level = TrustLevel[0]
- Guardian.new(user).can_send_private_message?(another_user).should be_false
+ Guardian.new(user).can_send_private_message?(another_user).should be_falsey
end
it "returns true to another user" do
- Guardian.new(user).can_send_private_message?(another_user).should be_true
+ Guardian.new(user).can_send_private_message?(another_user).should be_truthy
end
context "enable_private_messages is false" do
before { SiteSetting.stubs(:enable_private_messages).returns(false) }
it "returns false if user is not the contact user" do
- Guardian.new(user).can_send_private_message?(another_user).should be_false
+ Guardian.new(user).can_send_private_message?(another_user).should be_falsey
end
it "returns true for the contact user and system user" do
SiteSetting.stubs(:site_contact_username).returns(user.username)
- Guardian.new(user).can_send_private_message?(another_user).should be_true
- Guardian.new(Discourse.system_user).can_send_private_message?(another_user).should be_true
+ Guardian.new(user).can_send_private_message?(another_user).should be_truthy
+ Guardian.new(Discourse.system_user).can_send_private_message?(another_user).should be_truthy
end
end
context "target user is suspended" do
it "returns true for staff" do
- Guardian.new(admin).can_send_private_message?(suspended_user).should be_true
- Guardian.new(moderator).can_send_private_message?(suspended_user).should be_true
+ Guardian.new(admin).can_send_private_message?(suspended_user).should be_truthy
+ Guardian.new(moderator).can_send_private_message?(suspended_user).should be_truthy
end
it "returns false for regular users" do
- Guardian.new(user).can_send_private_message?(suspended_user).should be_false
+ Guardian.new(user).can_send_private_message?(suspended_user).should be_falsey
end
end
end
@@ -166,20 +166,20 @@ describe Guardian do
let(:topic) { Fabricate(:topic) }
it "returns false for a non logged in user" do
- Guardian.new(nil).can_reply_as_new_topic?(topic).should be_false
+ Guardian.new(nil).can_reply_as_new_topic?(topic).should be_falsey
end
it "returns false for a nil topic" do
- Guardian.new(user).can_reply_as_new_topic?(nil).should be_false
+ Guardian.new(user).can_reply_as_new_topic?(nil).should be_falsey
end
it "returns false for an untrusted user" do
user.trust_level = TrustLevel[0]
- Guardian.new(user).can_reply_as_new_topic?(topic).should be_false
+ Guardian.new(user).can_reply_as_new_topic?(topic).should be_falsey
end
it "returns true for a trusted user" do
- Guardian.new(user).can_reply_as_new_topic?(topic).should be_true
+ Guardian.new(user).can_reply_as_new_topic?(topic).should be_truthy
end
end
@@ -189,33 +189,33 @@ describe Guardian do
it 'displays visibility correctly' do
guardian = Guardian.new(user)
- guardian.can_see_post_actors?(nil, PostActionType.types[:like]).should be_false
- guardian.can_see_post_actors?(topic, PostActionType.types[:like]).should be_true
- guardian.can_see_post_actors?(topic, PostActionType.types[:bookmark]).should be_false
- guardian.can_see_post_actors?(topic, PostActionType.types[:off_topic]).should be_false
- guardian.can_see_post_actors?(topic, PostActionType.types[:spam]).should be_false
- guardian.can_see_post_actors?(topic, PostActionType.types[:vote]).should be_true
+ guardian.can_see_post_actors?(nil, PostActionType.types[:like]).should be_falsey
+ guardian.can_see_post_actors?(topic, PostActionType.types[:like]).should be_truthy
+ guardian.can_see_post_actors?(topic, PostActionType.types[:bookmark]).should be_falsey
+ guardian.can_see_post_actors?(topic, PostActionType.types[:off_topic]).should be_falsey
+ guardian.can_see_post_actors?(topic, PostActionType.types[:spam]).should be_falsey
+ guardian.can_see_post_actors?(topic, PostActionType.types[:vote]).should be_truthy
end
it 'returns false for private votes' do
topic.expects(:has_meta_data_boolean?).with(:private_poll).returns(true)
- Guardian.new(user).can_see_post_actors?(topic, PostActionType.types[:vote]).should be_false
+ Guardian.new(user).can_see_post_actors?(topic, PostActionType.types[:vote]).should be_falsey
end
end
describe 'can_impersonate?' do
it 'allows impersonation correctly' do
- Guardian.new(admin).can_impersonate?(nil).should be_false
- Guardian.new.can_impersonate?(user).should be_false
- Guardian.new(coding_horror).can_impersonate?(user).should be_false
- Guardian.new(admin).can_impersonate?(admin).should be_false
- Guardian.new(admin).can_impersonate?(another_admin).should be_false
- Guardian.new(admin).can_impersonate?(user).should be_true
- Guardian.new(admin).can_impersonate?(moderator).should be_true
+ Guardian.new(admin).can_impersonate?(nil).should be_falsey
+ Guardian.new.can_impersonate?(user).should be_falsey
+ Guardian.new(coding_horror).can_impersonate?(user).should be_falsey
+ Guardian.new(admin).can_impersonate?(admin).should be_falsey
+ Guardian.new(admin).can_impersonate?(another_admin).should be_falsey
+ Guardian.new(admin).can_impersonate?(user).should be_truthy
+ Guardian.new(admin).can_impersonate?(moderator).should be_truthy
Rails.configuration.stubs(:developer_emails).returns([admin.email])
- Guardian.new(admin).can_impersonate?(another_admin).should be_true
+ Guardian.new(admin).can_impersonate?(another_admin).should be_truthy
end
end
@@ -224,23 +224,23 @@ describe Guardian do
let(:moderator) { Fabricate.build(:moderator) }
it "doesn't allow anonymous users to invite" do
- Guardian.new.can_invite_to_forum?.should be_false
+ Guardian.new.can_invite_to_forum?.should be_falsey
end
it 'returns true when the site requires approving users and is mod' do
SiteSetting.expects(:must_approve_users?).returns(true)
- Guardian.new(moderator).can_invite_to_forum?.should be_true
+ Guardian.new(moderator).can_invite_to_forum?.should be_truthy
end
it 'returns false when the site requires approving users and is regular' do
SiteSetting.expects(:must_approve_users?).returns(true)
- Guardian.new(user).can_invite_to_forum?.should be_false
+ Guardian.new(user).can_invite_to_forum?.should be_falsey
end
it 'returns false when the local logins are disabled' do
SiteSetting.stubs(:enable_local_logins).returns(false)
- Guardian.new(user).can_invite_to_forum?.should be_false
- Guardian.new(moderator).can_invite_to_forum?.should be_false
+ Guardian.new(user).can_invite_to_forum?.should be_falsey
+ Guardian.new(moderator).can_invite_to_forum?.should be_falsey
end
end
@@ -255,34 +255,34 @@ describe Guardian do
let(:admin) { Fabricate(:admin) }
it 'handles invitation correctly' do
- Guardian.new(nil).can_invite_to?(topic).should be_false
- Guardian.new(moderator).can_invite_to?(nil).should be_false
- Guardian.new(moderator).can_invite_to?(topic).should be_true
- Guardian.new(user).can_invite_to?(topic).should be_false
+ Guardian.new(nil).can_invite_to?(topic).should be_falsey
+ Guardian.new(moderator).can_invite_to?(nil).should be_falsey
+ Guardian.new(moderator).can_invite_to?(topic).should be_truthy
+ Guardian.new(user).can_invite_to?(topic).should be_falsey
end
it 'returns true when the site requires approving users and is mod' do
SiteSetting.expects(:must_approve_users?).returns(true)
- Guardian.new(moderator).can_invite_to?(topic).should be_true
+ Guardian.new(moderator).can_invite_to?(topic).should be_truthy
end
it 'returns false when the site requires approving users and is regular' do
SiteSetting.expects(:must_approve_users?).returns(true)
- Guardian.new(coding_horror).can_invite_to?(topic).should be_false
+ Guardian.new(coding_horror).can_invite_to?(topic).should be_falsey
end
it 'returns false when local logins are disabled' do
SiteSetting.stubs(:enable_local_logins).returns(false)
- Guardian.new(moderator).can_invite_to?(topic).should be_false
- Guardian.new(user).can_invite_to?(topic).should be_false
+ Guardian.new(moderator).can_invite_to?(topic).should be_falsey
+ Guardian.new(user).can_invite_to?(topic).should be_falsey
end
it 'returns false for normal user on private topic' do
- Guardian.new(user).can_invite_to?(private_topic).should be_false
+ Guardian.new(user).can_invite_to?(private_topic).should be_falsey
end
it 'returns true for admin on private topic' do
- Guardian.new(admin).can_invite_to?(private_topic).should be_true
+ Guardian.new(admin).can_invite_to?(private_topic).should be_truthy
end
end
@@ -290,7 +290,7 @@ describe Guardian do
describe 'can_see?' do
it 'returns false with a nil object' do
- Guardian.new.can_see?(nil).should be_false
+ Guardian.new.can_see?(nil).should be_falsey
end
describe 'a Group' do
@@ -298,22 +298,22 @@ describe Guardian do
let(:invisible_group) { Group.new(visible: false) }
it "returns true when the group is visible" do
- Guardian.new.can_see?(group).should be_true
+ Guardian.new.can_see?(group).should be_truthy
end
it "returns true when the group is visible but the user is an admin" do
admin = Fabricate.build(:admin)
- Guardian.new(admin).can_see?(invisible_group).should be_true
+ Guardian.new(admin).can_see?(invisible_group).should be_truthy
end
it "returns false when the group is invisible" do
- Guardian.new.can_see?(invisible_group).should be_false
+ Guardian.new.can_see?(invisible_group).should be_falsey
end
end
describe 'a Topic' do
it 'allows non logged in users to view topics' do
- Guardian.new.can_see?(topic).should be_true
+ Guardian.new.can_see?(topic).should be_truthy
end
it 'correctly handles groups' do
@@ -324,29 +324,29 @@ describe Guardian do
topic = Fabricate(:topic, category: category)
- Guardian.new(user).can_see?(topic).should be_false
+ Guardian.new(user).can_see?(topic).should be_falsey
group.add(user)
group.save
- Guardian.new(user).can_see?(topic).should be_true
+ Guardian.new(user).can_see?(topic).should be_truthy
end
it "restricts deleted topics" do
topic = Fabricate(:topic)
topic.trash!(moderator)
- Guardian.new(build(:user)).can_see?(topic).should be_false
- Guardian.new(moderator).can_see?(topic).should be_true
- Guardian.new(admin).can_see?(topic).should be_true
+ Guardian.new(build(:user)).can_see?(topic).should be_falsey
+ Guardian.new(moderator).can_see?(topic).should be_truthy
+ Guardian.new(admin).can_see?(topic).should be_truthy
end
it "restricts private topics" do
user.save!
private_topic = Fabricate(:private_message_topic, user: user)
- Guardian.new(private_topic.user).can_see?(private_topic).should be_true
- Guardian.new(build(:user)).can_see?(private_topic).should be_false
- Guardian.new(moderator).can_see?(private_topic).should be_false
- Guardian.new(admin).can_see?(private_topic).should be_true
+ Guardian.new(private_topic.user).can_see?(private_topic).should be_truthy
+ Guardian.new(build(:user)).can_see?(private_topic).should be_falsey
+ Guardian.new(moderator).can_see?(private_topic).should be_falsey
+ Guardian.new(admin).can_see?(private_topic).should be_truthy
end
it "restricts private deleted topics" do
@@ -354,19 +354,19 @@ describe Guardian do
private_topic = Fabricate(:private_message_topic, user: user)
private_topic.trash!(admin)
- Guardian.new(private_topic.user).can_see?(private_topic).should be_false
- Guardian.new(build(:user)).can_see?(private_topic).should be_false
- Guardian.new(moderator).can_see?(private_topic).should be_false
- Guardian.new(admin).can_see?(private_topic).should be_true
+ Guardian.new(private_topic.user).can_see?(private_topic).should be_falsey
+ Guardian.new(build(:user)).can_see?(private_topic).should be_falsey
+ Guardian.new(moderator).can_see?(private_topic).should be_falsey
+ Guardian.new(admin).can_see?(private_topic).should be_truthy
end
it "restricts static doc topics" do
tos_topic = Fabricate(:topic, user: Discourse.system_user)
SiteSetting.stubs(:tos_topic_id).returns(tos_topic.id)
- Guardian.new(build(:user)).can_edit?(tos_topic).should be_false
- Guardian.new(moderator).can_edit?(tos_topic).should be_false
- Guardian.new(admin).can_edit?(tos_topic).should be_true
+ Guardian.new(build(:user)).can_edit?(tos_topic).should be_falsey
+ Guardian.new(moderator).can_edit?(tos_topic).should be_falsey
+ Guardian.new(admin).can_edit?(tos_topic).should be_truthy
end
end
@@ -376,19 +376,19 @@ describe Guardian do
post = Fabricate(:post)
topic = post.topic
- Guardian.new(user).can_see?(post).should be_true
+ Guardian.new(user).can_see?(post).should be_truthy
post.trash!(another_admin)
post.reload
- Guardian.new(user).can_see?(post).should be_false
- Guardian.new(admin).can_see?(post).should be_true
+ Guardian.new(user).can_see?(post).should be_falsey
+ Guardian.new(admin).can_see?(post).should be_truthy
post.recover!
post.reload
topic.trash!(another_admin)
topic.reload
- Guardian.new(user).can_see?(post).should be_false
- Guardian.new(admin).can_see?(post).should be_true
+ Guardian.new(user).can_see?(post).should be_falsey
+ Guardian.new(admin).can_see?(post).should be_truthy
end
end
@@ -399,21 +399,21 @@ describe Guardian do
before { SiteSetting.stubs(:edit_history_visible_to_public).returns(true) }
it 'is false for nil' do
- Guardian.new.can_see?(nil).should be_false
+ Guardian.new.can_see?(nil).should be_falsey
end
it 'is true if not logged in' do
- Guardian.new.can_see?(post_revision).should == true
+ Guardian.new.can_see?(post_revision).should be_truthy
end
it 'is true when logged in' do
- Guardian.new(Fabricate(:user)).can_see?(post_revision).should == true
+ Guardian.new(Fabricate(:user)).can_see?(post_revision).should be_truthy
end
it 'is true if the author has public edit history' do
public_post_revision = Fabricate(:post_revision)
public_post_revision.post.user.edit_history_public = true
- Guardian.new.can_see?(public_post_revision).should == true
+ Guardian.new.can_see?(public_post_revision).should be_truthy
end
end
@@ -421,22 +421,22 @@ describe Guardian do
before { SiteSetting.stubs(:edit_history_visible_to_public).returns(false) }
it 'is true for staff' do
- Guardian.new(Fabricate(:admin)).can_see?(post_revision).should == true
- Guardian.new(Fabricate(:moderator)).can_see?(post_revision).should == true
+ Guardian.new(Fabricate(:admin)).can_see?(post_revision).should be_truthy
+ Guardian.new(Fabricate(:moderator)).can_see?(post_revision).should be_truthy
end
it 'is true for trust level 4' do
- Guardian.new(trust_level_4).can_see?(post_revision).should == true
+ Guardian.new(trust_level_4).can_see?(post_revision).should be_truthy
end
it 'is false for trust level lower than 4' do
- Guardian.new(trust_level_3).can_see?(post_revision).should == false
+ Guardian.new(trust_level_3).can_see?(post_revision).should be_falsey
end
it 'is true if the author has public edit history' do
public_post_revision = Fabricate(:post_revision)
public_post_revision.post.user.edit_history_public = true
- Guardian.new.can_see?(public_post_revision).should == true
+ Guardian.new.can_see?(public_post_revision).should be_truthy
end
end
end
@@ -447,19 +447,19 @@ describe Guardian do
describe 'a Category' do
it 'returns false when not logged in' do
- Guardian.new.can_create?(Category).should be_false
+ Guardian.new.can_create?(Category).should be_falsey
end
it 'returns false when a regular user' do
- Guardian.new(user).can_create?(Category).should be_false
+ Guardian.new(user).can_create?(Category).should be_falsey
end
it 'returns false when a moderator' do
- Guardian.new(moderator).can_create?(Category).should be_false
+ Guardian.new(moderator).can_create?(Category).should be_falsey
end
it 'returns true when an admin' do
- Guardian.new(admin).can_create?(Category).should be_true
+ Guardian.new(admin).can_create?(Category).should be_truthy
end
end
@@ -468,24 +468,24 @@ describe Guardian do
category = Fabricate(:category)
category.set_permissions(:everyone => :create_post)
category.save
- Guardian.new(user).can_create?(Topic,category).should be_false
+ Guardian.new(user).can_create?(Topic,category).should be_falsey
end
it "is true for new users by default" do
- Guardian.new(user).can_create?(Topic,Fabricate(:category)).should be_true
+ Guardian.new(user).can_create?(Topic,Fabricate(:category)).should be_truthy
end
it "is false if user has not met minimum trust level" do
SiteSetting.stubs(:min_trust_to_create_topic).returns(1)
- Guardian.new(build(:user, trust_level: 0)).can_create?(Topic,Fabricate(:category)).should be_false
+ Guardian.new(build(:user, trust_level: 0)).can_create?(Topic,Fabricate(:category)).should be_falsey
end
it "is true if user has met or exceeded the minimum trust level" do
SiteSetting.stubs(:min_trust_to_create_topic).returns(1)
- Guardian.new(build(:user, trust_level: 1)).can_create?(Topic,Fabricate(:category)).should be_true
- Guardian.new(build(:user, trust_level: 2)).can_create?(Topic,Fabricate(:category)).should be_true
- Guardian.new(build(:admin, trust_level: 0)).can_create?(Topic,Fabricate(:category)).should be_true
- Guardian.new(build(:moderator, trust_level: 0)).can_create?(Topic,Fabricate(:category)).should be_true
+ Guardian.new(build(:user, trust_level: 1)).can_create?(Topic,Fabricate(:category)).should be_truthy
+ Guardian.new(build(:user, trust_level: 2)).can_create?(Topic,Fabricate(:category)).should be_truthy
+ Guardian.new(build(:admin, trust_level: 0)).can_create?(Topic,Fabricate(:category)).should be_truthy
+ Guardian.new(build(:moderator, trust_level: 0)).can_create?(Topic,Fabricate(:category)).should be_truthy
end
end
@@ -497,21 +497,21 @@ describe Guardian do
category.set_permissions(:everyone => :readonly)
category.save
- Guardian.new(topic.user).can_create?(Post, topic).should be_false
+ Guardian.new(topic.user).can_create?(Post, topic).should be_falsey
end
it "is false when not logged in" do
- Guardian.new.can_create?(Post, topic).should be_false
+ Guardian.new.can_create?(Post, topic).should be_falsey
end
it 'is true for a regular user' do
- Guardian.new(topic.user).can_create?(Post, topic).should be_true
+ Guardian.new(topic.user).can_create?(Post, topic).should be_truthy
end
it "is false when you can't see the topic" do
Guardian.any_instance.expects(:can_see?).with(topic).returns(false)
- Guardian.new(topic.user).can_create?(Post, topic).should be_false
+ Guardian.new(topic.user).can_create?(Post, topic).should be_falsey
end
context 'closed topic' do
@@ -520,23 +520,23 @@ describe Guardian do
end
it "doesn't allow new posts from regular users" do
- Guardian.new(topic.user).can_create?(Post, topic).should be_false
+ Guardian.new(topic.user).can_create?(Post, topic).should be_falsey
end
it 'allows editing of posts' do
- Guardian.new(topic.user).can_edit?(post).should be_true
+ Guardian.new(topic.user).can_edit?(post).should be_truthy
end
it "allows new posts from moderators" do
- Guardian.new(moderator).can_create?(Post, topic).should be_true
+ Guardian.new(moderator).can_create?(Post, topic).should be_truthy
end
it "allows new posts from admins" do
- Guardian.new(admin).can_create?(Post, topic).should be_true
+ Guardian.new(admin).can_create?(Post, topic).should be_truthy
end
it "allows new posts from trust_level_4s" do
- Guardian.new(trust_level_4).can_create?(Post, topic).should be_true
+ Guardian.new(trust_level_4).can_create?(Post, topic).should be_truthy
end
end
@@ -547,20 +547,20 @@ describe Guardian do
context 'regular users' do
it "doesn't allow new posts from regular users" do
- Guardian.new(coding_horror).can_create?(Post, topic).should be_false
+ Guardian.new(coding_horror).can_create?(Post, topic).should be_falsey
end
it 'does not allow editing of posts' do
- Guardian.new(coding_horror).can_edit?(post).should be_false
+ Guardian.new(coding_horror).can_edit?(post).should be_falsey
end
end
it "allows new posts from moderators" do
- Guardian.new(moderator).can_create?(Post, topic).should be_true
+ Guardian.new(moderator).can_create?(Post, topic).should be_truthy
end
it "allows new posts from admins" do
- Guardian.new(admin).can_create?(Post, topic).should be_true
+ Guardian.new(admin).can_create?(Post, topic).should be_truthy
end
end
@@ -570,15 +570,15 @@ describe Guardian do
end
it "doesn't allow new posts from regular users" do
- Guardian.new(coding_horror).can_create?(Post, topic).should be_false
+ Guardian.new(coding_horror).can_create?(Post, topic).should be_falsey
end
it "doesn't allow new posts from moderators users" do
- Guardian.new(moderator).can_create?(Post, topic).should be_false
+ Guardian.new(moderator).can_create?(Post, topic).should be_falsey
end
it "doesn't allow new posts from admins" do
- Guardian.new(admin).can_create?(Post, topic).should be_false
+ Guardian.new(admin).can_create?(Post, topic).should be_falsey
end
end
@@ -591,7 +591,7 @@ describe Guardian do
describe 'post_can_act?' do
it "isn't allowed on nil" do
- Guardian.new(user).post_can_act?(nil, nil).should be_false
+ Guardian.new(user).post_can_act?(nil, nil).should be_falsey
end
describe 'a Post' do
@@ -602,24 +602,24 @@ describe Guardian do
it "isn't allowed when not logged in" do
- Guardian.new(nil).post_can_act?(post,:vote).should be_false
+ Guardian.new(nil).post_can_act?(post,:vote).should be_falsey
end
it "is allowed as a regular user" do
- guardian.post_can_act?(post,:vote).should be_true
+ guardian.post_can_act?(post,:vote).should be_truthy
end
it "doesn't allow voting if the user has an action from voting already" do
- guardian.post_can_act?(post,:vote,taken_actions: {PostActionType.types[:vote] => 1}).should be_false
+ guardian.post_can_act?(post,:vote,taken_actions: {PostActionType.types[:vote] => 1}).should be_falsey
end
it "allows voting if the user has performed a different action" do
- guardian.post_can_act?(post,:vote,taken_actions: {PostActionType.types[:like] => 1}).should be_true
+ guardian.post_can_act?(post,:vote,taken_actions: {PostActionType.types[:like] => 1}).should be_truthy
end
it "isn't allowed on archived topics" do
topic.archived = true
- Guardian.new(user).post_can_act?(post,:like).should be_false
+ Guardian.new(user).post_can_act?(post,:like).should be_falsey
end
@@ -627,11 +627,11 @@ describe Guardian do
it "isn't allowed if the user voted and the topic doesn't allow multiple votes" do
Topic.any_instance.expects(:has_meta_data_boolean?).with(:single_vote).returns(true)
- Guardian.new(user).can_vote?(post, voted_in_topic: true).should be_false
+ Guardian.new(user).can_vote?(post, voted_in_topic: true).should be_falsey
end
it "is allowed if the user voted and the topic doesn't allow multiple votes" do
- Guardian.new(user).can_vote?(post, voted_in_topic: false).should be_true
+ Guardian.new(user).can_vote?(post, voted_in_topic: false).should be_truthy
end
end
@@ -641,38 +641,38 @@ describe Guardian do
describe "can_recover_topic?" do
it "returns false for a nil user" do
- Guardian.new(nil).can_recover_topic?(topic).should be_false
+ Guardian.new(nil).can_recover_topic?(topic).should be_falsey
end
it "returns false for a nil object" do
- Guardian.new(user).can_recover_topic?(nil).should be_false
+ Guardian.new(user).can_recover_topic?(nil).should be_falsey
end
it "returns false for a regular user" do
- Guardian.new(user).can_recover_topic?(topic).should be_false
+ Guardian.new(user).can_recover_topic?(topic).should be_falsey
end
it "returns true for a moderator" do
- Guardian.new(moderator).can_recover_topic?(topic).should be_true
+ Guardian.new(moderator).can_recover_topic?(topic).should be_truthy
end
end
describe "can_recover_post?" do
it "returns false for a nil user" do
- Guardian.new(nil).can_recover_post?(post).should be_false
+ Guardian.new(nil).can_recover_post?(post).should be_falsey
end
it "returns false for a nil object" do
- Guardian.new(user).can_recover_post?(nil).should be_false
+ Guardian.new(user).can_recover_post?(nil).should be_falsey
end
it "returns false for a regular user" do
- Guardian.new(user).can_recover_post?(post).should be_false
+ Guardian.new(user).can_recover_post?(post).should be_falsey
end
it "returns true for a moderator" do
- Guardian.new(moderator).can_recover_post?(post).should be_true
+ Guardian.new(moderator).can_recover_post?(post).should be_truthy
end
end
@@ -680,90 +680,90 @@ describe Guardian do
describe 'can_edit?' do
it 'returns false with a nil object' do
- Guardian.new(user).can_edit?(nil).should == false
+ Guardian.new(user).can_edit?(nil).should be_falsey
end
describe 'a Post' do
it 'returns false when not logged in' do
- Guardian.new.can_edit?(post).should be_false
+ Guardian.new.can_edit?(post).should be_falsey
end
it 'returns false when not logged in also for wiki post' do
post.wiki = true
- Guardian.new.can_edit?(post).should be_false
+ Guardian.new.can_edit?(post).should be_falsey
end
it 'returns true if you want to edit your own post' do
- Guardian.new(post.user).can_edit?(post).should be_true
+ Guardian.new(post.user).can_edit?(post).should be_truthy
end
it "returns false if the post is hidden due to flagging and it's too soon" do
post.hidden = true
post.hidden_at = Time.now
- Guardian.new(post.user).can_edit?(post).should be_false
+ Guardian.new(post.user).can_edit?(post).should be_falsey
end
it "returns true if the post is hidden due to flagging and it been enough time" do
post.hidden = true
post.hidden_at = (SiteSetting.cooldown_minutes_after_hiding_posts + 1).minutes.ago
- Guardian.new(post.user).can_edit?(post).should be_true
+ Guardian.new(post.user).can_edit?(post).should be_truthy
end
it "returns true if the post is hidden, it's been enough time and the edit window has expired" do
post.hidden = true
post.hidden_at = (SiteSetting.cooldown_minutes_after_hiding_posts + 1).minutes.ago
post.created_at = (SiteSetting.post_edit_time_limit + 1).minutes.ago
- Guardian.new(post.user).can_edit?(post).should be_true
+ Guardian.new(post.user).can_edit?(post).should be_truthy
end
it "returns true if the post is hidden due to flagging and it's got a nil `hidden_at`" do
post.hidden = true
post.hidden_at = nil
- Guardian.new(post.user).can_edit?(post).should be_true
+ Guardian.new(post.user).can_edit?(post).should be_truthy
end
it 'returns false if you are trying to edit a post you soft deleted' do
post.user_deleted = true
- Guardian.new(post.user).can_edit?(post).should be_false
+ Guardian.new(post.user).can_edit?(post).should be_falsey
end
it 'returns false if another regular user tries to edit a soft deleted wiki post' do
post.wiki = true
post.user_deleted = true
- Guardian.new(coding_horror).can_edit?(post).should be_false
+ Guardian.new(coding_horror).can_edit?(post).should be_falsey
end
it 'returns false if you are trying to edit a deleted post' do
post.deleted_at = 1.day.ago
- Guardian.new(post.user).can_edit?(post).should be_false
+ Guardian.new(post.user).can_edit?(post).should be_falsey
end
it 'returns false if another regular user tries to edit a deleted wiki post' do
post.wiki = true
post.deleted_at = 1.day.ago
- Guardian.new(coding_horror).can_edit?(post).should be_false
+ Guardian.new(coding_horror).can_edit?(post).should be_falsey
end
it 'returns false if another regular user tries to edit your post' do
- Guardian.new(coding_horror).can_edit?(post).should be_false
+ Guardian.new(coding_horror).can_edit?(post).should be_falsey
end
it 'returns true if another regular user tries to edit wiki post' do
post.wiki = true
- Guardian.new(coding_horror).can_edit?(post).should be_true
+ Guardian.new(coding_horror).can_edit?(post).should be_truthy
end
it 'returns true as a moderator' do
- Guardian.new(moderator).can_edit?(post).should be_true
+ Guardian.new(moderator).can_edit?(post).should be_truthy
end
it 'returns true as an admin' do
- Guardian.new(admin).can_edit?(post).should be_true
+ Guardian.new(admin).can_edit?(post).should be_truthy
end
it 'returns true as a trust level 4 user' do
- Guardian.new(trust_level_4).can_edit?(post).should be_true
+ Guardian.new(trust_level_4).can_edit?(post).should be_truthy
end
context 'post is older than post_edit_time_limit' do
@@ -773,7 +773,7 @@ describe Guardian do
end
it 'returns false to the author of the post' do
- Guardian.new(old_post.user).can_edit?(old_post).should == false
+ Guardian.new(old_post.user).can_edit?(old_post).should be_falsey
end
it 'returns true as a moderator' do
@@ -785,12 +785,12 @@ describe Guardian do
end
it 'returns false for another regular user trying to edit your post' do
- Guardian.new(coding_horror).can_edit?(old_post).should == false
+ Guardian.new(coding_horror).can_edit?(old_post).should be_falsey
end
it 'returns true for another regular user trying to edit a wiki post' do
old_post.wiki = true
- Guardian.new(coding_horror).can_edit?(old_post).should be_true
+ Guardian.new(coding_horror).can_edit?(old_post).should be_truthy
end
it 'returns false when another user has too low trust level to edit wiki post' do
@@ -798,7 +798,7 @@ describe Guardian do
post.wiki = true
coding_horror.trust_level = 1
- Guardian.new(coding_horror).can_edit?(post).should be_false
+ Guardian.new(coding_horror).can_edit?(post).should be_falsey
end
it 'returns true when another user has adequate trust level to edit wiki post' do
@@ -806,7 +806,7 @@ describe Guardian do
post.wiki = true
coding_horror.trust_level = 2
- Guardian.new(coding_horror).can_edit?(post).should be_true
+ Guardian.new(coding_horror).can_edit?(post).should be_truthy
end
it 'returns true for post author even when he has too low trust level to edit wiki post' do
@@ -814,7 +814,7 @@ describe Guardian do
post.wiki = true
post.user.trust_level = 1
- Guardian.new(post.user).can_edit?(post).should be_true
+ Guardian.new(post.user).can_edit?(post).should be_truthy
end
end
@@ -824,9 +824,9 @@ describe Guardian do
before { SiteSetting.stubs(:tos_topic_id).returns(tos_topic.id) }
it "restricts static doc posts" do
- Guardian.new(build(:user)).can_edit?(tos_first_post).should be_false
- Guardian.new(moderator).can_edit?(tos_first_post).should be_false
- Guardian.new(admin).can_edit?(tos_first_post).should be_true
+ Guardian.new(build(:user)).can_edit?(tos_first_post).should be_falsey
+ Guardian.new(moderator).can_edit?(tos_first_post).should be_falsey
+ Guardian.new(admin).can_edit?(tos_first_post).should be_truthy
end
end
end
@@ -834,7 +834,7 @@ describe Guardian do
describe 'a Topic' do
it 'returns false when not logged in' do
- Guardian.new.can_edit?(topic).should == false
+ Guardian.new.can_edit?(topic).should be_falsey
end
it 'returns true for editing your own post' do
@@ -843,7 +843,7 @@ describe Guardian do
it 'returns false as a regular user' do
- Guardian.new(coding_horror).can_edit?(topic).should == false
+ Guardian.new(coding_horror).can_edit?(topic).should be_falsey
end
context 'not archived' do
@@ -869,19 +869,19 @@ describe Guardian do
context 'archived' do
it 'returns true as a moderator' do
- Guardian.new(moderator).can_edit?(build(:topic, user: user, archived: true)).should == true
+ Guardian.new(moderator).can_edit?(build(:topic, user: user, archived: true)).should be_truthy
end
it 'returns true as an admin' do
- Guardian.new(admin).can_edit?(build(:topic, user: user, archived: true)).should == true
+ Guardian.new(admin).can_edit?(build(:topic, user: user, archived: true)).should be_truthy
end
it 'returns true at trust level 3' do
- Guardian.new(trust_level_3).can_edit?(build(:topic, user: user, archived: true)).should == true
+ Guardian.new(trust_level_3).can_edit?(build(:topic, user: user, archived: true)).should be_truthy
end
it 'returns false as a topic creator' do
- Guardian.new(user).can_edit?(build(:topic, user: user, archived: true)).should == false
+ Guardian.new(user).can_edit?(build(:topic, user: user, archived: true)).should be_falsey
end
end
end
@@ -891,42 +891,42 @@ describe Guardian do
let(:category) { Fabricate(:category) }
it 'returns false when not logged in' do
- Guardian.new.can_edit?(category).should be_false
+ Guardian.new.can_edit?(category).should be_falsey
end
it 'returns false as a regular user' do
- Guardian.new(category.user).can_edit?(category).should be_false
+ Guardian.new(category.user).can_edit?(category).should be_falsey
end
it 'returns false as a moderator' do
- Guardian.new(moderator).can_edit?(category).should be_false
+ Guardian.new(moderator).can_edit?(category).should be_falsey
end
it 'returns true as an admin' do
- Guardian.new(admin).can_edit?(category).should be_true
+ Guardian.new(admin).can_edit?(category).should be_truthy
end
end
describe 'a User' do
it 'returns false when not logged in' do
- Guardian.new.can_edit?(user).should be_false
+ Guardian.new.can_edit?(user).should be_falsey
end
it 'returns false as a different user' do
- Guardian.new(coding_horror).can_edit?(user).should be_false
+ Guardian.new(coding_horror).can_edit?(user).should be_falsey
end
it 'returns true when trying to edit yourself' do
- Guardian.new(user).can_edit?(user).should be_true
+ Guardian.new(user).can_edit?(user).should be_truthy
end
it 'returns true as a moderator' do
- Guardian.new(moderator).can_edit?(user).should be_true
+ Guardian.new(moderator).can_edit?(user).should be_truthy
end
it 'returns true as an admin' do
- Guardian.new(admin).can_edit?(user).should be_true
+ Guardian.new(admin).can_edit?(user).should be_truthy
end
end
@@ -935,29 +935,29 @@ describe Guardian do
context 'can_moderate?' do
it 'returns false with a nil object' do
- Guardian.new(user).can_moderate?(nil).should be_false
+ Guardian.new(user).can_moderate?(nil).should be_falsey
end
context 'a Topic' do
it 'returns false when not logged in' do
- Guardian.new.can_moderate?(topic).should be_false
+ Guardian.new.can_moderate?(topic).should be_falsey
end
it 'returns false when not a moderator' do
- Guardian.new(user).can_moderate?(topic).should be_false
+ Guardian.new(user).can_moderate?(topic).should be_falsey
end
it 'returns true when a moderator' do
- Guardian.new(moderator).can_moderate?(topic).should be_true
+ Guardian.new(moderator).can_moderate?(topic).should be_truthy
end
it 'returns true when an admin' do
- Guardian.new(admin).can_moderate?(topic).should be_true
+ Guardian.new(admin).can_moderate?(topic).should be_truthy
end
it 'returns true when trust level 4' do
- Guardian.new(trust_level_4).can_moderate?(topic).should be_true
+ Guardian.new(trust_level_4).can_moderate?(topic).should be_truthy
end
end
@@ -967,48 +967,48 @@ describe Guardian do
context 'can_see_flags?' do
it "returns false when there is no post" do
- Guardian.new(moderator).can_see_flags?(nil).should be_false
+ Guardian.new(moderator).can_see_flags?(nil).should be_falsey
end
it "returns false when there is no user" do
- Guardian.new(nil).can_see_flags?(post).should be_false
+ Guardian.new(nil).can_see_flags?(post).should be_falsey
end
it "allow regular users to see flags" do
- Guardian.new(user).can_see_flags?(post).should be_false
+ Guardian.new(user).can_see_flags?(post).should be_falsey
end
it "allows moderators to see flags" do
- Guardian.new(moderator).can_see_flags?(post).should be_true
+ Guardian.new(moderator).can_see_flags?(post).should be_truthy
end
it "allows moderators to see flags" do
- Guardian.new(admin).can_see_flags?(post).should be_true
+ Guardian.new(admin).can_see_flags?(post).should be_truthy
end
end
context 'can_move_posts?' do
it 'returns false with a nil object' do
- Guardian.new(user).can_move_posts?(nil).should be_false
+ Guardian.new(user).can_move_posts?(nil).should be_falsey
end
context 'a Topic' do
it 'returns false when not logged in' do
- Guardian.new.can_move_posts?(topic).should be_false
+ Guardian.new.can_move_posts?(topic).should be_falsey
end
it 'returns false when not a moderator' do
- Guardian.new(user).can_move_posts?(topic).should be_false
+ Guardian.new(user).can_move_posts?(topic).should be_falsey
end
it 'returns true when a moderator' do
- Guardian.new(moderator).can_move_posts?(topic).should be_true
+ Guardian.new(moderator).can_move_posts?(topic).should be_truthy
end
it 'returns true when an admin' do
- Guardian.new(admin).can_move_posts?(topic).should be_true
+ Guardian.new(admin).can_move_posts?(topic).should be_truthy
end
end
@@ -1018,7 +1018,7 @@ describe Guardian do
context 'can_delete?' do
it 'returns false with a nil object' do
- Guardian.new(user).can_delete?(nil).should be_false
+ Guardian.new(user).can_delete?(nil).should be_falsey
end
context 'a Topic' do
@@ -1028,25 +1028,25 @@ describe Guardian do
end
it 'returns false when not logged in' do
- Guardian.new.can_delete?(topic).should be_false
+ Guardian.new.can_delete?(topic).should be_falsey
end
it 'returns false when not a moderator' do
- Guardian.new(user).can_delete?(topic).should be_false
+ Guardian.new(user).can_delete?(topic).should be_falsey
end
it 'returns true when a moderator' do
- Guardian.new(moderator).can_delete?(topic).should be_true
+ Guardian.new(moderator).can_delete?(topic).should be_truthy
end
it 'returns true when an admin' do
- Guardian.new(admin).can_delete?(topic).should be_true
+ Guardian.new(admin).can_delete?(topic).should be_truthy
end
it 'returns false for static doc topics' do
tos_topic = Fabricate(:topic, user: Discourse.system_user)
SiteSetting.stubs(:tos_topic_id).returns(tos_topic.id)
- Guardian.new(admin).can_delete?(tos_topic).should be_false
+ Guardian.new(admin).can_delete?(tos_topic).should be_falsey
end
end
@@ -1057,35 +1057,35 @@ describe Guardian do
end
it 'returns false when not logged in' do
- Guardian.new.can_delete?(post).should be_false
+ Guardian.new.can_delete?(post).should be_falsey
end
it "returns false when trying to delete your own post that has already been deleted" do
post = Fabricate(:post)
PostDestroyer.new(user, post).destroy
post.reload
- Guardian.new(user).can_delete?(post).should be_false
+ Guardian.new(user).can_delete?(post).should be_falsey
end
it 'returns true when trying to delete your own post' do
- Guardian.new(user).can_delete?(post).should be_true
+ Guardian.new(user).can_delete?(post).should be_truthy
end
it "returns false when trying to delete another user's own post" do
- Guardian.new(Fabricate(:user)).can_delete?(post).should be_false
+ Guardian.new(Fabricate(:user)).can_delete?(post).should be_falsey
end
it "returns false when it's the OP, even as a moderator" do
post.update_attribute :post_number, 1
- Guardian.new(moderator).can_delete?(post).should be_false
+ Guardian.new(moderator).can_delete?(post).should be_falsey
end
it 'returns true when a moderator' do
- Guardian.new(moderator).can_delete?(post).should be_true
+ Guardian.new(moderator).can_delete?(post).should be_truthy
end
it 'returns true when an admin' do
- Guardian.new(admin).can_delete?(post).should be_true
+ Guardian.new(admin).can_delete?(post).should be_truthy
end
it 'returns false when post is first in a static doc topic' do
@@ -1093,7 +1093,7 @@ describe Guardian do
SiteSetting.stubs(:tos_topic_id).returns(tos_topic.id)
post.update_attribute :post_number, 1
post.update_attribute :topic_id, tos_topic.id
- Guardian.new(admin).can_delete?(post).should be_false
+ Guardian.new(admin).can_delete?(post).should be_falsey
end
context 'post is older than post_edit_time_limit' do
@@ -1130,11 +1130,11 @@ describe Guardian do
end
it "allows a staff member to delete it" do
- Guardian.new(moderator).can_delete?(post).should be_true
+ Guardian.new(moderator).can_delete?(post).should be_truthy
end
it "doesn't allow a regular user to delete it" do
- Guardian.new(post.user).can_delete?(post).should be_false
+ Guardian.new(post.user).can_delete?(post).should be_falsey
end
end
@@ -1146,54 +1146,54 @@ describe Guardian do
let(:category) { build(:category, user: moderator) }
it 'returns false when not logged in' do
- Guardian.new.can_delete?(category).should be_false
+ Guardian.new.can_delete?(category).should be_falsey
end
it 'returns false when a regular user' do
- Guardian.new(user).can_delete?(category).should be_false
+ Guardian.new(user).can_delete?(category).should be_falsey
end
it 'returns false when a moderator' do
- Guardian.new(moderator).can_delete?(category).should be_false
+ Guardian.new(moderator).can_delete?(category).should be_falsey
end
it 'returns true when an admin' do
- Guardian.new(admin).can_delete?(category).should be_true
+ Guardian.new(admin).can_delete?(category).should be_truthy
end
it "can't be deleted if it has a forum topic" do
category.topic_count = 10
- Guardian.new(moderator).can_delete?(category).should be_false
+ Guardian.new(moderator).can_delete?(category).should be_falsey
end
it "can't be deleted if it is the Uncategorized Category" do
uncategorized_cat_id = SiteSetting.uncategorized_category_id
uncategorized_category = Category.find(uncategorized_cat_id)
- Guardian.new(admin).can_delete?(uncategorized_category).should be_false
+ Guardian.new(admin).can_delete?(uncategorized_category).should be_falsey
end
it "can't be deleted if it has children" do
category.expects(:has_children?).returns(true)
- Guardian.new(admin).can_delete?(category).should be_false
+ Guardian.new(admin).can_delete?(category).should be_falsey
end
end
context 'can_suspend?' do
it 'returns false when a user tries to suspend another user' do
- Guardian.new(user).can_suspend?(coding_horror).should be_false
+ Guardian.new(user).can_suspend?(coding_horror).should be_falsey
end
it 'returns true when an admin tries to suspend another user' do
- Guardian.new(admin).can_suspend?(coding_horror).should be_true
+ Guardian.new(admin).can_suspend?(coding_horror).should be_truthy
end
it 'returns true when a moderator tries to suspend another user' do
- Guardian.new(moderator).can_suspend?(coding_horror).should be_true
+ Guardian.new(moderator).can_suspend?(coding_horror).should be_truthy
end
it 'returns false when staff tries to suspend staff' do
- Guardian.new(admin).can_suspend?(moderator).should be_false
+ Guardian.new(admin).can_suspend?(moderator).should be_falsey
end
end
@@ -1208,21 +1208,21 @@ describe Guardian do
}
it 'returns false when not logged in' do
- Guardian.new.can_delete?(post_action).should be_false
+ Guardian.new.can_delete?(post_action).should be_falsey
end
it 'returns false when not the user who created it' do
- Guardian.new(coding_horror).can_delete?(post_action).should be_false
+ Guardian.new(coding_horror).can_delete?(post_action).should be_falsey
end
it "returns false if the window has expired" do
post_action.created_at = 20.minutes.ago
SiteSetting.expects(:post_undo_action_window_mins).returns(10)
- Guardian.new(user).can_delete?(post_action).should be_false
+ Guardian.new(user).can_delete?(post_action).should be_falsey
end
it "returns true if it's yours" do
- Guardian.new(user).can_delete?(post_action).should be_true
+ Guardian.new(user).can_delete?(post_action).should be_truthy
end
end
@@ -1232,24 +1232,24 @@ describe Guardian do
context 'can_approve?' do
it "wont allow a non-logged in user to approve" do
- Guardian.new.can_approve?(user).should be_false
+ Guardian.new.can_approve?(user).should be_falsey
end
it "wont allow a non-admin to approve a user" do
- Guardian.new(coding_horror).can_approve?(user).should be_false
+ Guardian.new(coding_horror).can_approve?(user).should be_falsey
end
it "returns false when the user is already approved" do
user.approved = true
- Guardian.new(admin).can_approve?(user).should be_false
+ Guardian.new(admin).can_approve?(user).should be_falsey
end
it "allows an admin to approve a user" do
- Guardian.new(admin).can_approve?(user).should be_true
+ Guardian.new(admin).can_approve?(user).should be_truthy
end
it "allows a moderator to approve a user" do
- Guardian.new(moderator).can_approve?(user).should be_true
+ Guardian.new(moderator).can_approve?(user).should be_truthy
end
@@ -1257,107 +1257,107 @@ describe Guardian do
context 'can_grant_admin?' do
it "wont allow a non logged in user to grant an admin's access" do
- Guardian.new.can_grant_admin?(another_admin).should be_false
+ Guardian.new.can_grant_admin?(another_admin).should be_falsey
end
it "wont allow a regular user to revoke an admin's access" do
- Guardian.new(user).can_grant_admin?(another_admin).should be_false
+ Guardian.new(user).can_grant_admin?(another_admin).should be_falsey
end
it 'wont allow an admin to grant their own access' do
- Guardian.new(admin).can_grant_admin?(admin).should be_false
+ Guardian.new(admin).can_grant_admin?(admin).should be_falsey
end
it "allows an admin to grant a regular user access" do
admin.id = 1
user.id = 2
- Guardian.new(admin).can_grant_admin?(user).should be_true
+ Guardian.new(admin).can_grant_admin?(user).should be_truthy
end
end
context 'can_revoke_admin?' do
it "wont allow a non logged in user to revoke an admin's access" do
- Guardian.new.can_revoke_admin?(another_admin).should be_false
+ Guardian.new.can_revoke_admin?(another_admin).should be_falsey
end
it "wont allow a regular user to revoke an admin's access" do
- Guardian.new(user).can_revoke_admin?(another_admin).should be_false
+ Guardian.new(user).can_revoke_admin?(another_admin).should be_falsey
end
it 'wont allow an admin to revoke their own access' do
- Guardian.new(admin).can_revoke_admin?(admin).should be_false
+ Guardian.new(admin).can_revoke_admin?(admin).should be_falsey
end
it "allows an admin to revoke another admin's access" do
admin.id = 1
another_admin.id = 2
- Guardian.new(admin).can_revoke_admin?(another_admin).should be_true
+ Guardian.new(admin).can_revoke_admin?(another_admin).should be_truthy
end
end
context 'can_grant_moderation?' do
it "wont allow a non logged in user to grant an moderator's access" do
- Guardian.new.can_grant_moderation?(user).should be_false
+ Guardian.new.can_grant_moderation?(user).should be_falsey
end
it "wont allow a regular user to revoke an moderator's access" do
- Guardian.new(user).can_grant_moderation?(moderator).should be_false
+ Guardian.new(user).can_grant_moderation?(moderator).should be_falsey
end
it 'will allow an admin to grant their own moderator access' do
- Guardian.new(admin).can_grant_moderation?(admin).should be_true
+ Guardian.new(admin).can_grant_moderation?(admin).should be_truthy
end
it 'wont allow an admin to grant it to an already moderator' do
- Guardian.new(admin).can_grant_moderation?(moderator).should be_false
+ Guardian.new(admin).can_grant_moderation?(moderator).should be_falsey
end
it "allows an admin to grant a regular user access" do
- Guardian.new(admin).can_grant_moderation?(user).should be_true
+ Guardian.new(admin).can_grant_moderation?(user).should be_truthy
end
end
context 'can_revoke_moderation?' do
it "wont allow a non logged in user to revoke an moderator's access" do
- Guardian.new.can_revoke_moderation?(moderator).should be_false
+ Guardian.new.can_revoke_moderation?(moderator).should be_falsey
end
it "wont allow a regular user to revoke an moderator's access" do
- Guardian.new(user).can_revoke_moderation?(moderator).should be_false
+ Guardian.new(user).can_revoke_moderation?(moderator).should be_falsey
end
it 'wont allow a moderator to revoke their own moderator' do
- Guardian.new(moderator).can_revoke_moderation?(moderator).should be_false
+ Guardian.new(moderator).can_revoke_moderation?(moderator).should be_falsey
end
it "allows an admin to revoke a moderator's access" do
- Guardian.new(admin).can_revoke_moderation?(moderator).should be_true
+ Guardian.new(admin).can_revoke_moderation?(moderator).should be_truthy
end
it "allows an admin to revoke a moderator's access from self" do
admin.moderator = true
- Guardian.new(admin).can_revoke_moderation?(admin).should be_true
+ Guardian.new(admin).can_revoke_moderation?(admin).should be_truthy
end
it "does not allow revoke from non moderators" do
- Guardian.new(admin).can_revoke_moderation?(admin).should be_false
+ Guardian.new(admin).can_revoke_moderation?(admin).should be_falsey
end
end
context "can_see_invite_details?" do
it 'is false without a logged in user' do
- Guardian.new(nil).can_see_invite_details?(user).should be_false
+ Guardian.new(nil).can_see_invite_details?(user).should be_falsey
end
it 'is false without a user to look at' do
- Guardian.new(user).can_see_invite_details?(nil).should be_false
+ Guardian.new(user).can_see_invite_details?(nil).should be_falsey
end
it 'is true when looking at your own invites' do
- Guardian.new(user).can_see_invite_details?(user).should be_true
+ Guardian.new(user).can_see_invite_details?(user).should be_truthy
end
end
@@ -1371,11 +1371,11 @@ describe Guardian do
end
it "returns true for a nil user" do
- Guardian.new(nil).can_access_forum?.should be_true
+ Guardian.new(nil).can_access_forum?.should be_truthy
end
it "returns true for an unapproved user" do
- Guardian.new(unapproved_user).can_access_forum?.should be_true
+ Guardian.new(unapproved_user).can_access_forum?.should be_truthy
end
end
@@ -1385,21 +1385,21 @@ describe Guardian do
end
it "returns false for a nil user" do
- Guardian.new(nil).can_access_forum?.should be_false
+ Guardian.new(nil).can_access_forum?.should be_falsey
end
it "returns false for an unapproved user" do
- Guardian.new(unapproved_user).can_access_forum?.should be_false
+ Guardian.new(unapproved_user).can_access_forum?.should be_falsey
end
it "returns true for an admin user" do
unapproved_user.admin = true
- Guardian.new(unapproved_user).can_access_forum?.should be_true
+ Guardian.new(unapproved_user).can_access_forum?.should be_truthy
end
it "returns true for an approved user" do
unapproved_user.approved = true
- Guardian.new(unapproved_user).can_access_forum?.should be_true
+ Guardian.new(unapproved_user).can_access_forum?.should be_truthy
end
end
@@ -1408,15 +1408,15 @@ describe Guardian do
describe "can_delete_user?" do
it "is false without a logged in user" do
- Guardian.new(nil).can_delete_user?(user).should == false
+ Guardian.new(nil).can_delete_user?(user).should be_falsey
end
it "is false without a user to look at" do
- Guardian.new(admin).can_delete_user?(nil).should == false
+ Guardian.new(admin).can_delete_user?(nil).should be_falsey
end
it "is false for regular users" do
- Guardian.new(user).can_delete_user?(coding_horror).should == false
+ Guardian.new(user).can_delete_user?(coding_horror).should be_falsey
end
context "delete myself" do
@@ -1424,41 +1424,41 @@ describe Guardian do
subject { Guardian.new(myself).can_delete_user?(myself) }
it "is true to delete myself and I have never made a post" do
- subject.should == true
+ subject.should be_truthy
end
it "is true to delete myself and I have only made 1 post" do
myself.stubs(:post_count).returns(1)
- subject.should == true
+ subject.should be_truthy
end
it "is false to delete myself and I have made 2 posts" do
myself.stubs(:post_count).returns(2)
- subject.should == false
+ subject.should be_falsey
end
end
shared_examples "can_delete_user examples" do
it "is true if user is not an admin and has never posted" do
- Guardian.new(actor).can_delete_user?(Fabricate.build(:user, created_at: 100.days.ago)).should == true
+ Guardian.new(actor).can_delete_user?(Fabricate.build(:user, created_at: 100.days.ago)).should be_truthy
end
it "is true if user is not an admin and first post is not too old" do
user = Fabricate.build(:user, created_at: 100.days.ago)
user.stubs(:first_post_created_at).returns(9.days.ago)
SiteSetting.stubs(:delete_user_max_post_age).returns(10)
- Guardian.new(actor).can_delete_user?(user).should == true
+ Guardian.new(actor).can_delete_user?(user).should be_truthy
end
it "is false if user is an admin" do
- Guardian.new(actor).can_delete_user?(another_admin).should == false
+ Guardian.new(actor).can_delete_user?(another_admin).should be_falsey
end
it "is false if user's first post is too old" do
user = Fabricate.build(:user, created_at: 100.days.ago)
user.stubs(:first_post_created_at).returns(11.days.ago)
SiteSetting.stubs(:delete_user_max_post_age).returns(10)
- Guardian.new(actor).can_delete_user?(user).should == false
+ Guardian.new(actor).can_delete_user?(user).should be_falsey
end
end
@@ -1475,53 +1475,53 @@ describe Guardian do
describe "can_delete_all_posts?" do
it "is false without a logged in user" do
- Guardian.new(nil).can_delete_all_posts?(user).should be_false
+ Guardian.new(nil).can_delete_all_posts?(user).should be_falsey
end
it "is false without a user to look at" do
- Guardian.new(admin).can_delete_all_posts?(nil).should be_false
+ Guardian.new(admin).can_delete_all_posts?(nil).should be_falsey
end
it "is false for regular users" do
- Guardian.new(user).can_delete_all_posts?(coding_horror).should be_false
+ Guardian.new(user).can_delete_all_posts?(coding_horror).should be_falsey
end
shared_examples "can_delete_all_posts examples" do
it "is true if user has no posts" do
SiteSetting.stubs(:delete_user_max_post_age).returns(10)
- Guardian.new(actor).can_delete_all_posts?(Fabricate(:user, created_at: 100.days.ago)).should be_true
+ Guardian.new(actor).can_delete_all_posts?(Fabricate(:user, created_at: 100.days.ago)).should be_truthy
end
it "is true if user's first post is newer than delete_user_max_post_age days old" do
user = Fabricate(:user, created_at: 100.days.ago)
user.stubs(:first_post_created_at).returns(9.days.ago)
SiteSetting.stubs(:delete_user_max_post_age).returns(10)
- Guardian.new(actor).can_delete_all_posts?(user).should be_true
+ Guardian.new(actor).can_delete_all_posts?(user).should be_truthy
end
it "is false if user's first post is older than delete_user_max_post_age days old" do
user = Fabricate(:user, created_at: 100.days.ago)
user.stubs(:first_post_created_at).returns(11.days.ago)
SiteSetting.stubs(:delete_user_max_post_age).returns(10)
- Guardian.new(actor).can_delete_all_posts?(user).should be_false
+ Guardian.new(actor).can_delete_all_posts?(user).should be_falsey
end
it "is false if user is an admin" do
- Guardian.new(actor).can_delete_all_posts?(admin).should be_false
+ Guardian.new(actor).can_delete_all_posts?(admin).should be_falsey
end
it "is true if number of posts is small" do
u = Fabricate(:user, created_at: 1.day.ago)
u.stubs(:post_count).returns(1)
SiteSetting.stubs(:delete_all_posts_max).returns(10)
- Guardian.new(actor).can_delete_all_posts?(u).should be_true
+ Guardian.new(actor).can_delete_all_posts?(u).should be_truthy
end
it "is false if number of posts is not small" do
u = Fabricate(:user, created_at: 1.day.ago)
u.stubs(:post_count).returns(11)
SiteSetting.stubs(:delete_all_posts_max).returns(10)
- Guardian.new(actor).can_delete_all_posts?(u).should be_false
+ Guardian.new(actor).can_delete_all_posts?(u).should be_falsey
end
end
@@ -1538,23 +1538,23 @@ describe Guardian do
describe 'can_grant_title?' do
it 'is false without a logged in user' do
- Guardian.new(nil).can_grant_title?(user).should be_false
+ Guardian.new(nil).can_grant_title?(user).should be_falsey
end
it 'is false for regular users' do
- Guardian.new(user).can_grant_title?(user).should be_false
+ Guardian.new(user).can_grant_title?(user).should be_falsey
end
it 'is true for moderators' do
- Guardian.new(moderator).can_grant_title?(user).should be_true
+ Guardian.new(moderator).can_grant_title?(user).should be_truthy
end
it 'is true for admins' do
- Guardian.new(admin).can_grant_title?(user).should be_true
+ Guardian.new(admin).can_grant_title?(user).should be_truthy
end
it 'is false without a user to look at' do
- Guardian.new(admin).can_grant_title?(nil).should be_false
+ Guardian.new(admin).can_grant_title?(nil).should be_falsey
end
end
@@ -1562,38 +1562,38 @@ describe Guardian do
describe 'can_change_trust_level?' do
it 'is false without a logged in user' do
- Guardian.new(nil).can_change_trust_level?(user).should be_false
+ Guardian.new(nil).can_change_trust_level?(user).should be_falsey
end
it 'is false for regular users' do
- Guardian.new(user).can_change_trust_level?(user).should be_false
+ Guardian.new(user).can_change_trust_level?(user).should be_falsey
end
it 'is true for moderators' do
- Guardian.new(moderator).can_change_trust_level?(user).should be_true
+ Guardian.new(moderator).can_change_trust_level?(user).should be_truthy
end
it 'is true for admins' do
- Guardian.new(admin).can_change_trust_level?(user).should be_true
+ Guardian.new(admin).can_change_trust_level?(user).should be_truthy
end
end
describe "can_edit_username?" do
it "is false without a logged in user" do
- Guardian.new(nil).can_edit_username?(build(:user, created_at: 1.minute.ago)).should be_false
+ Guardian.new(nil).can_edit_username?(build(:user, created_at: 1.minute.ago)).should be_falsey
end
it "is false for regular users to edit another user's username" do
- Guardian.new(build(:user)).can_edit_username?(build(:user, created_at: 1.minute.ago)).should be_false
+ Guardian.new(build(:user)).can_edit_username?(build(:user, created_at: 1.minute.ago)).should be_falsey
end
shared_examples "staff can always change usernames" do
it "is true for moderators" do
- Guardian.new(moderator).can_edit_username?(user).should be_true
+ Guardian.new(moderator).can_edit_username?(user).should be_truthy
end
it "is true for admins" do
- Guardian.new(admin).can_edit_username?(user).should be_true
+ Guardian.new(admin).can_edit_username?(user).should be_truthy
end
end
@@ -1602,7 +1602,7 @@ describe Guardian do
include_examples "staff can always change usernames"
it "is true for the user to change their own username" do
- Guardian.new(target_user).can_edit_username?(target_user).should be_true
+ Guardian.new(target_user).can_edit_username?(target_user).should be_truthy
end
end
@@ -1616,7 +1616,7 @@ describe Guardian do
context 'with no posts' do
include_examples "staff can always change usernames"
it "is true for the user to change their own username" do
- Guardian.new(target_user).can_edit_username?(target_user).should be_true
+ Guardian.new(target_user).can_edit_username?(target_user).should be_truthy
end
end
@@ -1624,7 +1624,7 @@ describe Guardian do
before { target_user.stubs(:post_count).returns(1) }
include_examples "staff can always change usernames"
it "is false for the user to change their own username" do
- Guardian.new(target_user).can_edit_username?(target_user).should be_false
+ Guardian.new(target_user).can_edit_username?(target_user).should be_falsey
end
end
end
@@ -1637,7 +1637,7 @@ describe Guardian do
include_examples "staff can always change usernames"
it "is false for the user to change their own username" do
- Guardian.new(user).can_edit_username?(user).should be_false
+ Guardian.new(user).can_edit_username?(user).should be_falsey
end
end
@@ -1648,15 +1648,15 @@ describe Guardian do
end
it "is false for admins" do
- Guardian.new(admin).can_edit_username?(admin).should be_false
+ Guardian.new(admin).can_edit_username?(admin).should be_falsey
end
it "is false for moderators" do
- Guardian.new(moderator).can_edit_username?(moderator).should be_false
+ Guardian.new(moderator).can_edit_username?(moderator).should be_falsey
end
it "is false for users" do
- Guardian.new(user).can_edit_username?(user).should be_false
+ Guardian.new(user).can_edit_username?(user).should be_falsey
end
end
end
@@ -1668,23 +1668,23 @@ describe Guardian do
end
it "is false when not logged in" do
- Guardian.new(nil).can_edit_email?(build(:user, created_at: 1.minute.ago)).should be_false
+ Guardian.new(nil).can_edit_email?(build(:user, created_at: 1.minute.ago)).should be_falsey
end
it "is false for regular users to edit another user's email" do
- Guardian.new(build(:user)).can_edit_email?(build(:user, created_at: 1.minute.ago)).should be_false
+ Guardian.new(build(:user)).can_edit_email?(build(:user, created_at: 1.minute.ago)).should be_falsey
end
it "is true for a regular user to edit their own email" do
- Guardian.new(user).can_edit_email?(user).should be_true
+ Guardian.new(user).can_edit_email?(user).should be_truthy
end
it "is true for moderators" do
- Guardian.new(moderator).can_edit_email?(user).should be_true
+ Guardian.new(moderator).can_edit_email?(user).should be_truthy
end
it "is true for admins" do
- Guardian.new(admin).can_edit_email?(user).should be_true
+ Guardian.new(admin).can_edit_email?(user).should be_truthy
end
end
@@ -1694,23 +1694,23 @@ describe Guardian do
end
it "is false when not logged in" do
- Guardian.new(nil).can_edit_email?(build(:user, created_at: 1.minute.ago)).should be_false
+ Guardian.new(nil).can_edit_email?(build(:user, created_at: 1.minute.ago)).should be_falsey
end
it "is false for regular users to edit another user's email" do
- Guardian.new(build(:user)).can_edit_email?(build(:user, created_at: 1.minute.ago)).should be_false
+ Guardian.new(build(:user)).can_edit_email?(build(:user, created_at: 1.minute.ago)).should be_falsey
end
it "is false for a regular user to edit their own email" do
- Guardian.new(user).can_edit_email?(user).should be_false
+ Guardian.new(user).can_edit_email?(user).should be_falsey
end
it "is false for admins" do
- Guardian.new(admin).can_edit_email?(user).should be_false
+ Guardian.new(admin).can_edit_email?(user).should be_falsey
end
it "is false for moderators" do
- Guardian.new(moderator).can_edit_email?(user).should be_false
+ Guardian.new(moderator).can_edit_email?(user).should be_falsey
end
end
@@ -1721,41 +1721,41 @@ describe Guardian do
end
it "is false for admins" do
- Guardian.new(admin).can_edit_email?(admin).should be_false
+ Guardian.new(admin).can_edit_email?(admin).should be_falsey
end
it "is false for moderators" do
- Guardian.new(moderator).can_edit_email?(moderator).should be_false
+ Guardian.new(moderator).can_edit_email?(moderator).should be_falsey
end
it "is false for users" do
- Guardian.new(user).can_edit_email?(user).should be_false
+ Guardian.new(user).can_edit_email?(user).should be_falsey
end
end
end
describe 'can_edit_name?' do
it 'is false without a logged in user' do
- Guardian.new(nil).can_edit_name?(build(:user, created_at: 1.minute.ago)).should be_false
+ Guardian.new(nil).can_edit_name?(build(:user, created_at: 1.minute.ago)).should be_falsey
end
it "is false for regular users to edit another user's name" do
- Guardian.new(build(:user)).can_edit_name?(build(:user, created_at: 1.minute.ago)).should be_false
+ Guardian.new(build(:user)).can_edit_name?(build(:user, created_at: 1.minute.ago)).should be_falsey
end
context 'for a new user' do
let(:target_user) { build(:user, created_at: 1.minute.ago) }
it 'is true for the user to change their own name' do
- Guardian.new(target_user).can_edit_name?(target_user).should be_true
+ Guardian.new(target_user).can_edit_name?(target_user).should be_truthy
end
it 'is true for moderators' do
- Guardian.new(moderator).can_edit_name?(user).should be_true
+ Guardian.new(moderator).can_edit_name?(user).should be_truthy
end
it 'is true for admins' do
- Guardian.new(admin).can_edit_name?(user).should be_true
+ Guardian.new(admin).can_edit_name?(user).should be_truthy
end
end
@@ -1765,15 +1765,15 @@ describe Guardian do
end
it 'is false for the user to change their own name' do
- Guardian.new(user).can_edit_name?(user).should be_false
+ Guardian.new(user).can_edit_name?(user).should be_falsey
end
it 'is false for moderators' do
- Guardian.new(moderator).can_edit_name?(user).should be_false
+ Guardian.new(moderator).can_edit_name?(user).should be_falsey
end
it 'is false for admins' do
- Guardian.new(admin).can_edit_name?(user).should be_false
+ Guardian.new(admin).can_edit_name?(user).should be_falsey
end
end
@@ -1789,15 +1789,15 @@ describe Guardian do
end
it 'is true for admins' do
- Guardian.new(admin).can_edit_name?(admin).should be_true
+ Guardian.new(admin).can_edit_name?(admin).should be_truthy
end
it 'is true for moderators' do
- Guardian.new(moderator).can_edit_name?(moderator).should be_true
+ Guardian.new(moderator).can_edit_name?(moderator).should be_truthy
end
it 'is true for users' do
- Guardian.new(user).can_edit_name?(user).should be_true
+ Guardian.new(user).can_edit_name?(user).should be_truthy
end
end
@@ -1812,15 +1812,15 @@ describe Guardian do
end
it 'is false for admins' do
- Guardian.new(admin).can_edit_name?(admin).should be_false
+ Guardian.new(admin).can_edit_name?(admin).should be_falsey
end
it 'is false for moderators' do
- Guardian.new(moderator).can_edit_name?(moderator).should be_false
+ Guardian.new(moderator).can_edit_name?(moderator).should be_falsey
end
it 'is false for users' do
- Guardian.new(user).can_edit_name?(user).should be_false
+ Guardian.new(user).can_edit_name?(user).should be_falsey
end
end
@@ -1830,15 +1830,15 @@ describe Guardian do
end
it 'is true for admins' do
- Guardian.new(admin).can_edit_name?(admin).should be_true
+ Guardian.new(admin).can_edit_name?(admin).should be_truthy
end
it 'is true for moderators' do
- Guardian.new(moderator).can_edit_name?(moderator).should be_true
+ Guardian.new(moderator).can_edit_name?(moderator).should be_truthy
end
it 'is true for users' do
- Guardian.new(user).can_edit_name?(user).should be_true
+ Guardian.new(user).can_edit_name?(user).should be_truthy
end
end
end
@@ -1847,15 +1847,15 @@ describe Guardian do
describe 'can_wiki?' do
it 'returns false for regular user' do
- Guardian.new(coding_horror).can_wiki?.should be_false
+ Guardian.new(coding_horror).can_wiki?.should be_falsey
end
it 'returns true for admin user' do
- Guardian.new(admin).can_wiki?.should be_true
+ Guardian.new(admin).can_wiki?.should be_truthy
end
it 'returns true for trust_level_4 user' do
- Guardian.new(trust_level_4).can_wiki?.should be_true
+ Guardian.new(trust_level_4).can_wiki?.should be_truthy
end
end
end
diff --git a/spec/components/image_sizer_spec.rb b/spec/components/image_sizer_spec.rb
index 627e47f3065..53f9f902b9c 100644
--- a/spec/components/image_sizer_spec.rb
+++ b/spec/components/image_sizer_spec.rb
@@ -13,11 +13,11 @@ describe ImageSizer do
end
it 'returns nil if the width is nil' do
- ImageSizer.resize(nil, 100).should be_nil
+ ImageSizer.resize(nil, 100).should == nil
end
it 'returns nil if the height is nil' do
- ImageSizer.resize(100, nil).should be_nil
+ ImageSizer.resize(100, nil).should == nil
end
it 'works with string parameters' do
diff --git a/spec/components/js_locale_helper_spec.rb b/spec/components/js_locale_helper_spec.rb
index a182d2102ee..85206f44de8 100644
--- a/spec/components/js_locale_helper_spec.rb
+++ b/spec/components/js_locale_helper_spec.rb
@@ -71,7 +71,7 @@ describe JsLocaleHelper do
}))
ctx.eval('I18n.translations')["en"]["js"]["hello"].should == "world"
- ctx.eval('I18n.translations')["en"]["js"]["test_MF"].should be_nil
+ ctx.eval('I18n.translations')["en"]["js"]["test_MF"].should == nil
ctx.eval('I18n.messageFormat("test_MF", { HELLO: "hi", COUNT: 3 })').should == "hi 3 ducks"
ctx.eval('I18n.messageFormat("error_MF", { HELLO: "hi", COUNT: 3 })').should =~ /Invalid Format/
diff --git a/spec/components/middleware/anonymous_cache_spec.rb b/spec/components/middleware/anonymous_cache_spec.rb
index 0c93dc4191f..5555debea12 100644
--- a/spec/components/middleware/anonymous_cache_spec.rb
+++ b/spec/components/middleware/anonymous_cache_spec.rb
@@ -13,15 +13,15 @@ describe Middleware::AnonymousCache::Helper do
context "cachable?" do
it "true by default" do
- new_helper.cacheable?.should be_true
+ new_helper.cacheable?.should == true
end
it "is false for non GET" do
- new_helper("ANON_CACHE_DURATION" => 10, "REQUEST_METHOD" => "POST").cacheable?.should be_false
+ new_helper("ANON_CACHE_DURATION" => 10, "REQUEST_METHOD" => "POST").cacheable?.should == false
end
it "is false if it has an auth cookie" do
- new_helper("HTTP_COOKIE" => "jack=1; _t=#{"1"*32}; jill=2").cacheable?.should be_false
+ new_helper("HTTP_COOKIE" => "jack=1; _t=#{"1"*32}; jill=2").cacheable?.should == false
end
end
@@ -41,14 +41,14 @@ describe Middleware::AnonymousCache::Helper do
it "returns cached data for cached requests" do
helper.is_mobile = true
- helper.cached.should be_nil
+ helper.cached.should == nil
helper.cache([200, {"HELLO" => "WORLD"}, ["hello ", "my world"]])
helper = new_helper("ANON_CACHE_DURATION" => 10)
helper.is_mobile = true
helper.cached.should == [200, {"HELLO" => "WORLD"}, ["hello my world"]]
- crawler.cached.should be_nil
+ crawler.cached.should == nil
crawler.cache([200, {"HELLO" => "WORLD"}, ["hello ", "world"]])
crawler.cached.should == [200, {"HELLO" => "WORLD"}, ["hello world"]]
end
diff --git a/spec/components/pinned_check_spec.rb b/spec/components/pinned_check_spec.rb
index f858c936cf9..b108006ad4b 100644
--- a/spec/components/pinned_check_spec.rb
+++ b/spec/components/pinned_check_spec.rb
@@ -10,11 +10,11 @@ describe PinnedCheck do
context "without a topic_user record (either anonymous or never been in the topic)" do
it "returns false if the topic is not pinned" do
- PinnedCheck.pinned?(unpinned_topic).should be_false
+ PinnedCheck.pinned?(unpinned_topic).should == false
end
it "returns true if the topic is pinned" do
- PinnedCheck.pinned?(unpinned_topic).should be_false
+ PinnedCheck.pinned?(unpinned_topic).should == false
end
end
@@ -27,7 +27,7 @@ describe PinnedCheck do
let(:topic_user) { TopicUser.new(topic: unpinned_topic, user: user) }
it "returns false" do
- PinnedCheck.pinned?(unpinned_topic, topic_user).should be_false
+ PinnedCheck.pinned?(unpinned_topic, topic_user).should == false
end
end
@@ -36,17 +36,17 @@ describe PinnedCheck do
let(:topic_user) { TopicUser.new(topic: pinned_topic, user: user) }
it "is pinned if the topic_user's cleared_pinned_at is blank" do
- PinnedCheck.pinned?(pinned_topic, topic_user).should be_true
+ PinnedCheck.pinned?(pinned_topic, topic_user).should == true
end
it "is not pinned if the topic_user's cleared_pinned_at is later than when it was pinned_at" do
topic_user.cleared_pinned_at = (pinned_at + 1.hour)
- PinnedCheck.pinned?(pinned_topic, topic_user).should be_false
+ PinnedCheck.pinned?(pinned_topic, topic_user).should == false
end
it "is pinned if the topic_user's cleared_pinned_at is earlier than when it was pinned_at" do
topic_user.cleared_pinned_at = (pinned_at - 3.hours)
- PinnedCheck.pinned?(pinned_topic, topic_user).should be_true
+ PinnedCheck.pinned?(pinned_topic, topic_user).should == true
end
end
diff --git a/spec/components/plugin/instance_spec.rb b/spec/components/plugin/instance_spec.rb
index b649ff2719a..a971139060f 100644
--- a/spec/components/plugin/instance_spec.rb
+++ b/spec/components/plugin/instance_spec.rb
@@ -123,11 +123,11 @@ describe Plugin::Instance do
# calls ensure_assets! make sure they are there
plugin.assets.count.should == 1
plugin.assets.each do |a, opts|
- File.exists?(a).should be_true
+ File.exists?(a).should == true
end
# ensure it cleans up all crap in autogenerated directory
- File.exists?(junk_file).should be_false
+ File.exists?(junk_file).should == false
end
it "finds all the custom assets" do
diff --git a/spec/components/post_creator_spec.rb b/spec/components/post_creator_spec.rb
index 0620d386118..17038fae19a 100644
--- a/spec/components/post_creator_spec.rb
+++ b/spec/components/post_creator_spec.rb
@@ -59,7 +59,7 @@ describe PostCreator do
it "doesn't return true for spam" do
creator.create
- creator.spam?.should be_false
+ creator.spam?.should == false
end
it "does not notify on system messages" do
@@ -70,8 +70,8 @@ describe PostCreator do
end
# don't notify on system messages they introduce too much noise
channels = messages.map(&:channel)
- channels.find{|s| s =~ /unread/}.should be_nil
- channels.find{|s| s =~ /new/}.should be_nil
+ channels.find{|s| s =~ /unread/}.should == nil
+ channels.find{|s| s =~ /new/}.should == nil
end
it "generates the correct messages for a secure topic" do
@@ -104,7 +104,7 @@ describe PostCreator do
].sort
admin_ids = [Group[:admins].id]
- messages.any?{|m| m.group_ids != admin_ids && m.user_ids != [admin.id]}.should be_false
+ messages.any?{|m| m.group_ids != admin_ids && m.user_ids != [admin.id]}.should == false
end
it 'generates the correct messages for a normal topic' do
@@ -115,16 +115,16 @@ describe PostCreator do
end
latest = messages.find{|m| m.channel == "/latest"}
- latest.should_not be_nil
+ latest.should_not == nil
latest = messages.find{|m| m.channel == "/new"}
- latest.should_not be_nil
+ latest.should_not == nil
read = messages.find{|m| m.channel == "/unread/#{p.user_id}"}
- read.should_not be_nil
+ read.should_not == nil
user_action = messages.find{|m| m.channel == "/users/#{p.user.username}"}
- user_action.should_not be_nil
+ user_action.should_not == nil
messages.length.should == 5
end
@@ -207,7 +207,7 @@ describe PostCreator do
it 'ensures the user can auto-close the topic, but ignores auto-close param silently' do
Guardian.any_instance.stubs(:can_moderate?).returns(false)
post = PostCreator.new(user, basic_topic_params.merge(auto_close_time: 2)).create
- post.topic.auto_close_at.should be_nil
+ post.topic.auto_close_at.should == nil
end
end
end
@@ -288,7 +288,7 @@ describe PostCreator do
GroupMessage.stubs(:create)
creator.create
creator.errors.should be_present
- creator.spam?.should be_true
+ creator.spam?.should == true
end
it "sends a message to moderators" do
@@ -358,7 +358,7 @@ describe PostCreator do
post.topic.topic_allowed_users.count.should == 3
# PMs can't have a category
- post.topic.category.should be_nil
+ post.topic.category.should == nil
# does not notify an unrelated user
unrelated.notifications.count.should == 0
@@ -469,7 +469,7 @@ describe PostCreator do
it 'can save a post' do
creator = PostCreator.new(user, raw: 'q', title: 'q', skip_validations: true)
creator.create
- creator.errors.should be_nil
+ creator.errors.should == nil
end
end
@@ -494,7 +494,7 @@ describe PostCreator do
title: 'Reviews of Science Ovens',
raw: 'Did you know that you can use microwaves to cook your dinner? Science!')
creator.create
- TopicEmbed.where(embed_url: embed_url).exists?.should be_true
+ TopicEmbed.where(embed_url: embed_url).exists?.should == true
end
end
diff --git a/spec/components/post_destroyer_spec.rb b/spec/components/post_destroyer_spec.rb
index 669beb1824a..607c915d55a 100644
--- a/spec/components/post_destroyer_spec.rb
+++ b/spec/components/post_destroyer_spec.rb
@@ -106,7 +106,7 @@ describe PostDestroyer do
post2.deleted_at.should be_blank
post2.deleted_by.should be_blank
- post2.user_deleted.should be_true
+ post2.user_deleted.should == true
post2.raw.should == I18n.t('js.post.deleted_by_author', {count: 24})
post2.version.should == 2
@@ -114,7 +114,7 @@ describe PostDestroyer do
PostDestroyer.new(post2.user, post2).recover
post2.reload
post2.version.should == 3
- post2.user_deleted.should be_false
+ post2.user_deleted.should == false
post2.cooked.should == @orig
end
@@ -177,7 +177,7 @@ describe PostDestroyer do
let(:topic_user) { second_user.topic_users.find_by(topic_id: topic.id) }
it 'clears the posted flag for the second user' do
- topic_user.posted?.should be_false
+ topic_user.posted?.should == false
end
it "sets the second user's last_read_post_number back to 1" do
@@ -314,8 +314,8 @@ describe PostDestroyer do
PostDestroyer.new(moderator, second_post).destroy
- expect(UserAction.find_by(id: bookmark.id)).to be_nil
- expect(UserAction.find_by(id: like.id)).to be_nil
+ expect(UserAction.find_by(id: bookmark.id)).should == nil
+ expect(UserAction.find_by(id: like.id)).should == nil
end
end
diff --git a/spec/components/post_revisor_spec.rb b/spec/components/post_revisor_spec.rb
index 38a84f1b9b2..90769440171 100644
--- a/spec/components/post_revisor_spec.rb
+++ b/spec/components/post_revisor_spec.rb
@@ -16,7 +16,7 @@ describe PostRevisor do
describe 'with the same body' do
it "doesn't change version" do
lambda {
- subject.revise!(post.user, post.raw).should be_false
+ subject.revise!(post.user, post.raw).should == false
post.reload
}.should_not change(post, :version)
end
@@ -110,7 +110,7 @@ describe PostRevisor do
let(:new_description) { "this is my new description." }
- it "should have to description by default" do
+ it "should have no description by default" do
category.description.should be_blank
end
@@ -120,8 +120,8 @@ describe PostRevisor do
category.reload
end
- it "returns true for category_changed" do
- subject.category_changed.should be_true
+ it "returns the changed category info" do
+ subject.category_changed.should == category
end
it "updates the description of the category" do
@@ -155,7 +155,7 @@ describe PostRevisor do
category.description.should be_blank
end
- it "returns true for category_changed" do
+ it "returns the changed category info" do
subject.category_changed.should == category
end
end
@@ -211,7 +211,7 @@ describe PostRevisor do
let!(:result) { subject.revise!(changed_by, "lets update the body") }
it 'returns true' do
- result.should be_true
+ result.should == true
end
it 'updates the body' do
diff --git a/spec/components/pretty_text_spec.rb b/spec/components/pretty_text_spec.rb
index f9c0e632ccf..2378ab4d8d3 100644
--- a/spec/components/pretty_text_spec.rb
+++ b/spec/components/pretty_text_spec.rb
@@ -53,23 +53,23 @@ describe PrettyText do
end
it "should not inject nofollow in all local links" do
- (PrettyText.cook("cnn") !~ /nofollow/).should be_true
+ (PrettyText.cook("cnn") !~ /nofollow/).should == true
end
it "should not inject nofollow in all subdomain links" do
- (PrettyText.cook("cnn") !~ /nofollow/).should be_true
+ (PrettyText.cook("cnn") !~ /nofollow/).should == true
end
it "should not inject nofollow for foo.com" do
- (PrettyText.cook("cnn") !~ /nofollow/).should be_true
+ (PrettyText.cook("cnn") !~ /nofollow/).should == true
end
it "should not inject nofollow for bar.foo.com" do
- (PrettyText.cook("cnn") !~ /nofollow/).should be_true
+ (PrettyText.cook("cnn") !~ /nofollow/).should == true
end
it "should not inject nofollow if omit_nofollow option is given" do
- (PrettyText.cook('cnn', omit_nofollow: true) !~ /nofollow/).should be_true
+ (PrettyText.cook('cnn', omit_nofollow: true) !~ /nofollow/).should == true
end
end
diff --git a/spec/components/promotion_spec.rb b/spec/components/promotion_spec.rb
index 65a9b602587..af0f783c3d9 100644
--- a/spec/components/promotion_spec.rb
+++ b/spec/components/promotion_spec.rb
@@ -26,7 +26,7 @@ describe Promotion do
let!(:result) { promotion.review }
it "returns false" do
- result.should be_false
+ result.should == false
end
it "has not changed the user's trust level" do
@@ -45,7 +45,7 @@ describe Promotion do
end
it "returns true" do
- @result.should be_true
+ @result.should == true
end
it "has upgraded the user to basic" do
@@ -64,7 +64,7 @@ describe Promotion do
let!(:result) { promotion.review }
it "returns false" do
- result.should be_false
+ result.should == false
end
it "has not changed the user's trust level" do
@@ -88,7 +88,7 @@ describe Promotion do
end
it "returns true" do
- @result.should be_true
+ @result.should == true
end
it "has upgraded the user to regular" do
diff --git a/spec/components/rate_limiter_spec.rb b/spec/components/rate_limiter_spec.rb
index 7b2f27f5006..bed1724897b 100644
--- a/spec/components/rate_limiter_spec.rb
+++ b/spec/components/rate_limiter_spec.rb
@@ -14,7 +14,7 @@ describe RateLimiter do
end
it "returns true for can_perform?" do
- rate_limiter.can_perform?.should be_true
+ rate_limiter.can_perform?.should == true
end
it "doesn't raise an error on performed!" do
@@ -31,7 +31,7 @@ describe RateLimiter do
context 'never done' do
it "should perform right away" do
- rate_limiter.can_perform?.should be_true
+ rate_limiter.can_perform?.should == true
end
it "performs without an error" do
@@ -46,7 +46,7 @@ describe RateLimiter do
end
it "returns false for can_perform when the limit has been hit" do
- rate_limiter.can_perform?.should be_false
+ rate_limiter.can_perform?.should == false
end
it "raises an error the third time called" do
@@ -57,7 +57,7 @@ describe RateLimiter do
it "returns true for can_perform if the user is an admin" do
user.admin = true
- rate_limiter.can_perform?.should be_true
+ rate_limiter.can_perform?.should == true
end
it "doesn't raise an error when an admin performs the task" do
@@ -67,7 +67,7 @@ describe RateLimiter do
it "returns true for can_perform if the user is a mod" do
user.moderator = true
- rate_limiter.can_perform?.should be_true
+ rate_limiter.can_perform?.should == true
end
it "doesn't raise an error when a moderator performs the task" do
@@ -84,7 +84,7 @@ describe RateLimiter do
end
it "returns true for can_perform since there is now room" do
- rate_limiter.can_perform?.should be_true
+ rate_limiter.can_perform?.should == true
end
it "raises no error now that there is room" do
diff --git a/spec/components/redis_store_spec.rb b/spec/components/redis_store_spec.rb
index 3787e408b76..5e10774fc4b 100644
--- a/spec/components/redis_store_spec.rb
+++ b/spec/components/redis_store_spec.rb
@@ -51,7 +51,7 @@ describe "Redis Store" do
end
store.clear
- store.read("key").should be_nil
+ store.read("key").should == nil
cache.fetch("key").should == "key in cache"
end
diff --git a/spec/components/scheduler/schedule_info_spec.rb b/spec/components/scheduler/schedule_info_spec.rb
index 58649763deb..6b405f725d6 100644
--- a/spec/components/scheduler/schedule_info_spec.rb
+++ b/spec/components/scheduler/schedule_info_spec.rb
@@ -32,25 +32,25 @@ describe Scheduler::ScheduleInfo do
end
it 'starts off invalid' do
- @info.valid?.should be_false
+ @info.valid?.should == false
end
it 'will have a due date in the next 5 minutes if it was blank' do
@info.schedule!
- @info.valid?.should be_true
+ @info.valid?.should == true
@info.next_run.should be_within(5.minutes).of(Time.now.to_i)
end
it 'will have a due date within the next hour if it just ran' do
@info.prev_run = Time.now.to_i
@info.schedule!
- @info.valid?.should be_true
+ @info.valid?.should == true
@info.next_run.should be_within(1.hour * manager.random_ratio).of(Time.now.to_i + 1.hour)
end
it 'is invalid if way in the future' do
@info.next_run = Time.now.to_i + 1.year
- @info.valid?.should be_false
+ @info.valid?.should == false
end
end
@@ -79,19 +79,18 @@ describe Scheduler::ScheduleInfo do
end
it "starts off invalid" do
- @info.valid?.should be_false
+ @info.valid?.should == false
end
- it "will have a due date at the appropriate time if blank" do
- pending
- @info.next_run.should be_nil
+ skip "will have a due date at the appropriate time if blank" do
+ @info.next_run.should == nil
@info.schedule!
- @info.valid?.should be_true
+ @info.valid?.should == true
end
it 'is invalid if way in the future' do
@info.next_run = Time.now.to_i + 1.year
- @info.valid?.should be_false
+ @info.valid?.should == false
end
end
diff --git a/spec/components/score_calculator_spec.rb b/spec/components/score_calculator_spec.rb
index d1ea32bc6dd..df7be0a7e97 100644
--- a/spec/components/score_calculator_spec.rb
+++ b/spec/components/score_calculator_spec.rb
@@ -39,14 +39,14 @@ describe ScoreCalculator do
it "won't update the site settings when the site settings don't match" do
ScoreCalculator.new(reads: 3).calculate
topic.reload
- topic.has_summary.should be_false
+ topic.has_summary.should == false
end
it "removes the summary flag if the topic no longer qualifies" do
topic.update_column(:has_summary, true)
ScoreCalculator.new(reads: 3).calculate
topic.reload
- topic.has_summary.should be_false
+ topic.has_summary.should == false
end
it "won't update the site settings when the site settings don't match" do
@@ -56,7 +56,7 @@ describe ScoreCalculator do
ScoreCalculator.new(reads: 3).calculate
topic.reload
- topic.has_summary.should be_true
+ topic.has_summary.should == true
end
end
diff --git a/spec/components/suggested_topics_builder_spec.rb b/spec/components/suggested_topics_builder_spec.rb
index a10e3eddd76..86c88554452 100644
--- a/spec/components/suggested_topics_builder_spec.rb
+++ b/spec/components/suggested_topics_builder_spec.rb
@@ -45,7 +45,7 @@ describe SuggestedTopicsBuilder do
end
it "has the correct defaults" do
- builder.excluded_topic_ids.include?(topic.id).should be_true
+ builder.excluded_topic_ids.include?(topic.id).should == true
builder.results_left.should == 5
builder.size.should == 0
builder.should_not be_full
@@ -77,8 +77,8 @@ describe SuggestedTopicsBuilder do
builder.size.should == 1
builder.results_left.should == 4
builder.should_not be_full
- builder.excluded_topic_ids.include?(topic.id).should be_true
- builder.excluded_topic_ids.include?(other_topic.id).should be_true
+ builder.excluded_topic_ids.include?(topic.id).should == true
+ builder.excluded_topic_ids.include?(other_topic.id).should == true
end
end
diff --git a/spec/components/system_message_spec.rb b/spec/components/system_message_spec.rb
index 622fdfad23b..71426e6f237 100644
--- a/spec/components/system_message_spec.rb
+++ b/spec/components/system_message_spec.rb
@@ -19,7 +19,7 @@ describe SystemMessage do
topic.should be_private_message
topic.should be_valid
topic.subtype.should == TopicSubtype.system_message
- topic.allowed_users.include?(user).should be_true
+ topic.allowed_users.include?(user).should == true
end
end
diff --git a/spec/components/topic_creator_spec.rb b/spec/components/topic_creator_spec.rb
index 6181fabb060..3370084e281 100644
--- a/spec/components/topic_creator_spec.rb
+++ b/spec/components/topic_creator_spec.rb
@@ -38,7 +38,7 @@ describe TopicCreator do
it "ignores auto_close_time without raising an error" do
topic = TopicCreator.create(user, Guardian.new(user), valid_attrs.merge(auto_close_time: '24'))
topic.should be_valid
- topic.auto_close_at.should be_nil
+ topic.auto_close_at.should == nil
end
it "category name is case insensitive" do
diff --git a/spec/components/topic_query_spec.rb b/spec/components/topic_query_spec.rb
index 9ff3a3b84a3..0f0923a2fd8 100644
--- a/spec/components/topic_query_spec.rb
+++ b/spec/components/topic_query_spec.rb
@@ -151,10 +151,10 @@ describe TopicQuery do
topics.map(&:id).should == [pinned_topic, future_topic, closed_topic, archived_topic, regular_topic].map(&:id)
# includes the invisible topic if you're a moderator
- TopicQuery.new(moderator).list_latest.topics.include?(invisible_topic).should be_true
+ TopicQuery.new(moderator).list_latest.topics.include?(invisible_topic).should == true
# includes the invisible topic if you're an admin" do
- TopicQuery.new(admin).list_latest.topics.include?(invisible_topic).should be_true
+ TopicQuery.new(admin).list_latest.topics.include?(invisible_topic).should == true
end
context 'sort_order' do
@@ -351,7 +351,7 @@ describe TopicQuery do
let!(:created_topic) { create_post(user: user).topic }
it "includes the created topic" do
- topics.include?(created_topic).should be_true
+ topics.include?(created_topic).should == true
end
end
@@ -360,7 +360,7 @@ describe TopicQuery do
let!(:your_post) { create_post(user: user, topic: other_users_topic )}
it "includes the posted topic" do
- topics.include?(other_users_topic).should be_true
+ topics.include?(other_users_topic).should == true
end
end
diff --git a/spec/components/topic_view_spec.rb b/spec/components/topic_view_spec.rb
index d948a415f89..019f77485cd 100644
--- a/spec/components/topic_view_spec.rb
+++ b/spec/components/topic_view_spec.rb
@@ -193,14 +193,14 @@ describe TopicView do
context '.read?' do
it 'tracks correctly' do
# anon is assumed to have read everything
- TopicView.new(topic.id).read?(1).should be_true
+ TopicView.new(topic.id).read?(1).should == true
# random user has nothing
- topic_view.read?(1).should be_false
+ topic_view.read?(1).should == false
# a real user that just read it should have it marked
PostTiming.process_timings(coding_horror, topic.id, 1, [[1,1000]])
- TopicView.new(topic.id, coding_horror).read?(1).should be_true
+ TopicView.new(topic.id, coding_horror).read?(1).should == true
TopicView.new(topic.id, coding_horror).topic_user.should be_present
end
end
@@ -225,8 +225,8 @@ describe TopicView do
recent_posts.count.should == 25
# ordering
- recent_posts.include?(p1).should be_false
- recent_posts.include?(p3).should be_true
+ recent_posts.include?(p1).should == false
+ recent_posts.include?(p3).should == true
recent_posts.first.created_at.should > recent_posts.last.created_at
end
end
@@ -259,13 +259,13 @@ describe TopicView do
describe "contains_gaps?" do
it "works" do
# does not contain contains_gaps with default filtering
- topic_view.contains_gaps?.should be_false
+ topic_view.contains_gaps?.should == false
# contains contains_gaps when filtered by username" do
- TopicView.new(topic.id, coding_horror, username_filters: ['eviltrout']).contains_gaps?.should be_true
+ TopicView.new(topic.id, coding_horror, username_filters: ['eviltrout']).contains_gaps?.should == true
# contains contains_gaps when filtered by summary
- TopicView.new(topic.id, coding_horror, filter: 'summary').contains_gaps?.should be_true
+ TopicView.new(topic.id, coding_horror, filter: 'summary').contains_gaps?.should == true
# contains contains_gaps when filtered by best
- TopicView.new(topic.id, coding_horror, best: 5).contains_gaps?.should be_true
+ TopicView.new(topic.id, coding_horror, best: 5).contains_gaps?.should == true
end
end
@@ -309,21 +309,21 @@ describe TopicView do
near_view = topic_view_near(p1)
near_view.desired_post.should == p1
near_view.posts.should == [p1, p2, p3]
- near_view.contains_gaps?.should be_false
+ near_view.contains_gaps?.should == false
end
it "snaps to the upper boundary" do
near_view = topic_view_near(p5)
near_view.desired_post.should == p5
near_view.posts.should == [p2, p3, p5]
- near_view.contains_gaps?.should be_false
+ near_view.contains_gaps?.should == false
end
it "returns the posts in the middle" do
near_view = topic_view_near(p2)
near_view.desired_post.should == p2
near_view.posts.should == [p1, p2, p3]
- near_view.contains_gaps?.should be_false
+ near_view.contains_gaps?.should == false
end
it "gaps deleted posts to an admin" do
@@ -340,7 +340,7 @@ describe TopicView do
near_view = topic_view_near(p3, true)
near_view.desired_post.should == p3
near_view.posts.should == [p2, p3, p4]
- near_view.contains_gaps?.should be_false
+ near_view.contains_gaps?.should == false
end
it "gaps deleted posts by nuked users to an admin" do
@@ -358,7 +358,7 @@ describe TopicView do
near_view = topic_view_near(p5, true)
near_view.desired_post.should == p5
near_view.posts.should == [p4, p5, p6]
- near_view.contains_gaps?.should be_false
+ near_view.contains_gaps?.should == false
end
context "when 'posts per page' exceeds the number of posts" do
@@ -367,7 +367,7 @@ describe TopicView do
it 'returns all the posts' do
near_view = topic_view_near(p5)
near_view.posts.should == [p1, p2, p3, p5]
- near_view.contains_gaps?.should be_false
+ near_view.contains_gaps?.should == false
end
it 'gaps deleted posts to admins' do
@@ -382,7 +382,7 @@ describe TopicView do
coding_horror.admin = true
near_view = topic_view_near(p5, true)
near_view.posts.should == [p1, p2, p3, p4, p5, p6, p7]
- near_view.contains_gaps?.should be_false
+ near_view.contains_gaps?.should == false
end
end
end
diff --git a/spec/components/url_helper_spec.rb b/spec/components/url_helper_spec.rb
index 5b282a31c6a..a72bc5d7238 100644
--- a/spec/components/url_helper_spec.rb
+++ b/spec/components/url_helper_spec.rb
@@ -15,21 +15,21 @@ describe UrlHelper do
store = stub
store.expects(:has_been_uploaded?).returns(true)
Discourse.stubs(:store).returns(store)
- helper.is_local("http://discuss.site.com/path/to/file.png").should be_true
+ helper.is_local("http://discuss.site.com/path/to/file.png").should == true
end
it "is true for relative assets" do
store = stub
store.expects(:has_been_uploaded?).returns(false)
Discourse.stubs(:store).returns(store)
- helper.is_local("/assets/javascripts/all.js").should be_true
+ helper.is_local("/assets/javascripts/all.js").should == true
end
it "is true for plugin assets" do
store = stub
store.expects(:has_been_uploaded?).returns(false)
Discourse.stubs(:store).returns(store)
- helper.is_local("/plugins/all.js").should be_true
+ helper.is_local("/plugins/all.js").should == true
end
end
diff --git a/spec/components/user_name_suggester_spec.rb b/spec/components/user_name_suggester_spec.rb
index 7cd0b16b75c..de14323e5a7 100644
--- a/spec/components/user_name_suggester_spec.rb
+++ b/spec/components/user_name_suggester_spec.rb
@@ -15,7 +15,7 @@ describe UserNameSuggester do
end
it "doesn't raise an error on nil username" do
- UserNameSuggester.suggest(nil).should be_nil
+ UserNameSuggester.suggest(nil).should == nil
end
it 'corrects weird characters' do
diff --git a/spec/controllers/admin/api_controller_spec.rb b/spec/controllers/admin/api_controller_spec.rb
index b7b61f2ad03..1349f227950 100644
--- a/spec/controllers/admin/api_controller_spec.rb
+++ b/spec/controllers/admin/api_controller_spec.rb
@@ -3,7 +3,7 @@ require 'spec_helper'
describe Admin::ApiController do
it "is a subclass of AdminController" do
- (Admin::ApiController < Admin::AdminController).should be_true
+ (Admin::ApiController < Admin::AdminController).should == true
end
let!(:user) { log_in(:admin) }
diff --git a/spec/controllers/admin/backups_controller_spec.rb b/spec/controllers/admin/backups_controller_spec.rb
index 91bbfbf3b85..a27c781e6a7 100644
--- a/spec/controllers/admin/backups_controller_spec.rb
+++ b/spec/controllers/admin/backups_controller_spec.rb
@@ -3,7 +3,7 @@ require "spec_helper"
describe Admin::BackupsController do
it "is a subclass of AdminController" do
- (Admin::BackupsController < Admin::AdminController).should be_true
+ (Admin::BackupsController < Admin::AdminController).should == true
end
let(:backup_filename) { "2014-02-10-065935.tar.gz" }
@@ -81,7 +81,7 @@ describe Admin::BackupsController do
# response.should be_success
# json = JSON.parse(response.body)
- # json["message"].should_not be_nil
+ # json["message"].should_not == nil
# end
end
diff --git a/spec/controllers/admin/color_schemes_controller_spec.rb b/spec/controllers/admin/color_schemes_controller_spec.rb
index c4c24db48ff..9654d17bf72 100644
--- a/spec/controllers/admin/color_schemes_controller_spec.rb
+++ b/spec/controllers/admin/color_schemes_controller_spec.rb
@@ -2,7 +2,7 @@ require 'spec_helper'
describe Admin::ColorSchemesController do
it "is a subclass of AdminController" do
- (described_class < Admin::AdminController).should be_true
+ (described_class < Admin::AdminController).should == true
end
context "while logged in as an admin" do
diff --git a/spec/controllers/admin/dashboard_controller_spec.rb b/spec/controllers/admin/dashboard_controller_spec.rb
index 17d0ee253a0..332e335f250 100644
--- a/spec/controllers/admin/dashboard_controller_spec.rb
+++ b/spec/controllers/admin/dashboard_controller_spec.rb
@@ -8,7 +8,7 @@ describe Admin::DashboardController do
end
it "is a subclass of AdminController" do
- (Admin::DashboardController < Admin::AdminController).should be_true
+ (Admin::DashboardController < Admin::AdminController).should == true
end
context 'while logged in as an admin' do
diff --git a/spec/controllers/admin/email_controller_spec.rb b/spec/controllers/admin/email_controller_spec.rb
index 29b824da9ca..1c914714ae1 100644
--- a/spec/controllers/admin/email_controller_spec.rb
+++ b/spec/controllers/admin/email_controller_spec.rb
@@ -3,7 +3,7 @@ require 'spec_helper'
describe Admin::EmailController do
it "is a subclass of AdminController" do
- (Admin::EmailController < Admin::AdminController).should be_true
+ (Admin::EmailController < Admin::AdminController).should == true
end
let!(:user) { log_in(:admin) }
diff --git a/spec/controllers/admin/export_csv_controller_spec.rb b/spec/controllers/admin/export_csv_controller_spec.rb
index 90863df2bd6..cbf037e4ccb 100644
--- a/spec/controllers/admin/export_csv_controller_spec.rb
+++ b/spec/controllers/admin/export_csv_controller_spec.rb
@@ -3,7 +3,7 @@ require "spec_helper"
describe Admin::ExportCsvController do
it "is a subclass of AdminController" do
- (Admin::ExportCsvController < Admin::AdminController).should be_true
+ (Admin::ExportCsvController < Admin::AdminController).should == true
end
let(:export_filename) { "export_b6a2bc87.csv" }
diff --git a/spec/controllers/admin/flags_controller_spec.rb b/spec/controllers/admin/flags_controller_spec.rb
index 1daaacc5fee..766523e269c 100644
--- a/spec/controllers/admin/flags_controller_spec.rb
+++ b/spec/controllers/admin/flags_controller_spec.rb
@@ -3,7 +3,7 @@ require 'spec_helper'
describe Admin::FlagsController do
it "is a subclass of AdminController" do
- (Admin::FlagsController < Admin::AdminController).should be_true
+ (Admin::FlagsController < Admin::AdminController).should == true
end
context 'while logged in as an admin' do
diff --git a/spec/controllers/admin/groups_controller_spec.rb b/spec/controllers/admin/groups_controller_spec.rb
index 9ab5f2e0976..7c5192ea332 100644
--- a/spec/controllers/admin/groups_controller_spec.rb
+++ b/spec/controllers/admin/groups_controller_spec.rb
@@ -7,7 +7,7 @@ describe Admin::GroupsController do
end
it "is a subclass of AdminController" do
- (Admin::GroupsController < Admin::AdminController).should be_true
+ (Admin::GroupsController < Admin::AdminController).should == true
end
it "produces valid json for groups" do
diff --git a/spec/controllers/admin/impersonate_controller_spec.rb b/spec/controllers/admin/impersonate_controller_spec.rb
index 601f19dcf50..1bd528d3f3e 100644
--- a/spec/controllers/admin/impersonate_controller_spec.rb
+++ b/spec/controllers/admin/impersonate_controller_spec.rb
@@ -3,7 +3,7 @@ require 'spec_helper'
describe Admin::ImpersonateController do
it "is a subclass of AdminController" do
- (Admin::ImpersonateController < Admin::AdminController).should be_true
+ (Admin::ImpersonateController < Admin::AdminController).should == true
end
diff --git a/spec/controllers/admin/reports_controller_spec.rb b/spec/controllers/admin/reports_controller_spec.rb
index 40c2b1764c5..2412319fd3b 100644
--- a/spec/controllers/admin/reports_controller_spec.rb
+++ b/spec/controllers/admin/reports_controller_spec.rb
@@ -3,7 +3,7 @@ require 'spec_helper'
describe Admin::ReportsController do
it "is a subclass of AdminController" do
- (Admin::ReportsController < Admin::AdminController).should be_true
+ (Admin::ReportsController < Admin::AdminController).should == true
end
context 'while logged in as an admin' do
diff --git a/spec/controllers/admin/screened_emails_controller_spec.rb b/spec/controllers/admin/screened_emails_controller_spec.rb
index e10553ea2dd..a68661f877c 100644
--- a/spec/controllers/admin/screened_emails_controller_spec.rb
+++ b/spec/controllers/admin/screened_emails_controller_spec.rb
@@ -2,7 +2,7 @@ require 'spec_helper'
describe Admin::ScreenedEmailsController do
it "is a subclass of AdminController" do
- (Admin::ScreenedEmailsController < Admin::AdminController).should be_true
+ (Admin::ScreenedEmailsController < Admin::AdminController).should == true
end
let!(:user) { log_in(:admin) }
diff --git a/spec/controllers/admin/screened_ip_addresses_controller_spec.rb b/spec/controllers/admin/screened_ip_addresses_controller_spec.rb
index 2d78a00e674..edd6af13bb2 100644
--- a/spec/controllers/admin/screened_ip_addresses_controller_spec.rb
+++ b/spec/controllers/admin/screened_ip_addresses_controller_spec.rb
@@ -2,7 +2,7 @@ require 'spec_helper'
describe Admin::ScreenedIpAddressesController do
it "is a subclass of AdminController" do
- (Admin::ScreenedIpAddressesController < Admin::AdminController).should be_true
+ (Admin::ScreenedIpAddressesController < Admin::AdminController).should == true
end
let!(:user) { log_in(:admin) }
diff --git a/spec/controllers/admin/screened_urls_controller_spec.rb b/spec/controllers/admin/screened_urls_controller_spec.rb
index 979da4674e2..0966ee95d89 100644
--- a/spec/controllers/admin/screened_urls_controller_spec.rb
+++ b/spec/controllers/admin/screened_urls_controller_spec.rb
@@ -2,7 +2,7 @@ require 'spec_helper'
describe Admin::ScreenedUrlsController do
it "is a subclass of AdminController" do
- (Admin::ScreenedUrlsController < Admin::AdminController).should be_true
+ (Admin::ScreenedUrlsController < Admin::AdminController).should == true
end
let!(:user) { log_in(:admin) }
diff --git a/spec/controllers/admin/site_customizations_controller_spec.rb b/spec/controllers/admin/site_customizations_controller_spec.rb
index 76700ff3f14..944c1e374e5 100644
--- a/spec/controllers/admin/site_customizations_controller_spec.rb
+++ b/spec/controllers/admin/site_customizations_controller_spec.rb
@@ -3,7 +3,7 @@ require 'spec_helper'
describe Admin::SiteCustomizationsController do
it "is a subclass of AdminController" do
- (Admin::UsersController < Admin::AdminController).should be_true
+ (Admin::UsersController < Admin::AdminController).should == true
end
context 'while logged in as an admin' do
diff --git a/spec/controllers/admin/site_settings_controller_spec.rb b/spec/controllers/admin/site_settings_controller_spec.rb
index 4f2a9678719..030e27c9bbb 100644
--- a/spec/controllers/admin/site_settings_controller_spec.rb
+++ b/spec/controllers/admin/site_settings_controller_spec.rb
@@ -3,7 +3,7 @@ require 'spec_helper'
describe Admin::SiteSettingsController do
it "is a subclass of AdminController" do
- (Admin::SiteSettingsController < Admin::AdminController).should be_true
+ (Admin::SiteSettingsController < Admin::AdminController).should == true
end
context 'while logged in as an admin' do
diff --git a/spec/controllers/admin/site_text_controller_spec.rb b/spec/controllers/admin/site_text_controller_spec.rb
index 8944a54d738..d6eb57b91d3 100644
--- a/spec/controllers/admin/site_text_controller_spec.rb
+++ b/spec/controllers/admin/site_text_controller_spec.rb
@@ -3,7 +3,7 @@ require 'spec_helper'
describe Admin::SiteTextController do
it "is a subclass of AdminController" do
- (Admin::SiteTextController < Admin::AdminController).should be_true
+ (Admin::SiteTextController < Admin::AdminController).should == true
end
context 'while logged in as an admin' do
diff --git a/spec/controllers/admin/site_text_types_controller_spec.rb b/spec/controllers/admin/site_text_types_controller_spec.rb
index 13f5459bdd3..eb1c349e026 100644
--- a/spec/controllers/admin/site_text_types_controller_spec.rb
+++ b/spec/controllers/admin/site_text_types_controller_spec.rb
@@ -3,7 +3,7 @@ require 'spec_helper'
describe Admin::SiteTextTypesController do
it "is a subclass of AdminController" do
- (Admin::SiteTextTypesController < Admin::AdminController).should be_true
+ (Admin::SiteTextTypesController < Admin::AdminController).should == true
end
context 'while logged in as an admin' do
diff --git a/spec/controllers/admin/staff_action_logs_controller_spec.rb b/spec/controllers/admin/staff_action_logs_controller_spec.rb
index 023b495a218..8decc8b6a78 100644
--- a/spec/controllers/admin/staff_action_logs_controller_spec.rb
+++ b/spec/controllers/admin/staff_action_logs_controller_spec.rb
@@ -2,7 +2,7 @@ require 'spec_helper'
describe Admin::StaffActionLogsController do
it "is a subclass of AdminController" do
- (Admin::StaffActionLogsController < Admin::AdminController).should be_true
+ (Admin::StaffActionLogsController < Admin::AdminController).should == true
end
let!(:user) { log_in(:admin) }
diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb
index 56a9e551c69..948b88adae1 100644
--- a/spec/controllers/admin/users_controller_spec.rb
+++ b/spec/controllers/admin/users_controller_spec.rb
@@ -3,7 +3,7 @@ require 'spec_helper'
describe Admin::UsersController do
it 'is a subclass of AdminController' do
- (Admin::UsersController < Admin::AdminController).should be_true
+ (Admin::UsersController < Admin::AdminController).should == true
end
context 'while logged in as an admin' do
@@ -214,7 +214,7 @@ describe Admin::UsersController do
it 'updates the moderator flag' do
xhr :put, :revoke_moderation, user_id: @moderator.id
@moderator.reload
- @moderator.moderator.should_not be_true
+ @moderator.moderator.should_not == true
end
end
@@ -237,7 +237,7 @@ describe Admin::UsersController do
it 'updates the moderator flag' do
xhr :put, :grant_moderation, user_id: @another_user.id
@another_user.reload
- @another_user.moderator.should be_true
+ @another_user.moderator.should == true
end
end
diff --git a/spec/controllers/admin/versions_controller_spec.rb b/spec/controllers/admin/versions_controller_spec.rb
index 3825ceed9a7..a6ba9fc9c60 100644
--- a/spec/controllers/admin/versions_controller_spec.rb
+++ b/spec/controllers/admin/versions_controller_spec.rb
@@ -11,7 +11,7 @@ describe Admin::VersionsController do
end
it "is a subclass of AdminController" do
- (Admin::VersionsController < Admin::AdminController).should be_true
+ (Admin::VersionsController < Admin::AdminController).should == true
end
context 'while logged in as an admin' do
diff --git a/spec/controllers/draft_controller_spec.rb b/spec/controllers/draft_controller_spec.rb
index c73b9a6ca36..de5b2ea3088 100644
--- a/spec/controllers/draft_controller_spec.rb
+++ b/spec/controllers/draft_controller_spec.rb
@@ -16,7 +16,7 @@ describe DraftController do
user = log_in
Draft.set(user, 'xxx', 0, 'hi')
delete :destroy, draft_key: 'xxx', sequence: 0
- Draft.get(user, 'xxx', 0).should be_nil
+ Draft.get(user, 'xxx', 0).should == nil
end
end
diff --git a/spec/controllers/email_controller_spec.rb b/spec/controllers/email_controller_spec.rb
index e6fb69bdaf9..e67ce633f18 100644
--- a/spec/controllers/email_controller_spec.rb
+++ b/spec/controllers/email_controller_spec.rb
@@ -30,7 +30,7 @@ describe EmailController do
end
it 'subscribes the user' do
- user.email_digests.should be_true
+ user.email_digests.should == true
end
end
@@ -47,7 +47,7 @@ describe EmailController do
end
it 'unsubscribes the user' do
- user.email_digests.should be_false
+ user.email_digests.should == false
end
it "sets the appropriate instance variables" do
@@ -74,7 +74,7 @@ describe EmailController do
end
it 'does not unsubscribe the user' do
- user.email_digests.should be_true
+ user.email_digests.should == true
end
it 'sets the appropriate instance variables' do
@@ -92,7 +92,7 @@ describe EmailController do
end
it 'unsubscribes the user' do
- user.email_digests.should be_false
+ user.email_digests.should == false
end
it 'sets the appropriate instance variables' do
@@ -102,7 +102,7 @@ describe EmailController do
it "sets not_found when the key didn't match anything" do
get :unsubscribe, key: 'asdfasdf'
- assigns(:not_found).should be_true
+ assigns(:not_found).should == true
end
end
diff --git a/spec/controllers/post_actions_controller_spec.rb b/spec/controllers/post_actions_controller_spec.rb
index 4b719d6513a..f87a21958c4 100644
--- a/spec/controllers/post_actions_controller_spec.rb
+++ b/spec/controllers/post_actions_controller_spec.rb
@@ -94,7 +94,7 @@ describe PostActionsController do
it 'deletes the action' do
xhr :delete, :destroy, id: post.id, post_action_type_id: 1
- PostAction.exists?(user_id: user.id, post_id: post.id, post_action_type_id: 1, deleted_at: nil).should be_false
+ PostAction.exists?(user_id: user.id, post_id: post.id, post_action_type_id: 1, deleted_at: nil).should == false
end
it 'ensures it can be deleted' do
diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb
index 10e1d3cc257..75c26d5bb02 100644
--- a/spec/controllers/posts_controller_spec.rb
+++ b/spec/controllers/posts_controller_spec.rb
@@ -341,7 +341,7 @@ describe PostsController do
xhr :put, :wiki, post_id: post.id, wiki: 'true'
post.reload
- post.wiki.should be_true
+ post.wiki.should == true
end
it "can unwiki a post" do
@@ -351,7 +351,7 @@ describe PostsController do
xhr :put, :wiki, post_id: wikied_post.id, wiki: 'false'
wikied_post.reload
- wikied_post.wiki.should be_false
+ wikied_post.wiki.should == false
end
end
diff --git a/spec/controllers/topics_controller_spec.rb b/spec/controllers/topics_controller_spec.rb
index f6a41444a95..477192c3bc8 100644
--- a/spec/controllers/topics_controller_spec.rb
+++ b/spec/controllers/topics_controller_spec.rb
@@ -69,7 +69,7 @@ describe TopicsController do
it "returns success" do
response.should be_success
result = ::JSON.parse(response.body)
- result['success'].should be_true
+ result['success'].should == true
result['url'].should be_present
end
end
@@ -85,7 +85,7 @@ describe TopicsController do
it "returns JSON with a false success" do
response.should be_success
result = ::JSON.parse(response.body)
- result['success'].should be_false
+ result['success'].should == false
result['url'].should be_blank
end
end
@@ -129,7 +129,7 @@ describe TopicsController do
it "returns success" do
response.should be_success
result = ::JSON.parse(response.body)
- result['success'].should be_true
+ result['success'].should == true
result['url'].should be_present
end
end
@@ -145,7 +145,7 @@ describe TopicsController do
it "returns JSON with a false success" do
response.should be_success
result = ::JSON.parse(response.body)
- result['success'].should be_false
+ result['success'].should == false
result['url'].should be_blank
end
end
@@ -185,7 +185,7 @@ describe TopicsController do
it "returns success" do
response.should be_success
result = ::JSON.parse(response.body)
- result['success'].should be_true
+ result['success'].should == true
result['url'].should be_present
end
end
diff --git a/spec/controllers/user_actions_controller_spec.rb b/spec/controllers/user_actions_controller_spec.rb
index 0ab1528a87a..b08ae174886 100644
--- a/spec/controllers/user_actions_controller_spec.rb
+++ b/spec/controllers/user_actions_controller_spec.rb
@@ -19,7 +19,7 @@ describe UserActionsController do
actions.length.should == 1
action = actions[0]
action["acting_name"].should == post.user.name
- action["email"].should be_nil
+ action["email"].should == nil
action["post_number"].should == 1
end
end
diff --git a/spec/controllers/user_badges_controller_spec.rb b/spec/controllers/user_badges_controller_spec.rb
index d95cf0cc5b8..e278ddcae96 100644
--- a/spec/controllers/user_badges_controller_spec.rb
+++ b/spec/controllers/user_badges_controller_spec.rb
@@ -13,7 +13,7 @@ describe UserBadgesController do
xhr :get, :index, badge_id: badge.id
response.status.should == 200
parsed = JSON.parse(response.body)
- parsed["topics"].should be_nil
+ parsed["topics"].should == nil
parsed["user_badges"][0]["post_id"].should == nil
end
end
@@ -46,7 +46,7 @@ describe UserBadgesController do
response.status.should == 200
parsed = JSON.parse(response.body)
- parsed["user_badges"].first.has_key?('count').should be_true
+ parsed["user_badges"].first.has_key?('count').should == true
end
end
@@ -102,7 +102,7 @@ describe UserBadgesController do
StaffActionLogger.any_instance.expects(:log_badge_revoke).once
xhr :delete, :destroy, id: user_badge.id
response.status.should == 200
- UserBadge.find_by(id: user_badge.id).should be_nil
+ UserBadge.find_by(id: user_badge.id).should == nil
end
end
end
diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb
index 3c6ff7fbf6c..7d72c48aacd 100644
--- a/spec/controllers/users_controller_spec.rb
+++ b/spec/controllers/users_controller_spec.rb
@@ -251,7 +251,7 @@ describe UsersController do
it 'disallows login' do
flash[:error].should be_present
session[:current_user_id].should be_blank
- assigns[:invalid_token].should be_nil
+ assigns[:invalid_token].should == nil
response.should be_success
end
end
@@ -264,7 +264,7 @@ describe UsersController do
it 'disallows login' do
flash[:error].should be_present
session[:current_user_id].should be_blank
- assigns[:invalid_token].should be_true
+ assigns[:invalid_token].should == true
response.should be_success
end
end
@@ -345,7 +345,7 @@ describe UsersController do
SiteSetting.stubs(:allow_new_registrations).returns(false)
post_user
json = JSON.parse(response.body)
- json['success'].should be_false
+ json['success'].should == false
json['message'].should be_present
end
@@ -355,7 +355,7 @@ describe UsersController do
post_user
- expect(JSON.parse(response.body)['active']).to be_false
+ expect(JSON.parse(response.body)['active']).to be_falsey
end
context "and 'must approve users' site setting is enabled" do
@@ -373,14 +373,12 @@ describe UsersController do
it 'indicates the user is not active in the response' do
post_user
- expect(JSON.parse(response.body)['active']).to be_false
+ expect(JSON.parse(response.body)['active']).to be_falsey
end
it "shows the 'waiting approval' message" do
post_user
- expect(JSON.parse(response.body)['message']).to eq(
- I18n.t 'login.wait_approval'
- )
+ expect(JSON.parse(response.body)['message']).to eq(I18n.t 'login.wait_approval')
end
end
end
@@ -410,14 +408,14 @@ describe UsersController do
it 'indicates the user is active in the response' do
User.any_instance.expects(:enqueue_welcome_message)
post_user
- expect(JSON.parse(response.body)['active']).to be_true
+ expect(JSON.parse(response.body)['active']).to be_truthy
end
it 'returns 500 status when new registrations are disabled' do
SiteSetting.stubs(:allow_new_registrations).returns(false)
post_user
json = JSON.parse(response.body)
- json['success'].should be_false
+ json['success'].should == false
json['message'].should be_present
end
@@ -449,11 +447,11 @@ describe UsersController do
it 'has the proper JSON' do
json = JSON::parse(response.body)
- json["success"].should be_true
+ json["success"].should == true
end
it 'should not result in an active account' do
- User.find_by(username: @user.username).active.should be_false
+ User.find_by(username: @user.username).active.should == false
end
end
@@ -472,7 +470,7 @@ describe UsersController do
it 'should say it was successful' do
xhr :post, :create, create_params
json = JSON::parse(response.body)
- json["success"].should be_true
+ json["success"].should == true
end
end
@@ -513,7 +511,7 @@ describe UsersController do
it 'should report failed' do
xhr :post, :create, create_params
json = JSON::parse(response.body)
- json["success"].should_not be_true
+ json["success"].should_not == true
end
end
@@ -593,7 +591,7 @@ describe UsersController do
end
it 'should return available as false in the JSON' do
- ::JSON.parse(response.body)['available'].should be_false
+ ::JSON.parse(response.body)['available'].should == false
end
it 'should return a suggested username' do
@@ -607,7 +605,7 @@ describe UsersController do
end
it 'should return available in the JSON' do
- ::JSON.parse(response.body)['available'].should be_true
+ ::JSON.parse(response.body)['available'].should == true
end
end
@@ -637,7 +635,7 @@ describe UsersController do
end
it 'should not return an available key' do
- ::JSON.parse(response.body)['available'].should be_nil
+ ::JSON.parse(response.body)['available'].should == nil
end
it 'should return an error message' do
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
index dbc92f9251b..75efb1c8679 100644
--- a/spec/helpers/application_helper_spec.rb
+++ b/spec/helpers/application_helper_spec.rb
@@ -19,38 +19,38 @@ describe ApplicationHelper do
it "is true if mobile_view is '1' in the session" do
session[:mobile_view] = '1'
- helper.mobile_view?.should be_true
+ helper.mobile_view?.should == true
end
it "is false if mobile_view is '0' in the session" do
session[:mobile_view] = '0'
- helper.mobile_view?.should be_false
+ helper.mobile_view?.should == false
end
context "mobile_view is not set" do
it "is false if user agent is not mobile" do
controller.request.stubs(:user_agent).returns('Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.17 Safari/537.36')
- helper.mobile_view?.should be_false
+ helper.mobile_view?.should be_falsey
end
it "is true for iPhone" do
controller.request.stubs(:user_agent).returns('Mozilla/5.0 (iPhone; U; ru; CPU iPhone OS 4_2_1 like Mac OS X; ru) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148a Safari/6533.18.5')
- helper.mobile_view?.should be_true
+ helper.mobile_view?.should == true
end
it "is false for iPad" do
controller.request.stubs(:user_agent).returns("Mozilla/5.0 (iPad; CPU OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B176 Safari/7534.48.3")
- helper.mobile_view?.should be_false
+ helper.mobile_view?.should == false
end
it "is false for Nexus 10 tablet" do
controller.request.stubs(:user_agent).returns("Mozilla/5.0 (Linux; Android 4.2.1; Nexus 10 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Safari/535.19")
- helper.mobile_view?.should be_false
+ helper.mobile_view?.should be_falsey
end
it "is true for Nexus 7 tablet" do
controller.request.stubs(:user_agent).returns("Mozilla/5.0 (Linux; Android 4.1.2; Nexus 7 Build/JZ054K) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Safari/535.19")
- helper.mobile_view?.should be_true
+ helper.mobile_view?.should == true
end
end
end
@@ -62,23 +62,23 @@ describe ApplicationHelper do
it "is false if mobile_view is '1' in the session" do
session[:mobile_view] = '1'
- helper.mobile_view?.should be_false
+ helper.mobile_view?.should == false
end
it "is false if mobile_view is '0' in the session" do
session[:mobile_view] = '0'
- helper.mobile_view?.should be_false
+ helper.mobile_view?.should == false
end
context "mobile_view is not set" do
it "is false if user agent is not mobile" do
controller.request.stubs(:user_agent).returns('Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.17 Safari/537.36')
- helper.mobile_view?.should be_false
+ helper.mobile_view?.should == false
end
it "is false for iPhone" do
controller.request.stubs(:user_agent).returns('Mozilla/5.0 (iPhone; U; ru; CPU iPhone OS 4_2_1 like Mac OS X; ru) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148a Safari/6533.18.5')
- helper.mobile_view?.should be_false
+ helper.mobile_view?.should == false
end
end
end
diff --git a/spec/integration/spam_rules_spec.rb b/spec/integration/spam_rules_spec.rb
index 936c33b7baf..0666b0a88d6 100644
--- a/spec/integration/spam_rules_spec.rb
+++ b/spec/integration/spam_rules_spec.rb
@@ -39,7 +39,7 @@ describe SpamRulesEnforcer do
When { PostAction.act(user2, spam_post, PostActionType.types[:spam]) }
- Invariant { expect(Guardian.new(spammer).can_create_topic?(nil)).to be_false }
+ Invariant { expect(Guardian.new(spammer).can_create_topic?(nil)).should == 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 { expect{PostCreator.create(spammer, {topic_id: another_topic.id, raw: 'my reply is spam in your topic', archetype_id: 1})}.to raise_error(Discourse::InvalidAccess) }
@@ -73,7 +73,7 @@ describe SpamRulesEnforcer do
Given { SiteSetting.stubs(:flags_required_to_hide_post).returns(2) }
When { PostAction.act(user2, spam_post, PostActionType.types[:spam]) }
Then { expect(spammer.reload).to be_blocked }
- And { expect(Guardian.new(spammer).can_create_topic?(nil)).to be_false }
+ And { expect(Guardian.new(spammer).can_create_topic?(nil)).should == false }
end
end
end
@@ -87,7 +87,7 @@ describe SpamRulesEnforcer do
When { PostAction.act(user1, spam_post, PostActionType.types[:spam]) }
When { PostAction.act(user2, spam_post, PostActionType.types[:spam]) }
Then { expect(spam_post.reload).to_not be_hidden }
- And { expect(Guardian.new(spammer).can_create_topic?(nil)).to be_true }
+ And { expect(Guardian.new(spammer).can_create_topic?(nil)).should == true }
And { expect{PostCreator.create(spammer, {title: 'limited time offer for you', raw: 'better buy this stuff ok', archetype_id: 1})}.to_not raise_error }
And { expect(spammer.reload.private_topics_count).to eq(private_messages_count) }
end
diff --git a/spec/integration/topic_auto_close_spec.rb b/spec/integration/topic_auto_close_spec.rb
index 7f6c90aaf28..2e6df3a14bb 100644
--- a/spec/integration/topic_auto_close_spec.rb
+++ b/spec/integration/topic_auto_close_spec.rb
@@ -29,13 +29,13 @@ describe Topic do
context 'uncategorized' do
Given(:category) { nil }
- Then { topic.auto_close_at.should be_nil }
+ Then { topic.auto_close_at.should == nil }
And { scheduled_jobs_for(:close_topic).should be_empty }
end
context 'category without default auto-close' do
Given(:category) { Fabricate(:category, auto_close_hours: nil) }
- Then { topic.auto_close_at.should be_nil }
+ Then { topic.auto_close_at.should == nil }
And { scheduled_jobs_for(:close_topic).should be_empty }
end
@@ -63,8 +63,8 @@ describe Topic do
context 'topic is closed manually' do
When { staff_topic.update_status('closed', true, admin) }
- Then { staff_topic.reload.auto_close_at.should be_nil }
- And { staff_topic.auto_close_started_at.should be_nil }
+ Then { staff_topic.reload.auto_close_at.should == nil }
+ And { staff_topic.auto_close_started_at.should == nil }
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 be_nil }
- And { auto_closed_topic.auto_close_started_at.should be_nil }
+ Then { auto_closed_topic.reload.auto_close_at.should == nil }
+ And { auto_closed_topic.auto_close_started_at.should == nil }
end
end
end
diff --git a/spec/jobs/bulk_invite_spec.rb b/spec/jobs/bulk_invite_spec.rb
index 5899b6588f9..d6571dcc235 100644
--- a/spec/jobs/bulk_invite_spec.rb
+++ b/spec/jobs/bulk_invite_spec.rb
@@ -24,7 +24,7 @@ describe Jobs::BulkInvite do
it 'reads csv file' do
bulk_invite.current_user = user
bulk_invite.read_csv_file(csv_file)
- Invite.where(email: "robin@outlook.com").exists?.should be_true
+ Invite.where(email: "robin@outlook.com").exists?.should == true
end
end
@@ -41,7 +41,7 @@ describe Jobs::BulkInvite do
bulk_invite.current_user = user
bulk_invite.send_invite(csv_info, 1)
- Invite.where(email: email).exists?.should be_true
+ Invite.where(email: email).exists?.should == true
end
it 'creates an invite with group' do
@@ -52,7 +52,7 @@ describe Jobs::BulkInvite do
bulk_invite.send_invite(csv_info, 1)
invite = Invite.where(email: email).first
invite.should be_present
- InvitedGroup.where(invite_id: invite.id, group_id: group.id).exists?.should be_true
+ InvitedGroup.where(invite_id: invite.id, group_id: group.id).exists?.should == true
end
it 'creates an invite with topic' do
@@ -63,7 +63,7 @@ describe Jobs::BulkInvite do
bulk_invite.send_invite(csv_info, 1)
invite = Invite.where(email: email).first
invite.should be_present
- TopicInvite.where(invite_id: invite.id, topic_id: topic.id).exists?.should be_true
+ TopicInvite.where(invite_id: invite.id, topic_id: topic.id).exists?.should == true
end
it 'creates an invite with group and topic' do
@@ -75,8 +75,8 @@ describe Jobs::BulkInvite do
bulk_invite.send_invite(csv_info, 1)
invite = Invite.where(email: email).first
invite.should be_present
- InvitedGroup.where(invite_id: invite.id, group_id: group.id).exists?.should be_true
- TopicInvite.where(invite_id: invite.id, topic_id: topic.id).exists?.should be_true
+ InvitedGroup.where(invite_id: invite.id, group_id: group.id).exists?.should == true
+ TopicInvite.where(invite_id: invite.id, topic_id: topic.id).exists?.should == true
end
end
diff --git a/spec/jobs/enqueue_digest_emails_spec.rb b/spec/jobs/enqueue_digest_emails_spec.rb
index 4bf96acd587..e27aa9922ac 100644
--- a/spec/jobs/enqueue_digest_emails_spec.rb
+++ b/spec/jobs/enqueue_digest_emails_spec.rb
@@ -10,7 +10,7 @@ describe Jobs::EnqueueDigestEmails do
let!(:user_no_digests) { Fabricate(:active_user, email_digests: false, last_emailed_at: 8.days.ago, last_seen_at: 10.days.ago) }
it "doesn't return users with email disabled" do
- Jobs::EnqueueDigestEmails.new.target_user_ids.include?(user_no_digests.id).should be_false
+ Jobs::EnqueueDigestEmails.new.target_user_ids.include?(user_no_digests.id).should == false
end
end
@@ -36,7 +36,7 @@ describe Jobs::EnqueueDigestEmails do
let!(:user_emailed_recently) { Fabricate(:active_user, last_emailed_at: 6.days.ago) }
it "doesn't return users who have been emailed recently" do
- Jobs::EnqueueDigestEmails.new.target_user_ids.include?(user_emailed_recently.id).should be_false
+ Jobs::EnqueueDigestEmails.new.target_user_ids.include?(user_emailed_recently.id).should == false
end
end
@@ -45,7 +45,7 @@ describe Jobs::EnqueueDigestEmails do
let!(:inactive_user) { Fabricate(:user, active: false) }
it "doesn't return users who have been emailed recently" do
- Jobs::EnqueueDigestEmails.new.target_user_ids.include?(inactive_user.id).should be_false
+ Jobs::EnqueueDigestEmails.new.target_user_ids.include?(inactive_user.id).should == false
end
end
@@ -55,12 +55,12 @@ describe Jobs::EnqueueDigestEmails do
it "doesn't return users who have been emailed recently" do
user = user_visited_this_week
- Jobs::EnqueueDigestEmails.new.target_user_ids.include?(user.id).should be_false
+ Jobs::EnqueueDigestEmails.new.target_user_ids.include?(user.id).should == false
end
it "does return users who have been emailed recently but have email_always set" do
user = user_visited_this_week_email_always
- Jobs::EnqueueDigestEmails.new.target_user_ids.include?(user.id).should be_true
+ Jobs::EnqueueDigestEmails.new.target_user_ids.include?(user.id).should == true
end
end
diff --git a/spec/jobs/feature_topic_users_spec.rb b/spec/jobs/feature_topic_users_spec.rb
index 36c7db9aa09..2d759ce7da9 100644
--- a/spec/jobs/feature_topic_users_spec.rb
+++ b/spec/jobs/feature_topic_users_spec.rb
@@ -22,22 +22,22 @@ describe Jobs::FeatureTopicUsers do
it "won't feature the OP" do
Jobs::FeatureTopicUsers.new.execute(topic_id: topic.id)
- topic.reload.featured_user_ids.include?(topic.user_id).should be_false
+ topic.reload.featured_user_ids.include?(topic.user_id).should == false
end
it "features the second poster" do
Jobs::FeatureTopicUsers.new.execute(topic_id: topic.id)
- topic.reload.featured_user_ids.include?(coding_horror.id).should be_true
+ topic.reload.featured_user_ids.include?(coding_horror.id).should == true
end
it "will not feature the second poster if we supply their post to be ignored" do
Jobs::FeatureTopicUsers.new.execute(topic_id: topic.id, except_post_id: second_post.id)
- topic.reload.featured_user_ids.include?(coding_horror.id).should be_false
+ topic.reload.featured_user_ids.include?(coding_horror.id).should == false
end
it "won't feature the last poster" do
Jobs::FeatureTopicUsers.new.execute(topic_id: topic.id)
- topic.reload.featured_user_ids.include?(evil_trout.id).should be_false
+ topic.reload.featured_user_ids.include?(evil_trout.id).should == false
end
end
diff --git a/spec/jobs/jobs_spec.rb b/spec/jobs/jobs_spec.rb
index 579bd507a58..58671f9c848 100644
--- a/spec/jobs/jobs_spec.rb
+++ b/spec/jobs/jobs_spec.rb
@@ -84,14 +84,14 @@ describe Jobs do
job_to_keep2 = stub_everything(klass: 'Sidekiq::Extensions::DelayedClass', args: [YAML.dump(['Jobs::DrinkBeer', :delayed_perform, [{beer_id: 44}]])])
job_to_keep2.expects(:delete).never
Sidekiq::ScheduledSet.stubs(:new).returns( [job_to_keep1, job_to_delete, job_to_keep2] )
- Jobs.cancel_scheduled_job(:drink_beer, {beer_id: 42}).should be_true
+ Jobs.cancel_scheduled_job(:drink_beer, {beer_id: 42}).should == true
end
it 'returns false when no matching job is scheduled' do
job_to_keep = stub_everything(klass: 'Sidekiq::Extensions::DelayedClass', args: [YAML.dump(['Jobs::DrinkBeer', :delayed_perform, [{beer_id: 43}]])])
job_to_keep.expects(:delete).never
Sidekiq::ScheduledSet.stubs(:new).returns( [job_to_keep] )
- Jobs.cancel_scheduled_job(:drink_beer, {beer_id: 42}).should be_false
+ Jobs.cancel_scheduled_job(:drink_beer, {beer_id: 42}).should == false
end
end
diff --git a/spec/mailers/test_mailer_spec.rb b/spec/mailers/test_mailer_spec.rb
index 939d1cfaba4..1937dadcbe1 100644
--- a/spec/mailers/test_mailer_spec.rb
+++ b/spec/mailers/test_mailer_spec.rb
@@ -3,13 +3,16 @@ require "spec_helper"
describe TestMailer do
describe "send_test" do
- subject { TestMailer.send_test('marcheline@adventuretime.ooo') }
- its(:to) { should == ['marcheline@adventuretime.ooo'] }
- its(:subject) { should be_present }
- its(:body) { should be_present }
- its(:from) { should == [SiteSetting.notification_email] }
+ it "works" do
+ test_mailer = TestMailer.send_test('marcheline@adventuretime.ooo')
+
+ test_mailer.from.should == [SiteSetting.notification_email]
+ test_mailer.to.should == ['marcheline@adventuretime.ooo']
+ test_mailer.subject.should be_present
+ test_mailer.body.should be_present
+ end
+
end
-
end
diff --git a/spec/models/admin_dashboard_data_spec.rb b/spec/models/admin_dashboard_data_spec.rb
index a441099e2ef..fbf320cd3e9 100644
--- a/spec/models/admin_dashboard_data_spec.rb
+++ b/spec/models/admin_dashboard_data_spec.rb
@@ -7,17 +7,17 @@ describe AdminDashboardData do
it 'returns nil when running in production mode' do
Rails.stubs(env: ActiveSupport::StringInquirer.new('production'))
- subject.should be_nil
+ subject.should == nil
end
it 'returns a string when running in development mode' do
Rails.stubs(env: ActiveSupport::StringInquirer.new('development'))
- subject.should_not be_nil
+ subject.should_not == nil
end
it 'returns a string when running in test mode' do
Rails.stubs(env: ActiveSupport::StringInquirer.new('test'))
- subject.should_not be_nil
+ subject.should_not == nil
end
end
@@ -26,17 +26,17 @@ describe AdminDashboardData do
it 'returns nil when host_names is set' do
Discourse.stubs(:current_hostname).returns('something.com')
- subject.should be_nil
+ subject.should == nil
end
it 'returns a string when host_name is localhost' do
Discourse.stubs(:current_hostname).returns('localhost')
- subject.should_not be_nil
+ subject.should_not == nil
end
it 'returns a string when host_name is production.localhost' do
Discourse.stubs(:current_hostname).returns('production.localhost')
- subject.should_not be_nil
+ subject.should_not == nil
end
end
@@ -45,12 +45,12 @@ describe AdminDashboardData do
it 'returns nil when gc params are set' do
ENV.stubs(:[]).with('RUBY_GC_MALLOC_LIMIT').returns(90000000)
- subject.should be_nil
+ subject.should == nil
end
it 'returns a string when gc params are not set' do
ENV.stubs(:[]).with('RUBY_GC_MALLOC_LIMIT').returns(nil)
- subject.should_not be_nil
+ subject.should_not == nil
end
end
@@ -60,31 +60,31 @@ describe AdminDashboardData do
it 'returns nil when sidekiq processed a job recently' do
Jobs.stubs(:last_job_performed_at).returns(1.minute.ago)
Jobs.stubs(:queued).returns(0)
- subject.should be_nil
+ subject.should == nil
end
it 'returns nil when last job processed was a long time ago, but no jobs are queued' do
Jobs.stubs(:last_job_performed_at).returns(7.days.ago)
Jobs.stubs(:queued).returns(0)
- subject.should be_nil
+ subject.should == nil
end
it 'returns nil when no jobs have ever been processed, but no jobs are queued' do
Jobs.stubs(:last_job_performed_at).returns(nil)
Jobs.stubs(:queued).returns(0)
- subject.should be_nil
+ subject.should == nil
end
it 'returns a string when no jobs were processed recently and some jobs are queued' do
Jobs.stubs(:last_job_performed_at).returns(20.minutes.ago)
Jobs.stubs(:queued).returns(1)
- subject.should_not be_nil
+ subject.should_not == nil
end
it 'returns a string when no jobs have ever been processed, and some jobs are queued' do
Jobs.stubs(:last_job_performed_at).returns(nil)
Jobs.stubs(:queued).returns(1)
- subject.should_not be_nil
+ subject.should_not == nil
end
end
@@ -93,17 +93,17 @@ describe AdminDashboardData do
it 'returns nil when total ram is 1 GB' do
MemInfo.any_instance.stubs(:mem_total).returns(1025272)
- subject.should be_nil
+ subject.should == nil
end
it 'returns nil when total ram cannot be determined' do
MemInfo.any_instance.stubs(:mem_total).returns(nil)
- subject.should be_nil
+ subject.should == nil
end
it 'returns a string when total ram is less than 1 GB' do
MemInfo.any_instance.stubs(:mem_total).returns(512636)
- subject.should_not be_nil
+ subject.should_not == nil
end
end
@@ -125,7 +125,7 @@ describe AdminDashboardData do
it 'returns a string when in production env' do
Rails.stubs(env: ActiveSupport::StringInquirer.new('production'))
- expect(subject).to_not be_nil
+ expect(subject).not_to be_nil
end
end
end
@@ -140,12 +140,12 @@ describe AdminDashboardData do
end
it 'returns a string when favicon_url is default' do
- expect(subject).to_not be_nil
+ expect(subject).not_to be_nil
end
it 'returns a string when favicon_url contains default filename' do
SiteSetting.stubs(:favicon_url).returns("/prefix#{SiteSetting.defaults[:favicon_url]}")
- expect(subject).to_not be_nil
+ expect(subject).not_to be_nil
end
it 'returns nil when favicon_url does not match default-favicon.png' do
@@ -161,12 +161,12 @@ describe AdminDashboardData do
end
it 'returns a string when logo_url is default' do
- expect(subject).to_not be_nil
+ expect(subject).not_to be_nil
end
it 'returns a string when logo_url contains default filename' do
SiteSetting.stubs(:logo_url).returns("/prefix#{SiteSetting.defaults[:logo_url]}")
- expect(subject).to_not be_nil
+ expect(subject).not_to be_nil
end
it 'returns nil when logo_url does not match d-logo-sketch.png' do
@@ -184,7 +184,7 @@ describe AdminDashboardData do
context 'when disabled' do
it 'returns nil' do
SiteSetting.stubs(enable_setting).returns(false)
- subject.should be_nil
+ subject.should == nil
end
end
@@ -196,25 +196,25 @@ describe AdminDashboardData do
it 'returns nil key and secret are set' do
SiteSetting.stubs(key).returns('12313213')
SiteSetting.stubs(secret).returns('12312313123')
- subject.should be_nil
+ subject.should == nil
end
it 'returns a string when key is not set' do
SiteSetting.stubs(key).returns('')
SiteSetting.stubs(secret).returns('12312313123')
- subject.should_not be_nil
+ subject.should_not == nil
end
it 'returns a string when secret is not set' do
SiteSetting.stubs(key).returns('123123')
SiteSetting.stubs(secret).returns('')
- subject.should_not be_nil
+ subject.should_not == nil
end
it 'returns a string when key and secret are not set' do
SiteSetting.stubs(key).returns('')
SiteSetting.stubs(secret).returns('')
- subject.should_not be_nil
+ subject.should_not == nil
end
end
end
diff --git a/spec/models/badge_spec.rb b/spec/models/badge_spec.rb
index 07fddcf0b41..16301ffdc27 100644
--- a/spec/models/badge_spec.rb
+++ b/spec/models/badge_spec.rb
@@ -4,7 +4,7 @@ require_dependency 'badge'
describe Badge do
it 'has a valid system attribute for new badges' do
- Badge.create!(name: "test", badge_type_id: 1).system?.should be_false
+ Badge.create!(name: "test", badge_type_id: 1).system?.should == false
end
end
diff --git a/spec/models/category_spec.rb b/spec/models/category_spec.rb
index 700d5e32a6a..39fa1f9ca5c 100644
--- a/spec/models/category_spec.rb
+++ b/spec/models/category_spec.rb
@@ -39,7 +39,7 @@ describe Category do
it "can determine read_restricted" do
read_restricted, resolved = Category.resolve_permissions(:everyone => :full)
- read_restricted.should be_false
+ read_restricted.should == false
resolved.should == []
end
end
@@ -102,13 +102,13 @@ describe Category do
let(:group) { Fabricate(:group) }
it "secures categories correctly" do
- category.read_restricted?.should be_false
+ category.read_restricted?.should == false
category.set_permissions({})
- category.read_restricted?.should be_true
+ category.read_restricted?.should == true
category.set_permissions(:everyone => :full)
- category.read_restricted?.should be_false
+ category.read_restricted?.should == false
user.secure_categories.should be_empty
@@ -216,7 +216,7 @@ describe Category do
@topic.pinned_at.should be_present
- Guardian.new(@category.user).can_delete?(@topic).should be_false
+ Guardian.new(@category.user).can_delete?(@topic).should == false
@topic.posts.count.should == 1
@@ -243,7 +243,7 @@ describe Category do
it "should not set its description topic to auto-close" do
category = Fabricate(:category, name: 'Closing Topics', auto_close_hours: 1)
- category.topic.auto_close_at.should be_nil
+ category.topic.auto_close_at.should == nil
end
describe "creating a new category with the same slug" do
@@ -286,8 +286,8 @@ describe Category do
end
it 'is deleted correctly' do
- Category.exists?(id: @category_id).should be_false
- Topic.exists?(id: @topic_id).should be_false
+ Category.exists?(id: @category_id).should == false
+ Topic.exists?(id: @topic_id).should == false
end
end
diff --git a/spec/models/color_scheme_spec.rb b/spec/models/color_scheme_spec.rb
index 5770c1ba330..63e4993a1a3 100644
--- a/spec/models/color_scheme_spec.rb
+++ b/spec/models/color_scheme_spec.rb
@@ -43,7 +43,7 @@ describe ColorScheme do
context "hex_for_name without anything enabled" do
it "returns nil for a missing attribute" do
- described_class.hex_for_name('undefined').should be_nil
+ described_class.hex_for_name('undefined').should == nil
end
it "returns the base color for an attribute" do
@@ -65,11 +65,11 @@ describe ColorScheme do
describe "#enabled" do
it "returns nil when there is no enabled record" do
- described_class.enabled.should be_nil
+ described_class.enabled.should == nil
end
it "returns the enabled color scheme" do
- described_class.hex_for_name('$primary_background_color').should be_nil
+ described_class.hex_for_name('$primary_background_color').should == nil
c = described_class.create(valid_params.merge(enabled: true))
described_class.enabled.id.should == c.id
described_class.hex_for_name('$primary_background_color').should == "FFBB00"
diff --git a/spec/models/digest_email_site_setting_spec.rb b/spec/models/digest_email_site_setting_spec.rb
index 5f74cbe50a5..e4ec9579958 100644
--- a/spec/models/digest_email_site_setting_spec.rb
+++ b/spec/models/digest_email_site_setting_spec.rb
@@ -3,16 +3,16 @@ require 'spec_helper'
describe DigestEmailSiteSetting do
describe 'valid_value?' do
it 'returns true for a valid value as an int' do
- DigestEmailSiteSetting.valid_value?(1).should be_true
+ DigestEmailSiteSetting.valid_value?(1).should == true
end
it 'returns true for a valid value as a string' do
- DigestEmailSiteSetting.valid_value?('1').should be_true
+ DigestEmailSiteSetting.valid_value?('1').should == true
end
it 'returns false for an invalid value' do
- DigestEmailSiteSetting.valid_value?(1.5).should be_false
- DigestEmailSiteSetting.valid_value?('7 dogs').should be_false
+ DigestEmailSiteSetting.valid_value?(1.5).should == false
+ DigestEmailSiteSetting.valid_value?('7 dogs').should == false
end
end
end
diff --git a/spec/models/discourse_single_sign_on_spec.rb b/spec/models/discourse_single_sign_on_spec.rb
index 6f18624af6f..5f174c8b492 100644
--- a/spec/models/discourse_single_sign_on_spec.rb
+++ b/spec/models/discourse_single_sign_on_spec.rb
@@ -87,6 +87,6 @@ describe DiscourseSingleSignOn do
url.should == @sso_url
sso = DiscourseSingleSignOn.parse(payload)
- sso.nonce.should_not be_nil
+ sso.nonce.should_not == nil
end
end
diff --git a/spec/models/draft_spec.rb b/spec/models/draft_spec.rb
index 38943cfa491..e62f667dda2 100644
--- a/spec/models/draft_spec.rb
+++ b/spec/models/draft_spec.rb
@@ -11,7 +11,7 @@ describe Draft do
it "uses the user id and key correctly" do
Draft.set(@user, "test", 0,"data")
- Draft.get(Fabricate.build(:coding_horror), "test", 0).should be_nil
+ Draft.get(Fabricate.build(:coding_horror), "test", 0).should == nil
end
it "should overwrite draft data correctly" do
@@ -23,14 +23,14 @@ describe Draft do
it "should clear drafts on request" do
Draft.set(@user, "test", 0, "data")
Draft.clear(@user, "test", 0)
- Draft.get(@user, "test", 0).should be_nil
+ Draft.get(@user, "test", 0).should == nil
end
it "should disregard old draft if sequence decreases" do
Draft.set(@user, "test", 0, "data")
Draft.set(@user, "test", 1, "hello")
Draft.set(@user, "test", 0, "foo")
- Draft.get(@user, "test", 0).should be_nil
+ Draft.get(@user, "test", 0).should == nil
Draft.get(@user, "test", 1).should == "hello"
end
@@ -41,7 +41,7 @@ describe Draft do
Draft.set(u, Draft::NEW_TOPIC, 0, 'my draft')
_t = Fabricate(:topic, user: u)
s = DraftSequence.current(u, Draft::NEW_TOPIC)
- Draft.get(u, Draft::NEW_TOPIC, s).should be_nil
+ Draft.get(u, Draft::NEW_TOPIC, s).should == nil
end
it 'nukes new pm draft after a pm is created' do
@@ -49,7 +49,7 @@ describe Draft do
Draft.set(u, Draft::NEW_PRIVATE_MESSAGE, 0, 'my draft')
t = Fabricate(:topic, user: u, archetype: Archetype.private_message, category_id: nil)
s = DraftSequence.current(t.user, Draft::NEW_PRIVATE_MESSAGE)
- Draft.get(u, Draft::NEW_PRIVATE_MESSAGE, s).should be_nil
+ Draft.get(u, Draft::NEW_PRIVATE_MESSAGE, s).should == nil
end
it 'does not nuke new topic draft after a pm is created' do
@@ -67,7 +67,7 @@ describe Draft do
Draft.set(p.user, p.topic.draft_key, 0,'hello')
PostCreator.new(user, raw: Fabricate.build(:post).raw).create
- Draft.get(p.user, p.topic.draft_key, DraftSequence.current(p.user, p.topic.draft_key)).should be_nil
+ Draft.get(p.user, p.topic.draft_key, DraftSequence.current(p.user, p.topic.draft_key)).should == nil
end
it 'nukes the post draft when a post is revised' do
@@ -75,7 +75,7 @@ describe Draft do
Draft.set(p.user, p.topic.draft_key, 0,'hello')
p.revise(p.user, 'another test')
s = DraftSequence.current(p.user, p.topic.draft_key)
- Draft.get(p.user, p.topic.draft_key, s).should be_nil
+ Draft.get(p.user, p.topic.draft_key, s).should == nil
end
it 'increases the sequence number when a post is revised' do
diff --git a/spec/models/email_log_spec.rb b/spec/models/email_log_spec.rb
index 9db88984fd2..789fe9d4a0c 100644
--- a/spec/models/email_log_spec.rb
+++ b/spec/models/email_log_spec.rb
@@ -49,7 +49,7 @@ describe EmailLog do
context "when user's email does not exist email logs" do
it "returns nil" do
- expect(user.email_logs.last_sent_email_address).to be_nil
+ expect(user.email_logs.last_sent_email_address).should == nil
end
end
end
diff --git a/spec/models/email_token_spec.rb b/spec/models/email_token_spec.rb
index db7df7cd6e3..b42e1bdab2c 100644
--- a/spec/models/email_token_spec.rb
+++ b/spec/models/email_token_spec.rb
@@ -89,7 +89,7 @@ describe EmailToken do
context 'welcome message' do
it 'sends a welcome message when the user is activated' do
user = EmailToken.confirm(email_token.token)
- user.send_welcome_message.should be_true
+ user.send_welcome_message.should == true
end
context "when using the code a second time" do
@@ -98,7 +98,7 @@ describe EmailToken do
SiteSetting.email_token_grace_period_hours = 1
EmailToken.confirm(email_token.token)
user = EmailToken.confirm(email_token.token)
- user.send_welcome_message.should be_false
+ user.send_welcome_message.should == false
end
end
diff --git a/spec/models/error_log_spec.rb b/spec/models/error_log_spec.rb
index bb49068a53c..1afd68b6948 100644
--- a/spec/models/error_log_spec.rb
+++ b/spec/models/error_log_spec.rb
@@ -25,7 +25,7 @@ describe ErrorLog do
it "creates a non empty file on first call" do
ErrorLog.clear_all!
ErrorLog.add_row!(hello: "world")
- File.exists?(ErrorLog.filename).should be_true
+ File.exists?(ErrorLog.filename).should == true
end
end
diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb
index 8b2452e02e3..d71a20c4d37 100644
--- a/spec/models/group_spec.rb
+++ b/spec/models/group_spec.rb
@@ -15,17 +15,17 @@ describe Group do
it "is invalid for blank" do
group.name = ""
- group.valid?.should be_false
+ group.valid?.should == false
end
it "is valid for a longer name" do
group.name = "this_is_a_name"
- group.valid?.should be_true
+ group.valid?.should == true
end
it "is invalid for non names" do
group.name = "this is_a_name"
- group.valid?.should be_false
+ group.valid?.should == false
end
end
diff --git a/spec/models/invite_spec.rb b/spec/models/invite_spec.rb
index d9e45e62ae3..8fbdfd96faa 100644
--- a/spec/models/invite_spec.rb
+++ b/spec/models/invite_spec.rb
@@ -16,7 +16,7 @@ describe Invite do
end
it "should not allow a user to invite themselves" do
- invite.email_already_exists.should be_true
+ invite.email_already_exists.should == true
end
end
@@ -26,7 +26,7 @@ describe Invite do
context 'saved' do
subject { Fabricate(:invite) }
its(:invite_key) { should be_present }
- its(:email_already_exists) { should be_false }
+ its(:email_already_exists) { should == false }
it 'should store a lower case version of the email' do
subject.email.should == iceking
@@ -117,7 +117,7 @@ describe Invite do
invite.should be_blank
# gives the user permission to access the topic
- topic.allowed_users.include?(coding_horror).should be_true
+ topic.allowed_users.include?(coding_horror).should == true
end
end
@@ -177,8 +177,8 @@ describe Invite do
let!(:user) { invite.redeem }
it 'works correctly' do
- user.is_a?(User).should be_true
- user.send_welcome_message.should be_true
+ user.is_a?(User).should == true
+ user.send_welcome_message.should == true
user.trust_level.should == SiteSetting.default_invitee_trust_level
end
@@ -214,7 +214,7 @@ describe Invite do
it 'will not redeem twice' do
invite.redeem.should be_present
- invite.redeem.send_welcome_message.should be_false
+ invite.redeem.send_welcome_message.should == false
end
end
end
@@ -233,8 +233,8 @@ describe Invite do
it 'adds the user to the topic_users' do
user = invite.redeem
topic.reload
- topic.allowed_users.include?(user).should be_true
- Guardian.new(user).can_see?(topic).should be_true
+ topic.allowed_users.include?(user).should == true
+ Guardian.new(user).can_see?(topic).should == true
end
end
@@ -246,7 +246,7 @@ describe Invite do
it 'adds the user to the topic_users' do
topic.reload
- topic.allowed_users.include?(user).should be_true
+ topic.allowed_users.include?(user).should == true
end
end
@@ -258,8 +258,8 @@ describe Invite do
let(:another_topic) { Fabricate(:topic, category_id: nil, archetype: "private_message", user: coding_horror) }
it 'adds the user to the topic_users of the first topic' do
- topic.allowed_users.include?(user).should be_true
- another_topic.allowed_users.include?(user).should be_true
+ topic.allowed_users.include?(user).should == true
+ another_topic.allowed_users.include?(user).should == true
another_invite.reload
another_invite.should_not be_redeemed
end
diff --git a/spec/models/optimized_image_spec.rb b/spec/models/optimized_image_spec.rb
index f322c937ef0..3dfdb0cc9f7 100644
--- a/spec/models/optimized_image_spec.rb
+++ b/spec/models/optimized_image_spec.rb
@@ -16,7 +16,7 @@ describe OptimizedImage do
it "returns nil" do
OptimizedImage.expects(:resize).returns(false)
- OptimizedImage.create_for(upload, 100, 200).should be_nil
+ OptimizedImage.create_for(upload, 100, 200).should == nil
end
end
@@ -59,7 +59,7 @@ describe OptimizedImage do
it "returns nil" do
OptimizedImage.expects(:resize).returns(false)
- OptimizedImage.create_for(upload, 100, 200).should be_nil
+ OptimizedImage.create_for(upload, 100, 200).should == nil
end
end
diff --git a/spec/models/permalink_spec.rb b/spec/models/permalink_spec.rb
index de5118fa3ea..b324caf695d 100644
--- a/spec/models/permalink_spec.rb
+++ b/spec/models/permalink_spec.rb
@@ -29,7 +29,7 @@ describe Permalink do
it "returns nil when topic_id is set but topic is not found" do
permalink.topic_id = 99999
- target_url.should be_nil
+ target_url.should == nil
end
it "returns a post url when post_id is set" do
@@ -39,7 +39,7 @@ describe Permalink do
it "returns nil when post_id is set but post is not found" do
permalink.post_id = 99999
- target_url.should be_nil
+ target_url.should == nil
end
it "returns a post url when post_id and topic_id are both set" do
@@ -55,7 +55,7 @@ describe Permalink do
it "returns nil when category_id is set but category is not found" do
permalink.category_id = 99999
- target_url.should be_nil
+ target_url.should == nil
end
it "returns a post url when topic_id, post_id, and category_id are all set for some reason" do
@@ -66,7 +66,7 @@ describe Permalink do
end
it "returns nil when nothing is set" do
- target_url.should be_nil
+ target_url.should == nil
end
end
end
diff --git a/spec/models/post_action_spec.rb b/spec/models/post_action_spec.rb
index ce95700f252..0e5136fc385 100644
--- a/spec/models/post_action_spec.rb
+++ b/spec/models/post_action_spec.rb
@@ -46,7 +46,7 @@ describe PostAction do
# reply to PM should not clear flag
PostCreator.new(mod, topic_id: posts[0].topic_id, raw: "This is my test reply to the user, it should clear flags").create
action.reload
- action.deleted_at.should be_nil
+ action.deleted_at.should == nil
# Acting on the flag should post an automated status message
topic.posts.count.should == 2
@@ -113,19 +113,19 @@ describe PostAction do
post = create_post
PostAction.act(codinghorror, post, PostActionType.types[:off_topic])
- post.hidden.should be_false
+ post.hidden.should == false
post.hidden_at.should be_blank
PostAction.defer_flags!(post, admin)
PostAction.flagged_posts_count.should == 0
post.reload
- post.hidden.should be_false
+ post.hidden.should == false
post.hidden_at.should be_blank
PostAction.hide_post!(post, PostActionType.types[:off_topic])
post.reload
- post.hidden.should be_true
+ post.hidden.should == true
post.hidden_at.should be_present
end
@@ -292,38 +292,38 @@ describe PostAction do
post.reload
- post.hidden.should be_true
+ post.hidden.should == true
post.hidden_at.should be_present
post.hidden_reason_id.should == Post.hidden_reasons[:flag_threshold_reached]
- post.topic.visible.should be_false
+ post.topic.visible.should == false
post.revise(post.user, post.raw + " ha I edited it ")
post.reload
- post.hidden.should be_false
- post.hidden_reason_id.should be_nil
+ post.hidden.should == false
+ post.hidden_reason_id.should == nil
post.hidden_at.should be_blank
- post.topic.visible.should be_true
+ post.topic.visible.should == true
PostAction.act(eviltrout, post, PostActionType.types[:spam])
PostAction.act(walterwhite, post, PostActionType.types[:off_topic])
post.reload
- post.hidden.should be_true
+ post.hidden.should == true
post.hidden_at.should be_present
post.hidden_reason_id.should == Post.hidden_reasons[:flag_threshold_reached_again]
- post.topic.visible.should be_false
+ post.topic.visible.should == false
post.revise(post.user, post.raw + " ha I edited it again ")
post.reload
- post.hidden.should be_true
- post.hidden_at.should be_true
+ post.hidden.should == true
+ post.hidden_at.should be_present
post.hidden_reason_id.should == Post.hidden_reasons[:flag_threshold_reached_again]
- post.topic.visible.should be_false
+ post.topic.visible.should == false
end
it "can flag the topic instead of a post" do
diff --git a/spec/models/post_mover_spec.rb b/spec/models/post_mover_spec.rb
index 2c340b70983..a14b9d1a3a9 100644
--- a/spec/models/post_mover_spec.rb
+++ b/spec/models/post_mover_spec.rb
@@ -121,7 +121,7 @@ describe PostMover do
p2.post_number.should == 2
p2.topic_id.should == moved_to.id
p2.reply_count.should == 1
- p2.reply_to_post_number.should be_nil
+ p2.reply_to_post_number.should == nil
p4.reload
p4.post_number.should == 3
@@ -207,7 +207,7 @@ describe PostMover do
p2.post_number.should == 3
p2.topic_id.should == moved_to.id
p2.reply_count.should == 1
- p2.reply_to_post_number.should be_nil
+ p2.reply_to_post_number.should == nil
p4.reload
p4.post_number.should == 4
diff --git a/spec/models/post_revision_spec.rb b/spec/models/post_revision_spec.rb
index ab10fac970f..44500bc088f 100644
--- a/spec/models/post_revision_spec.rb
+++ b/spec/models/post_revision_spec.rb
@@ -66,8 +66,8 @@ describe PostRevision do
r = create_rev("wiki" => [false, true])
changes = r.wiki_changes
- changes[:previous_wiki].should be_false
- changes[:current_wiki].should be_true
+ changes[:previous_wiki].should == false
+ changes[:current_wiki].should == true
end
it "can find post_type changes" do
diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb
index 6f0dbc52475..8a4c0773257 100644
--- a/spec/models/post_spec.rb
+++ b/spec/models/post_spec.rb
@@ -468,7 +468,7 @@ describe Post do
it 'has no revision' do
post.revisions.size.should == 0
first_version_at.should be_present
- post.revise(post.user, post.raw).should be_false
+ post.revise(post.user, post.raw).should == false
end
describe 'with the same body' do
@@ -563,7 +563,7 @@ describe Post do
let!(:result) { post.revise(changed_by, 'updated body') }
it 'acts correctly' do
- result.should be_true
+ result.should == true
post.raw.should == 'updated body'
post.invalidate_oneboxes.should == true
post.version.should == 2
@@ -594,7 +594,7 @@ describe Post do
let(:post) { Fabricate(:post, post_args) }
it "has correct info set" do
- post.user_deleted?.should be_false
+ post.user_deleted?.should == false
post.post_number.should be_present
post.excerpt.should be_present
post.post_type.should == Post.types[:regular]
@@ -671,8 +671,8 @@ describe Post do
it 'has the correct info set' do
multi_reply.quote_count.should == 2
- post.replies.include?(multi_reply).should be_true
- reply.replies.include?(multi_reply).should be_true
+ post.replies.include?(multi_reply).should == true
+ reply.replies.include?(multi_reply).should == true
end
end
@@ -763,14 +763,14 @@ describe Post do
SiteSetting.stubs(:tl3_links_no_follow).returns(false)
post.user.trust_level = 3
post.save
- (post.cooked =~ /nofollow/).should be_false
+ post.cooked.should_not =~ /nofollow/
end
it "when tl3_links_no_follow is true, should add nofollow for trust level 3 and higher" do
SiteSetting.stubs(:tl3_links_no_follow).returns(true)
post.user.trust_level = 3
post.save
- (post.cooked =~ /nofollow/).should be_true
+ post.cooked.should =~ /nofollow/
end
end
diff --git a/spec/models/quoted_post_spec.rb b/spec/models/quoted_post_spec.rb
index 14ce241babe..38c50cb8e9e 100644
--- a/spec/models/quoted_post_spec.rb
+++ b/spec/models/quoted_post_spec.rb
@@ -4,10 +4,10 @@ describe QuotedPost do
it 'correctly extracts quotes in integration test' do
post1 = create_post
post2 = create_post(topic_id: post1.topic_id,
- raw: "[quote=\"#{post1.user.username}, post: 1, topic:#{post1.topic_id}\"]\ntest\n[/quote]\nthis is a test post",
+ raw: "[quote=\"#{post1.user.username}, post: 1, topic:#{post1.topic_id}\"]\ntest\n[/quote]\nthis is a test post",
reply_to_post_number: 1)
- QuotedPost.find_by(post_id: post2.id, quoted_post_id: post1.id).should_not be_nil
+ QuotedPost.find_by(post_id: post2.id, quoted_post_id: post1.id).should_not == nil
post2.reply_quoted.should == true
end
@@ -23,7 +23,7 @@ HTML
QuotedPost.extract_from(post2)
QuotedPost.where(post_id: post2.id).count.should == 1
- QuotedPost.find_by(post_id: post2.id, quoted_post_id: post1.id).should_not be_nil
+ QuotedPost.find_by(post_id: post2.id, quoted_post_id: post1.id).should_not == nil
post2.reply_quoted.should == false
end
diff --git a/spec/models/screened_email_spec.rb b/spec/models/screened_email_spec.rb
index 5feaf2e001a..67c9cb446dc 100644
--- a/spec/models/screened_email_spec.rb
+++ b/spec/models/screened_email_spec.rb
@@ -13,7 +13,7 @@ describe ScreenedEmail do
it "last_match_at is null" do
# If we manually load the table with some emails, we can see whether those emails
# have ever been blocked by looking at last_match_at.
- ScreenedEmail.create(email: email).last_match_at.should be_nil
+ ScreenedEmail.create(email: email).last_match_at.should == nil
end
it "downcases the email" do
@@ -56,24 +56,24 @@ describe ScreenedEmail do
subject { ScreenedEmail.should_block?(email) }
it "returns false if a record with the email doesn't exist" do
- subject.should be_false
+ subject.should == false
end
it "returns true when there is a record with the email" do
- ScreenedEmail.should_block?(email).should be_false
+ ScreenedEmail.should_block?(email).should == false
ScreenedEmail.create(email: email).save
- ScreenedEmail.should_block?(email).should be_true
+ ScreenedEmail.should_block?(email).should == true
end
it "returns true when there is a record with a similar email" do
- ScreenedEmail.should_block?(email).should be_false
+ ScreenedEmail.should_block?(email).should == false
ScreenedEmail.create(email: similar_email).save
- ScreenedEmail.should_block?(email).should be_true
+ ScreenedEmail.should_block?(email).should == true
end
it "returns true when it's same email, but all caps" do
ScreenedEmail.create(email: email).save
- ScreenedEmail.should_block?(email.upcase).should be_true
+ ScreenedEmail.should_block?(email.upcase).should == true
end
shared_examples "when a ScreenedEmail record matches" do
@@ -87,13 +87,13 @@ describe ScreenedEmail do
context "action_type is :block" do
let!(:screened_email) { Fabricate(:screened_email, email: email, action_type: ScreenedEmail.actions[:block]) }
- it { should be_true }
+ it { should == true }
include_examples "when a ScreenedEmail record matches"
end
context "action_type is :do_nothing" do
let!(:screened_email) { Fabricate(:screened_email, email: email, action_type: ScreenedEmail.actions[:do_nothing]) }
- it { should be_false }
+ it { should == false }
include_examples "when a ScreenedEmail record matches"
end
end
diff --git a/spec/models/screened_ip_address_spec.rb b/spec/models/screened_ip_address_spec.rb
index eafa2d6ba76..27b67ddb5c5 100644
--- a/spec/models/screened_ip_address_spec.rb
+++ b/spec/models/screened_ip_address_spec.rb
@@ -35,7 +35,7 @@ describe ScreenedIpAddress do
describe "ip_address_with_mask" do
it "returns nil when ip_address is nil" do
- described_class.new.ip_address_with_mask.should be_nil
+ described_class.new.ip_address_with_mask.should == nil
end
it "returns ip_address without mask if there is no mask" do
diff --git a/spec/models/screened_url_spec.rb b/spec/models/screened_url_spec.rb
index 33d435e6882..54c8a045b1b 100644
--- a/spec/models/screened_url_spec.rb
+++ b/spec/models/screened_url_spec.rb
@@ -13,7 +13,7 @@ describe ScreenedUrl do
end
it "last_match_at is null" do
- described_class.create(valid_params).last_match_at.should be_nil
+ described_class.create(valid_params).last_match_at.should == nil
end
it "normalizes the url and domain" do
@@ -88,7 +88,7 @@ describe ScreenedUrl do
describe 'find_match' do
it 'returns nil when there is no match' do
- described_class.find_match('http://spamspot.com/buy/it').should be_nil
+ described_class.find_match('http://spamspot.com/buy/it').should == nil
end
it 'returns the record when there is an exact match' do
diff --git a/spec/models/site_customization_spec.rb b/spec/models/site_customization_spec.rb
index cce7e562766..ce967487fa4 100644
--- a/spec/models/site_customization_spec.rb
+++ b/spec/models/site_customization_spec.rb
@@ -31,7 +31,7 @@ describe SiteCustomization do
end
it 'finds no style when none enabled' do
- SiteCustomization.enabled_style_key.should be_nil
+ SiteCustomization.enabled_style_key.should == nil
end
@@ -50,7 +50,7 @@ describe SiteCustomization do
# this bypasses the before / after stuff
SiteCustomization.exec_sql('delete from site_customizations')
- SiteCustomization.enabled_style_key.should be_nil
+ SiteCustomization.enabled_style_key.should == nil
end
end
@@ -156,13 +156,13 @@ describe SiteCustomization do
it 'should compile scss' do
c = SiteCustomization.create!(user_id: user.id, name: "test", stylesheet: '$black: #000; #a { color: $black; }', header: '')
s = c.stylesheet_baked.gsub(' ', '').gsub("\n", '')
- (s.include?("#a{color:#000;}") || s.include?("#a{color:black;}")).should be_true
+ (s.include?("#a{color:#000;}") || s.include?("#a{color:black;}")).should == true
end
it 'should compile mobile scss' do
c = SiteCustomization.create!(user_id: user.id, name: "test", stylesheet: '', header: '', mobile_stylesheet: '$black: #000; #a { color: $black; }', mobile_header: '')
s = c.mobile_stylesheet_baked.gsub(' ', '').gsub("\n", '')
- (s.include?("#a{color:#000;}") || s.include?("#a{color:black;}")).should be_true
+ (s.include?("#a{color:#000;}") || s.include?("#a{color:black;}")).should == true
end
it 'should allow including discourse styles' do
diff --git a/spec/models/top_menu_item_spec.rb b/spec/models/top_menu_item_spec.rb
index fc921791d44..4f716f8e5fd 100644
--- a/spec/models/top_menu_item_spec.rb
+++ b/spec/models/top_menu_item_spec.rb
@@ -12,21 +12,21 @@ describe TopMenuItem do
it 'has a filter' do
expect(items[0].filter).to eq('nope')
- expect(items[0].has_filter?).to be_true
+ expect(items[0].has_filter?).to be_truthy
expect(items[2].filter).to eq('not')
- expect(items[2].has_filter?).to be_true
+ expect(items[2].has_filter?).to be_truthy
end
it 'does not have a filter' do
expect(items[1].filter).to be_nil
- expect(items[1].has_filter?).to be_false
+ expect(items[1].has_filter?).to be_falsey
expect(items[3].filter).to be_nil
- expect(items[3].has_filter?).to be_false
+ expect(items[3].has_filter?).to be_falsey
end
it "has a specific category" do
- expect(items.first.has_specific_category?).to be_false
- expect(items.last.has_specific_category?).to be_true
+ expect(items.first.has_specific_category?).to be_falsey
+ expect(items.last.has_specific_category?).to be_truthy
end
it "does not have a specific category" do
diff --git a/spec/models/topic_embed_spec.rb b/spec/models/topic_embed_spec.rb
index 81b24637358..fcb44248d4d 100644
--- a/spec/models/topic_embed_spec.rb
+++ b/spec/models/topic_embed_spec.rb
@@ -14,7 +14,7 @@ describe TopicEmbed do
let(:contents) { "hello world new post hello
" }
it "returns nil when the URL is malformed" do
- TopicEmbed.import(user, "invalid url", title, contents).should be_nil
+ TopicEmbed.import(user, "invalid url", title, contents).should == nil
TopicEmbed.count.should == 0
end
@@ -29,9 +29,9 @@ describe TopicEmbed do
post.cooked.should == post.raw
# It converts relative URLs to absolute
- post.cooked.start_with?("hello world new post hello
").should be_true
+ post.cooked.start_with?("hello world new post hello
").should == true
- post.topic.has_topic_embed?.should be_true
+ post.topic.has_topic_embed?.should == true
TopicEmbed.where(topic_id: post.topic_id).should be_present
end
diff --git a/spec/models/topic_link_click_spec.rb b/spec/models/topic_link_click_spec.rb
index ad916c90292..9fd7d1f24a9 100644
--- a/spec/models/topic_link_click_spec.rb
+++ b/spec/models/topic_link_click_spec.rb
@@ -48,7 +48,7 @@ describe TopicLinkClick do
let(:click) { TopicLinkClick.create_from(url: "url that doesn't exist", post_id: @post.id, ip: '127.0.0.1') }
it "returns nil" do
- click.should be_nil
+ click.should == nil
end
end
diff --git a/spec/models/topic_link_spec.rb b/spec/models/topic_link_spec.rb
index 5e78b51def6..e561ded7057 100644
--- a/spec/models/topic_link_spec.rb
+++ b/spec/models/topic_link_spec.rb
@@ -20,7 +20,7 @@ describe TopicLink do
ftl = TopicLink.new(url: "/t/#{topic.id}",
topic_id: topic.id,
link_topic_id: topic.id)
- ftl.valid?.should be_false
+ ftl.valid?.should == false
end
describe 'external links' do
@@ -40,10 +40,10 @@ http://b.com/#{'a'*500}
topic.topic_links.count.should == 2
# works with markdown links
- topic.topic_links.exists?(url: "http://a.com/").should be_true
+ topic.topic_links.exists?(url: "http://a.com/").should == true
#works with markdown links followed by a period
- topic.topic_links.exists?(url: "http://b.com/b").should be_true
+ topic.topic_links.exists?(url: "http://b.com/b").should == true
end
end
@@ -227,8 +227,8 @@ http://b.com/#{'a'*500}
TopicLink.extract_from(linked_post)
- topic.topic_links.first.should be_nil
- pm.topic_links.first.should_not be_nil
+ topic.topic_links.first.should == nil
+ pm.topic_links.first.should_not == nil
end
end
diff --git a/spec/models/topic_spec.rb b/spec/models/topic_spec.rb
index 74dbc6dd4bb..1662f5956b9 100644
--- a/spec/models/topic_spec.rb
+++ b/spec/models/topic_spec.rb
@@ -33,7 +33,7 @@ describe Topic do
it "doesn't update it to be shorter due to cleaning using TextCleaner" do
topic.title = 'unread glitch'
- topic.save.should be_false
+ topic.save.should == false
end
end
@@ -267,14 +267,14 @@ describe Topic do
let(:topic) { Fabricate(:private_message_topic) }
it "should integrate correctly" do
- Guardian.new(topic.user).can_see?(topic).should be_true
- Guardian.new.can_see?(topic).should be_false
- Guardian.new(evil_trout).can_see?(topic).should be_false
- Guardian.new(coding_horror).can_see?(topic).should be_true
+ Guardian.new(topic.user).can_see?(topic).should == true
+ Guardian.new.can_see?(topic).should == false
+ Guardian.new(evil_trout).can_see?(topic).should == false
+ Guardian.new(coding_horror).can_see?(topic).should == true
TopicQuery.new(evil_trout).list_latest.topics.should_not include(topic)
# invites
- topic.invite(topic.user, 'duhhhhh').should be_false
+ topic.invite(topic.user, 'duhhhhh').should == false
end
context 'invite' do
@@ -285,12 +285,12 @@ describe Topic do
context 'by username' do
it 'adds and removes walter to the allowed users' do
- topic.invite(topic.user, walter.username).should be_true
- topic.allowed_users.include?(walter).should be_true
+ topic.invite(topic.user, walter.username).should == true
+ topic.allowed_users.include?(walter).should == true
- topic.remove_allowed_user(walter.username).should be_true
+ topic.remove_allowed_user(walter.username).should == true
topic.reload
- topic.allowed_users.include?(walter).should be_false
+ topic.allowed_users.include?(walter).should == false
end
it 'creates a notification' do
@@ -302,9 +302,9 @@ describe Topic do
it 'adds user correctly' do
lambda {
- topic.invite(topic.user, walter.email).should be_true
+ topic.invite(topic.user, walter.email).should == true
}.should change(Notification, :count)
- topic.allowed_users.include?(walter).should be_true
+ topic.allowed_users.include?(walter).should == true
end
end
@@ -682,7 +682,7 @@ describe Topic do
@topic.last_post_user_id.should == @second_user.id
@topic.last_posted_at.to_i.should == @new_post.created_at.to_i
topic_user = @second_user.topic_users.find_by(topic_id: @topic.id)
- topic_user.posted?.should be_true
+ topic_user.posted?.should == true
end
end
@@ -759,7 +759,7 @@ describe Topic do
it 'is a regular topic by default' do
topic.archetype.should == Archetype.default
- topic.has_summary.should be_false
+ topic.has_summary.should == false
topic.percent_rank.should == 1.0
topic.should be_visible
topic.pinned_at.should be_blank
@@ -924,7 +924,7 @@ describe Topic do
let!(:topic) { Fabricate(:topic, category: Fabricate(:category)) }
it 'returns false' do
- topic.change_category_to_id(nil).should eq(false) # don't use "be_false" here because it would also match nil
+ topic.change_category_to_id(nil).should eq(false) # don't use "== false" here because it would also match nil
end
end
@@ -1033,7 +1033,7 @@ describe Topic do
topic = Fabricate(:topic)
Jobs.expects(:enqueue_at).with(12.hours.from_now, :close_topic, has_entries(topic_id: topic.id, user_id: topic.user_id))
topic.auto_close_at = 12.hours.from_now
- topic.save.should be_true
+ topic.save.should == true
end
end
@@ -1044,7 +1044,7 @@ describe Topic do
Jobs.expects(:enqueue_at).with(12.hours.from_now, :close_topic, has_entries(topic_id: topic.id, user_id: closer.id))
topic.auto_close_at = 12.hours.from_now
topic.auto_close_user = closer
- topic.save.should be_true
+ topic.save.should == true
end
end
@@ -1053,8 +1053,8 @@ describe Topic do
topic = Fabricate(:topic, auto_close_at: 1.day.from_now)
Jobs.expects(:cancel_scheduled_job).with(:close_topic, {topic_id: topic.id})
topic.auto_close_at = nil
- topic.save.should be_true
- topic.auto_close_user.should be_nil
+ topic.save.should == true
+ topic.auto_close_user.should == nil
end
it 'when auto_close_user is removed, it updates the job' do
@@ -1064,7 +1064,7 @@ describe Topic do
Jobs.expects(:cancel_scheduled_job).with(:close_topic, {topic_id: topic.id})
Jobs.expects(:enqueue_at).with(1.day.from_now, :close_topic, has_entries(topic_id: topic.id, user_id: topic.user_id))
topic.auto_close_user = nil
- topic.save.should be_true
+ topic.save.should == true
end
end
@@ -1075,7 +1075,7 @@ describe Topic do
Jobs.expects(:cancel_scheduled_job).with(:close_topic, {topic_id: topic.id})
Jobs.expects(:enqueue_at).with(3.days.from_now, :close_topic, has_entry(topic_id: topic.id))
topic.auto_close_at = 3.days.from_now
- topic.save.should be_true
+ topic.save.should == true
end
end
@@ -1087,7 +1087,7 @@ describe Topic do
Jobs.expects(:cancel_scheduled_job).with(:close_topic, {topic_id: topic.id})
Jobs.expects(:enqueue_at).with(1.day.from_now, :close_topic, has_entries(topic_id: topic.id, user_id: admin.id))
topic.auto_close_user = admin
- topic.save.should be_true
+ topic.save.should == true
end
end
@@ -1097,7 +1097,7 @@ describe Topic do
Jobs.expects(:cancel_scheduled_job).never
topic = Fabricate(:topic, auto_close_at: 1.day.from_now)
topic.title = 'A new title that is long enough'
- topic.save.should be_true
+ topic.save.should == true
end
end
@@ -1136,7 +1136,7 @@ describe Topic do
it 'can take nil' do
topic.auto_close_hours = nil
- topic.auto_close_at.should be_nil
+ topic.auto_close_at.should == nil
end
end
@@ -1330,8 +1330,9 @@ describe Topic do
it "limits new users to max_topics_in_first_day and max_posts_in_first_day" do
SiteSetting.stubs(:max_topics_in_first_day).returns(1)
SiteSetting.stubs(:max_replies_in_first_day).returns(1)
- RateLimiter.stubs(:disabled?).returns(false)
SiteSetting.stubs(:client_settings_json).returns(SiteSetting.client_settings_json_uncached)
+ RateLimiter.stubs(:rate_limit_create_topic).returns(100)
+ RateLimiter.stubs(:disabled?).returns(false)
start = Time.now.tomorrow.beginning_of_day
@@ -1361,14 +1362,14 @@ describe Topic do
context "when Topic count is geater than minimum_topics_similar" do
it "should be true" do
Topic.stubs(:count).returns(30)
- expect(Topic.count_exceeds_minimum?).to be_true
+ expect(Topic.count_exceeds_minimum?).to be_truthy
end
end
context "when topic's count is less than minimum_topics_similar" do
it "should be false" do
Topic.stubs(:count).returns(10)
- expect(Topic.count_exceeds_minimum?).to_not be_true
+ expect(Topic.count_exceeds_minimum?).to_not be_truthy
end
end
@@ -1391,22 +1392,22 @@ describe Topic do
end
it "is true with the correct settings and topic_embed" do
- topic.expandable_first_post?.should be_true
+ topic.expandable_first_post?.should == true
end
it "is false if embeddable_host is blank" do
SiteSetting.stubs(:embeddable_host).returns(nil)
- topic.expandable_first_post?.should be_false
+ topic.expandable_first_post?.should == false
end
it "is false if embed_truncate? is false" do
SiteSetting.stubs(:embed_truncate?).returns(false)
- topic.expandable_first_post?.should be_false
+ topic.expandable_first_post?.should == false
end
it "is false if has_topic_embed? is false" do
topic.stubs(:has_topic_embed?).returns(false)
- topic.expandable_first_post?.should be_false
+ topic.expandable_first_post?.should == false
end
end
diff --git a/spec/models/topic_tracking_state_spec.rb b/spec/models/topic_tracking_state_spec.rb
index 0d979ceb998..f65a1e4eb76 100644
--- a/spec/models/topic_tracking_state_spec.rb
+++ b/spec/models/topic_tracking_state_spec.rb
@@ -29,7 +29,7 @@ describe TopicTrackingState do
row.topic_id.should == post.topic_id
row.highest_post_number.should == 1
- row.last_read_post_number.should be_nil
+ row.last_read_post_number.should == nil
row.user_id.should == user.id
# lets not leak out random users
diff --git a/spec/models/topic_user_spec.rb b/spec/models/topic_user_spec.rb
index fab7a1fc9f2..382f8e3ef6c 100644
--- a/spec/models/topic_user_spec.rb
+++ b/spec/models/topic_user_spec.rb
@@ -62,21 +62,21 @@ describe TopicUser 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 be_nil
+ topic_user.notifications_changed_at.should_not == 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 be_nil
+ topic_user.notifications_changed_at.should_not == 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 be_nil
+ topic_user.notifications_changed_at.should_not == nil
end
it 'should watch topics a user created' do
@@ -233,7 +233,7 @@ describe TopicUser do
end
it 'has a key in the lookup for this forum topic' do
- TopicUser.lookup_for(user, [topic]).has_key?(topic.id).should be_true
+ TopicUser.lookup_for(user, [topic]).has_key?(topic.id).should == true
end
end
@@ -283,7 +283,7 @@ describe TopicUser do
# mails nothing to random users
tu = TopicUser.find_by(user_id: user1.id, topic_id: post.topic_id)
- tu.should be_nil
+ tu.should == nil
# mails other user
tu = TopicUser.find_by(user_id: user2.id, topic_id: post.topic_id)
diff --git a/spec/models/user_action_spec.rb b/spec/models/user_action_spec.rb
index bcfd11f824b..f66314d2596 100644
--- a/spec/models/user_action_spec.rb
+++ b/spec/models/user_action_spec.rb
@@ -121,8 +121,8 @@ describe UserAction do
end
it 'should result in correct data assignment' do
- @liker_action.should_not be_nil
- @likee_action.should_not be_nil
+ @liker_action.should_not == nil
+ @likee_action.should_not == nil
likee.user_stat.reload.likes_received.should == 1
liker.user_stat.reload.likes_given.should == 1
@@ -163,13 +163,13 @@ describe UserAction do
@action = @post.user.user_actions.find_by(action_type: UserAction::NEW_TOPIC)
end
it 'should exist' do
- @action.should_not be_nil
+ @action.should_not == nil
@action.created_at.should be_within(1).of(@post.topic.created_at)
end
end
it 'should not log a post user action' do
- @post.user.user_actions.find_by(action_type: UserAction::REPLY).should be_nil
+ @post.user.user_actions.find_by(action_type: UserAction::REPLY).should == nil
end
@@ -183,9 +183,9 @@ describe UserAction do
end
it 'should log user actions correctly' do
- @response.user.user_actions.find_by(action_type: UserAction::REPLY).should_not be_nil
- @post.user.user_actions.find_by(action_type: UserAction::RESPONSE).should_not be_nil
- @mentioned.user_actions.find_by(action_type: UserAction::MENTION).should_not be_nil
+ @response.user.user_actions.find_by(action_type: UserAction::REPLY).should_not == nil
+ @post.user.user_actions.find_by(action_type: UserAction::RESPONSE).should_not == nil
+ @mentioned.user_actions.find_by(action_type: UserAction::MENTION).should_not == nil
@post.user.user_actions.joins(:target_post).where('posts.post_number = 2').count.should == 1
end
@@ -213,7 +213,7 @@ describe UserAction do
@action.user_id.should == @user.id
PostAction.remove_act(@user, @post, PostActionType.types[:bookmark])
- @user.user_actions.find_by(action_type: UserAction::BOOKMARK).should be_nil
+ @user.user_actions.find_by(action_type: UserAction::BOOKMARK).should == nil
end
end
diff --git a/spec/models/user_avatar_spec.rb b/spec/models/user_avatar_spec.rb
index a621580e932..d084281f9e2 100644
--- a/spec/models/user_avatar_spec.rb
+++ b/spec/models/user_avatar_spec.rb
@@ -15,6 +15,6 @@ describe UserAvatar do
FileHelper.expects(:download).returns(temp)
avatar.update_gravatar!
temp.unlink
- avatar.gravatar_upload.should_not be_nil
+ avatar.gravatar_upload.should_not == nil
end
end
diff --git a/spec/models/user_profile_spec.rb b/spec/models/user_profile_spec.rb
index af0ba63716e..410355cd7ec 100644
--- a/spec/models/user_profile_spec.rb
+++ b/spec/models/user_profile_spec.rb
@@ -24,12 +24,12 @@ describe UserProfile do
let(:user_profile) { Fabricate.build(:user_profile) }
it 'is not valid without user' do
- expect(user_profile.valid?).to be_false
+ expect(user_profile.valid?).should == false
end
it 'is is valid with user' do
user_profile.user = Fabricate.build(:user)
- expect(user_profile.valid?).to be_true
+ expect(user_profile.valid?).should == true
end
it "doesn't support really long bios" do
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 3f85e6d44c4..08281e04a6f 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -90,7 +90,7 @@ describe User do
end
it 'returns true' do
- @result.should be_true
+ @result.should == true
end
it 'should change the username' do
@@ -114,7 +114,7 @@ describe User do
end
it 'returns false' do
- @result.should be_false
+ @result.should == false
end
it 'should not change the username' do
@@ -132,7 +132,7 @@ describe User do
let!(:myself) { Fabricate(:user, username: 'hansolo') }
it 'should return true' do
- myself.change_username('HanSolo').should be_true
+ myself.change_username('HanSolo').should == true
end
it 'should change the username' do
@@ -149,17 +149,17 @@ describe User do
it 'should allow a shorter username than default' do
result = user.change_username('a' * @custom_min)
- result.should_not be_false
+ result.should_not == false
end
it 'should not allow a shorter username than limit' do
result = user.change_username('a' * (@custom_min - 1))
- result.should be_false
+ result.should == false
end
it 'should not allow a longer username than limit' do
result = user.change_username('a' * (User.username_length.end + 1))
- result.should be_false
+ result.should == false
end
end
end
@@ -179,7 +179,7 @@ describe User do
expect(Post.where(id: @posts.map(&:id))).to be_empty
@posts.each do |p|
if p.post_number == 1
- expect(Topic.find_by(id: p.topic_id)).to be_nil
+ expect(Topic.find_by(id: p.topic_id)).should == nil
end
end
end
@@ -208,24 +208,24 @@ describe User do
it { should_not be_approved }
its(:approved_at) { should be_blank }
its(:approved_by_id) { should be_blank }
- its(:email_private_messages) { should be_true }
- its(:email_direct ) { should be_true }
+ its(:email_private_messages) { should == true }
+ its(:email_direct ) { should == true }
context 'digest emails' do
it 'defaults to digests every week' do
- subject.email_digests.should be_true
+ subject.email_digests.should == true
subject.digest_after_days.should == 7
end
it 'uses default_digest_email_frequency' do
SiteSetting.stubs(:default_digest_email_frequency).returns(1)
- subject.email_digests.should be_true
+ subject.email_digests.should == true
subject.digest_after_days.should == 1
end
it 'disables digests by default if site setting says so' do
SiteSetting.stubs(:default_digest_email_frequency).returns('')
- subject.email_digests.should be_false
+ subject.email_digests.should == false
end
end
@@ -276,39 +276,39 @@ describe User do
end
it "is true for your basic level" do
- user.has_trust_level?(TrustLevel[0]).should be_true
+ user.has_trust_level?(TrustLevel[0]).should == true
end
it "is false for a higher level" do
- user.has_trust_level?(TrustLevel[2]).should be_false
+ user.has_trust_level?(TrustLevel[2]).should == false
end
it "is true if you exceed the level" do
user.trust_level = TrustLevel[4]
- user.has_trust_level?(TrustLevel[1]).should be_true
+ user.has_trust_level?(TrustLevel[1]).should == true
end
it "is true for an admin even with a low trust level" do
user.trust_level = TrustLevel[0]
user.admin = true
- user.has_trust_level?(TrustLevel[1]).should be_true
+ user.has_trust_level?(TrustLevel[1]).should == true
end
end
describe 'moderator' do
it "isn't a moderator by default" do
- user.moderator?.should be_false
+ user.moderator?.should == false
end
it "is a moderator if the user level is moderator" do
user.moderator = true
- user.has_trust_level?(TrustLevel[4]).should be_true
+ user.has_trust_level?(TrustLevel[4]).should == true
end
it "is staff if the user is an admin" do
user.admin = true
- user.staff?.should be_true
+ user.staff?.should == true
end
end
@@ -322,36 +322,36 @@ describe User do
describe '#staff?' do
subject { user.staff? }
- it { should be_false }
+ it { should == false }
context 'for a moderator user' do
before { user.moderator = true }
- it { should be_true }
+ it { should == true }
end
context 'for an admin user' do
before { user.admin = true }
- it { should be_true }
+ it { should == true }
end
end
describe '#regular?' do
subject { user.regular? }
- it { should be_true }
+ it { should == true }
context 'for a moderator user' do
before { user.moderator = true }
- it { should be_false }
+ it { should == false }
end
context 'for an admin user' do
before { user.admin = true }
- it { should be_false }
+ it { should == false }
end
end
end
@@ -464,22 +464,22 @@ describe User do
it "should not allow saving if username is reused" do
@codinghorror.username = @user.username
- @codinghorror.save.should be_false
+ @codinghorror.save.should == false
end
it "should not allow saving if username is reused in different casing" do
@codinghorror.username = @user.username.upcase
- @codinghorror.save.should be_false
+ @codinghorror.save.should == false
end
end
context '.username_available?' do
it "returns true for a username that is available" do
- User.username_available?('BruceWayne').should be_true
+ User.username_available?('BruceWayne').should == true
end
it 'returns false when a username is taken' do
- User.username_available?(Fabricate(:user).username).should be_false
+ User.username_available?(Fabricate(:user).username).should == false
end
end
@@ -571,11 +571,11 @@ describe User do
end
it "should have a valid password after the initial save" do
- @user.confirm_password?("ilovepasta").should be_true
+ @user.confirm_password?("ilovepasta").should == true
end
it "should not have an active account after initial save" do
- @user.active.should be_false
+ @user.active.should == false
end
end
@@ -592,16 +592,16 @@ describe User do
end
it "should act correctly" do
- user.previous_visit_at.should be_nil
+ user.previous_visit_at.should == nil
# first visit
user.update_last_seen!(first_visit_date)
- user.previous_visit_at.should be_nil
+ user.previous_visit_at.should == nil
# updated same time
user.update_last_seen!(first_visit_date)
user.reload
- user.previous_visit_at.should be_nil
+ user.previous_visit_at.should == nil
# second visit
user.update_last_seen!(second_visit_date)
@@ -620,7 +620,7 @@ describe User do
let(:user) { Fabricate(:user) }
it "should have a blank last seen on creation" do
- user.last_seen_at.should be_nil
+ user.last_seen_at.should == nil
end
it "should have 0 for days_visited" do
@@ -696,7 +696,7 @@ describe User do
context 'when email has not been confirmed yet' do
it 'should return false' do
- user.email_confirmed?.should be_false
+ user.email_confirmed?.should == false
end
end
@@ -704,7 +704,7 @@ describe User do
it 'should return true' do
token = user.email_tokens.find_by(email: user.email)
EmailToken.confirm(token.token)
- user.email_confirmed?.should be_true
+ user.email_confirmed?.should == true
end
end
@@ -712,7 +712,7 @@ describe User do
it 'should return false' do
user.email_tokens.each {|t| t.destroy}
user.reload
- user.email_confirmed?.should be_true
+ user.email_confirmed?.should == true
end
end
end
@@ -774,7 +774,7 @@ describe User do
expect(found_user).to eq bob
found_user = User.find_by_username_or_email('bob1')
- expect(found_user).to be_nil
+ expect(found_user).should == nil
found_user = User.find_by_email('bob@Example.com')
expect(found_user).to eq bob
@@ -783,7 +783,7 @@ describe User do
expect(found_user).to eq bob
found_user = User.find_by_email('bob')
- expect(found_user).to be_nil
+ expect(found_user).should == nil
found_user = User.find_by_username('bOb')
expect(found_user).to eq bob
@@ -873,11 +873,11 @@ describe User do
it "does not return true for staff" do
user.stubs(:staff?).returns(true)
- user.posted_too_much_in_topic?(topic.id).should be_false
+ user.posted_too_much_in_topic?(topic.id).should == false
end
it "returns true when the user has posted too much" do
- user.posted_too_much_in_topic?(topic.id).should be_true
+ user.posted_too_much_in_topic?(topic.id).should == true
end
context "with a reply" do
@@ -886,7 +886,7 @@ describe User do
end
it "resets the `posted_too_much` threshold" do
- user.posted_too_much_in_topic?(topic.id).should be_false
+ user.posted_too_much_in_topic?(topic.id).should == false
end
end
end
@@ -894,7 +894,7 @@ describe User do
it "returns false for a user who created the topic" do
topic_user = topic.user
topic_user.trust_level = TrustLevel[0]
- topic.user.posted_too_much_in_topic?(topic.id).should be_false
+ topic.user.posted_too_much_in_topic?(topic.id).should == false
end
end
@@ -979,7 +979,7 @@ describe User do
let!(:user) { Fabricate(:user) }
it "has no primary_group_id by default" do
- user.primary_group_id.should be_nil
+ user.primary_group_id.should == nil
end
context "when the user has a group" do
@@ -1002,7 +1002,7 @@ describe User do
# It should unset it from the primary_group_id
user.reload
- user.primary_group_id.should be_nil
+ user.primary_group_id.should == nil
end
end
end
@@ -1160,9 +1160,9 @@ describe User do
it 'should only remove old, inactive users' do
User.purge_inactive
all_users = User.all
- all_users.include?(user).should be_true
- all_users.include?(inactive).should be_true
- all_users.include?(inactive_old).should be_false
+ all_users.include?(user).should == true
+ all_users.include?(inactive).should == true
+ all_users.include?(inactive_old).should == false
end
end
diff --git a/spec/serializers/post_serializer_spec.rb b/spec/serializers/post_serializer_spec.rb
index e37a8fcccba..de17f419252 100644
--- a/spec/serializers/post_serializer_spec.rb
+++ b/spec/serializers/post_serializer_spec.rb
@@ -54,11 +54,11 @@ describe PostSerializer do
subject { PostSerializer.new(post, scope: Guardian.new(Fabricate(:admin)), root: false).as_json }
it "serializes correctly" do
- [:name, :username, :display_username, :avatar_template].each do |attr|
+ [:name, :username, :display_username, :avatar_template, :user_title, :trust_level].each do |attr|
subject[attr].should be_nil
end
- [:moderator?, :staff?, :yours, :user_title, :trust_level].each do |attr|
- subject[attr].should be_false
+ [:moderator, :staff, :yours].each do |attr|
+ subject[attr].should == false
end
end
end
@@ -104,8 +104,8 @@ describe PostSerializer do
let(:post) { Fabricate.build(:post, raw: raw, user: user, hidden: true, hidden_reason_id: Post.hidden_reasons[:flag_threshold_reached]) }
it "shows the raw post only if authorized to see it" do
- serialized_post_for_user(nil)[:raw].should be_nil
- serialized_post_for_user(Fabricate(:user))[:raw].should be_nil
+ serialized_post_for_user(nil)[:raw].should == nil
+ serialized_post_for_user(Fabricate(:user))[:raw].should == nil
serialized_post_for_user(user)[:raw].should == raw
serialized_post_for_user(Fabricate(:moderator))[:raw].should == raw
diff --git a/spec/serializers/user_serializer_spec.rb b/spec/serializers/user_serializer_spec.rb
index 2ef554a42da..7bdb95a7471 100644
--- a/spec/serializers/user_serializer_spec.rb
+++ b/spec/serializers/user_serializer_spec.rb
@@ -86,7 +86,7 @@ describe UserSerializer do
it "serializes the fields listed in public_user_custom_fields site setting" do
SiteSetting.stubs(:public_user_custom_fields).returns('public_field')
json[:custom_fields]['public_field'].should == user.custom_fields['public_field']
- json[:custom_fields]['secret_field'].should be_nil
+ json[:custom_fields]['secret_field'].should == nil
end
end
end
diff --git a/spec/services/auto_block_spec.rb b/spec/services/auto_block_spec.rb
index d2834867514..1ce8f3771af 100644
--- a/spec/services/auto_block_spec.rb
+++ b/spec/services/auto_block_spec.rb
@@ -105,7 +105,7 @@ describe SpamRule::AutoBlock do
it 'prevents the user from making new posts' do
subject.block_user
- expect(Guardian.new(user).can_create_post?(nil)).to be_false
+ expect(Guardian.new(user).can_create_post?(nil)).to be_falsey
end
it 'sends private message to moderators' do
@@ -173,39 +173,39 @@ describe SpamRule::AutoBlock do
it 'returns false if there are no spam flags' do
subject.stubs(:num_spam_flags_against_user).returns(0)
subject.stubs(:num_users_who_flagged_spam_against_user).returns(0)
- expect(subject.block?).to be_false
+ expect(subject.block?).to be_falsey
end
it 'returns false if there are not received enough flags' do
subject.stubs(:num_spam_flags_against_user).returns(1)
subject.stubs(:num_users_who_flagged_spam_against_user).returns(2)
- expect(subject.block?).to be_false
+ expect(subject.block?).to be_falsey
end
it 'returns false if there have not been enough users' do
subject.stubs(:num_spam_flags_against_user).returns(2)
subject.stubs(:num_users_who_flagged_spam_against_user).returns(1)
- expect(subject.block?).to be_false
+ expect(subject.block?).to be_falsey
end
it 'returns false if num_flags_to_block_new_user is 0' do
SiteSetting.stubs(:num_flags_to_block_new_user).returns(0)
subject.stubs(:num_spam_flags_against_user).returns(100)
subject.stubs(:num_users_who_flagged_spam_against_user).returns(100)
- expect(subject.block?).to be_false
+ expect(subject.block?).to be_falsey
end
it 'returns false if num_users_to_block_new_user is 0' do
SiteSetting.stubs(:num_users_to_block_new_user).returns(0)
subject.stubs(:num_spam_flags_against_user).returns(100)
subject.stubs(:num_users_who_flagged_spam_against_user).returns(100)
- expect(subject.block?).to be_false
+ expect(subject.block?).to be_falsey
end
it 'returns true when there are enough flags from enough users' do
subject.stubs(:num_spam_flags_against_user).returns(2)
subject.stubs(:num_users_who_flagged_spam_against_user).returns(2)
- expect(subject.block?).to be_true
+ expect(subject.block?).to be_truthy
end
end
@@ -214,7 +214,7 @@ describe SpamRule::AutoBlock do
subject { described_class.new(user) }
it 'returns false' do
- expect(subject.block?).to be_true
+ expect(subject.block?).to be_truthy
end
end
end
diff --git a/spec/services/badge_granter_spec.rb b/spec/services/badge_granter_spec.rb
index cd85d3f6b36..f6544e95b12 100644
--- a/spec/services/badge_granter_spec.rb
+++ b/spec/services/badge_granter_spec.rb
@@ -176,8 +176,8 @@ describe BadgeGranter do
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 be_nil
- UserBadge.where(user_id: user.id, badge_id: 2).first.should be_nil
+ 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
end
it "grants system like badges" do
@@ -185,7 +185,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 be_nil
+ UserBadge.find_by(user_id: user.id, badge_id: 5).should_not == nil
post = create_post(topic: post.topic, user: user)
action = PostAction.act(liker, post, PostActionType.types[:like])
@@ -196,25 +196,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 be_nil
+ 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
# 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 be_nil
+ UserBadge.find_by(user_id: user.id, badge_id: Badge::GoodPost).should_not == 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 be_nil
+ UserBadge.find_by(user_id: user.id, badge_id: Badge::GreatPost).should_not == 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 be_nil
+ UserBadge.find_by(user_id: user.id, badge_id: Badge::GreatPost).should == nil
end
end
diff --git a/spec/services/color_scheme_revisor_spec.rb b/spec/services/color_scheme_revisor_spec.rb
index 374a48ad567..122d21a38cf 100644
--- a/spec/services/color_scheme_revisor_spec.rb
+++ b/spec/services/color_scheme_revisor_spec.rb
@@ -77,7 +77,7 @@ 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 be_nil
+ 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'
@@ -124,7 +124,7 @@ describe ColorSchemeRevisor do
expect {
described_class.revert(color_scheme)
}.to change { ColorScheme.count }.by(-1)
- color_scheme.reload.previous_version.should be_nil
+ color_scheme.reload.previous_version.should == nil
end
end
end
diff --git a/spec/services/group_message_spec.rb b/spec/services/group_message_spec.rb
index 1908140db92..c320f6d88e2 100644
--- a/spec/services/group_message_spec.rb
+++ b/spec/services/group_message_spec.rb
@@ -83,19 +83,19 @@ describe GroupMessage do
describe 'sent_recently?' do
it 'returns true if redis says so' do
$redis.stubs(:get).with(group_message.sent_recently_key).returns('1')
- expect(group_message.sent_recently?).to be_true
+ expect(group_message.sent_recently?).to be_truthy
end
it 'returns false if redis returns nil' do
$redis.stubs(:get).with(group_message.sent_recently_key).returns(nil)
- expect(group_message.sent_recently?).to be_false
+ expect(group_message.sent_recently?).to be_falsey
end
it 'always returns false if limit_once_per is false' do
gm = GroupMessage.new(moderators_group, :user_automatically_blocked, {user: user, limit_once_per: false})
gm.stubs(:sent_recently_key).returns('the_key')
$redis.stubs(:get).with(gm.sent_recently_key).returns('1')
- expect(gm.sent_recently?).to be_false
+ expect(gm.sent_recently?).to be_falsey
end
end
diff --git a/spec/services/staff_action_logger_spec.rb b/spec/services/staff_action_logger_spec.rb
index 09018d0214a..e56c05dda8d 100644
--- a/spec/services/staff_action_logger_spec.rb
+++ b/spec/services/staff_action_logger_spec.rb
@@ -83,7 +83,7 @@ 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 be_nil
+ log_record.previous_value.should == nil
log_record.new_value.should be_present
json = ::JSON.parse(log_record.new_value)
json['stylesheet'].should be_present
@@ -109,7 +109,7 @@ describe StaffActionLogger 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 be_nil
+ log_record.new_value.should == nil
json = ::JSON.parse(log_record.previous_value)
json['stylesheet'].should == site_customization.stylesheet
json['header'].should == site_customization.header
diff --git a/spec/services/user_destroyer_spec.rb b/spec/services/user_destroyer_spec.rb
index 630dc88773d..b3a71db9818 100644
--- a/spec/services/user_destroyer_spec.rb
+++ b/spec/services/user_destroyer_spec.rb
@@ -111,22 +111,22 @@ describe UserDestroyer do
it "deletes the posts" do
destroy
- post.reload.deleted_at.should_not be_nil
- post.user_id.should be_nil
+ post.reload.deleted_at.should_not == nil
+ post.user_id.should == nil
end
it "does not delete topics started by others in which the user has replies" do
destroy
- topic.reload.deleted_at.should be_nil
- topic.user_id.should_not be_nil
+ topic.reload.deleted_at.should == nil
+ topic.user_id.should_not == 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 be_nil
- spammer_topic.user_id.should be_nil
+ spammer_topic.reload.deleted_at.should_not == nil
+ spammer_topic.user_id.should == nil
end
end
@@ -138,8 +138,8 @@ describe UserDestroyer do
it "deletes the posts" do
destroy
- post.reload.deleted_at.should_not be_nil
- post.user_id.should be_nil
+ post.reload.deleted_at.should_not == nil
+ post.user_id.should == nil
end
end
end
@@ -159,7 +159,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 be_nil
+ deleted_post.reload.user_id.should == nil
end
end
diff --git a/spec/services/user_updater_spec.rb b/spec/services/user_updater_spec.rb
index 8ecbbc6491d..3ba8f25c30d 100644
--- a/spec/services/user_updater_spec.rb
+++ b/spec/services/user_updater_spec.rb
@@ -28,7 +28,7 @@ describe UserUpdater do
user = Fabricate(:user)
updater = described_class.new(acting_user, user)
- expect(updater.update).to be_true
+ expect(updater.update).to be_truthy
end
end
@@ -38,7 +38,7 @@ describe UserUpdater do
user.stubs(save: false)
updater = described_class.new(acting_user, user)
- expect(updater.update).to be_false
+ expect(updater.update).to be_falsey
end
end
diff --git a/spec/services/username_checker_service_spec.rb b/spec/services/username_checker_service_spec.rb
index 6c05448e483..4f419ac8f74 100644
--- a/spec/services/username_checker_service_spec.rb
+++ b/spec/services/username_checker_service_spec.rb
@@ -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 be_false
+ result[:available].should == false
result[:suggestion].should 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 be_true
+ result[:available].should == true
end
end
diff --git a/spec/views/omniauth_callbacks/failure.html.erb_spec.rb b/spec/views/omniauth_callbacks/failure.html.erb_spec.rb
index d6e8eadf21a..7237399b170 100644
--- a/spec/views/omniauth_callbacks/failure.html.erb_spec.rb
+++ b/spec/views/omniauth_callbacks/failure.html.erb_spec.rb
@@ -6,7 +6,7 @@ describe "users/omniauth_callbacks/failure.html.erb" do
flash[:error] = I18n.t("login.omniauth_error", strategy: 'test')
render
- rendered.match(I18n.t("login.omniauth_error", strategy: 'test')).should be_true
+ rendered.match(I18n.t("login.omniauth_error", strategy: 'test')).should_not == nil
end
-end
\ No newline at end of file
+end