From e274bb1757aa3c27645c181bae6164131a7a35dd Mon Sep 17 00:00:00 2001 From: Jeff Shumate Date: Wed, 25 Jan 2012 22:27:46 -0700 Subject: add source url for post --- spec/models/refinery/blog/post_spec.rb | 35 ++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'spec/models') diff --git a/spec/models/refinery/blog/post_spec.rb b/spec/models/refinery/blog/post_spec.rb index 60a04ec..fb7e3b1 100644 --- a/spec/models/refinery/blog/post_spec.rb +++ b/spec/models/refinery/blog/post_spec.rb @@ -212,9 +212,40 @@ module Refinery subject.class.teasers_enabled?.should be_false end end - end - + + describe "source url" do + it "should allow a source url and title" do + p = FactoryGirl.create(:blog_post, :source_url => 'google.com', :source_url_title => 'author') + p.should be_valid + p.source_url.should include('google') + p.source_url_title.should include('author') + end + end + + describe ".validate_source_url?" do + context "with Refinery::Setting validate_source_url set to true" do + before do + Refinery::Setting.set(:validate_source_url, { :scoping => 'blog', :value => true }) + Refinery::Blog.validate_source_url = true + end + it "should have canonical url" do + p = FactoryGirl.create(:blog_post, :source_url => 'google.com', :source_url_title => 'google') + p.source_url.should include('www') + end + end + context "with Refinery::Setting validate_source_url set to false" do + before do + Refinery::Setting.set(:validate_source_url, { :scoping => 'blog', :value => false }) + Refinery::Blog.validate_source_url = false + end + it "should have original url" do + p = FactoryGirl.create(:blog_post, :source_url => 'google.com', :source_url_title => 'google') + p.source_url.should_not include('www') + end + end + end + end end end \ No newline at end of file -- cgit v1.2.3