acts-as-taggable-on 2.0.0.pre1 → 2.0.0.pre3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,10 +30,26 @@ describe "Tagger" do
30
30
  @taggable.tags_from(@user).sort.should == %w(ruby scheme).sort
31
31
  @taggable.tags_from(@user2).sort.should == %w(java lisp python ruby).sort
32
32
 
33
- @taggable.all_tags_list_on(:tags).sort.should == %w(ruby scheme java python lisp).sort
33
+ @taggable.all_tags_list.sort.should == %w(ruby scheme java python lisp).sort
34
34
  @taggable.all_tags_on(:tags).size.should == 6
35
35
  end
36
36
 
37
+ it "should not lose tags" do
38
+ @taggable.update_attributes(:tag_list => 'ruby')
39
+ @user.tag(@taggable, :with => 'ruby, scheme', :on => :tags)
40
+
41
+ [@taggable, @user].each(&:reload)
42
+ @taggable.tag_list.should == %w(ruby)
43
+ @taggable.all_tags_list.sort.should == %w(ruby scheme).sort
44
+
45
+ lambda {
46
+ @taggable.update_attributes(:tag_list => "")
47
+ }.should change(Tagging, :count).by(-1)
48
+
49
+ @taggable.tag_list.should == []
50
+ @taggable.all_tags_list.sort.should == %w(ruby scheme).sort
51
+ end
52
+
37
53
  it "is tagger" do
38
54
  @user.is_tagger?.should(be_true)
39
55
  end
@@ -12,7 +12,12 @@ describe Tagging do
12
12
  @tagging.context = "tags"
13
13
 
14
14
  @tagging.should_not be_valid
15
- @tagging.errors[:tag_id].should == ["can't be blank"]
15
+
16
+ if ActiveRecord::VERSION::MAJOR >= 3
17
+ @tagging.errors[:tag_id].should == ["can't be blank"]
18
+ else
19
+ @tagging.errors[:tag_id].should == "can't be blank"
20
+ end
16
21
  end
17
22
 
18
23
  it "should not create duplicate taggings" do
@@ -11,8 +11,6 @@ describe TagsHelper do
11
11
  @helper = class Helper
12
12
  include TagsHelper
13
13
  end.new
14
-
15
-
16
14
  end
17
15
 
18
16
  it "should yield the proper css classes" do
@@ -0,0 +1,32 @@
1
+ class TaggableModel < ActiveRecord::Base
2
+ acts_as_taggable
3
+ acts_as_taggable_on :languages
4
+ acts_as_taggable_on :skills
5
+ acts_as_taggable_on :needs, :offerings
6
+ end
7
+
8
+ class OtherTaggableModel < ActiveRecord::Base
9
+ acts_as_taggable_on :tags, :languages
10
+ acts_as_taggable_on :needs, :offerings
11
+ end
12
+
13
+ class InheritingTaggableModel < TaggableModel
14
+ end
15
+
16
+ class AlteredInheritingTaggableModel < TaggableModel
17
+ acts_as_taggable_on :parts
18
+ end
19
+
20
+ class TaggableUser < ActiveRecord::Base
21
+ acts_as_tagger
22
+ end
23
+
24
+ class UntaggableModel < ActiveRecord::Base
25
+ end
26
+
27
+ if ActiveRecord::VERSION::MAJOR < 3
28
+ [TaggableModel, OtherTaggableModel, InheritingTaggableModel,
29
+ AlteredInheritingTaggableModel, TaggableUser, UntaggableModel].each do |klass|
30
+ klass.send(:include, ActsAsTaggableOn::ActiveRecord::Backports)
31
+ end
32
+ end
@@ -19,11 +19,13 @@ ActiveRecord::Schema.define :version => 0 do
19
19
  create_table :taggable_models, :force => true do |t|
20
20
  t.column :name, :string
21
21
  t.column :type, :string
22
- #t.column :cached_tag_list, :string
22
+ t.column :cached_tag_list, :string
23
23
  end
