Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for content node rss feed, paragraph. Fixed rss title for…
… content node.
- Loading branch information
Doug Youch
committed
Feb 19, 2010
1 parent
88653fa
commit 81ecc33
Showing
6 changed files
with
93 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
require File.dirname(__FILE__) + "/../../spec_helper" | ||
|
||
describe Editor::ContentFeature, :type => :view do | ||
|
||
reset_domain_tables :site_nodes, :content_nodes, :site_versions, :content_types | ||
|
||
before(:each) do | ||
@feature = build_feature('/editor/content_feature') | ||
end | ||
|
||
it "should render recent content" do | ||
SiteVersion.default.root_node.add_subpage('home') | ||
SiteVersion.default.root_node.add_subpage('about-us') | ||
SiteVersion.default.root_node.add_subpage('contact') | ||
|
||
@type = ContentType.create :component => 'editor', :content_name => 'Static Pages', :content_type => 'SiteNode', :title_field => 'name', :url_field => 'id', :search_results => 1, :editable => 0, :created_at => Time.now, :updated_at => Time.now | ||
@type.id.should_not be_nil | ||
ContentNode.update_all :content_type_id => @type.id | ||
|
||
@nodes = ContentNode.find(:all, :limit => 10) | ||
|
||
@output = @feature.recent_content_feature(:nodes => @nodes) | ||
@output.should include('home') | ||
@output.should include('about-us') | ||
@output.should include('contact') | ||
@output.should include('Static Pages') | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require File.dirname(__FILE__) + "/../../spec_helper" | ||
|
||
|
||
describe Editor::ContentRenderer, :type => :controller do | ||
controller_name :page | ||
|
||
integrate_views | ||
|
||
describe "Recent Content Paragraph" do | ||
def generate_renderer(data = {}) | ||
build_renderer('/page','/editor/content/recent_content',data,{}) | ||
end | ||
|
||
it "should render the recent content paragraph" do | ||
ContentNode.should_receive(:find).once.with(:all, :conditions => nil, :limit => 10, :order => 'created_at DESC').and_return([]) | ||
@rnd = generate_renderer | ||
@rnd.should_render_feature("recent_content") | ||
renderer_get @rnd | ||
end | ||
|
||
it "should render the recent content paragraph for specific types" do | ||
ContentNode.should_receive(:find).once.with(:all, :conditions => {:content_type_id => [4, 5]}, :limit => 10, :order => 'created_at DESC').and_return([]) | ||
@rnd = generate_renderer :content_type_ids => [4, 5] | ||
@rnd.should_render_feature("recent_content") | ||
renderer_get @rnd | ||
end | ||
|
||
it "should render the recent content paragraph by most recently updated" do | ||
ContentNode.should_receive(:find).once.with(:all, :conditions => nil, :limit => 5, :order => 'updated_at DESC').and_return([]) | ||
@rnd = generate_renderer :order_by => 'updated', :count => 5 | ||
@rnd.should_render_feature("recent_content") | ||
renderer_get @rnd | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
vendor/modules/feed/spec/models/feed/content_node_rss_handler_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require File.expand_path(File.dirname(__FILE__)) + "/../../../../../../spec/spec_helper" | ||
|
||
describe Feed::ContentNodeRssHandler do | ||
|
||
reset_domain_tables :site_nodes, :content_nodes, :site_versions, :content_types | ||
|
||
it "should create the data for a content node rss feed" do | ||
home = SiteVersion.default.root_node.add_subpage('home') | ||
SiteVersion.default.root_node.add_subpage('about-us') | ||
SiteVersion.default.root_node.add_subpage('contact') | ||
|
||
@type = ContentType.create :component => 'editor', :content_name => 'Static Pages', :content_type => 'SiteNode', :title_field => 'name', :url_field => 'id', :search_results => 1, :editable => 0, :created_at => Time.now, :updated_at => Time.now | ||
@type.id.should_not be_nil | ||
ContentNode.update_all :content_type_id => @type.id | ||
|
||
@options = Feed::ContentNodeRssHandler::Options.new({:feed_title => 'My Static Pages', :description => 'My Description for static pages', :link_id => home.id}) | ||
@feed = Feed::ContentNodeRssHandler.new(@options) | ||
data = @feed.get_feed | ||
data[:title].should == 'My Static Pages' | ||
data[:description].should == 'My Description for static pages' | ||
data[:link].should include('/home') | ||
|
||
data[:items].detect { |item| item[:link].include?('/home') && item[:title] == 'Home' }.should be_true | ||
data[:items].detect { |item| item[:link].include?('/about-us') && item[:title] == 'About Us' }.should be_true | ||
data[:items].detect { |item| item[:link].include?('/contact') && item[:title] == 'Contact' }.should be_true | ||
end | ||
end |