Guest User

Untitled

a guest
Feb 21st, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. Index: app/models/site.rb
  2.  
  3. ===================================================================
  4.  
  5. --- app/models/site.rb (revision 2383)
  6.  
  7. +++ app/models/site.rb (working copy)
  8.  
  9. @@ -93,8 +93,11 @@
  10.  
  11. end
  12.  
  13. def tags
  14. - Tag.find(:all, :conditions => ['contents.type = ? AND contents.site_id = ?', 'Article', id], :order => 'tags.name',
  15. - :joins => "INNER JOIN taggings ON taggings.tag_id = tags.id INNER JOIN contents ON (taggings.taggable_id = contents.id AND taggings.taggable_type = 'Content')")
  16. + Tag.find(:all, :select => "DISTINCT tags.name",
  17. + :joins => "INNER JOIN taggings ON taggings.tag_id = tags.id INNER JOIN contents ON (taggings.taggable_id = contents.id AND
  18. + taggings.taggable_type = 'Content')",
  19. + :conditions => ['contents.type = ? AND contents.site_id = ?', 'Article', id],
  20. + :order => 'tags.name')
  21. end
  22.  
  23. def theme_path
  24. Index: test/fixtures/taggings.yml
  25.  
  26. ===================================================================
  27.  
  28. --- test/fixtures/taggings.yml (revision 2383)
  29.  
  30. +++ test/fixtures/taggings.yml (working copy)
  31.  
  32. @@ -7,4 +7,19 @@
  33.  
  34. id: 2
  35. tag_id: 2
  36. taggable_id: 2
  37. + taggable_type: Content
  38. +rails_future:
  39. + id: 3
  40. + tag_id: 2
  41. + taggable_id: 5
  42. + taggable_type: Content
  43. +mongrel_future:
  44. + id: 4
  45. + tag_id: 3
  46. + taggable_id: 5
  47. + taggable_type: Content
  48. +ruby_future:
  49. + id: 5
  50. + tag_id: 1
  51. + taggable_id: 5
  52. taggable_type: Content
  53.  
  54. \ No newline at end of file
  55.  
  56. Index: test/unit/tagging_test.rb
  57.  
  58. ===================================================================
  59.  
  60. --- test/unit/tagging_test.rb (revision 2383)
  61.  
  62. +++ test/unit/tagging_test.rb (working copy)
  63.  
  64. @@ -74,6 +74,6 @@
  65.  
  66. end
  67.  
  68. specify "should find by tags in site" do
  69. - assert_models_equal [tags(:rails)], sites(:first).tags
  70. + assert_models_equal [tags(:mongrel), tags(:rails), tags(:ruby)], sites(:first).tags
  71. end
  72. end
Add Comment
Please, Sign In to add comment