Last Updated by Admin at 10:30 am on March 30, 2008
} end it "should render a timezone-adjusted timestamp" do helper.timestamp(Time.local(2008, 3, 30, 10, 30)).should == "10:30 am on March 30, 2008" end it "should determine whether a meta area item should be visible" do helper.meta_visible(:meta_more).should be_empty helper.meta_visible(:meta_less).should == {:style => "display: none"} helper.meta_visible(:meta).should == {:style => "display: none"} end it "should not have meta errors" do helper.meta_errors?.should be_false end it "should provide a meta_label of 'Less' when meta_errors? is true" do helper.stub!(:meta_errors?).and_return(true) helper.meta_label.should == 'Less' end it "should provide a meta_label of 'More' when meta_errors? is false" do helper.stub!(:meta_errors?).and_return(false) helper.meta_label.should == 'More' end it "should render a Javascript snippet to toggle the meta area" do helper.toggle_javascript_for("joe").should == "Element.toggle('joe'); Element.toggle('more-joe'); Element.toggle('less-joe'); return false;" end it "should render an image tag with a default file extension" do helper.should_receive(:image_tag).with("admin/plus.png", {}) helper.image("plus") end it "should render an image submit tag with a default file extension" do helper.should_receive(:image_submit_tag).with("admin/plus.png", {}) helper.image_submit("plus") end it "should provide the admin object" do helper.admin.should == Radiant::AdminUI.instance end it "should return filter options for select" do helper.filter_options_for_select.should =~ %r{} helper.filter_options_for_select.should =~ %r{} end it "should include the regions helper" do ApplicationHelper.included_modules.should include(Admin::RegionsHelper) end describe 'stylesheet_and_javascript_overrides' do before do @override_css_path = "#{Rails.root}/public/stylesheets/admin/overrides.css" @override_sass_path = "#{Rails.root}/public/stylesheets/sass/admin/overrides.sass" @override_js_path = "#{Rails.root}/public/javascripts/admin/overrides.js" File.stub!(:exist?) end it "should render a link to the overrides.css file when it exists" do File.should_receive(:exist?).with(@override_css_path).and_return(true) helper.stylesheet_and_javascript_overrides.should have_tag('link[href*=?][media=?][rel=?][type=?]','/stylesheets/admin/overrides.css','screen','stylesheet','text/css') end it "should render a link to the overrides.css file when the overrides.sass file exists" do File.should_receive(:exist?).with(@override_sass_path).and_return(true) helper.stylesheet_and_javascript_overrides.should have_tag('link[href*=?][media=?][rel=?][type=?]','/stylesheets/admin/overrides.css','screen','stylesheet','text/css') end it "should not render a link to the overrides.css file when it does not exist" do File.should_receive(:exist?).at_least(:once).with(@override_css_path).and_return(false) helper.stylesheet_and_javascript_overrides.should_not have_tag('link[href*=?][media=?][rel=?][type=?]','/stylesheets/admin/overrides.css','screen','stylesheet','text/css') end it "should not render a link to the overrides.css file when the overrides.css and overrides.sass file does not exist" do File.should_receive(:exist?).at_least(:once).with(@override_css_path).and_return(false) File.should_receive(:exist?).at_least(:once).with(@override_sass_path).and_return(false) helper.stylesheet_and_javascript_overrides.should_not have_tag('link[href*=?][media=?][rel=?][type=?]','/stylesheets/admin/overrides.css','screen','stylesheet','text/css') end it "should render a link to the overrides.js file when it exists" do File.should_receive(:exist?).at_least(:once).with(@override_js_path).and_return(true) helper.stylesheet_and_javascript_overrides.should have_tag('script[src*=?][type=?]','/javascripts/admin/overrides.js', 'text/javascript') end it "should not render a link to the overrides.js file when it does not exist" do File.should_receive(:exist?).at_least(:once).with(@override_js_path).and_return(false) helper.stylesheet_and_javascript_overrides.should_not have_tag('script[src*=?][type=?]','/javascripts/admin/overrides.js', 'text/javascript') end end # describe "pagination" do # before do # @collection = WillPaginate::Collection.new(1, 10, 100) # request = mock("request") # helper.stub!(:request).and_return(request) # helper.stub!(:will_paginate_options).and_return({}) # helper.stub!(:will_paginate).and_return("pagination of some kind") # helper.stub!(:link_to).and_return("link") # end # # it "should render pagination controls for a supplied list" do # helper.pagination_for(@collection).should have_tag('div.pagination').with_tag('span.current', :text => '1') # end # # it "should include a depagination link by default" do # helper.pagination_for(@collection).should have_tag('div.depaginate') # end # # it "should omit the depagination link when :depaginate is false" do # helper.pagination_for(@collection, :depaginate => false).should_not have_tag('div.depaginate') # end # # it "should omit the depagination link when the :max_list_length is exceeded" do # helper.pagination_for(@collection, :depaginate => true, :max_list_length => 5).should_not have_tag('div.depaginate') # end # # it "should use the max_list_length config item when no other value is specified" do # Radiant::Config['pagination.max_list_length'] = 50 # helper.pagination_for(@collection).should_not have_tag('div.depaginate') # end # # it "should disregard list length when max_list_length is false" do # Radiant::Config['pagination.max_list_length'] = 50 # helper.pagination_for(@collection, :max_list_length => false).should_not have_tag('div.depaginate') # end # # end end