mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 20:34:50 +08:00
few components with rspec3 syntax
This commit is contained in:
@ -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 == true
|
||||
expect(helper.is_local("http://discuss.site.com/path/to/file.png")).to eq(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 == true
|
||||
expect(helper.is_local("/assets/javascripts/all.js")).to eq(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 == true
|
||||
expect(helper.is_local("/plugins/all.js")).to eq(true)
|
||||
end
|
||||
|
||||
end
|
||||
@ -37,16 +37,16 @@ describe UrlHelper do
|
||||
describe "#absolute" do
|
||||
|
||||
it "does not change non-relative url" do
|
||||
helper.absolute("http://www.discourse.org").should == "http://www.discourse.org"
|
||||
expect(helper.absolute("http://www.discourse.org")).to eq("http://www.discourse.org")
|
||||
end
|
||||
|
||||
it "changes a relative url to an absolute one using base url by default" do
|
||||
helper.absolute("/path/to/file").should == "http://test.localhost/path/to/file"
|
||||
expect(helper.absolute("/path/to/file")).to eq("http://test.localhost/path/to/file")
|
||||
end
|
||||
|
||||
it "changes a relative url to an absolute one using the cdn when enabled" do
|
||||
Rails.configuration.action_controller.stubs(:asset_host).returns("http://my.cdn.com")
|
||||
helper.absolute("/path/to/file").should == "http://my.cdn.com/path/to/file"
|
||||
expect(helper.absolute("/path/to/file")).to eq("http://my.cdn.com/path/to/file")
|
||||
end
|
||||
|
||||
end
|
||||
@ -55,7 +55,7 @@ describe UrlHelper do
|
||||
|
||||
it "changes a relative url to an absolute one using base url even when cdn is enabled" do
|
||||
Rails.configuration.action_controller.stubs(:asset_host).returns("http://my.cdn.com")
|
||||
helper.absolute_without_cdn("/path/to/file").should == "http://test.localhost/path/to/file"
|
||||
expect(helper.absolute_without_cdn("/path/to/file")).to eq("http://test.localhost/path/to/file")
|
||||
end
|
||||
|
||||
end
|
||||
@ -63,9 +63,9 @@ describe UrlHelper do
|
||||
describe "#schemaless" do
|
||||
|
||||
it "removes http or https schemas only" do
|
||||
helper.schemaless("http://www.discourse.org").should == "//www.discourse.org"
|
||||
helper.schemaless("https://secure.discourse.org").should == "//secure.discourse.org"
|
||||
helper.schemaless("ftp://ftp.discourse.org").should == "ftp://ftp.discourse.org"
|
||||
expect(helper.schemaless("http://www.discourse.org")).to eq("//www.discourse.org")
|
||||
expect(helper.schemaless("https://secure.discourse.org")).to eq("//secure.discourse.org")
|
||||
expect(helper.schemaless("ftp://ftp.discourse.org")).to eq("ftp://ftp.discourse.org")
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user