protolif-acts_as_taggable_on_steroids 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.markdown +157 -0
- data/Rakefile +22 -0
- data/app/helpers/tags_helper.rb +13 -0
- data/app/models/tag.rb +63 -0
- data/app/models/tag_list.rb +109 -0
- data/app/models/tagging.rb +16 -0
- data/lib/acts_as_taggable.rb +2 -0
- data/lib/acts_as_taggable/active_record_extension.rb +244 -0
- data/lib/acts_as_taggable/engine.rb +16 -0
- data/lib/generators/acts_as_taggable_migration/acts_as_taggable_migration_generator.rb +24 -0
- data/lib/generators/acts_as_taggable_migration/templates/migration.rb +22 -0
- data/test/acts_as_taggable_test.rb +373 -0
- data/test/database.yml +11 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +9 -0
- data/test/dummy/app/assets/stylesheets/application.css +7 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/models/magazine.rb +3 -0
- data/test/dummy/app/models/photo.rb +8 -0
- data/test/dummy/app/models/post.rb +7 -0
- data/test/dummy/app/models/special_post.rb +2 -0
- data/test/dummy/app/models/subscription.rb +4 -0
- data/test/dummy/app/models/user.rb +7 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +45 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +30 -0
- data/test/dummy/config/environments/production.rb +60 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +10 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +58 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/schema.rb +48 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +2041 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +26 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/fixtures/magazines.yml +5 -0
- data/test/fixtures/photos.yml +19 -0
- data/test/fixtures/posts.yml +27 -0
- data/test/fixtures/subscriptions.yml +3 -0
- data/test/fixtures/taggings.yml +107 -0
- data/test/fixtures/tags.yml +14 -0
- data/test/fixtures/users.yml +5 -0
- data/test/support/query_counter.rb +29 -0
- data/test/tag_list_test.rb +119 -0
- data/test/tag_test.rb +63 -0
- data/test/tagging_test.rb +11 -0
- data/test/tags_helper_test.rb +25 -0
- data/test/test_helper.rb +61 -0
- metadata +189 -0
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TaggingTest < ActiveSupport::TestCase
|
4
|
+
def test_tag
|
5
|
+
assert_equal tags(:good), taggings(:jonathan_sky_good).tag
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_taggable
|
9
|
+
assert_equal posts(:jonathan_sky), taggings(:jonathan_sky_good).taggable
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TagsHelperTest < ActiveSupport::TestCase
|
4
|
+
include TagsHelper
|
5
|
+
|
6
|
+
def test_tag_cloud
|
7
|
+
cloud_elements = []
|
8
|
+
|
9
|
+
tag_cloud Post.tag_counts, %w(css1 css2 css3 css4) do |tag, css_class|
|
10
|
+
cloud_elements << [tag, css_class]
|
11
|
+
end
|
12
|
+
|
13
|
+
assert cloud_elements.include?([tags(:good), "css2"])
|
14
|
+
assert cloud_elements.include?([tags(:bad), "css1"])
|
15
|
+
assert cloud_elements.include?([tags(:nature), "css4"])
|
16
|
+
assert cloud_elements.include?([tags(:question), "css1"])
|
17
|
+
assert_equal 4, cloud_elements.size
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_tag_cloud_when_no_tags
|
21
|
+
tag_cloud SpecialPost.tag_counts, %w(css1) do
|
22
|
+
assert false, "tag_cloud should not yield"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
|
+
require "rails/test_help"
|
6
|
+
|
7
|
+
Rails.backtrace_cleaner.remove_silencers!
|
8
|
+
|
9
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
10
|
+
|
11
|
+
|
12
|
+
class ActiveSupport::TestCase #:nodoc:
|
13
|
+
include ActiveRecord::TestFixtures
|
14
|
+
|
15
|
+
self.fixture_path = File.dirname(__FILE__) + "/fixtures/"
|
16
|
+
|
17
|
+
self.use_transactional_fixtures = true
|
18
|
+
self.use_instantiated_fixtures = false
|
19
|
+
|
20
|
+
fixtures :all
|
21
|
+
|
22
|
+
def assert_equivalent(expected, actual, message = nil)
|
23
|
+
if expected.first.is_a?(ActiveRecord::Base)
|
24
|
+
assert_equal expected.sort_by(&:id), actual.sort_by(&:id), message
|
25
|
+
else
|
26
|
+
assert_equal expected.sort, actual.sort, message
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def assert_tag_counts(tags, expected_values)
|
31
|
+
# Map the tag fixture names to real tag names
|
32
|
+
expected_values = expected_values.inject({}) do |hash, (tag, count)|
|
33
|
+
hash[tags(tag).name] = count
|
34
|
+
hash
|
35
|
+
end
|
36
|
+
|
37
|
+
tags.each do |tag|
|
38
|
+
value = expected_values.delete(tag.name)
|
39
|
+
|
40
|
+
assert_not_nil value, "Expected count for #{tag.name} was not provided"
|
41
|
+
assert_equal value, tag.count, "Expected value of #{value} for #{tag.name}, but was #{tag.count}"
|
42
|
+
end
|
43
|
+
|
44
|
+
unless expected_values.empty?
|
45
|
+
assert false, "The following tag counts were not present: #{expected_values.inspect}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def assert_queries(expected_count = 1)
|
50
|
+
actual_count = ActiveRecord::Base.count_queries do
|
51
|
+
yield
|
52
|
+
end
|
53
|
+
ensure
|
54
|
+
assert_equal expected_count, actual_count, "Instead of the expected #{expected_count} queries, #{actual_count} actual queries were executed."
|
55
|
+
end
|
56
|
+
|
57
|
+
def assert_no_queries(&block)
|
58
|
+
assert_queries(0, &block)
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
metadata
ADDED
@@ -0,0 +1,189 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: protolif-acts_as_taggable_on_steroids
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.1.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- DHH
|
9
|
+
- Jonathan Viney
|
10
|
+
- Julien Portalier
|
11
|
+
- Bruno Bornsztein
|
12
|
+
- James Dunn
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
date: 2012-03-11 00:00:00.000000000 Z
|
17
|
+
dependencies:
|
18
|
+
- !ruby/object:Gem::Dependency
|
19
|
+
name: rails
|
20
|
+
requirement: &70249527740940 !ruby/object:Gem::Requirement
|
21
|
+
none: false
|
22
|
+
requirements:
|
23
|
+
- - ~>
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: 3.2.1
|
26
|
+
type: :runtime
|
27
|
+
prerelease: false
|
28
|
+
version_requirements: *70249527740940
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: sqlite3
|
31
|
+
requirement: &70249527740480 !ruby/object:Gem::Requirement
|
32
|
+
none: false
|
33
|
+
requirements:
|
34
|
+
- - ! '>='
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
type: :development
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: *70249527740480
|
40
|
+
description: Rails 3 tagging system based on a fork of a fork of a fork of acts_as_taggable
|
41
|
+
by DHH.
|
42
|
+
email: james.dunn+taggable@protolif.com
|
43
|
+
executables: []
|
44
|
+
extensions: []
|
45
|
+
extra_rdoc_files: []
|
46
|
+
files:
|
47
|
+
- app/helpers/tags_helper.rb
|
48
|
+
- app/models/tag.rb
|
49
|
+
- app/models/tag_list.rb
|
50
|
+
- app/models/tagging.rb
|
51
|
+
- lib/acts_as_taggable/active_record_extension.rb
|
52
|
+
- lib/acts_as_taggable/engine.rb
|
53
|
+
- lib/acts_as_taggable.rb
|
54
|
+
- lib/generators/acts_as_taggable_migration/acts_as_taggable_migration_generator.rb
|
55
|
+
- lib/generators/acts_as_taggable_migration/templates/migration.rb
|
56
|
+
- MIT-LICENSE
|
57
|
+
- Rakefile
|
58
|
+
- README.markdown
|
59
|
+
- test/acts_as_taggable_test.rb
|
60
|
+
- test/database.yml
|
61
|
+
- test/dummy/app/assets/javascripts/application.js
|
62
|
+
- test/dummy/app/assets/stylesheets/application.css
|
63
|
+
- test/dummy/app/controllers/application_controller.rb
|
64
|
+
- test/dummy/app/helpers/application_helper.rb
|
65
|
+
- test/dummy/app/models/magazine.rb
|
66
|
+
- test/dummy/app/models/photo.rb
|
67
|
+
- test/dummy/app/models/post.rb
|
68
|
+
- test/dummy/app/models/special_post.rb
|
69
|
+
- test/dummy/app/models/subscription.rb
|
70
|
+
- test/dummy/app/models/user.rb
|
71
|
+
- test/dummy/app/views/layouts/application.html.erb
|
72
|
+
- test/dummy/config/application.rb
|
73
|
+
- test/dummy/config/boot.rb
|
74
|
+
- test/dummy/config/database.yml
|
75
|
+
- test/dummy/config/environment.rb
|
76
|
+
- test/dummy/config/environments/development.rb
|
77
|
+
- test/dummy/config/environments/production.rb
|
78
|
+
- test/dummy/config/environments/test.rb
|
79
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
80
|
+
- test/dummy/config/initializers/inflections.rb
|
81
|
+
- test/dummy/config/initializers/mime_types.rb
|
82
|
+
- test/dummy/config/initializers/secret_token.rb
|
83
|
+
- test/dummy/config/initializers/session_store.rb
|
84
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
85
|
+
- test/dummy/config/locales/en.yml
|
86
|
+
- test/dummy/config/routes.rb
|
87
|
+
- test/dummy/config.ru
|
88
|
+
- test/dummy/db/development.sqlite3
|
89
|
+
- test/dummy/db/schema.rb
|
90
|
+
- test/dummy/db/test.sqlite3
|
91
|
+
- test/dummy/log/test.log
|
92
|
+
- test/dummy/public/404.html
|
93
|
+
- test/dummy/public/422.html
|
94
|
+
- test/dummy/public/500.html
|
95
|
+
- test/dummy/public/favicon.ico
|
96
|
+
- test/dummy/Rakefile
|
97
|
+
- test/dummy/script/rails
|
98
|
+
- test/fixtures/magazines.yml
|
99
|
+
- test/fixtures/photos.yml
|
100
|
+
- test/fixtures/posts.yml
|
101
|
+
- test/fixtures/subscriptions.yml
|
102
|
+
- test/fixtures/taggings.yml
|
103
|
+
- test/fixtures/tags.yml
|
104
|
+
- test/fixtures/users.yml
|
105
|
+
- test/support/query_counter.rb
|
106
|
+
- test/tag_list_test.rb
|
107
|
+
- test/tag_test.rb
|
108
|
+
- test/tagging_test.rb
|
109
|
+
- test/tags_helper_test.rb
|
110
|
+
- test/test_helper.rb
|
111
|
+
homepage: http://github.com/protolif/acts_as_taggable_on_steroids
|
112
|
+
licenses: []
|
113
|
+
post_install_message:
|
114
|
+
rdoc_options:
|
115
|
+
- --inline-source
|
116
|
+
- --charset=UTF-8
|
117
|
+
require_paths:
|
118
|
+
- lib
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
none: false
|
121
|
+
requirements:
|
122
|
+
- - ! '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
|
+
none: false
|
127
|
+
requirements:
|
128
|
+
- - ! '>='
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
requirements: []
|
132
|
+
rubyforge_project: acts_as_taggable_on_steroids
|
133
|
+
rubygems_version: 1.8.11
|
134
|
+
signing_key:
|
135
|
+
specification_version: 3
|
136
|
+
summary: Allows users to your models, without doing all of the work.
|
137
|
+
test_files:
|
138
|
+
- test/acts_as_taggable_test.rb
|
139
|
+
- test/database.yml
|
140
|
+
- test/dummy/app/assets/javascripts/application.js
|
141
|
+
- test/dummy/app/assets/stylesheets/application.css
|
142
|
+
- test/dummy/app/controllers/application_controller.rb
|
143
|
+
- test/dummy/app/helpers/application_helper.rb
|
144
|
+
- test/dummy/app/models/magazine.rb
|
145
|
+
- test/dummy/app/models/photo.rb
|
146
|
+
- test/dummy/app/models/post.rb
|
147
|
+
- test/dummy/app/models/special_post.rb
|
148
|
+
- test/dummy/app/models/subscription.rb
|
149
|
+
- test/dummy/app/models/user.rb
|
150
|
+
- test/dummy/app/views/layouts/application.html.erb
|
151
|
+
- test/dummy/config/application.rb
|
152
|
+
- test/dummy/config/boot.rb
|
153
|
+
- test/dummy/config/database.yml
|
154
|
+
- test/dummy/config/environment.rb
|
155
|
+
- test/dummy/config/environments/development.rb
|
156
|
+
- test/dummy/config/environments/production.rb
|
157
|
+
- test/dummy/config/environments/test.rb
|
158
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
159
|
+
- test/dummy/config/initializers/inflections.rb
|
160
|
+
- test/dummy/config/initializers/mime_types.rb
|
161
|
+
- test/dummy/config/initializers/secret_token.rb
|
162
|
+
- test/dummy/config/initializers/session_store.rb
|
163
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
164
|
+
- test/dummy/config/locales/en.yml
|
165
|
+
- test/dummy/config/routes.rb
|
166
|
+
- test/dummy/config.ru
|
167
|
+
- test/dummy/db/development.sqlite3
|
168
|
+
- test/dummy/db/schema.rb
|
169
|
+
- test/dummy/db/test.sqlite3
|
170
|
+
- test/dummy/log/test.log
|
171
|
+
- test/dummy/public/404.html
|
172
|
+
- test/dummy/public/422.html
|
173
|
+
- test/dummy/public/500.html
|
174
|
+
- test/dummy/public/favicon.ico
|
175
|
+
- test/dummy/Rakefile
|
176
|
+
- test/dummy/script/rails
|
177
|
+
- test/fixtures/magazines.yml
|
178
|
+
- test/fixtures/photos.yml
|
179
|
+
- test/fixtures/posts.yml
|
180
|
+
- test/fixtures/subscriptions.yml
|
181
|
+
- test/fixtures/taggings.yml
|
182
|
+
- test/fixtures/tags.yml
|
183
|
+
- test/fixtures/users.yml
|
184
|
+
- test/support/query_counter.rb
|
185
|
+
- test/tag_list_test.rb
|
186
|
+
- test/tag_test.rb
|
187
|
+
- test/tagging_test.rb
|
188
|
+
- test/tags_helper_test.rb
|
189
|
+
- test/test_helper.rb
|