24
+
24
25
  create_table :taggable_users, :force => true do |t|
25
26
  t.column :name, :string
26
27
  end
28
+
27
29
  create_table :other_taggable_models, :force => true do |t|
28
30
  t.column :name, :string
29
31
  t.column :type, :string
@@ -1,8 +1,20 @@
1
+ begin
2
+ # Try to require the preresolved locked set of gems.
3
+ require File.expand_path("../.bundle/environment", __FILE__)
4
+ rescue LoadError
5
+ # Fall back on doing an unlocked resolve at runtime.
6
+ require "rubygems" unless RUBY_VERSION >= "1.9"
7
+ require "bundler"
8
+ Bundler.setup
9
+ end
10
+
11
+ Bundler.require
1
12
  require File.expand_path('../../lib/acts-as-taggable-on', __FILE__)
2
- Bundler.require :test
3
13
 
4
- module Rspec::Core::ExampleGroupSubject
5
- alias :context :describe
14
+ if defined?(Rspec::Core::ExampleGroupSubject)
15
+ module Rspec::Core::ExampleGroupSubject
16
+ alias :context :describe
17
+ end
6
18
  end
7
19
 
8
20
  class Array
@@ -13,46 +25,15 @@ class Array
13
25
  end
14
26
  end
15
27
 
28
+ # Setup a database
16
29
  TEST_DATABASE_FILE = File.join(File.dirname(__FILE__), '..', 'test.sqlite3')
17
-
18
30
  File.unlink(TEST_DATABASE_FILE) if File.exist?(TEST_DATABASE_FILE)
19
- ActiveRecord::Base.establish_connection(
20
- "adapter" => "sqlite3", "database" => TEST_DATABASE_FILE
21
- )
22
-
23
- Rails.logger = Logger.new(File.join(File.dirname(__FILE__), "debug.log"))
31
+ ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => TEST_DATABASE_FILE
24
32
 
25
33
  ActiveRecord::Base.silence do
26
34
  ActiveRecord::Migration.verbose = false
27
35
  load(File.dirname(__FILE__) + '/schema.rb')
28
- end
29
-
30
- $: << File.join(File.dirname(__FILE__), '..', 'lib')
31
-
32
- class TaggableModel < ActiveRecord::Base
33
- acts_as_taggable
34
- acts_as_taggable_on :languages
35
- acts_as_taggable_on :skills
36
- acts_as_taggable_on :needs, :offerings
37
- end
38
-
39
- class OtherTaggableModel < ActiveRecord::Base
40
- acts_as_taggable_on :tags, :languages
41
- acts_as_taggable_on :needs, :offerings
42
- end
43
-
44
- class InheritingTaggableModel < TaggableModel
45
- end
46
-
47
- class AlteredInheritingTaggableModel < TaggableModel
48
- acts_as_taggable_on :parts
49
- end
50
-
51
- class TaggableUser < ActiveRecord::Base
52
- acts_as_tagger
53
- end
54
-
55
- class UntaggableModel < ActiveRecord::Base
36
+ load(File.dirname(__FILE__) + '/models.rb')
56
37
  end
57
38
 
58
39
  def clean_database!
metadata CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 2
7
7
  - 0
8
8
  - 0
9
- - pre1
10
- version: 2.0.0.pre1
9
+ - pre3
10
+ version: 2.0.0.pre3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Bleigh
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-03-08 00:00:00 +01:00
18
+ date: 2010-03-22 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -36,8 +36,16 @@ files:
36
36
  - VERSION
37
37
  - lib/acts-as-taggable-on.rb
38
38
  - lib/acts_as_taggable_on/acts_as_taggable_on.rb
39
+ - lib/acts_as_taggable_on/acts_as_taggable_on/aggregate.rb
40
+ - lib/acts_as_taggable_on/acts_as_taggable_on/cache.rb
41
+ - lib/acts_as_taggable_on/acts_as_taggable_on/core.rb
42
+ - lib/acts_as_taggable_on/acts_as_taggable_on/ownership.rb
43
+ - lib/acts_as_taggable_on/acts_as_taggable_on/related.rb
39
44
  - lib/acts_as_taggable_on/acts_as_tagger.rb
