public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
fix tag deletion issue with articles

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@2152 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Sun Sep 10 21:26:10 -0700 2006
commit  5e0c253816d981c709f88c77499fcacfb637a31a
tree    49c066f57722f51c6056d524a774dd4b010711eb
parent  c59b7f882b866665fd5c34d2bb2ffde3d5a84cf4
...
19
20
21
22
 
23
24
25
...
19
20
21
 
22
23
24
25
0
@@ -19,7 +19,7 @@ class Tagging < ActiveRecord::Base
0
     # Tagging.delete_from taggable, [Tag, Tag, Tag]
0
     def delete_from(taggable, tags)
0
       delete_all ['taggable_id = ? and taggable_type = ? and tag_id in (?)',
0
- taggable.id, taggable.class.name, tags.collect { |t| t.is_a?(Tag) ? t.id : t }] if tags.any?
0
+ taggable.id, taggable.class.base_class.name, tags.collect { |t| t.is_a?(Tag) ? t.id : t }] if tags.any?
0
     end
0
 
0
     # Adds tags to the taggable object
...
245
246
247
248
 
249
250
251
252
253
254
 
255
256
257
258
259
260
261
 
 
262
263
264
...
245
246
247
 
248
249
250
251
252
253
 
254
255
256
257
258
259
 
 
260
261
262
263
264
0
@@ -245,20 +245,20 @@ class Admin::ArticlesControllerTest < Test::Unit::TestCase
0
   def test_should_show_published_checkbox_checked_by_default
0
     get :index
0
     assert_response :success
0
- assert_tag 'input', :attributes => { :id => 'published', :type => 'checkbox', :checked => 'checked' }
0
+ assert_tag 'input', :attributes => { :id => 'article_published', :type => 'checkbox', :checked => 'checked' }
0
   end
0
 
0
   def test_should_show_published_checkbox_checked
0
     get :index, :published => '1'
0
     assert_response :success
0
- assert_tag 'input', :attributes => { :id => 'published', :type => 'checkbox', :checked => 'checked' }
0
+ assert_tag 'input', :attributes => { :id => 'article_published', :type => 'checkbox', :checked => 'checked' }
0
   end
0
 
0
   def test_should_show_published_checkbox_unchecked
0
     get :index, :published => '0'
0
     assert_response :success
0
- assert_tag 'input', :attributes => { :id => 'published', :type => 'checkbox' }
0
- assert_no_tag 'input', :attributes => { :id => 'published', :type => 'checkbox', :checked => 'checked' }
0
+ assert_tag 'input', :attributes => { :id => 'article_published', :type => 'checkbox' }
0
+ assert_no_tag 'input', :attributes => { :id => 'article_published', :type => 'checkbox', :checked => 'checked' }
0
   end
0
 
0
   def test_should_show_draft_checkbox_for_new_articles
...
1
2
3
4
 
 
5
6
 
7
8
9
10
 
11
12
13
...
16
17
18
19
 
20
21
22
...
25
26
27
28
 
29
30
31
...
33
34
35
36
37
 
 
38
39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
41
 
 
 
 
 
 
 
 
 
 
42
43
44
...
1
2
 
 
3
4
5
 
6
7
8
9
 
10
11
12
13
...
16
17
18
 
19
20
21
22
...
25
26
27
 
28
29
30
31
...
33
34
35
 
 
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
 
67
68
69
70
71
72
73
74
75
76
77
78
79
0
@@ -1,13 +1,13 @@
0
 require File.dirname(__FILE__) + '/../test_helper'
0
 
0
-class TaggingTest < Test::Unit::TestCase
0
- fixtures :taggings, :tags, :assets, :contents, :sites
0
+context "Asset Tagging" do
0
+ fixtures :taggings, :tags, :assets
0
 
0
- def test_should_show_taggable_tags
0
+ specify "should show taggable tags" do
0
     assert_models_equal [tags(:ruby)], assets(:gif).tags
0
   end
0
 
0
- def test_should_add_tags
0
+ specify "should add tags" do
0
     assert_difference Tagging, :count do
0
       assert_no_difference Tag, :count do
0
         Tagging.add_to assets(:gif), [tags(:rails)]
0
@@ -16,7 +16,7 @@ class TaggingTest < Test::Unit::TestCase
0
     assert_models_equal [tags(:rails), tags(:ruby)], assets(:gif).reload.tags
0
   end
0
 
0
- def test_should_delete_tags
0
+ specify "should delete tags" do
0
     assert_difference Tagging, :count, -1 do
0
       assert_no_difference Tag, :count do
0
         Tagging.delete_from assets(:gif), [tags(:ruby)]
0
@@ -25,7 +25,7 @@ class TaggingTest < Test::Unit::TestCase
0
     assert_equal [], assets(:gif).reload.tags
0
   end
0
   
0
- def test_should_change_tags
0
+ specify "should change tags" do
0
     assert_difference Tagging, :count, 2 do
0
       assert_difference Tag, :count do
0
         Tagging.set_on assets(:gif), 'rails, mongrel, foo'
0
@@ -33,12 +33,47 @@ class TaggingTest < Test::Unit::TestCase
0
     end
0
     assert_models_equal [Tag[:foo], tags(:mongrel), tags(:rails)], assets(:gif).reload.tags
0
   end
0
-
0
- def test_should_find_by_tags
0
+
0
+ specify "should find by tags" do
0
     assert_models_equal [assets(:gif)], Asset.find_tagged_with('ruby, rails')
0
   end
0
+end
0
+
0
+context "Article Tagging" do
0
+ fixtures :taggings, :tags, :contents, :sites
0
+
0
+ specify "should show taggable tags" do
0
+ assert_models_equal [tags(:rails)], contents(:another).tags
0
+ end
0
+
0
+ specify "should add tags" do
0
+ assert_difference Tagging, :count do
0
+ assert_no_difference Tag, :count do
0
+ Tagging.add_to contents(:another), [tags(:ruby)]
0
+ end
0
+ end
0
+ assert_models_equal [tags(:rails), tags(:ruby)], contents(:another).reload.tags
0
+ end
0
+
0
+ specify "should delete tags" do
0
+ assert_difference Tagging, :count, -1 do
0
+ assert_no_difference Tag, :count do
0
+ Tagging.delete_from contents(:another), [tags(:rails)]
0
+ end
0
+ end
0
+ assert_equal [], contents(:another).reload.tags
0
+ end
0
   
0
- def test_should_find_tags_by_site
0
+ specify "should change tags" do
0
+ assert_difference Tagging, :count, 2 do
0
+ assert_difference Tag, :count do
0
+ Tagging.set_on contents(:another), 'ruby, mongrel, foo'
0
+ end
0
+ end
0
+ assert_models_equal [Tag[:foo], tags(:mongrel), tags(:ruby)], contents(:another).reload.tags
0
+ end
0
+
0
+ specify "should find by tags in site" do
0
     assert_models_equal [tags(:rails)], sites(:first).tags
0
   end
0
 end

Comments

    No one has commented yet.