diff --git a/spec/helpers/wiki_helper_spec.rb b/spec/helpers/wiki_helper_spec.rb index 39222fd5e..996d13150 100755 --- a/spec/helpers/wiki_helper_spec.rb +++ b/spec/helpers/wiki_helper_spec.rb @@ -243,4 +243,27 @@ def controller end end end + + describe '#collection_title' do + before(:each) do + @category.stub!(:title).and_return('Category Title') + @tags = ['Tag 1', 'Tag 2'] + end + + it "should show the full collection title if all parameters are given" do + helper.collection_title(@category, @tags).should == "Pages about Category Title, tagged Tag 1 and Tag 2" + end + + it "should show the collection title with category title if only category is given" do + helper.collection_title(@category, nil).should == "Pages about Category Title" + end + + it "should show the collection title with tags if only tags are given" do + helper.collection_title(nil, @tags).should == "Pages tagged Tag 1 and Tag 2" + end + + it "should show the default collection title if no parameters are given" do + helper.collection_title(nil, nil).should == "All pages" + end + end end \ No newline at end of file diff --git a/vendor/engines/adva_wiki/app/controllers/wiki_controller.rb b/vendor/engines/adva_wiki/app/controllers/wiki_controller.rb index 08fc2734a..659047169 100644 --- a/vendor/engines/adva_wiki/app/controllers/wiki_controller.rb +++ b/vendor/engines/adva_wiki/app/controllers/wiki_controller.rb @@ -14,8 +14,6 @@ class WikiController < BaseController cache_sweeper :wikipage_sweeper, :category_sweeper, :tag_sweeper, :only => [:create, :update, :rollback, :destroy] guards_permissions :wikipage, :except => [:index, :show, :diff] - helper_method :collection_title - def index respond_to do |format| format.html { render @section.render_options } @@ -88,13 +86,6 @@ def destroy private - def collection_title - title = [] - title << "about #{@category.title}" if @category - title << "tagged #{@tags.to_sentence}" if @tags - title.empty? ? 'All pages' : 'Pages ' + title.join(', ') - end - def set_section super raise SectionRoutingError.new("Section must be a Wiki: #{@section.inspect}") unless @section.is_a? Wiki diff --git a/vendor/engines/adva_wiki/app/helpers/wiki_helper.rb b/vendor/engines/adva_wiki/app/helpers/wiki_helper.rb index 01f653062..a0e72124f 100644 --- a/vendor/engines/adva_wiki/app/helpers/wiki_helper.rb +++ b/vendor/engines/adva_wiki/app/helpers/wiki_helper.rb @@ -84,4 +84,10 @@ def wiki_edit_links(wikipage, options = {}) content_tag :ul, links * "\n", :class => 'links' end + def collection_title(category=nil, tags=nil) + title = [] + title << "about #{category.title}" if category + title << "tagged #{tags.to_sentence}" if tags + title.empty? ? 'All pages' : 'Pages ' + title.join(', ') + end end \ No newline at end of file diff --git a/vendor/engines/adva_wiki/app/views/wiki/index.html.erb b/vendor/engines/adva_wiki/app/views/wiki/index.html.erb index d6547fd28..71951e7b4 100644 --- a/vendor/engines/adva_wiki/app/views/wiki/index.html.erb +++ b/vendor/engines/adva_wiki/app/views/wiki/index.html.erb @@ -1,4 +1,4 @@ -

<%= collection_title %>

+

<%= collection_title(@category, @tags) %>

<% if @wikipages.size > 0 -%>