acts-as-taggable-on-simonwh 2.0.0.pre1

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.
@@ -0,0 +1,40 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe "Tagger" do
4
+ before(:each) do
5
+ clean_database!
6
+ @user = TaggableUser.new
7
+ @taggable = TaggableModel.new(:name => "Bob Jones")
8
+ end
9
+
10
+ it "should have taggings" do
11
+ @user.tag(@taggable, :with=>'ruby,scheme', :on=>:tags)
12
+ @user.owned_taggings.size == 2
13
+ end
14
+
15
+ it "should have tags" do
16
+ @user.tag(@taggable, :with=>'ruby,scheme', :on=>:tags)
17
+ @user.owned_tags.size == 2
18
+ end
19
+
20
+ it "should not overlap or lose tags from different users" do
21
+ @user2 = TaggableUser.new
22
+ lambda{
23
+ @user.tag(@taggable, :with => 'ruby, scheme', :on => :tags)
24
+ @user2.tag(@taggable, :with => 'java, python, lisp, ruby', :on => :tags)
25
+ }.should change(Tagging, :count).by(6)
26
+
27
+ @user.owned_tags.map(&:name).sort.should == %w(ruby scheme).sort
28
+ @user2.owned_tags.map(&:name).sort.should == %w(java python lisp ruby).sort
29
+
30
+ @taggable.tags_from(@user).sort.should == %w(ruby scheme).sort
31
+ @taggable.tags_from(@user2).sort.should == %w(java lisp python ruby).sort
32
+
33
+ @taggable.all_tags_list_on(:tags).sort.should == %w(ruby scheme java python lisp).sort
34
+ @taggable.all_tags_on(:tags).size.should == 6
35
+ end
36
+
37
+ it "is tagger" do
38
+ @user.is_tagger?.should(be_true)
39
+ end
40
+ end
@@ -0,0 +1,26 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Tagging do
4
+ before(:each) do
5
+ clean_database!
6
+ @tagging = Tagging.new
7
+ end
8
+
9
+ it "should not be valid with a invalid tag" do
10
+ @tagging.taggable = TaggableModel.create(:name => "Bob Jones")
11
+ @tagging.tag = Tag.new(:name => "")
12
+ @tagging.context = "tags"
13
+
14
+ @tagging.should_not be_valid
15
+ @tagging.errors[:tag_id].should == ["can't be blank"]
16
+ end
17
+
18
+ it "should not create duplicate taggings" do
19
+ @taggable = TaggableModel.create(:name => "Bob Jones")
20
+ @tag = Tag.create(:name => "awesome")
21
+
22
+ lambda {
23
+ 2.times { Tagging.create(:taggable => @taggable, :tag => @tag, :context => 'tags') }
24
+ }.should change(Tagging, :count).by(1)
25
+ end
26
+ end
@@ -0,0 +1,30 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe TagsHelper do
4
+ before(:each) do
5
+ clean_database!
6
+
7
+ @bob = TaggableModel.create(:name => "Bob Jones", :language_list => "ruby, php")
8
+ @tom = TaggableModel.create(:name => "Tom Marley", :language_list => "ruby, java")
9
+ @eve = TaggableModel.create(:name => "Eve Nodd", :language_list => "ruby, c++")
10
+
11
+ @helper = class Helper
12
+ include TagsHelper
13
+ end.new
14
+
15
+
16
+ end
17
+
18
+ it "should yield the proper css classes" do
19
+ tags = { }
20
+
21
+ @helper.tag_cloud(TaggableModel.tag_counts_on(:languages), ["sucky", "awesome"]) do |tag, css_class|
22
+ tags[tag.name] = css_class
23
+ end
24
+
25
+ tags["ruby"].should == "awesome"
26
+ tags["java"].should == "sucky"
27
+ tags["c++"].should == "sucky"
28
+ tags["php"].should == "sucky"
29
+ end
30
+ end
data/spec/schema.rb ADDED
@@ -0,0 +1,32 @@
1
+ ActiveRecord::Schema.define :version => 0 do
2
+ create_table "taggings", :force => true do |t|
3
+ t.integer "tag_id", :limit => 11
4
+ t.integer "taggable_id", :limit => 11
5
+ t.string "taggable_type"
6
+ t.string "context"
7
+ t.datetime "created_at"
8
+ t.integer "tagger_id", :limit => 11
9
+ t.string "tagger_type"
10
+ end
11
+
12
+ add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id"
13
+ add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context"
14
+
15
+ create_table "tags", :force => true do |t|
16
+ t.string "name"
17
+ end
18
+
19
+ create_table :taggable_models, :force => true do |t|
20
+ t.column :name, :string
21
+ t.column :type, :string
22
+ #t.column :cached_tag_list, :string
23
+ end
24
+ create_table :taggable_users, :force => true do |t|
25
+ t.column :name, :string
26
+ end
27
+ create_table :other_taggable_models, :force => true do |t|
28
+ t.column :name, :string
29
+ t.column :type, :string
30
+ #t.column :cached_tag_list, :string
31
+ end
32
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --backtrace
@@ -0,0 +1,75 @@
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"
7
+ require "bundler"
8
+ Bundler.setup
9
+ end
10
+ Bundler.require
11
+
12
+ require File.expand_path('../../lib/acts-as-taggable-on', __FILE__)
13
+
14
+ module Rspec::Core::ExampleGroupSubject
15
+ alias :context :describe
16
+ end
17
+
18
+ class Array
19
+ def freq
20
+ k=Hash.new(0)
21
+ each {|e| k[e]+=1}
22
+ k
23
+ end
24
+ end
25
+
26
+ TEST_DATABASE_FILE = File.join(File.dirname(__FILE__), '..', 'test.sqlite3')
27
+
28
+ File.unlink(TEST_DATABASE_FILE) if File.exist?(TEST_DATABASE_FILE)
29
+ ActiveRecord::Base.establish_connection(
30
+ "adapter" => "sqlite3", "database" => TEST_DATABASE_FILE
31
+ )
32
+
33
+ Rails.logger = Logger.new(File.join(File.dirname(__FILE__), "debug.log"))
34
+
35
+ ActiveRecord::Base.silence do
36
+ ActiveRecord::Migration.verbose = false
37
+ load(File.dirname(__FILE__) + '/schema.rb')
38
+ end
39
+
40
+ $: << File.join(File.dirname(__FILE__), '..', 'lib')
41
+
42
+ class TaggableModel < ActiveRecord::Base
43
+ acts_as_taggable
44
+ acts_as_taggable_on :languages
45
+ acts_as_taggable_on :skills
46
+ acts_as_taggable_on :needs, :offerings
47
+ end
48
+
49
+ class OtherTaggableModel < ActiveRecord::Base
50
+ acts_as_taggable_on :tags, :languages
51
+ acts_as_taggable_on :needs, :offerings
52
+ end
53
+
54
+ class InheritingTaggableModel < TaggableModel
55
+ end
56
+
57
+ class AlteredInheritingTaggableModel < TaggableModel
58
+ acts_as_taggable_on :parts
59
+ end
60
+
61
+ class TaggableUser < ActiveRecord::Base
62
+ acts_as_tagger
63
+ end
64
+
65
+ class UntaggableModel < ActiveRecord::Base
66
+ end
67
+
68
+ def clean_database!
69
+ $debug = false
70
+ models = [Tag, Tagging, TaggableModel, OtherTaggableModel, InheritingTaggableModel,
71
+ AlteredInheritingTaggableModel, TaggableUser]
72
+ models.each do |model|
73
+ model.destroy_all
74
+ end
75
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: acts-as-taggable-on-simonwh
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: true
5
+ segments:
6
+ - 2
7
+ - 0
8
+ - 0
9
+ - pre1
10
+ version: 2.0.0.pre1
11
+ platform: ruby
12
+ authors:
13
+ - Michael Bleigh
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-03-08 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: With ActsAsTaggableOn, you could tag a single model on several contexts, such as skills, interests, and awards. It also provides other advanced functionality.
23
+ email: michael@intridea.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files:
29
+ - README.rdoc
30
+ files:
31
+ - CHANGELOG
32
+ - Gemfile
33
+ - MIT-LICENSE
34
+ - README.rdoc
35
+ - Rakefile
36
+ - VERSION
37
+ - lib/acts-as-taggable-on.rb
38
+ - lib/acts_as_taggable_on/acts_as_taggable_on.rb
39
+ - lib/acts_as_taggable_on/acts_as_tagger.rb
40
+ - lib/acts_as_taggable_on/group_helper.rb
41
+ - lib/acts_as_taggable_on/tag.rb
42
+ - lib/acts_as_taggable_on/tag_list.rb
43
+ - lib/acts_as_taggable_on/tagging.rb
44
+ - lib/acts_as_taggable_on/tags_helper.rb
45
+ - lib/generators/acts_as_taggable_on/migration/migration_generator.rb
46
+ - lib/generators/acts_as_taggable_on/migration/templates/active_record/migration.rb
47
+ - spec/acts_as_taggable_on/acts_as_taggable_on_spec.rb
48
+ - spec/acts_as_taggable_on/acts_as_tagger_spec.rb
49
+ - spec/acts_as_taggable_on/group_helper_spec.rb
50
+ - spec/acts_as_taggable_on/tag_list_spec.rb
51
+ - spec/acts_as_taggable_on/tag_spec.rb
52
+ - spec/acts_as_taggable_on/taggable_spec.rb
53
+ - spec/acts_as_taggable_on/tagger_spec.rb
54
+ - spec/acts_as_taggable_on/tagging_spec.rb
55
+ - spec/acts_as_taggable_on/tags_helper_spec.rb
56
+ - spec/schema.rb
57
+ - spec/spec.opts
58
+ - spec/spec_helper.rb
59
+ has_rdoc: true
60
+ homepage: http://github.com/mbleigh/acts-as-taggable-on
61
+ licenses: []
62
+
63
+ post_install_message:
64
+ rdoc_options:
65
+ - --charset=UTF-8
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ segments:
73
+ - 0
74
+ version: "0"
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">"
78
+ - !ruby/object:Gem::Version
79
+ segments:
80
+ - 1
81
+ - 3
82
+ - 1
83
+ version: 1.3.1
84
+ requirements: []
85
+
86
+ rubyforge_project:
87
+ rubygems_version: 1.3.6
88
+ signing_key:
89
+ specification_version: 3
90
+ summary: ActsAsTaggableOn is a tagging plugin for Rails that provides multiple tagging contexts on a single model.
91
+ test_files:
92
+ - spec/acts_as_taggable_on/acts_as_taggable_on_spec.rb
93
+ - spec/acts_as_taggable_on/acts_as_tagger_spec.rb
94
+ - spec/acts_as_taggable_on/group_helper_spec.rb
95
+ - spec/acts_as_taggable_on/tag_list_spec.rb
96
+ - spec/acts_as_taggable_on/tag_spec.rb
97
+ - spec/acts_as_taggable_on/taggable_spec.rb
98
+ - spec/acts_as_taggable_on/tagger_spec.rb
99
+ - spec/acts_as_taggable_on/tagging_spec.rb
100
+ - spec/acts_as_taggable_on/tags_helper_spec.rb
101
+ - spec/schema.rb
102
+ - spec/spec_helper.rb