mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 23:36:11 +08:00
Update rspec syntax to v3
update rspec syntax to v3 change syntax to rspec v3 oops. fix typo mailers classes with rspec3 syntax helpers with rspec3 syntax jobs with rspec3 syntax serializers with rspec3 syntax views with rspec3 syntax support to rspec3 syntax category spec with rspec3 syntax
This commit is contained in:
@ -2,9 +2,9 @@ require 'spec_helper'
|
||||
|
||||
describe TopicEmbed do
|
||||
|
||||
it { should belong_to :topic }
|
||||
it { should belong_to :post }
|
||||
it { should validate_presence_of :embed_url }
|
||||
it { is_expected.to belong_to :topic }
|
||||
it { is_expected.to belong_to :post }
|
||||
it { is_expected.to validate_presence_of :embed_url }
|
||||
|
||||
context '.import' do
|
||||
|
||||
@ -14,42 +14,42 @@ describe TopicEmbed do
|
||||
let(:contents) { "hello world new post <a href='/hello'>hello</a> <img src='/images/wat.jpg'>" }
|
||||
|
||||
it "returns nil when the URL is malformed" do
|
||||
TopicEmbed.import(user, "invalid url", title, contents).should == nil
|
||||
TopicEmbed.count.should == 0
|
||||
expect(TopicEmbed.import(user, "invalid url", title, contents)).to eq(nil)
|
||||
expect(TopicEmbed.count).to eq(0)
|
||||
end
|
||||
|
||||
context 'creation of a post' do
|
||||
let!(:post) { TopicEmbed.import(user, url, title, contents) }
|
||||
|
||||
it "works as expected with a new URL" do
|
||||
post.should be_present
|
||||
expect(post).to be_present
|
||||
|
||||
# It uses raw_html rendering
|
||||
post.cook_method.should == Post.cook_methods[:raw_html]
|
||||
post.cooked.should == post.raw
|
||||
expect(post.cook_method).to eq(Post.cook_methods[:raw_html])
|
||||
expect(post.cooked).to eq(post.raw)
|
||||
|
||||
# It converts relative URLs to absolute
|
||||
post.cooked.start_with?("hello world new post <a href=\"http://eviltrout.com/hello\">hello</a> <img src=\"http://eviltrout.com/images/wat.jpg\">").should == true
|
||||
expect(post.cooked.start_with?("hello world new post <a href=\"http://eviltrout.com/hello\">hello</a> <img src=\"http://eviltrout.com/images/wat.jpg\">")).to eq(true)
|
||||
|
||||
post.topic.has_topic_embed?.should == true
|
||||
TopicEmbed.where(topic_id: post.topic_id).should be_present
|
||||
expect(post.topic.has_topic_embed?).to eq(true)
|
||||
expect(TopicEmbed.where(topic_id: post.topic_id)).to be_present
|
||||
end
|
||||
|
||||
it "Supports updating the post" do
|
||||
post = TopicEmbed.import(user, url, title, "muhahaha new contents!")
|
||||
post.cooked.should =~ /new contents/
|
||||
expect(post.cooked).to match(/new contents/)
|
||||
end
|
||||
|
||||
it "Should leave uppercase Feed Entry URL untouched in content" do
|
||||
cased_url = 'http://eviltrout.com/ABCD'
|
||||
post = TopicEmbed.import(user, cased_url, title, "some random content")
|
||||
post.cooked.should =~ /#{cased_url}/
|
||||
expect(post.cooked).to match(/#{cased_url}/)
|
||||
end
|
||||
|
||||
it "Should leave lowercase Feed Entry URL untouched in content" do
|
||||
cased_url = 'http://eviltrout.com/abcd'
|
||||
post = TopicEmbed.import(user, cased_url, title, "some random content")
|
||||
post.cooked.should =~ /#{cased_url}/
|
||||
expect(post.cooked).to match(/#{cased_url}/)
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user