mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
few components with rspec3 syntax
This commit is contained in:
@ -10,7 +10,7 @@ describe Discourse do
|
||||
context 'current_hostname' do
|
||||
|
||||
it 'returns the hostname from the current db connection' do
|
||||
Discourse.current_hostname.should == 'foo.com'
|
||||
expect(Discourse.current_hostname).to eq('foo.com')
|
||||
end
|
||||
|
||||
end
|
||||
@ -22,7 +22,7 @@ describe Discourse do
|
||||
end
|
||||
|
||||
it 'has a non https base url' do
|
||||
Discourse.base_url.should == "http://foo.com"
|
||||
expect(Discourse.base_url).to eq("http://foo.com")
|
||||
end
|
||||
end
|
||||
|
||||
@ -32,7 +32,7 @@ describe Discourse do
|
||||
end
|
||||
|
||||
it 'has a non-ssl base url' do
|
||||
Discourse.base_url.should == "https://foo.com"
|
||||
expect(Discourse.base_url).to eq("https://foo.com")
|
||||
end
|
||||
end
|
||||
|
||||
@ -42,7 +42,7 @@ describe Discourse do
|
||||
end
|
||||
|
||||
it "returns the non standart port in the base url" do
|
||||
Discourse.base_url.should == "http://foo.com:3000"
|
||||
expect(Discourse.base_url).to eq("http://foo.com:3000")
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -54,17 +54,17 @@ describe Discourse do
|
||||
|
||||
it 'returns the user specified by the site setting site_contact_username' do
|
||||
SiteSetting.stubs(:site_contact_username).returns(another_admin.username)
|
||||
Discourse.site_contact_user.should == another_admin
|
||||
expect(Discourse.site_contact_user).to eq(another_admin)
|
||||
end
|
||||
|
||||
it 'returns the user specified by the site setting site_contact_username regardless of its case' do
|
||||
SiteSetting.stubs(:site_contact_username).returns(another_admin.username.upcase)
|
||||
Discourse.site_contact_user.should == another_admin
|
||||
expect(Discourse.site_contact_user).to eq(another_admin)
|
||||
end
|
||||
|
||||
it 'returns the first admin user otherwise' do
|
||||
SiteSetting.stubs(:site_contact_username).returns(nil)
|
||||
Discourse.site_contact_user.should == admin
|
||||
expect(Discourse.site_contact_user).to eq(admin)
|
||||
end
|
||||
|
||||
end
|
||||
@ -72,7 +72,7 @@ describe Discourse do
|
||||
context "#store" do
|
||||
|
||||
it "returns LocalStore by default" do
|
||||
Discourse.store.should be_a(FileStore::LocalStore)
|
||||
expect(Discourse.store).to be_a(FileStore::LocalStore)
|
||||
end
|
||||
|
||||
it "returns S3Store when S3 is enabled" do
|
||||
@ -80,7 +80,7 @@ describe Discourse do
|
||||
SiteSetting.stubs(:s3_upload_bucket).returns("s3_bucket")
|
||||
SiteSetting.stubs(:s3_access_key_id).returns("s3_access_key_id")
|
||||
SiteSetting.stubs(:s3_secret_access_key).returns("s3_secret_access_key")
|
||||
Discourse.store.should be_a(FileStore::S3Store)
|
||||
expect(Discourse.store).to be_a(FileStore::S3Store)
|
||||
end
|
||||
|
||||
end
|
||||
@ -109,12 +109,12 @@ describe Discourse do
|
||||
|
||||
it "returns true when the key is present in redis" do
|
||||
$redis.expects(:get).with(Discourse.readonly_mode_key).returns("1")
|
||||
Discourse.readonly_mode?.should == true
|
||||
expect(Discourse.readonly_mode?).to eq(true)
|
||||
end
|
||||
|
||||
it "returns false when the key is not present in redis" do
|
||||
$redis.expects(:get).with(Discourse.readonly_mode_key).returns(nil)
|
||||
Discourse.readonly_mode?.should == false
|
||||
expect(Discourse.readonly_mode?).to eq(false)
|
||||
end
|
||||
|
||||
end
|
||||
@ -140,16 +140,16 @@ describe Discourse do
|
||||
exception = StandardError.new
|
||||
|
||||
Discourse.handle_exception(exception, nil, nil)
|
||||
logger.exception.should == exception
|
||||
logger.context.keys.should == [:current_db, :current_hostname]
|
||||
expect(logger.exception).to eq(exception)
|
||||
expect(logger.context.keys).to eq([:current_db, :current_hostname])
|
||||
end
|
||||
|
||||
it "correctly passes extra context" do
|
||||
exception = StandardError.new
|
||||
|
||||
Discourse.handle_exception(exception, {message: "Doing a test", post_id: 31}, nil)
|
||||
logger.exception.should == exception
|
||||
logger.context.keys.sort.should == [:current_db, :current_hostname, :message, :post_id].sort
|
||||
expect(logger.exception).to eq(exception)
|
||||
expect(logger.context.keys.sort).to eq([:current_db, :current_hostname, :message, :post_id].sort)
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user