40
- - lib/acts_as_taggable_on/group_helper.rb
45
+ - lib/acts_as_taggable_on/compatibility/Gemfile
46
+ - lib/acts_as_taggable_on/compatibility/active_record_backports.rb
47
+ - lib/acts_as_taggable_on/compatibility/tag.rb
48
+ - lib/acts_as_taggable_on/compatibility/tagging.rb
41
49
  - lib/acts_as_taggable_on/tag.rb
42
50
  - lib/acts_as_taggable_on/tag_list.rb
43
51
  - lib/acts_as_taggable_on/tagging.rb
@@ -46,13 +54,13 @@ files:
46
54
  - lib/generators/acts_as_taggable_on/migration/templates/active_record/migration.rb
47
55
  - spec/acts_as_taggable_on/acts_as_taggable_on_spec.rb
48
56
  - spec/acts_as_taggable_on/acts_as_tagger_spec.rb
49
- - spec/acts_as_taggable_on/group_helper_spec.rb
50
57
  - spec/acts_as_taggable_on/tag_list_spec.rb
51
58
  - spec/acts_as_taggable_on/tag_spec.rb
52
59
  - spec/acts_as_taggable_on/taggable_spec.rb
53
60
  - spec/acts_as_taggable_on/tagger_spec.rb
54
61
  - spec/acts_as_taggable_on/tagging_spec.rb
55
62
  - spec/acts_as_taggable_on/tags_helper_spec.rb
63
+ - spec/models.rb
56
64
  - spec/schema.rb
57
65
  - spec/spec.opts
58
66
  - spec/spec_helper.rb
@@ -91,12 +99,12 @@ summary: ActsAsTaggableOn is a tagging plugin for Rails that provides multiple t
91
99
  test_files:
92
100
  - spec/acts_as_taggable_on/acts_as_taggable_on_spec.rb
93
101
  - spec/acts_as_taggable_on/acts_as_tagger_spec.rb
94
- - spec/acts_as_taggable_on/group_helper_spec.rb
95
102
  - spec/acts_as_taggable_on/tag_list_spec.rb
96
103
  - spec/acts_as_taggable_on/tag_spec.rb
97
104
  - spec/acts_as_taggable_on/taggable_spec.rb
98
105
  - spec/acts_as_taggable_on/tagger_spec.rb
99
106
  - spec/acts_as_taggable_on/tagging_spec.rb
100
107
  - spec/acts_as_taggable_on/tags_helper_spec.rb
108
+ - spec/models.rb
101
109
  - spec/schema.rb
102
110
  - spec/spec_helper.rb
@@ -1,14 +0,0 @@
1
- module ActiveRecord
2
- module Acts
3
- module TaggableOn
4
- module GroupHelper
5
-
6
- # all column names are necessary for PostgreSQL group clause
7
- def grouped_column_names_for(object)
8
- object.column_names.map { |column| "#{object.table_name}.#{column}" }.join(", ")
9
- end
10
-
11
- end
12
- end
13
- end
14
- end
@@ -1,21 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
-
3
- describe "Group Helper" do
4
- before(:each) do
5
- clean_database!
6
- end
7
-
8
- describe "grouped_column_names_for method" do
9
- before(:each) do
10
- @taggable = TaggableModel.new(:name => "Bob Jones")
11
- end
12
-
13
- it "should return all column names joined for Tag GROUP clause" do
14
- @taggable.grouped_column_names_for(Tag).should == "tags.id, tags.name"
15
- end
16
-
17
- it "should return all column names joined for TaggableModel GROUP clause" do
18
- @taggable.grouped_column_names_for(TaggableModel).should == "taggable_models.id, taggable_models.name, taggable_models.type"
19
- end
20
- end
21
- end