Permalink
Browse files

Fixed tagcloud behaviour

  • Loading branch information...
1 parent 2f3d31f commit c2ec1140573fdd2c1f14d71fcfc2b3f813c178fa @nettsundere nettsundere committed Dec 19, 2012
Showing with 36 additions and 12 deletions.
  1. +13 −9 init.rb
  2. +5 −3 lib/tagging_plugin/tagging_patches.rb
  3. +18 −0 test/integration/tagging_test.rb
View
22 init.rb
@@ -31,19 +31,23 @@
macro :tagcloud do |obj, args|
args, options = extract_macro_options(args, :parent)
- if obj.is_a? WikiContent
- project = obj.page.wiki.project
+ return if params[:controller] == "mailer"
+
+ if obj
+ if obj.is_a? WikiContent
+ project = obj.page.wiki.project
+ else
+ project = obj.project
+ end
else
- project = obj.project
+ project = Project.visible.where(:identifier => params[:project_id]).first
end
if project # this may be an attempt to render tag cloud when deleting wiki page
- if !@controller.is_a?(Mailer)
- if obj.is_a?(WikiContent)
- @controller.send(:render_to_string, { :partial => 'tagging/tagcloud_search', :locals => {:project => project} })
- else
- @controller.send(:render_to_string, { :partial => 'tagging/tagcloud', :locals => {:project => project} })
- end
+ if [WikiContent, WikiContent::Version, NilClass].include?(obj.class)
+ render :partial => 'tagging/tagcloud_search', :project => project
+ elsif [Journal, Issue].include?(obj.class)
+ render :partial => 'tagging/tagcloud', :project => project
end
end
end
@@ -144,9 +144,11 @@ def self.included(base) # :nodoc:
module InstanceMethods
def update_with_tags
- if tags = params[:wiki_page][:tags]
- tags = TagsHelper.from_string(tags)
- @page.tags_to_update = tags
+ if params[:wiki_page]
+ if tags = params[:wiki_page][:tags]
+ tags = TagsHelper.from_string(tags)
+ @page.tags_to_update = tags
+ end
end
update_without_tags
end
@@ -109,6 +109,24 @@ def test_should_update_inline_issue_tags
end
context "wiki_page" do
+ def test_should_generate_wiki_tagcloud
+ edit_page_path = edit_project_wiki_path(@project_with_wiki_tags, "newpage")
+ page_path = project_wiki_path(@project_with_wiki_tags, "newpage")
+
+ page_content = @wiki_page_with_tags_content.attributes.merge(
+ 'text' => "{{tag(11)}} {{tag(14 15)}} {{tagcloud}}"
+ )
+
+ page_attrs = @wiki_page_with_tags.attributes
+
+ get_via_redirect(edit_page_path)
+ assert_response :success
+ put_via_redirect(page_path, :wiki_page => page_attrs, :content => page_content)
+ assert_response :success
+ get_via_redirect(page_path)
+ assert_response :success
+ end
+
def test_should_create_wiki_page_tags_from_input
Setting.plugin_redmine_tagging[:wiki_pages_inline] = "0"

0 comments on commit c2ec114

Please sign in to comment.