diff options
| author | hukl <contact@smyck.org> | 2009-09-17 12:03:28 +0200 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-09-17 12:03:37 +0200 |
| commit | bd408aaae6d7a20fecc7673d807d3c88392cf516 (patch) | |
| tree | 0629c9fa5997bd21677c310130ad46942e2c6ace /vendor/plugins | |
| parent | c7b11c1ba050e23ea460e26073beba5b7f15c0f1 (diff) | |
switched tagging plugin again for postgresql compatibility
Diffstat (limited to 'vendor/plugins')
57 files changed, 1809 insertions, 915 deletions
diff --git a/vendor/plugins/acts_as_taggable_on_steroids/CHANGELOG b/vendor/plugins/acts_as_taggable_on_steroids/CHANGELOG new file mode 100644 index 0000000..5391c15 --- /dev/null +++ b/vendor/plugins/acts_as_taggable_on_steroids/CHANGELOG | |||
| @@ -0,0 +1,212 @@ | |||
| 1 | [11 Jun 09] | ||
| 2 | |||
| 3 | * Remove deprecated TagCountsExtension. | ||
| 4 | |||
| 5 | * Update tests to use foxy fixtures [Jonas Wagner] | ||
| 6 | |||
| 7 | * Allow hash conditions to be passed to Tag.counts [Jonas Wagner] | ||
| 8 | |||
| 9 | [3 Jun 09] | ||
| 10 | |||
| 11 | * Upgrade tests for Rails 2.3 | ||
| 12 | |||
| 13 | [18 Mar 09] | ||
| 14 | |||
| 15 | * Change callbacks used to save tags. | ||
| 16 | |||
| 17 | [18 Feb 09] | ||
| 18 | |||
| 19 | * Greatly improve speed when using find_tagged_with and :match_all [notonthehighstreet.com]. | ||
| 20 | |||
| 21 | [17 Sep 08] | ||
| 22 | |||
| 23 | * Sanitize scope conditions in find_options_for_tag_counts [Rémy-Christophe Schermesser] | ||
| 24 | |||
| 25 | [23 Aug 08] | ||
| 26 | |||
| 27 | * Fix tag_counts instance method when no tags are present. | ||
| 28 | |||
| 29 | * Make tag_counts instance_method merge any :conditions passed to it. | ||
| 30 | |||
| 31 | [30 Mar 08] | ||
| 32 | |||
| 33 | * Make TagList.from accept array arguments. | ||
| 34 | |||
| 35 | [29 Mar 08] | ||
| 36 | |||
| 37 | * Improve parsing of quotes inside tags [Arturas Slajus]. | ||
| 38 | |||
| 39 | * Add Tag.counts method. | ||
| 40 | |||
| 41 | [28 Mar 08] | ||
| 42 | |||
| 43 | * Make Tag#taggings :dependent => :destroy. | ||
| 44 | |||
| 45 | [27 Mar 08] | ||
| 46 | |||
| 47 | * Fix documentation for tag_counts. | ||
| 48 | |||
| 49 | [18 Mar 08] | ||
| 50 | |||
| 51 | * Add TagList#toggle [Pete Yandell]. | ||
| 52 | |||
| 53 | # Add find_related_tags method [Austin Foncaier]. | ||
| 54 | |||
| 55 | [30 Jan 08] | ||
| 56 | |||
| 57 | * Fix Tag.destroy_unused on Rails 2.0. | ||
| 58 | |||
| 59 | [23 October 2007] | ||
| 60 | |||
| 61 | * Make find_options_for_tag_counts and find_options_for_tagged_with dup their options. | ||
| 62 | |||
| 63 | * Apply conditions properly in find_options_for_tag_counts. | ||
| 64 | |||
| 65 | * Fix tag_cloud when no tags are present. | ||
| 66 | |||
| 67 | [22 October 2007] | ||
| 68 | |||
| 69 | * Fix find_tagged_with using :match_all and :include. | ||
| 70 | |||
| 71 | * Use inner joins instead of left outer joins. | ||
| 72 | |||
| 73 | [15 October 2007] | ||
| 74 | |||
| 75 | * Make find_tagged_with correctly apply :conditions | ||
| 76 | |||
| 77 | * Add Tag.destroy_unused option. | ||
| 78 | |||
| 79 | [11 October 2007] | ||
| 80 | |||
| 81 | * Make tag_counts work correctly with STI. | ||
| 82 | |||
| 83 | [3 October 2007] | ||
| 84 | |||
| 85 | * Improve documentation. | ||
| 86 | |||
| 87 | * Fix TagsHelper and test. | ||
| 88 | |||
| 89 | [2 October 2007] | ||
| 90 | |||
| 91 | * Remove TagList.parse, use TagList.from instead. | ||
| 92 | |||
| 93 | * Add :parse option to TagList#new, TagList#add, and TagList#remove. | ||
| 94 | |||
| 95 | tag_list = TagList.new("One, Two", :parse => true) # ["One", "Two"] | ||
| 96 | |||
| 97 | tag_list # ["One", "Two"] | ||
| 98 | tag_list.add("Three, Four", :parse => true) # ["One", "Two", "Three", "Four"] | ||
| 99 | |||
| 100 | * Remove TagList#names. | ||
| 101 | |||
| 102 | [29 September 2007] | ||
| 103 | |||
| 104 | * Add TagsHelper to assist with generating tag clouds and provide a simple example. | ||
| 105 | |||
| 106 | [27 September 2007] | ||
| 107 | |||
| 108 | * Add #tag_counts method to get tag counts for a specific object's tags. | ||
| 109 | |||
| 110 | * BACKWARDS INCOMPATIBILITY: Rename #find_options_for_tagged_with to #find_options_for_find_tagged_with | ||
| 111 | |||
| 112 | [17 September 2007] | ||
| 113 | |||
| 114 | * Fix clearing of cached tag list when all tags removed. | ||
| 115 | |||
| 116 | [12 September 2007] | ||
| 117 | |||
| 118 | * Make the TagList class inherit from Array. | ||
| 119 | |||
| 120 | * Deprecate obsolete TagList#names. | ||
| 121 | |||
| 122 | [6 September 2007] | ||
| 123 | |||
| 124 | * Add TagList#include? and TagList#empty? | ||
| 125 | |||
| 126 | [26 August 2007] | ||
| 127 | |||
| 128 | * Remove deprecated Tag.delimiter. Use TagList.delimiter instead. | ||
| 129 | |||
| 130 | [25 August 2007] | ||
| 131 | |||
| 132 | * Make tag_counts work with has_many :through | ||
| 133 | |||
| 134 | [23 August 2007] | ||
| 135 | |||
| 136 | * Make search comparisons case-insensitive across different databases. [Moisés Machado] | ||
| 137 | |||
| 138 | * Improve compatiblity with STI. [Moisés Machado] | ||
| 139 | |||
| 140 | [25 July 2007] | ||
| 141 | |||
| 142 | * Respect custom table names for the Tag and Tagging classes. | ||
| 143 | |||
| 144 | * Fix the :exclude option for find_tagged_with | ||
| 145 | |||
| 146 | [17 July 2007] | ||
| 147 | |||
| 148 | * Make the migration work on edge rails | ||
| 149 | |||
| 150 | [8 July 2007] | ||
| 151 | |||
| 152 | * find_options_for_tagged_with should not alter its arguments | ||
| 153 | |||
| 154 | [1 July 2007] | ||
| 155 | |||
| 156 | * Fix incorrect tagging when the case of the tag list is changed. | ||
| 157 | |||
| 158 | * Fix deprecated Tag.delimiter accessor. | ||
| 159 | |||
| 160 | [23 June 2007] | ||
| 161 | |||
| 162 | * Add validation to Tag model. | ||
| 163 | |||
| 164 | * find_options_for_tagged_with should always return a hash. | ||
| 165 | |||
| 166 | * find_tagged_with passing in no tags should return an empty array. | ||
| 167 | |||
| 168 | * Improve compatibility with PostgreSQL. | ||
| 169 | |||
| 170 | [21 June 2007] | ||
| 171 | |||
| 172 | * Remove extra .rb from generated migration file name. | ||
| 173 | |||
| 174 | [15 June 2007] | ||
| 175 | |||
| 176 | * Introduce TagList class. | ||
| 177 | |||
| 178 | * Various cleanups and improvements. | ||
| 179 | |||
| 180 | * Use TagList.delimiter now, not Tag.delimiter. Tag.delimiter will be removed at some stage. | ||
| 181 | |||
| 182 | [11 June 2007] | ||
| 183 | |||
| 184 | * Restructure the creation of the options for find_tagged_with [Thijs Cadier] | ||
| 185 | |||
| 186 | * Add an example migration with a generator. | ||
| 187 | |||
| 188 | * Add caching. | ||
| 189 | |||
| 190 | * Fix compatibility with Ruby < 1.8.6 | ||
| 191 | |||
| 192 | [23 April 2007] | ||
| 193 | |||
| 194 | * Make tag_list to respect Tag.delimiter | ||
| 195 | |||
| 196 | [31 March 2007] | ||
| 197 | |||
| 198 | * Add Tag.delimiter accessor to change how tags are parsed. | ||
| 199 | |||
| 200 | * Fix :include => :tags when used with find_tagged_with | ||
| 201 | |||
| 202 | [7 March 2007] | ||
| 203 | |||
| 204 | * Fix tag_counts for SQLServer [Brad Young] | ||
| 205 | |||
| 206 | [21 Feb 2007] | ||
| 207 | |||
| 208 | * Use scoping instead of TagCountsExtension [Michael Schuerig] | ||
| 209 | |||
| 210 | [7 Jan 2007] | ||
| 211 | |||
| 212 | * Add :match_all to find_tagged_with [Michael Sheakoski] | ||
diff --git a/vendor/plugins/acts_as_taggable_redux/MIT-LICENSE b/vendor/plugins/acts_as_taggable_on_steroids/MIT-LICENSE index c28cad7..602bda2 100644 --- a/vendor/plugins/acts_as_taggable_redux/MIT-LICENSE +++ b/vendor/plugins/acts_as_taggable_on_steroids/MIT-LICENSE | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | Copyright (c) 2007 monki(Wesley Beary) | 1 | Copyright (c) 2006 Jonathan Viney |
| 2 | 2 | ||
| 3 | Permission is hereby granted, free of charge, to any person obtaining | 3 | Permission is hereby granted, free of charge, to any person obtaining |
| 4 | a copy of this software and associated documentation files (the | 4 | a copy of this software and associated documentation files (the |
| @@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |||
| 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
| 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file | 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
diff --git a/vendor/plugins/acts_as_taggable_on_steroids/README b/vendor/plugins/acts_as_taggable_on_steroids/README new file mode 100644 index 0000000..b794030 --- /dev/null +++ b/vendor/plugins/acts_as_taggable_on_steroids/README | |||
| @@ -0,0 +1,151 @@ | |||
| 1 | = acts_as_taggable_on_steroids | ||
| 2 | |||
| 3 | If you find this plugin useful, please consider a donation to show your support! | ||
| 4 | |||
| 5 | http://www.paypal.com/cgi-bin/webscr?cmd=_send-money | ||
| 6 | |||
| 7 | Email address: jonathan.viney@gmail.com | ||
| 8 | |||
| 9 | == Instructions | ||
| 10 | |||
| 11 | This plugin is based on acts_as_taggable by DHH but includes extras | ||
| 12 | such as tests, smarter tag assignment, and tag cloud calculations. | ||
| 13 | |||
| 14 | == Installation | ||
| 15 | |||
| 16 | ruby script/plugin install git://github.com/jviney/acts_as_taggable_on_steroids.git | ||
| 17 | |||
| 18 | == Usage | ||
| 19 | |||
| 20 | === Prepare database | ||
| 21 | |||
| 22 | Generate and apply the migration: | ||
| 23 | |||
| 24 | ruby script/generate acts_as_taggable_migration | ||
| 25 | rake db:migrate | ||
| 26 | |||
| 27 | === Basic tagging | ||
| 28 | |||
| 29 | Let's suppose users have many posts and we want those posts to have tags. | ||
| 30 | The first step is to add +acts_as_taggable+ to the Post class: | ||
| 31 | |||
| 32 | class Post < ActiveRecord::Base | ||
| 33 | acts_as_taggable | ||
| 34 | |||
| 35 | belongs_to :user | ||
| 36 | end | ||
| 37 | |||
| 38 | We can now use the tagging methods provided by acts_as_taggable, <tt>#tag_list</tt> and <tt>#tag_list=</tt>. Both these | ||
| 39 | methods work like regular attribute accessors. | ||
| 40 | |||
| 41 | p = Post.find(:first) | ||
| 42 | p.tag_list # [] | ||
| 43 | p.tag_list = "Funny, Silly" | ||
| 44 | p.save | ||
| 45 | p.tag_list # ["Funny", "Silly"] | ||
| 46 | |||
| 47 | You can also add or remove arrays of tags. | ||
| 48 | |||
| 49 | p.tag_list.add("Great", "Awful") | ||
| 50 | p.tag_list.remove("Funny") | ||
| 51 | |||
| 52 | In your views you should use something like the following: | ||
| 53 | |||
| 54 | <%= f.label :tag_list %> | ||
| 55 | <%= f.text_field :tag_list, :size => 80 %> | ||
| 56 | |||
| 57 | === Finding tagged objects | ||
| 58 | |||
| 59 | To retrieve objects tagged with a certain tag, use find_tagged_with. | ||
| 60 | |||
| 61 | Post.find_tagged_with('Funny, Silly') | ||
| 62 | |||
| 63 | By default, find_tagged_with will find objects that have any of the given tags. To | ||
| 64 | find only objects that are tagged with all the given tags, use match_all. | ||
| 65 | |||
| 66 | Post.find_tagged_with('Funny, Silly', :match_all => true) | ||
| 67 | |||
| 68 | See <tt>ActiveRecord::Acts::Taggable::InstanceMethods</tt> for more methods and options. | ||
| 69 | |||
| 70 | === Tag cloud calculations | ||
| 71 | |||
| 72 | To construct tag clouds, the frequency of each tag needs to be calculated. | ||
| 73 | Because we specified +acts_as_taggable+ on the <tt>Post</tt> class, we can | ||
| 74 | get a calculation of all the tag counts by using <tt>Post.tag_counts</tt>. But what if we wanted a tag count for | ||
| 75 | an single user's posts? To achieve this we call tag_counts on the association: | ||
| 76 | |||
| 77 | User.find(:first).posts.tag_counts | ||
| 78 | |||
| 79 | A helper is included to assist with generating tag clouds. Include it in your helper file: | ||
| 80 | |||
| 81 | module ApplicationHelper | ||
| 82 | include TagsHelper | ||
| 83 | end | ||
| 84 | |||
| 85 | You can also use the <tt>counts</tt> method on <tt>Tag</tt> to get the counts for all tags in the database. | ||
| 86 | |||
| 87 | Tag.counts | ||
| 88 | |||
| 89 | Here is an example that generates a tag cloud. | ||
| 90 | |||
| 91 | Controller: | ||
| 92 | |||
| 93 | class PostController < ApplicationController | ||
| 94 | def tag_cloud | ||
| 95 | @tags = Post.tag_counts | ||
| 96 | end | ||
| 97 | end | ||
| 98 | |||
| 99 | View: | ||
| 100 | <% tag_cloud @tags, %w(css1 css2 css3 css4) do |tag, css_class| %> | ||
| 101 | <%= link_to tag.name, { :action => :tag, :id => tag.name }, :class => css_class %> | ||
| 102 | <% end %> | ||
| 103 | |||
| 104 | CSS: | ||
| 105 | |||
| 106 | .css1 { font-size: 1.0em; } | ||
| 107 | .css2 { font-size: 1.2em; } | ||
| 108 | .css3 { font-size: 1.4em; } | ||
| 109 | .css4 { font-size: 1.6em; } | ||
| 110 | |||
| 111 | === Caching | ||
| 112 | |||
| 113 | It is useful to cache the list of tags to reduce the number of queries executed. To do this, | ||
| 114 | add a column named <tt>cached_tag_list</tt> to the model which is being tagged. The column should be long enough to hold | ||
| 115 | the full tag list and must have a default value of null, not an empty string. | ||
| 116 | |||
| 117 | class CachePostTagList < ActiveRecord::Migration | ||
| 118 | def self.up | ||
| 119 | add_column :posts, :cached_tag_list, :string | ||
| 120 | end | ||
| 121 | end | ||
| 122 | |||
| 123 | class Post < ActiveRecord::Base | ||
| 124 | acts_as_taggable | ||
| 125 | |||
| 126 | # The caching column defaults to cached_tag_list, but can be changed: | ||
| 127 | # | ||
| 128 | # set_cached_tag_list_column_name "my_caching_column_name" | ||
| 129 | end | ||
| 130 | |||
| 131 | The details of the caching are handled for you. Just continue to use the tag_list accessor as you normally would. | ||
| 132 | Note that the cached tag list will not be updated if you directly create Tagging objects or manually append to the | ||
| 133 | <tt>tags</tt> or <tt>taggings</tt> associations. To update the cached tag list you should call <tt>save_cached_tag_list</tt> manually. | ||
| 134 | |||
| 135 | === Delimiter | ||
| 136 | |||
| 137 | If you want to change the delimiter used to parse and present tags, set TagList.delimiter. | ||
| 138 | For example, to use spaces instead of commas, add the following to config/environment.rb: | ||
| 139 | |||
| 140 | TagList.delimiter = " " | ||
| 141 | |||
| 142 | === Unused tags | ||
| 143 | |||
| 144 | Set Tag.destroy_unused to remove tags when they are no longer being | ||
| 145 | used to tag any objects. Defaults to false. | ||
| 146 | |||
| 147 | Tag.destroy_unused = true | ||
| 148 | |||
| 149 | === Other | ||
| 150 | |||
| 151 | Problems, comments, and suggestions all welcome. jonathan.viney@gmail.com | ||
diff --git a/vendor/plugins/acts_as_taggable_redux/Rakefile b/vendor/plugins/acts_as_taggable_on_steroids/Rakefile index 3c968e2..93c2706 100644 --- a/vendor/plugins/acts_as_taggable_redux/Rakefile +++ b/vendor/plugins/acts_as_taggable_on_steroids/Rakefile | |||
| @@ -5,17 +5,17 @@ require 'rake/rdoctask' | |||
| 5 | desc 'Default: run unit tests.' | 5 | desc 'Default: run unit tests.' |
| 6 | task :default => :test | 6 | task :default => :test |
| 7 | 7 | ||
| 8 | desc 'Test the acts_as_taggable_redux plugin.' | 8 | desc 'Test the acts_as_taggable_on_steroids plugin.' |
| 9 | Rake::TestTask.new(:test) do |t| | 9 | Rake::TestTask.new(:test) do |t| |
| 10 | t.libs << 'lib' | 10 | t.libs << 'test' |
| 11 | t.pattern = 'test/**/*_test.rb' | 11 | t.pattern = 'test/**/*_test.rb' |
| 12 | t.verbose = true | 12 | t.verbose = true |
| 13 | end | 13 | end |
| 14 | 14 | ||
| 15 | desc 'Generate documentation for the acts_as_taggable_redux plugin.' | 15 | desc 'Generate documentation for the acts_as_taggable_on_steroids plugin.' |
| 16 | Rake::RDocTask.new(:rdoc) do |rdoc| | 16 | Rake::RDocTask.new(:rdoc) do |rdoc| |
| 17 | rdoc.rdoc_dir = 'rdoc' | 17 | rdoc.rdoc_dir = 'rdoc' |
| 18 | rdoc.title = 'ActsAsTaggableRedux' | 18 | rdoc.title = 'Acts As Taggable On Steroids' |
| 19 | rdoc.options << '--line-numbers' << '--inline-source' | 19 | rdoc.options << '--line-numbers' << '--inline-source' |
| 20 | rdoc.rdoc_files.include('README') | 20 | rdoc.rdoc_files.include('README') |
| 21 | rdoc.rdoc_files.include('lib/**/*.rb') | 21 | rdoc.rdoc_files.include('lib/**/*.rb') |
diff --git a/vendor/plugins/acts_as_taggable_on_steroids/acts_as_taggable_on_steroids.gemspec b/vendor/plugins/acts_as_taggable_on_steroids/acts_as_taggable_on_steroids.gemspec new file mode 100644 index 0000000..f91ad4d --- /dev/null +++ b/vendor/plugins/acts_as_taggable_on_steroids/acts_as_taggable_on_steroids.gemspec | |||
| @@ -0,0 +1,54 @@ | |||
| 1 | Gem::Specification.new do |s| | ||
| 2 | s.name = "acts_as_taggable_on_steroids" | ||
| 3 | s.version = "1.1" | ||
| 4 | s.date = "2009-06-11" | ||
| 5 | s.summary = "Rails plugin that is based on acts_as_taggable by DHH but includes extras such as tests, smarter tag assignment, and tag cloud calculations." | ||
| 6 | s.email = "jonathan.viney@gmail.com" | ||
| 7 | s.homepage = "http://github.com/jviney/acts_as_taggable_on_steroids" | ||
| 8 | s.description = "Rails plugin that is based on acts_as_taggable by DHH but includes extras such as tests, smarter tag assignment, and tag cloud calculations." | ||
| 9 | s.has_rdoc = true | ||
| 10 | s.rdoc_options = ["--inline-source", "--charset=UTF-8"] | ||
| 11 | s.rubyforge_project = "acts_as_taggable_on_steroids" | ||
| 12 | s.authors = "Jonathan Viney" | ||
| 13 | s.files = [ | ||
| 14 | "acts_as_taggable_on_steroids.gemspec", | ||
| 15 | "CHANGELOG", | ||
| 16 | "generators/acts_as_taggable_migration", | ||
| 17 | "generators/acts_as_taggable_migration/acts_as_taggable_migration_generator.rb", | ||
| 18 | "generators/acts_as_taggable_migration/templates", | ||
| 19 | "generators/acts_as_taggable_migration/templates/migration.rb", | ||
| 20 | "init.rb", | ||
| 21 | "lib/acts_as_taggable.rb", | ||
| 22 | "lib/tag.rb", | ||
| 23 | "lib/tag_list.rb", | ||
| 24 | "lib/tagging.rb", | ||
| 25 | "lib/tags_helper.rb", | ||
| 26 | "MIT-LICENSE", | ||
| 27 | "Rakefile", | ||
| 28 | "README", | ||
| 29 | ] | ||
| 30 | s.test_files = [ | ||
| 31 | "test/abstract_unit.rb", | ||
| 32 | "test/acts_as_taggable_test.rb", | ||
| 33 | "test/database.yml", | ||
| 34 | "test/fixtures", | ||
| 35 | "test/fixtures/magazine.rb", | ||
| 36 | "test/fixtures/magazines.yml", | ||
| 37 | "test/fixtures/photo.rb", | ||
| 38 | "test/fixtures/photos.yml", | ||
| 39 | "test/fixtures/post.rb", | ||
| 40 | "test/fixtures/posts.yml", | ||
| 41 | "test/fixtures/special_post.rb", | ||
| 42 | "test/fixtures/subscription.rb", | ||
| 43 | "test/fixtures/subscriptions.yml", | ||
| 44 | "test/fixtures/taggings.yml", | ||
| 45 | "test/fixtures/tags.yml", | ||
| 46 | "test/fixtures/user.rb", | ||
| 47 | "test/fixtures/users.yml", | ||
| 48 | "test/schema.rb", | ||
| 49 | "test/tag_list_test.rb", | ||
| 50 | "test/tag_test.rb", | ||
| 51 | "test/tagging_test.rb", | ||
| 52 | "test/tags_helper_test.rb" | ||
| 53 | ] | ||
| 54 | end | ||
diff --git a/vendor/plugins/acts_as_taggable_on_steroids/generators/acts_as_taggable_migration/acts_as_taggable_migration_generator.rb b/vendor/plugins/acts_as_taggable_on_steroids/generators/acts_as_taggable_migration/acts_as_taggable_migration_generator.rb new file mode 100644 index 0000000..be9b39c --- /dev/null +++ b/vendor/plugins/acts_as_taggable_on_steroids/generators/acts_as_taggable_migration/acts_as_taggable_migration_generator.rb | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | class ActsAsTaggableMigrationGenerator < Rails::Generator::Base | ||
| 2 | def manifest | ||
| 3 | record do |m| | ||
| 4 | m.migration_template 'migration.rb', 'db/migrate' | ||
| 5 | end | ||
| 6 | end | ||
| 7 | |||
| 8 | def file_name | ||
| 9 | "acts_as_taggable_migration" | ||
| 10 | end | ||
| 11 | end | ||
diff --git a/vendor/plugins/acts_as_taggable_on_steroids/generators/acts_as_taggable_migration/templates/migration.rb b/vendor/plugins/acts_as_taggable_on_steroids/generators/acts_as_taggable_migration/templates/migration.rb new file mode 100644 index 0000000..ea0c2cc --- /dev/null +++ b/vendor/plugins/acts_as_taggable_on_steroids/generators/acts_as_taggable_migration/templates/migration.rb | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | class ActsAsTaggableMigration < ActiveRecord::Migration | ||
| 2 | def self.up | ||
| 3 | create_table :tags do |t| | ||
| 4 | t.column :name, :string | ||
| 5 | end | ||
| 6 | |||
| 7 | create_table :taggings do |t| | ||
| 8 | t.column :tag_id, :integer | ||
| 9 | t.column :taggable_id, :integer | ||
| 10 | |||
| 11 | # You should make sure that the column created is | ||
| 12 | # long enough to store the required class names. | ||
| 13 | t.column :taggable_type, :string | ||
| 14 | |||
| 15 | t.column :created_at, :datetime | ||
| 16 | end | ||
| 17 | |||
| 18 | add_index :taggings, :tag_id | ||
| 19 | add_index :taggings, [:taggable_id, :taggable_type] | ||
| 20 | end | ||
| 21 | |||
| 22 | def self.down | ||
| 23 | drop_table :taggings | ||
| 24 | drop_table :tags | ||
| 25 | end | ||
| 26 | end | ||
diff --git a/vendor/plugins/acts_as_taggable_on_steroids/init.rb b/vendor/plugins/acts_as_taggable_on_steroids/init.rb new file mode 100644 index 0000000..64505b9 --- /dev/null +++ b/vendor/plugins/acts_as_taggable_on_steroids/init.rb | |||
| @@ -0,0 +1 @@ | |||
| require File.dirname(__FILE__) + '/lib/acts_as_taggable' | |||
diff --git a/vendor/plugins/acts_as_taggable_on_steroids/lib/acts_as_taggable.rb b/vendor/plugins/acts_as_taggable_on_steroids/lib/acts_as_taggable.rb new file mode 100644 index 0000000..7a96ef0 --- /dev/null +++ b/vendor/plugins/acts_as_taggable_on_steroids/lib/acts_as_taggable.rb | |||
| @@ -0,0 +1,230 @@ | |||
| 1 | module ActiveRecord #:nodoc: | ||
| 2 | module Acts #:nodoc: | ||
| 3 | module Taggable #:nodoc: | ||
| 4 | def self.included(base) | ||
| 5 | base.extend(ClassMethods) | ||
| 6 | end | ||
| 7 | |||
| 8 | module ClassMethods | ||
| 9 | def acts_as_taggable | ||
| 10 | has_many :taggings, :as => :taggable, :dependent => :destroy, :include => :tag | ||
| 11 | has_many :tags, :through => :taggings | ||
| 12 | |||
| 13 | before_save :save_cached_tag_list | ||
| 14 | |||
| 15 | after_create :save_tags | ||
| 16 | after_update :save_tags | ||
| 17 | |||
| 18 | include ActiveRecord::Acts::Taggable::InstanceMethods | ||
| 19 | extend ActiveRecord::Acts::Taggable::SingletonMethods | ||
| 20 | |||
| 21 | alias_method_chain :reload, :tag_list | ||
| 22 | end | ||
| 23 | |||
| 24 | def cached_tag_list_column_name | ||
| 25 | "cached_tag_list" | ||
| 26 | end | ||
| 27 | |||
| 28 | def set_cached_tag_list_column_name(value = nil, &block) | ||
| 29 | define_attr_method :cached_tag_list_column_name, value, &block | ||
| 30 | end | ||
| 31 | end | ||
| 32 | |||
| 33 | module SingletonMethods | ||
| 34 | # Returns an array of related tags. | ||
| 35 | # Related tags are all the other tags that are found on the models tagged with the provided tags. | ||
| 36 | # | ||
| 37 | # Pass either a tag, string, or an array of strings or tags. | ||
| 38 | # | ||
| 39 | # Options: | ||
| 40 | # :order - SQL Order how to order the tags. Defaults to "count DESC, tags.name". | ||
| 41 | def find_related_tags(tags, options = {}) | ||
| 42 | tags = tags.is_a?(Array) ? TagList.new(tags.map(&:to_s)) : TagList.from(tags) | ||
| 43 | |||
| 44 | related_models = find_tagged_with(tags) | ||
| 45 | |||
| 46 | return [] if related_models.blank? | ||
| 47 | |||
| 48 | related_ids = related_models.to_s(:db) | ||
| 49 | |||
| 50 | Tag.find(:all, options.merge({ | ||
| 51 | :select => "#{Tag.table_name}.*, COUNT(#{Tag.table_name}.id) AS count", | ||
| 52 | :joins => "JOIN #{Tagging.table_name} ON #{Tagging.table_name}.taggable_type = '#{base_class.name}' | ||
| 53 | AND #{Tagging.table_name}.taggable_id IN (#{related_ids}) | ||
| 54 | AND #{Tagging.table_name}.tag_id = #{Tag.table_name}.id", | ||
| 55 | :order => options[:order] || "count DESC, #{Tag.table_name}.name", | ||
| 56 | :group => "#{Tag.table_name}.id, #{Tag.table_name}.name HAVING #{Tag.table_name}.name NOT IN (#{tags.map { |n| quote_value(n) }.join(",")})" | ||
| 57 | })) | ||
| 58 | end | ||
| 59 | |||
| 60 | # Pass either a tag, string, or an array of strings or tags. | ||
| 61 | # | ||
| 62 | # Options: | ||
| 63 | # :exclude - Find models that are not tagged with the given tags | ||
| 64 | # :match_all - Find models that match all of the given tags, not just one | ||
| 65 | # :conditions - A piece of SQL conditions to add to the query | ||
| 66 | def find_tagged_with(*args) | ||
| 67 | options = find_options_for_find_tagged_with(*args) | ||
| 68 | options.blank? ? [] : find(:all, options) | ||
| 69 | end | ||
| 70 | |||
| 71 | def find_options_for_find_tagged_with(tags, options = {}) | ||
| 72 | tags = tags.is_a?(Array) ? TagList.new(tags.map(&:to_s)) : TagList.from(tags) | ||
| 73 | options = options.dup | ||
| 74 | |||
| 75 | return {} if tags.empty? | ||
| 76 | |||
| 77 | conditions = [] | ||
| 78 | conditions << sanitize_sql(options.delete(:conditions)) if options[:conditions] | ||
| 79 | |||
| 80 | taggings_alias, tags_alias = "#{table_name}_taggings", "#{table_name}_tags" | ||
| 81 | |||
| 82 | joins = [ | ||
| 83 | "INNER JOIN #{Tagging.table_name} #{taggings_alias} ON #{taggings_alias}.taggable_id = #{table_name}.#{primary_key} AND #{taggings_alias}.taggable_type = #{quote_value(base_class.name)}", | ||
| 84 | "INNER JOIN #{Tag.table_name} #{tags_alias} ON #{tags_alias}.id = #{taggings_alias}.tag_id" | ||
| 85 | ] | ||
| 86 | |||
| 87 | if options.delete(:exclude) | ||
| 88 | conditions << <<-END | ||
| 89 | #{table_name}.id NOT IN | ||
| 90 | (SELECT #{Tagging.table_name}.taggable_id FROM #{Tagging.table_name} | ||
| 91 | INNER JOIN #{Tag.table_name} ON #{Tagging.table_name}.tag_id = #{Tag.table_name}.id | ||
| 92 | WHERE #{tags_condition(tags)} AND #{Tagging.table_name}.taggable_type = #{quote_value(base_class.name)}) | ||
| 93 | END | ||
| 94 | else | ||
| 95 | if options.delete(:match_all) | ||
| 96 | joins << joins_for_match_all_tags(tags) | ||
| 97 | else | ||
| 98 | conditions << tags_condition(tags, tags_alias) | ||
| 99 | end | ||
| 100 | end | ||
| 101 | |||
| 102 | { :select => "DISTINCT #{table_name}.*", | ||
| 103 | :joins => joins.join(" "), | ||
| 104 | :conditions => conditions.join(" AND ") | ||
| 105 | }.reverse_merge!(options) | ||
| 106 | end | ||
| 107 | |||
| 108 | def joins_for_match_all_tags(tags) | ||
| 109 | joins = [] | ||
| 110 | |||
| 111 | tags.each_with_index do |tag, index| | ||
| 112 | taggings_alias, tags_alias = "taggings_#{index}", "tags_#{index}" | ||
| 113 | |||
| 114 | join = <<-END | ||
| 115 | INNER JOIN #{Tagging.table_name} #{taggings_alias} ON | ||
| 116 | #{taggings_alias}.taggable_id = #{table_name}.#{primary_key} AND | ||
| 117 | #{taggings_alias}.taggable_type = #{quote_value(base_class.name)} | ||
| 118 | |||
| 119 | INNER JOIN #{Tag.table_name} #{tags_alias} ON | ||
| 120 | #{taggings_alias}.tag_id = #{tags_alias}.id AND | ||
| 121 | #{tags_alias}.name = ? | ||
| 122 | END | ||
| 123 | |||
| 124 | joins << sanitize_sql([join, tag]) | ||
| 125 | end | ||
| 126 | |||
| 127 | joins.join(" ") | ||
| 128 | end | ||
| 129 | |||
| 130 | # Calculate the tag counts for all tags. | ||
| 131 | # | ||
| 132 | # See Tag.counts for available options. | ||
| 133 | def tag_counts(options = {}) | ||
| 134 | Tag.find(:all, find_options_for_tag_counts(options)) | ||
| 135 | end | ||
| 136 | |||
| 137 | def find_options_for_tag_counts(options = {}) | ||
| 138 | options = options.dup | ||
| 139 | scope = scope(:find) | ||
| 140 | |||
| 141 | conditions = [] | ||
| 142 | conditions << send(:sanitize_conditions, options.delete(:conditions)) if options[:conditions] | ||
| 143 | conditions << send(:sanitize_conditions, scope[:conditions]) if scope && scope[:conditions] | ||
| 144 | conditions << "#{Tagging.table_name}.taggable_type = #{quote_value(base_class.name)}" | ||
| 145 | conditions << type_condition unless descends_from_active_record? | ||
| 146 | conditions.compact! | ||
| 147 | conditions = conditions.join(" AND ") | ||
| 148 | |||
| 149 | joins = ["INNER JOIN #{table_name} ON #{table_name}.#{primary_key} = #{Tagging.table_name}.taggable_id"] | ||
| 150 | joins << options.delete(:joins) if options[:joins] | ||
| 151 | joins << scope[:joins] if scope && scope[:joins] | ||
| 152 | joins = joins.join(" ") | ||
| 153 | |||
| 154 | options = { :conditions => conditions, :joins => joins }.update(options) | ||
| 155 | |||
| 156 | Tag.options_for_counts(options) | ||
| 157 | end | ||
| 158 | |||
| 159 | def caching_tag_list? | ||
| 160 | column_names.include?(cached_tag_list_column_name) | ||
| 161 | end | ||
| 162 | |||
| 163 | private | ||
| 164 | def tags_condition(tags, table_name = Tag.table_name) | ||
| 165 | condition = tags.map { |t| sanitize_sql(["#{table_name}.name LIKE ?", t]) }.join(" OR ") | ||
| 166 | "(" + condition + ")" unless condition.blank? | ||
| 167 | end | ||
| 168 | end | ||
| 169 | |||
| 170 | module InstanceMethods | ||
| 171 | def tag_list | ||
| 172 | return @tag_list if @tag_list | ||
| 173 | |||
| 174 | if self.class.caching_tag_list? and !(cached_value = send(self.class.cached_tag_list_column_name)).nil? | ||
| 175 | @tag_list = TagList.from(cached_value) | ||
| 176 | else | ||
| 177 | @tag_list = TagList.new(*tags.map(&:name)) | ||
| 178 | end | ||
| 179 | end | ||
| 180 | |||
| 181 | def tag_list=(value) | ||
| 182 | @tag_list = TagList.from(value) | ||
| 183 | end | ||
| 184 | |||
| 185 | def save_cached_tag_list | ||
| 186 | if self.class.caching_tag_list? | ||
| 187 | self[self.class.cached_tag_list_column_name] = tag_list.to_s | ||
| 188 | end | ||
| 189 | end | ||
| 190 | |||
| 191 | def save_tags | ||
| 192 | return unless @tag_list | ||
| 193 | |||
| 194 | new_tag_names = @tag_list - tags.map(&:name) | ||
| 195 | old_tags = tags.reject { |tag| @tag_list.include?(tag.name) } | ||
| 196 | |||
| 197 | self.class.transaction do | ||
| 198 | if old_tags.any? | ||
| 199 | taggings.find(:all, :conditions => ["tag_id IN (?)", old_tags.map(&:id)]).each(&:destroy) | ||
| 200 | taggings.reset | ||
| 201 | end | ||
| 202 | |||
| 203 | new_tag_names.each do |new_tag_name| | ||
| 204 | tags << Tag.find_or_create_with_like_by_name(new_tag_name) | ||
| 205 | end | ||
| 206 | end | ||
| 207 | |||
| 208 | true | ||
| 209 | end | ||
| 210 | |||
| 211 | # Calculate the tag counts for the tags used by this model. | ||
| 212 | # | ||
| 213 | # The possible options are the same as the tag_counts class method. | ||
| 214 | def tag_counts(options = {}) | ||
| 215 | return [] if tag_list.blank? | ||
| 216 | |||
| 217 | options[:conditions] = self.class.send(:merge_conditions, options[:conditions], self.class.send(:tags_condition, tag_list)) | ||
| 218 | self.class.tag_counts(options) | ||
| 219 | end | ||
| 220 | |||
| 221 | def reload_with_tag_list(*args) #:nodoc: | ||
| 222 | @tag_list = nil | ||
| 223 | reload_without_tag_list(*args) | ||
| 224 | end | ||
| 225 | end | ||
| 226 | end | ||
| 227 | end | ||
| 228 | end | ||
| 229 | |||
| 230 | ActiveRecord::Base.send(:include, ActiveRecord::Acts::Taggable) | ||
diff --git a/vendor/plugins/acts_as_taggable_on_steroids/lib/tag.rb b/vendor/plugins/acts_as_taggable_on_steroids/lib/tag.rb new file mode 100644 index 0000000..44f0991 --- /dev/null +++ b/vendor/plugins/acts_as_taggable_on_steroids/lib/tag.rb | |||
| @@ -0,0 +1,71 @@ | |||
| 1 | class Tag < ActiveRecord::Base | ||
| 2 | has_many :taggings, :dependent => :destroy | ||
| 3 | |||
| 4 | validates_presence_of :name | ||
| 5 | validates_uniqueness_of :name | ||
| 6 | |||
| 7 | cattr_accessor :destroy_unused | ||
| 8 | self.destroy_unused = false | ||
| 9 | |||
| 10 | # LIKE is used for cross-database case-insensitivity | ||
| 11 | def self.find_or_create_with_like_by_name(name) | ||
| 12 | find(:first, :conditions => ["name LIKE ?", name]) || create(:name => name) | ||
| 13 | end | ||
| 14 | |||
| 15 | def ==(object) | ||
| 16 | super || (object.is_a?(Tag) && name == object.name) | ||
| 17 | end | ||
| 18 | |||
| 19 | def to_s | ||
| 20 | name | ||
| 21 | end | ||
| 22 | |||
| 23 | def count | ||
| 24 | read_attribute(:count).to_i | ||
| 25 | end | ||
| 26 | |||
| 27 | class << self | ||
| 28 | # Calculate the tag counts for all tags. | ||
| 29 | # :start_at - Restrict the tags to those created after a certain time | ||
| 30 | # :end_at - Restrict the tags to those created before a certain time | ||
| 31 | # :conditions - A piece of SQL conditions to add to the query | ||
| 32 | # :limit - The maximum number of tags to return | ||
| 33 | # :order - A piece of SQL to order by. Eg 'count desc' or 'taggings.created_at desc' | ||
| 34 | # :at_least - Exclude tags with a frequency less than the given value | ||
| 35 | # :at_most - Exclude tags with a frequency greater than the given value | ||
| 36 | def counts(options = {}) | ||
| 37 | find(:all, options_for_counts(options)) | ||
| 38 | end | ||
| 39 | |||
| 40 | def options_for_counts(options = {}) | ||
| 41 | options.assert_valid_keys :start_at, :end_at, :conditions, :at_least, :at_most, :order, :limit, :joins | ||
| 42 | options = options.dup | ||
| 43 | |||
| 44 | start_at = sanitize_sql(["#{Tagging.table_name}.created_at >= ?", options.delete(:start_at)]) if options[:start_at] | ||
| 45 | end_at = sanitize_sql(["#{Tagging.table_name}.created_at <= ?", options.delete(:end_at)]) if options[:end_at] | ||
| 46 | |||
| 47 | conditions = [ | ||
| 48 | (sanitize_sql(options.delete(:conditions)) if options[:conditions]), | ||
| 49 | start_at, | ||
| 50 | end_at | ||
| 51 | ].compact | ||
| 52 | |||
| 53 | conditions = conditions.join(' AND ') if conditions.any? | ||
| 54 | |||
| 55 | joins = ["INNER JOIN #{Tagging.table_name} ON #{Tag.table_name}.id = #{Tagging.table_name}.tag_id"] | ||
| 56 | joins << options.delete(:joins) if options[:joins] | ||
| 57 | |||
| 58 | at_least = sanitize_sql(['COUNT(*) >= ?', options.delete(:at_least)]) if options[:at_least] | ||
| 59 | at_most = sanitize_sql(['COUNT(*) <= ?', options.delete(:at_most)]) if options[:at_most] | ||
| 60 | having = [at_least, at_most].compact.join(' AND ') | ||
| 61 | group_by = "#{Tag.table_name}.id, #{Tag.table_name}.name HAVING COUNT(*) > 0" | ||
| 62 | group_by << " AND #{having}" unless having.blank? | ||
| 63 | |||
| 64 | { :select => "#{Tag.table_name}.id, #{Tag.table_name}.name, COUNT(*) AS count", | ||
| 65 | :joins => joins.join(" "), | ||
| 66 | :conditions => conditions, | ||
| 67 | :group => group_by | ||
| 68 | }.update(options) | ||
| 69 | end | ||
| 70 | end | ||
| 71 | end | ||
diff --git a/vendor/plugins/acts_as_taggable_on_steroids/lib/tag_list.rb b/vendor/plugins/acts_as_taggable_on_steroids/lib/tag_list.rb new file mode 100644 index 0000000..700399b --- /dev/null +++ b/vendor/plugins/acts_as_taggable_on_steroids/lib/tag_list.rb | |||
| @@ -0,0 +1,108 @@ | |||
| 1 | class TagList < Array | ||
| 2 | cattr_accessor :delimiter | ||
| 3 | self.delimiter = ',' | ||
| 4 | |||
| 5 | def initialize(*args) | ||
| 6 | add(*args) | ||
| 7 | end | ||
| 8 | |||
| 9 | # Add tags to the tag_list. Duplicate or blank tags will be ignored. | ||
| 10 | # | ||
| 11 | # tag_list.add("Fun", "Happy") | ||
| 12 | # | ||
| 13 | # Use the <tt>:parse</tt> option to add an unparsed tag string. | ||
| 14 | # | ||
| 15 | # tag_list.add("Fun, Happy", :parse => true) | ||
| 16 | def add(*names) | ||
| 17 | extract_and_apply_options!(names) | ||
| 18 | concat(names) | ||
| 19 | clean! | ||
| 20 | self | ||
| 21 | end | ||
| 22 | |||
| 23 | # Remove specific tags from the tag_list. | ||
| 24 | # | ||
| 25 | # tag_list.remove("Sad", "Lonely") | ||
| 26 | # | ||
| 27 | # Like #add, the <tt>:parse</tt> option can be used to remove multiple tags in a string. | ||
| 28 | # | ||
| 29 | # tag_list.remove("Sad, Lonely", :parse => true) | ||
| 30 | def remove(*names) | ||
| 31 | extract_and_apply_options!(names) | ||
| 32 | delete_if { |name| names.include?(name) } | ||
| 33 | self | ||
| 34 | end | ||
| 35 | |||
| 36 | # Toggle the presence of the given tags. | ||
| 37 | # If a tag is already in the list it is removed, otherwise it is added. | ||
| 38 | def toggle(*names) | ||
| 39 | extract_and_apply_options!(names) | ||
| 40 | |||
| 41 | names.each do |name| | ||
| 42 | include?(name) ? delete(name) : push(name) | ||
| 43 | end | ||
| 44 | |||
| 45 | clean! | ||
| 46 | self | ||
| 47 | end | ||
| 48 | |||
| 49 | # Transform the tag_list into a tag string suitable for edting in a form. | ||
| 50 | # The tags are joined with <tt>TagList.delimiter</tt> and quoted if necessary. | ||
| 51 | # | ||
| 52 | # tag_list = TagList.new("Round", "Square,Cube") | ||
| 53 | # tag_list.to_s # 'Round, "Square,Cube"' | ||
| 54 | def to_s | ||
| 55 | clean! | ||
| 56 | |||
| 57 | map do |name| | ||
| 58 | name.include?(delimiter) ? "\"#{name}\"" : name | ||
| 59 | end.join(delimiter.ends_with?(" ") ? delimiter : "#{delimiter} ") | ||
| 60 | end | ||
| 61 | |||
| 62 | private | ||
| 63 | # Remove whitespace, duplicates, and blanks. | ||
| 64 | def clean! | ||
| 65 | reject!(&:blank?) | ||
| 66 | map!(&:strip) | ||
| 67 | uniq! | ||
| 68 | end | ||
| 69 | |||
| 70 | def extract_and_apply_options!(args) | ||
| 71 | options = args.last.is_a?(Hash) ? args.pop : {} | ||
| 72 | options.assert_valid_keys :parse | ||
| 73 | |||
| 74 | if options[:parse] | ||
| 75 | args.map! { |a| self.class.from(a) } | ||
| 76 | end | ||
| 77 | |||
| 78 | args.flatten! | ||
| 79 | end | ||
| 80 | |||
| 81 | class << self | ||
| 82 | # Returns a new TagList using the given tag string. | ||
| 83 | # | ||
| 84 | # tag_list = TagList.from("One , Two, Three") | ||
| 85 | # tag_list # ["One", "Two", "Three"] | ||
| 86 | def from(source) | ||
| 87 | returning new do |tag_list| | ||
| 88 | |||
| 89 | case source | ||
| 90 | when Array | ||
| 91 | tag_list.add(source) | ||
| 92 | else | ||
| 93 | string = source.to_s.dup | ||
| 94 | |||
| 95 | # Parse the quoted tags | ||
| 96 | [ | ||
| 97 | /\s*#{delimiter}\s*(['"])(.*?)\1\s*/, | ||
| 98 | /^\s*(['"])(.*?)\1\s*#{delimiter}?/ | ||
| 99 | ].each do |re| | ||
| 100 | string.gsub!(re) { tag_list << $2; "" } | ||
| 101 | end | ||
| 102 | |||
| 103 | tag_list.add(string.split(delimiter)) | ||
| 104 | end | ||
| 105 | end | ||
| 106 | end | ||
| 107 | end | ||
| 108 | end | ||
diff --git a/vendor/plugins/acts_as_taggable_on_steroids/lib/tagging.rb b/vendor/plugins/acts_as_taggable_on_steroids/lib/tagging.rb new file mode 100644 index 0000000..87bc44d --- /dev/null +++ b/vendor/plugins/acts_as_taggable_on_steroids/lib/tagging.rb | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | class Tagging < ActiveRecord::Base #:nodoc: | ||
| 2 | belongs_to :tag | ||
| 3 | belongs_to :taggable, :polymorphic => true | ||
| 4 | |||
| 5 | def after_destroy | ||
| 6 | if Tag.destroy_unused | ||
| 7 | if tag.taggings.count.zero? | ||
| 8 | tag.destroy | ||
| 9 | end | ||
| 10 | end | ||
| 11 | end | ||
| 12 | end | ||
diff --git a/vendor/plugins/acts_as_taggable_on_steroids/lib/tags_helper.rb b/vendor/plugins/acts_as_taggable_on_steroids/lib/tags_helper.rb new file mode 100644 index 0000000..d5644b7 --- /dev/null +++ b/vendor/plugins/acts_as_taggable_on_steroids/lib/tags_helper.rb | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | module TagsHelper | ||
| 2 | # See the README for an example using tag_cloud. | ||
| 3 | def tag_cloud(tags, classes) | ||
| 4 | return if tags.empty? | ||
| 5 | |||
| 6 | max_count = tags.sort_by(&:count).last.count.to_f | ||
| 7 | |||
| 8 | tags.each do |tag| | ||
| 9 | index = ((tag.count / max_count) * (classes.size - 1)).round | ||
| 10 | yield tag, classes[index] | ||
| 11 | end | ||
| 12 | end | ||
| 13 | end | ||
diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/abstract_unit.rb b/vendor/plugins/acts_as_taggable_on_steroids/test/abstract_unit.rb new file mode 100644 index 0000000..f480387 --- /dev/null +++ b/vendor/plugins/acts_as_taggable_on_steroids/test/abstract_unit.rb | |||
| @@ -0,0 +1,102 @@ | |||
| 1 | require 'test/unit' | ||
| 2 | |||
| 3 | begin | ||
| 4 | require File.dirname(__FILE__) + '/../../../../config/environment' | ||
| 5 | rescue LoadError | ||
| 6 | require 'rubygems' | ||
| 7 | gem 'activerecord' | ||
| 8 | gem 'actionpack' | ||
| 9 | require 'active_record' | ||
| 10 | require 'action_controller' | ||
| 11 | end | ||
| 12 | |||
| 13 | # Search for fixtures first | ||
| 14 | fixture_path = File.dirname(__FILE__) + '/fixtures/' | ||
| 15 | ActiveSupport::Dependencies.load_paths.insert(0, fixture_path) | ||
| 16 | |||
| 17 | require "active_record/test_case" | ||
| 18 | require "active_record/fixtures" | ||
| 19 | |||
| 20 | require File.dirname(__FILE__) + '/../lib/acts_as_taggable' | ||
| 21 | require_dependency File.dirname(__FILE__) + '/../lib/tag_list' | ||
| 22 | require_dependency File.dirname(__FILE__) + '/../lib/tags_helper' | ||
| 23 | |||
| 24 | ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + '/debug.log') | ||
| 25 | ActiveRecord::Base.configurations = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml')) | ||
| 26 | ActiveRecord::Base.establish_connection(ENV['DB'] || 'mysql') | ||
| 27 | |||
| 28 | load(File.dirname(__FILE__) + '/schema.rb') | ||
| 29 | |||
| 30 | class ActiveSupport::TestCase #:nodoc: | ||
| 31 | include ActiveRecord::TestFixtures | ||
| 32 | |||
| 33 | self.fixture_path = File.dirname(__FILE__) + "/fixtures/" | ||
| 34 | |||
| 35 | self.use_transactional_fixtures = true | ||
| 36 | self.use_instantiated_fixtures = false | ||
| 37 | |||
| 38 | fixtures :all | ||
| 39 | |||
| 40 | def assert_equivalent(expected, actual, message = nil) | ||
| 41 | if expected.first.is_a?(ActiveRecord::Base) | ||
| 42 | assert_equal expected.sort_by(&:id), actual.sort_by(&:id), message | ||
| 43 | else | ||
| 44 | assert_equal expected.sort, actual.sort, message | ||
| 45 | end | ||
| 46 | end | ||
| 47 | |||
| 48 | def assert_tag_counts(tags, expected_values) | ||
| 49 | # Map the tag fixture names to real tag names | ||
| 50 | expected_values = expected_values.inject({}) do |hash, (tag, count)| | ||
| 51 | hash[tags(tag).name] = count | ||
| 52 | hash | ||
| 53 | end | ||
| 54 | |||
| 55 | tags.each do |tag| | ||
| 56 | value = expected_values.delete(tag.name) | ||
| 57 | |||
| 58 | assert_not_nil value, "Expected count for #{tag.name} was not provided" | ||
| 59 | assert_equal value, tag.count, "Expected value of #{value} for #{tag.name}, but was #{tag.count}" | ||
| 60 | end | ||
| 61 | |||
| 62 | unless expected_values.empty? | ||
| 63 | assert false, "The following tag counts were not present: #{expected_values.inspect}" | ||
| 64 | end | ||
| 65 | end | ||
| 66 | |||
| 67 | def assert_queries(num = 1) | ||
| 68 | $query_count = 0 | ||
| 69 | yield | ||
| 70 | ensure | ||
| 71 | assert_equal num, $query_count, "#{$query_count} instead of #{num} queries were executed." | ||
| 72 | end | ||
| 73 | |||
| 74 | def assert_no_queries(&block) | ||
| 75 | assert_queries(0, &block) | ||
| 76 | end | ||
| 77 | |||
| 78 | # From Rails trunk | ||
| 79 | def assert_difference(expressions, difference = 1, message = nil, &block) | ||
| 80 | expression_evaluations = [expressions].flatten.collect{|expression| lambda { eval(expression, block.binding) } } | ||
| 81 | |||
| 82 | original_values = expression_evaluations.inject([]) { |memo, expression| memo << expression.call } | ||
| 83 | yield | ||
| 84 | expression_evaluations.each_with_index do |expression, i| | ||
| 85 | assert_equal original_values[i] + difference, expression.call, message | ||
| 86 | end | ||
| 87 | end | ||
| 88 | |||
| 89 | def assert_no_difference(expressions, message = nil, &block) | ||
| 90 | assert_difference expressions, 0, message, &block | ||
| 91 | end | ||
| 92 | end | ||
| 93 | |||
| 94 | ActiveRecord::Base.connection.class.class_eval do | ||
| 95 | def execute_with_counting(sql, name = nil, &block) | ||
| 96 | $query_count ||= 0 | ||
| 97 | $query_count += 1 | ||
| 98 | execute_without_counting(sql, name, &block) | ||
| 99 | end | ||
| 100 | |||
| 101 | alias_method_chain :execute, :counting | ||
| 102 | end | ||
diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/acts_as_taggable_test.rb b/vendor/plugins/acts_as_taggable_on_steroids/test/acts_as_taggable_test.rb new file mode 100644 index 0000000..9766d34 --- /dev/null +++ b/vendor/plugins/acts_as_taggable_on_steroids/test/acts_as_taggable_test.rb | |||
| @@ -0,0 +1,384 @@ | |||
| 1 | require File.dirname(__FILE__) + '/abstract_unit' | ||
| 2 | |||
| 3 | class ActsAsTaggableOnSteroidsTest < ActiveSupport::TestCase | ||
| 4 | def test_find_related_tags_with | ||
| 5 | assert_equivalent [tags(:good), tags(:bad), tags(:question)], Post.find_related_tags("nature") | ||
| 6 | assert_equivalent [tags(:nature)], Post.find_related_tags([tags(:good)]) | ||
| 7 | assert_equivalent [tags(:bad), tags(:question)], Post.find_related_tags(["Very Good", "Nature"]) | ||
| 8 | assert_equivalent [tags(:bad), tags(:question)], Post.find_related_tags([tags(:good), tags(:nature)]) | ||
| 9 | end | ||
| 10 | |||
| 11 | def test_find_tagged_with_include_and_order | ||
| 12 | assert_equal photos(:sam_sky, :sam_flower, :jonathan_dog), Photo.find_tagged_with("Nature", :order => "photos.title DESC", :include => :user) | ||
| 13 | end | ||
| 14 | |||
| 15 | def test_find_related_tags_with_non_existent_tags | ||
| 16 | assert_equal [], Post.find_related_tags("ABCDEFG") | ||
| 17 | assert_equal [], Post.find_related_tags(['HIJKLM']) | ||
| 18 | end | ||
| 19 | |||
| 20 | def test_find_related_tags_with_nothing | ||
| 21 | assert_equal [], Post.find_related_tags("") | ||
| 22 | assert_equal [], Post.find_related_tags([]) | ||
| 23 | end | ||
| 24 | |||
| 25 | def test_find_tagged_with | ||
| 26 | assert_equivalent [posts(:jonathan_sky), posts(:sam_flowers)], Post.find_tagged_with('"Very good"') | ||
| 27 | assert_equal Post.find_tagged_with('"Very good"'), Post.find_tagged_with(['Very good']) | ||
| 28 | assert_equal Post.find_tagged_with('"Very good"'), Post.find_tagged_with([tags(:good)]) | ||
| 29 | |||
| 30 | assert_equivalent [photos(:jonathan_dog), photos(:sam_flower), photos(:sam_sky)], Photo.find_tagged_with('Nature') | ||
| 31 | assert_equal Photo.find_tagged_with('Nature'), Photo.find_tagged_with(['Nature']) | ||
| 32 | assert_equal Photo.find_tagged_with('Nature'), Photo.find_tagged_with([tags(:nature)]) | ||
| 33 | |||
| 34 | assert_equivalent [photos(:jonathan_bad_cat), photos(:jonathan_dog), photos(:jonathan_questioning_dog)], Photo.find_tagged_with('"Crazy animal" Bad') | ||
| 35 | assert_equal Photo.find_tagged_with('"Crazy animal" Bad'), Photo.find_tagged_with(['Crazy animal', 'Bad']) | ||
| 36 | assert_equal Photo.find_tagged_with('"Crazy animal" Bad'), Photo.find_tagged_with([tags(:animal), tags(:bad)]) | ||
| 37 | end | ||
| 38 | |||
| 39 | def test_find_tagged_with_nothing | ||
| 40 | assert_equal [], Post.find_tagged_with("") | ||
| 41 | assert_equal [], Post.find_tagged_with([]) | ||
| 42 | end | ||
| 43 | |||
| 44 | def test_find_tagged_with_nonexistant_tags | ||
| 45 | assert_equal [], Post.find_tagged_with('ABCDEFG') | ||
| 46 | assert_equal [], Photo.find_tagged_with(['HIJKLM']) | ||
| 47 | assert_equal [], Photo.find_tagged_with([Tag.new(:name => 'unsaved tag')]) | ||
| 48 | end | ||
| 49 | |||
| 50 | def test_find_tagged_with_match_all | ||
| 51 | assert_equivalent [photos(:jonathan_dog)], Photo.find_tagged_with('Crazy animal, "Nature"', :match_all => true) | ||
| 52 | end | ||
| 53 | |||
| 54 | def test_find_tagged_with_match_all_and_include | ||
| 55 | assert_equivalent [posts(:jonathan_sky), posts(:sam_flowers)], Post.find_tagged_with(['Very good', 'Nature'], :match_all => true, :include => :tags) | ||
| 56 | end | ||
| 57 | |||
| 58 | def test_find_tagged_with_conditions | ||
| 59 | assert_equal [], Post.find_tagged_with('"Very good", Nature', :conditions => '1=0') | ||
| 60 | end | ||
| 61 | |||
| 62 | def test_find_tagged_with_duplicates_options_hash | ||
| 63 | options = { :conditions => '1=1' }.freeze | ||
| 64 | assert_nothing_raised { Post.find_tagged_with("Nature", options) } | ||
| 65 | end | ||
| 66 | |||
| 67 | def test_find_tagged_with_exclusions | ||
| 68 | assert_equivalent [photos(:jonathan_questioning_dog), photos(:jonathan_bad_cat)], Photo.find_tagged_with("Nature", :exclude => true) | ||
| 69 | assert_equivalent [posts(:jonathan_grass), posts(:jonathan_rain), posts(:jonathan_cloudy), posts(:jonathan_still_cloudy)], Post.find_tagged_with("'Very good', Bad", :exclude => true) | ||
| 70 | end | ||
| 71 | |||
| 72 | def test_find_options_for_find_tagged_with_no_tags_returns_empty_hash | ||
| 73 | assert_equal Hash.new, Post.find_options_for_find_tagged_with("") | ||
| 74 | assert_equal Hash.new, Post.find_options_for_find_tagged_with([nil]) | ||
| 75 | end | ||
| 76 | |||
| 77 | def test_find_options_for_find_tagged_with_leaves_arguments_unchanged | ||
| 78 | original_tags = photos(:jonathan_questioning_dog).tags.dup | ||
| 79 | Photo.find_options_for_find_tagged_with(photos(:jonathan_questioning_dog).tags) | ||
| 80 | assert_equal original_tags, photos(:jonathan_questioning_dog).tags | ||
| 81 | end | ||
| 82 | |||
| 83 | def test_find_options_for_find_tagged_with_respects_custom_table_name | ||
| 84 | Tagging.table_name = "categorisations" | ||
| 85 | Tag.table_name = "categories" | ||
| 86 | |||
| 87 | options = Photo.find_options_for_find_tagged_with("Hello") | ||
| 88 | |||
| 89 | assert_no_match(/ taggings /, options[:joins]) | ||
| 90 | assert_no_match(/ tags /, options[:joins]) | ||
| 91 | |||
| 92 | assert_match(/ categorisations /, options[:joins]) | ||
| 93 | assert_match(/ categories /, options[:joins]) | ||
| 94 | ensure | ||
| 95 | Tagging.table_name = "taggings" | ||
| 96 | Tag.table_name = "tags" | ||
| 97 | end | ||
| 98 | |||
| 99 | def test_include_tags_on_find_tagged_with | ||
| 100 | assert_nothing_raised do | ||
| 101 | Photo.find_tagged_with('Nature', :include => :tags) | ||
| 102 | Photo.find_tagged_with("Nature", :include => { :taggings => :tag }) | ||
| 103 | end | ||
| 104 | end | ||
| 105 | |||
| 106 | def test_basic_tag_counts_on_class | ||
| 107 | assert_tag_counts Post.tag_counts, :good => 2, :nature => 7, :question => 1, :bad => 1 | ||
| 108 | assert_tag_counts Photo.tag_counts, :good => 1, :nature => 3, :question => 1, :bad => 1, :animal => 3 | ||
| 109 | end | ||
| 110 | |||
| 111 | def test_tag_counts_on_class_with_date_conditions | ||
| 112 | assert_tag_counts Post.tag_counts(:start_at => Date.new(2006, 8, 4)), :good => 1, :nature => 5, :question => 1, :bad => 1 | ||
| 113 | assert_tag_counts Post.tag_counts(:end_at => Date.new(2006, 8, 6)), :good => 1, :nature => 4, :question => 1 | ||
| 114 | assert_tag_counts Post.tag_counts(:start_at => Date.new(2006, 8, 5), :end_at => Date.new(2006, 8, 10)), :good => 1, :nature => 4, :bad => 1 | ||
| 115 | |||
| 116 | assert_tag_counts Photo.tag_counts(:start_at => Date.new(2006, 8, 12), :end_at => Date.new(2006, 8, 19)), :good => 1, :nature => 2, :bad => 1, :question => 1, :animal => 3 | ||
| 117 | end | ||
| 118 | |||
| 119 | def test_tag_counts_on_class_with_frequencies | ||
| 120 | assert_tag_counts Photo.tag_counts(:at_least => 2), :nature => 3, :animal => 3 | ||
| 121 | assert_tag_counts Photo.tag_counts(:at_most => 2), :good => 1, :question => 1, :bad => 1 | ||
| 122 | end | ||
| 123 | |||
| 124 | def test_tag_counts_on_class_with_frequencies_and_conditions | ||
| 125 | assert_tag_counts Photo.tag_counts(:at_least => 2, :conditions => '1=1'), :nature => 3, :animal => 3 | ||
| 126 | end | ||
| 127 | |||
| 128 | def test_tag_counts_duplicates_options_hash | ||
| 129 | options = { :at_least => 2, :conditions => '1=1' }.freeze | ||
| 130 | assert_nothing_raised { Photo.tag_counts(options) } | ||
| 131 | end | ||
| 132 | |||
| 133 | def test_tag_counts_with_limit | ||
| 134 | assert_equal 2, Photo.tag_counts(:limit => 2).size | ||
| 135 | assert_equal 1, Post.tag_counts(:at_least => 4, :limit => 2).size | ||
| 136 | end | ||
| 137 | |||
| 138 | def test_tag_counts_with_limit_and_order | ||
| 139 | assert_equal [tags(:nature), tags(:good)], Post.tag_counts(:order => 'count desc', :limit => 2) | ||
| 140 | end | ||
| 141 | |||
| 142 | def test_tag_counts_on_association | ||
| 143 | assert_tag_counts users(:jonathan).posts.tag_counts, :good => 1, :nature => 5, :question => 1 | ||
| 144 | assert_tag_counts users(:sam).posts.tag_counts, :good => 1, :nature => 2, :bad => 1 | ||
| 145 | |||
| 146 | assert_tag_counts users(:jonathan).photos.tag_counts, :animal => 3, :nature => 1, :question => 1, :bad => 1 | ||
| 147 | assert_tag_counts users(:sam).photos.tag_counts, :nature => 2, :good => 1 | ||
| 148 | end | ||
| 149 | |||
| 150 | def test_tag_counts_on_association_with_options | ||
| 151 | assert_equal [], users(:jonathan).posts.tag_counts(:conditions => '1=0') | ||
| 152 | assert_tag_counts users(:jonathan).posts.tag_counts(:at_most => 2), :good => 1, :question => 1 | ||
| 153 | end | ||
| 154 | |||
| 155 | def test_tag_counts_on_has_many_through | ||
| 156 | assert_tag_counts users(:jonathan).magazines.tag_counts, :good => 1 | ||
| 157 | end | ||
| 158 | |||
| 159 | def test_tag_counts_on_model_instance | ||
| 160 | assert_tag_counts photos(:jonathan_dog).tag_counts, :animal => 3, :nature => 3 | ||
| 161 | end | ||
| 162 | |||
| 163 | def test_tag_counts_on_model_instance_merges_conditions | ||
| 164 | assert_tag_counts photos(:jonathan_dog).tag_counts(:conditions => "tags.name = 'Crazy animal'"), :animal => 3 | ||
| 165 | end | ||
| 166 | |||
| 167 | def test_tag_counts_on_model_instance_with_no_tags | ||
| 168 | photo = Photo.create! | ||
| 169 | |||
| 170 | assert_tag_counts photo.tag_counts, {} | ||
| 171 | end | ||
| 172 | |||
| 173 | def test_tag_counts_should_sanitize_scope_conditions | ||
| 174 | Photo.send :with_scope, :find => { :conditions => ["tags.id = ?", tags(:animal).id] } do | ||
| 175 | assert_tag_counts Photo.tag_counts, :animal => 3 | ||
| 176 | end | ||
| 177 | end | ||
| 178 | |||
| 179 | def test_tag_counts_respects_custom_table_names | ||
| 180 | Tagging.table_name = "categorisations" | ||
| 181 | Tag.table_name = "categories" | ||
| 182 | |||
| 183 | options = Photo.find_options_for_tag_counts(:start_at => 2.weeks.ago, :end_at => Date.today) | ||
| 184 | sql = options.values.join(' ') | ||
| 185 | |||
| 186 | assert_no_match /taggings/, sql | ||
| 187 | assert_no_match /tags/, sql | ||
| 188 | |||
| 189 | assert_match /categorisations/, sql | ||
| 190 | assert_match /categories/, sql | ||
| 191 | ensure | ||
| 192 | Tagging.table_name = "taggings" | ||
| 193 | Tag.table_name = "tags" | ||
| 194 | end | ||
| 195 | |||
| 196 | def test_tag_list_reader | ||
| 197 | assert_equivalent ["Very good", "Nature"], posts(:jonathan_sky).tag_list | ||
| 198 | assert_equivalent ["Bad", "Crazy animal"], photos(:jonathan_bad_cat).tag_list | ||
| 199 | end | ||
| 200 | |||
| 201 | def test_reassign_tag_list | ||
| 202 | assert_equivalent ["Nature", "Question"], posts(:jonathan_rain).tag_list | ||
| 203 | posts(:jonathan_rain).taggings.reload | ||
| 204 | |||
| 205 | # Only an update of the posts table should be executed, the other two queries are for savepoints | ||
| 206 | assert_queries 3 do | ||
| 207 | posts(:jonathan_rain).update_attributes!(:tag_list => posts(:jonathan_rain).tag_list.to_s) | ||
| 208 | end | ||
| 209 | |||
| 210 | assert_equivalent ["Nature", "Question"], posts(:jonathan_rain).tag_list | ||
| 211 | end | ||
| 212 | |||
| 213 | def test_new_tags | ||
| 214 | assert_equivalent ["Very good", "Nature"], posts(:jonathan_sky).tag_list | ||
| 215 | posts(:jonathan_sky).update_attributes!(:tag_list => "#{posts(:jonathan_sky).tag_list}, One, Two") | ||
| 216 | assert_equivalent ["Very good", "Nature", "One", "Two"], posts(:jonathan_sky).tag_list | ||
| 217 | end | ||
| 218 | |||
| 219 | def test_remove_tag | ||
| 220 | assert_equivalent ["Very good", "Nature"], posts(:jonathan_sky).tag_list | ||
| 221 | posts(:jonathan_sky).update_attributes!(:tag_list => "Nature") | ||
| 222 | assert_equivalent ["Nature"], posts(:jonathan_sky).tag_list | ||
| 223 | end | ||
| 224 | |||
| 225 | def test_change_case_of_tags | ||
| 226 | original_tag_names = photos(:jonathan_questioning_dog).tag_list | ||
| 227 | photos(:jonathan_questioning_dog).update_attributes!(:tag_list => photos(:jonathan_questioning_dog).tag_list.to_s.upcase) | ||
| 228 | |||
| 229 | # The new tag list is not uppercase becuase the AR finders are not case-sensitive | ||
| 230 | # and find the old tags when re-tagging with the uppercase tags. | ||
| 231 | assert_equivalent original_tag_names, photos(:jonathan_questioning_dog).reload.tag_list | ||
| 232 | end | ||
| 233 | |||
| 234 | def test_remove_and_add_tag | ||
| 235 | assert_equivalent ["Very good", "Nature"], posts(:jonathan_sky).tag_list | ||
| 236 | posts(:jonathan_sky).update_attributes!(:tag_list => "Nature, Beautiful") | ||
| 237 | assert_equivalent ["Nature", "Beautiful"], posts(:jonathan_sky).tag_list | ||
| 238 | end | ||
| 239 | |||
| 240 | def test_tags_not_saved_if_validation_fails | ||
| 241 | assert_equivalent ["Very good", "Nature"], posts(:jonathan_sky).tag_list | ||
| 242 | assert !posts(:jonathan_sky).update_attributes(:tag_list => "One, Two", :text => "") | ||
| 243 | assert_equivalent ["Very good", "Nature"], Post.find(posts(:jonathan_sky).id).tag_list | ||
| 244 | end | ||
| 245 | |||
| 246 | def test_tag_list_accessors_on_new_record | ||
| 247 | p = Post.new(:text => 'Test') | ||
| 248 | |||
| 249 | assert p.tag_list.blank? | ||
| 250 | p.tag_list = "One, Two" | ||
| 251 | assert_equal "One, Two", p.tag_list.to_s | ||
| 252 | end | ||
| 253 | |||
| 254 | def test_clear_tag_list_with_nil | ||
| 255 | p = photos(:jonathan_questioning_dog) | ||
| 256 | |||
| 257 | assert !p.tag_list.blank? | ||
| 258 | assert p.update_attributes(:tag_list => nil) | ||
| 259 | assert p.tag_list.blank? | ||
| 260 | |||
| 261 | assert p.reload.tag_list.blank? | ||
| 262 | end | ||
| 263 | |||
| 264 | def test_clear_tag_list_with_string | ||
| 265 | p = photos(:jonathan_questioning_dog) | ||
| 266 | |||
| 267 | assert !p.tag_list.blank? | ||
| 268 | assert p.update_attributes(:tag_list => ' ') | ||
| 269 | assert p.tag_list.blank? | ||
| 270 | |||
| 271 | assert p.reload.tag_list.blank? | ||
| 272 | end | ||
| 273 | |||
| 274 | def test_tag_list_reset_on_reload | ||
| 275 | p = photos(:jonathan_questioning_dog) | ||
| 276 | assert !p.tag_list.blank? | ||
| 277 | p.tag_list = nil | ||
| 278 | assert p.tag_list.blank? | ||
| 279 | assert !p.reload.tag_list.blank? | ||
| 280 | end | ||
| 281 | |||
| 282 | def test_instance_tag_counts | ||
| 283 | assert_tag_counts posts(:jonathan_sky).tag_counts, :good => 2, :nature => 7 | ||
| 284 | end | ||
| 285 | |||
| 286 | def test_tag_list_populated_when_cache_nil | ||
| 287 | assert_nil posts(:jonathan_sky).cached_tag_list | ||
| 288 | posts(:jonathan_sky).save! | ||
| 289 | assert_equal posts(:jonathan_sky).tag_list.to_s, posts(:jonathan_sky).cached_tag_list | ||
| 290 | end | ||
| 291 | |||
| 292 | def test_cached_tag_list_used | ||
| 293 | posts(:jonathan_sky).save! | ||
| 294 | posts(:jonathan_sky).reload | ||
| 295 | |||
| 296 | assert_no_queries do | ||
| 297 | assert_equivalent ["Very good", "Nature"], posts(:jonathan_sky).tag_list | ||
| 298 | end | ||
| 299 | end | ||
| 300 | |||
| 301 | def test_cached_tag_list_not_used | ||
| 302 | # Load fixture and column information | ||
| 303 | posts(:jonathan_sky).taggings(:reload) | ||
| 304 | |||
| 305 | assert_queries 1 do | ||
| 306 | # Tags association will be loaded | ||
| 307 | posts(:jonathan_sky).tag_list | ||
| 308 | end | ||
| 309 | end | ||
| 310 | |||
| 311 | def test_cached_tag_list_updated | ||
| 312 | assert_nil posts(:jonathan_sky).cached_tag_list | ||
| 313 | posts(:jonathan_sky).save! | ||
| 314 | assert_equivalent ["Very good", "Nature"], TagList.from(posts(:jonathan_sky).cached_tag_list) | ||
| 315 | posts(:jonathan_sky).update_attributes!(:tag_list => "None") | ||
| 316 | |||
| 317 | assert_equal 'None', posts(:jonathan_sky).cached_tag_list | ||
| 318 | assert_equal 'None', posts(:jonathan_sky).reload.cached_tag_list | ||
| 319 | end | ||
| 320 | |||
| 321 | def test_clearing_cached_tag_list | ||
| 322 | # Generate the cached tag list | ||
| 323 | posts(:jonathan_sky).save! | ||
| 324 | |||
| 325 | posts(:jonathan_sky).update_attributes!(:tag_list => "") | ||
| 326 | assert_equal "", posts(:jonathan_sky).cached_tag_list | ||
| 327 | end | ||
| 328 | |||
| 329 | def test_find_tagged_with_using_sti | ||
| 330 | special_post = SpecialPost.create!(:text => "Test", :tag_list => "Random") | ||
| 331 | |||
| 332 | assert_equal [special_post], SpecialPost.find_tagged_with("Random") | ||
| 333 | assert Post.find_tagged_with("Random").include?(special_post) | ||
| 334 | end | ||
| 335 | |||
| 336 | def test_tag_counts_using_sti | ||
| 337 | SpecialPost.create!(:text => "Test", :tag_list => "Nature") | ||
| 338 | |||
| 339 | assert_tag_counts SpecialPost.tag_counts, :nature => 1 | ||
| 340 | end | ||
| 341 | |||
| 342 | def test_case_insensitivity | ||
| 343 | assert_difference "Tag.count", 1 do | ||
| 344 | Post.create!(:text => "Test", :tag_list => "one") | ||
| 345 | Post.create!(:text => "Test", :tag_list => "One") | ||
| 346 | end | ||
| 347 | |||
| 348 | assert_equal Post.find_tagged_with("Nature"), Post.find_tagged_with("nature") | ||
| 349 | end | ||
| 350 | |||
| 351 | def test_tag_not_destroyed_when_unused | ||
| 352 | posts(:jonathan_sky).tag_list.add("Random") | ||
| 353 | posts(:jonathan_sky).save! | ||
| 354 | |||
| 355 | assert_no_difference 'Tag.count' do | ||
| 356 | posts(:jonathan_sky).tag_list.remove("Random") | ||
| 357 | posts(:jonathan_sky).save! | ||
| 358 | end | ||
| 359 | end | ||
| 360 | |||
| 361 | def test_tag_destroyed_when_unused | ||
| 362 | Tag.destroy_unused = true | ||
| 363 | |||
| 364 | posts(:jonathan_sky).tag_list.add("Random") | ||
| 365 | posts(:jonathan_sky).save! | ||
| 366 | |||
| 367 | assert_difference 'Tag.count', -1 do | ||
| 368 | posts(:jonathan_sky).tag_list.remove("Random") | ||
| 369 | posts(:jonathan_sky).save! | ||
| 370 | end | ||
| 371 | ensure | ||
| 372 | Tag.destroy_unused = false | ||
| 373 | end | ||
| 374 | end | ||
| 375 | |||
| 376 | class ActsAsTaggableOnSteroidsFormTest < ActiveSupport::TestCase | ||
| 377 | include ActionView::Helpers::FormHelper | ||
| 378 | |||
| 379 | def test_tag_list_contents | ||
| 380 | fields_for :post, posts(:jonathan_sky) do |f| | ||
| 381 | assert_match /Nature, Very good/, f.text_field(:tag_list) | ||
| 382 | end | ||
| 383 | end | ||
| 384 | end | ||
diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/magazine.rb b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/magazine.rb new file mode 100644 index 0000000..554afe4 --- /dev/null +++ b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/magazine.rb | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | class Magazine < ActiveRecord::Base | ||
| 2 | acts_as_taggable | ||
| 3 | end | ||
diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/magazines.yml b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/magazines.yml new file mode 100644 index 0000000..7124fd9 --- /dev/null +++ b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/magazines.yml | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | ruby: | ||
| 2 | name: Ruby | ||
| 3 | |||
| 4 | rails: | ||
| 5 | name: Rails | ||
diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/photo.rb b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/photo.rb new file mode 100644 index 0000000..224957f --- /dev/null +++ b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/photo.rb | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | class Photo < ActiveRecord::Base | ||
| 2 | acts_as_taggable | ||
| 3 | |||
| 4 | belongs_to :user | ||
| 5 | end | ||
| 6 | |||
| 7 | class SpecialPhoto < Photo | ||
| 8 | end | ||
diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/photos.yml b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/photos.yml new file mode 100644 index 0000000..bf078cf --- /dev/null +++ b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/photos.yml | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | jonathan_dog: | ||
| 2 | user: jonathan | ||
| 3 | title: A small dog | ||
| 4 | |||
| 5 | jonathan_questioning_dog: | ||
| 6 | user: jonathan | ||
| 7 | title: What does this dog want? | ||
| 8 | |||
| 9 | jonathan_bad_cat: | ||
| 10 | user: jonathan | ||
| 11 | title: Bad cat | ||
| 12 | |||
| 13 | sam_flower: | ||
| 14 | user: sam | ||
| 15 | title: Flower | ||
| 16 | |||
| 17 | sam_sky: | ||
| 18 | user: sam | ||
| 19 | title: Sky | ||
diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/post.rb b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/post.rb new file mode 100644 index 0000000..bee100a --- /dev/null +++ b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/post.rb | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | class Post < ActiveRecord::Base | ||
| 2 | acts_as_taggable | ||
| 3 | |||
| 4 | belongs_to :user | ||
| 5 | |||
| 6 | validates_presence_of :text | ||
| 7 | end | ||
diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/posts.yml b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/posts.yml new file mode 100644 index 0000000..50e91bc --- /dev/null +++ b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/posts.yml | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | jonathan_sky: | ||
| 2 | user: jonathan | ||
| 3 | text: The sky is particularly blue today | ||
| 4 | |||
| 5 | jonathan_grass: | ||
| 6 | user: jonathan | ||
| 7 | text: The grass seems very green | ||
| 8 | |||
| 9 | jonathan_rain: | ||
| 10 | user: jonathan | ||
| 11 | text: Why does the rain fall? | ||
| 12 | |||
| 13 | jonathan_cloudy: | ||
| 14 | user: jonathan | ||
| 15 | text: Is it cloudy? | ||
| 16 | |||
| 17 | jonathan_still_cloudy: | ||
| 18 | user: jonathan | ||
| 19 | text: Is it still cloudy? | ||
| 20 | |||
| 21 | sam_ground: | ||
| 22 | user: sam | ||
| 23 | text: The ground is looking too brown | ||
| 24 | |||
| 25 | sam_flowers: | ||
| 26 | user: sam | ||
| 27 | text: Why are the flowers dead? | ||
diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/special_post.rb b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/special_post.rb new file mode 100644 index 0000000..366a0d5 --- /dev/null +++ b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/special_post.rb | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | class SpecialPost < Post | ||
| 2 | end | ||
diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/subscription.rb b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/subscription.rb new file mode 100644 index 0000000..e975cb7 --- /dev/null +++ b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/subscription.rb | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | class Subscription < ActiveRecord::Base | ||
| 2 | belongs_to :user | ||
| 3 | belongs_to :magazine | ||
| 4 | end | ||
diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/subscriptions.yml b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/subscriptions.yml new file mode 100644 index 0000000..d294e51 --- /dev/null +++ b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/subscriptions.yml | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | jonathan_rails: | ||
| 2 | user: jonathan | ||
| 3 | magazine: ruby | ||
diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/taggings.yml b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/taggings.yml new file mode 100644 index 0000000..1193b56 --- /dev/null +++ b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/taggings.yml | |||
| @@ -0,0 +1,107 @@ | |||
| 1 | # Posts | ||
| 2 | jonathan_sky_good: | ||
| 3 | tag: good | ||
| 4 | taggable: jonathan_sky (Post) | ||
| 5 | created_at: 2006-08-01 | ||
| 6 | |||
| 7 | jonathan_sky_nature: | ||
| 8 | tag: nature | ||
| 9 | taggable: jonathan_sky (Post) | ||
| 10 | created_at: 2006-08-02 | ||
| 11 | |||
| 12 | jonathan_grass_nature: | ||
| 13 | tag: nature | ||
| 14 | taggable: jonathan_grass (Post) | ||
| 15 | created_at: 2006-08-03 | ||
| 16 | |||
| 17 | jonathan_rain_question: | ||
| 18 | tag: question | ||
| 19 | taggable: jonathan_rain (Post) | ||
| 20 | created_at: 2006-08-04 | ||
| 21 | |||
| 22 | jonathan_rain_nature: | ||
| 23 | tag: nature | ||
| 24 | taggable: jonathan_rain (Post) | ||
| 25 | created_at: 2006-08-05 | ||
| 26 | |||
| 27 | jonathan_cloudy_nature: | ||
| 28 | tag: nature | ||
| 29 | taggable: jonathan_cloudy (Post) | ||
| 30 | created_at: 2006-08-06 | ||
| 31 | |||
| 32 | jonathan_still_cloudy_nature: | ||
| 33 | tag: nature | ||
| 34 | taggable: jonathan_still_cloudy (Post) | ||
| 35 | created_at: 2006-08-07 | ||
| 36 | |||
| 37 | sam_ground_nature: | ||
| 38 | tag: nature | ||
| 39 | taggable: sam_ground (Post) | ||
| 40 | created_at: 2006-08-08 | ||
| 41 | |||
| 42 | sam_ground_bad: | ||
| 43 | tag: bad | ||
| 44 | taggable: sam_ground (Post) | ||
| 45 | created_at: 2006-08-09 | ||
| 46 | |||
| 47 | sam_flowers_good: | ||
| 48 | tag: good | ||
| 49 | taggable: sam_flowers (Post) | ||
| 50 | created_at: 2006-08-10 | ||
| 51 | |||
| 52 | sam_flowers_nature: | ||
| 53 | tag: nature | ||
| 54 | taggable: sam_flowers (Post) | ||
| 55 | created_at: 2006-08-11 | ||
| 56 | |||
| 57 | # Photos | ||
| 58 | jonathan_dog_animal: | ||
| 59 | tag: animal | ||
| 60 | taggable: jonathan_dog (Photo) | ||
| 61 | created_at: 2006-08-12 | ||
| 62 | |||
| 63 | jonathan_dog_nature: | ||
| 64 | tag: nature | ||
| 65 | taggable: jonathan_dog (Photo) | ||
| 66 | created_at: 2006-08-13 | ||
| 67 | |||
| 68 | jonathan_questioning_dog_animal: | ||
| 69 | tag: animal | ||
| 70 | taggable: jonathan_questioning_dog (Photo) | ||
| 71 | created_at: 2006-08-14 | ||
| 72 | |||
| 73 | jonathan_questioning_dog_question: | ||
| 74 | tag: question | ||
| 75 | taggable: jonathan_questioning_dog (Photo) | ||
| 76 | created_at: 2006-08-15 | ||
| 77 | |||
| 78 | jonathan_bad_cat_bad: | ||
| 79 | tag: bad | ||
| 80 | taggable: jonathan_bad_cat (Photo) | ||
| 81 | created_at: 2006-08-16 | ||
| 82 | |||
| 83 | jonathan_bad_cat_animal: | ||
| 84 | tag: animal | ||
| 85 | taggable: jonathan_bad_cat (Photo) | ||
| 86 | created_at: 2006-08-17 | ||
| 87 | |||
| 88 | sam_flower_nature: | ||
| 89 | tag: nature | ||
| 90 | taggable: sam_flower (Photo) | ||
| 91 | created_at: 2006-08-18 | ||
| 92 | |||
| 93 | sam_flower_good: | ||
| 94 | tag: good | ||
| 95 | taggable: sam_flower (Photo) | ||
| 96 | created_at: 2006-08-19 | ||
| 97 | |||
| 98 | sam_sky_nature: | ||
| 99 | tag: nature | ||
| 100 | taggable: sam_sky (Photo) | ||
| 101 | created_at: 2006-08-20 | ||
| 102 | |||
| 103 | # Magazines | ||
| 104 | ruby_good: | ||
| 105 | tag: good | ||
| 106 | taggable: ruby (Magazine) | ||
| 107 | created_at: 2007-08-25 | ||
diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/tags.yml b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/tags.yml new file mode 100644 index 0000000..a3c2aa5 --- /dev/null +++ b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/tags.yml | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | good: | ||
| 2 | name: Very good | ||
| 3 | |||
| 4 | bad: | ||
| 5 | name: Bad | ||
| 6 | |||
| 7 | nature: | ||
| 8 | name: Nature | ||
| 9 | |||
| 10 | question: | ||
| 11 | name: Question | ||
| 12 | |||
| 13 | animal: | ||
| 14 | name: Crazy animal | ||
diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/user.rb b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/user.rb new file mode 100644 index 0000000..8c0f787 --- /dev/null +++ b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/user.rb | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | class User < ActiveRecord::Base | ||
| 2 | has_many :posts | ||
| 3 | has_many :photos | ||
| 4 | |||
| 5 | has_many :subscriptions | ||
| 6 | has_many :magazines, :through => :subscriptions | ||
| 7 | end | ||
diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/users.yml b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/users.yml new file mode 100644 index 0000000..e6f22d3 --- /dev/null +++ b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/users.yml | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | jonathan: | ||
| 2 | name: Jonathan | ||
| 3 | |||
| 4 | sam: | ||
| 5 | name: Sam | ||
diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/tag_list_test.rb b/vendor/plugins/acts_as_taggable_on_steroids/test/tag_list_test.rb new file mode 100644 index 0000000..17d4ab9 --- /dev/null +++ b/vendor/plugins/acts_as_taggable_on_steroids/test/tag_list_test.rb | |||
| @@ -0,0 +1,119 @@ | |||
| 1 | require File.dirname(__FILE__) + '/abstract_unit' | ||
| 2 | |||
| 3 | class TagListTest < ActiveSupport::TestCase | ||
| 4 | def test_from_leaves_string_unchanged | ||
| 5 | tags = '"One ", Two' | ||
| 6 | original = tags.dup | ||
| 7 | TagList.from(tags) | ||
| 8 | assert_equal tags, original | ||
| 9 | end | ||
| 10 | |||
| 11 | def test_from_single_name | ||
| 12 | assert_equal %w(Fun), TagList.from("Fun") | ||
| 13 | assert_equal %w(Fun), TagList.from('"Fun"') | ||
| 14 | end | ||
| 15 | |||
| 16 | def test_from_blank | ||
| 17 | assert_equal [], TagList.from(nil) | ||
| 18 | assert_equal [], TagList.from("") | ||
| 19 | end | ||
| 20 | |||
| 21 | def test_from_single_quoted_tag | ||
| 22 | assert_equal ['with, comma'], TagList.from('"with, comma"') | ||
| 23 | end | ||
| 24 | |||
| 25 | def test_spaces_do_not_delineate | ||
| 26 | assert_equal ['A B', 'C'], TagList.from('A B, C') | ||
| 27 | end | ||
| 28 | |||
| 29 | def test_from_multiple_tags | ||
| 30 | assert_equivalent %w(Alpha Beta Delta Gamma), TagList.from("Alpha, Beta, Delta, Gamma") | ||
| 31 | end | ||
| 32 | |||
| 33 | def test_from_multiple_tags_with_quotes | ||
| 34 | assert_equivalent %w(Alpha Beta Delta Gamma), TagList.from('Alpha, "Beta", Gamma , "Delta"') | ||
| 35 | end | ||
| 36 | |||
| 37 | def test_from_with_single_quotes | ||
| 38 | assert_equivalent ['A B', 'C'], TagList.from("'A B', C") | ||
| 39 | end | ||
| 40 | |||
| 41 | def test_from_multiple_tags_with_quote_and_commas | ||
| 42 | assert_equivalent ['Alpha, Beta', 'Delta', 'Gamma, something'], TagList.from('"Alpha, Beta", Delta, "Gamma, something"') | ||
| 43 | end | ||
| 44 | |||
| 45 | def test_from_with_inner_quotes | ||
| 46 | assert_equivalent ["House", "Drum 'n' Bass", "Trance"], TagList.from("House, Drum 'n' Bass, Trance") | ||
| 47 | assert_equivalent ["House", "Drum'n'Bass", "Trance"], TagList.from("House, Drum'n'Bass, Trance") | ||
| 48 | end | ||
| 49 | |||
| 50 | def test_from_removes_white_space | ||
| 51 | assert_equivalent %w(Alpha Beta), TagList.from('" Alpha ", "Beta "') | ||
| 52 | assert_equivalent %w(Alpha Beta), TagList.from(' Alpha, Beta ') | ||
| 53 | end | ||
| 54 | |||
| 55 | def test_from_and_new_treat_both_accept_arrays | ||
| 56 | tags = ["One", "Two"] | ||
| 57 | |||
| 58 | assert_equal TagList.from(tags), TagList.new(tags) | ||
| 59 | end | ||
| 60 | |||
| 61 | def test_alternative_delimiter | ||
| 62 | TagList.delimiter = " " | ||
| 63 | |||
| 64 | assert_equal %w(One Two), TagList.from("One Two") | ||
| 65 | assert_equal ['One two', 'three', 'four'], TagList.from('"One two" three four') | ||
| 66 | ensure | ||
| 67 | TagList.delimiter = "," | ||
| 68 | end | ||
| 69 | |||
| 70 | def test_duplicate_tags_removed | ||
| 71 | assert_equal %w(One), TagList.from("One, One") | ||
| 72 | end | ||
| 73 | |||
| 74 | def test_to_s_with_commas | ||
| 75 | assert_equal "Question, Crazy Animal", TagList.new("Question", "Crazy Animal").to_s | ||
| 76 | end | ||
| 77 | |||
| 78 | def test_to_s_with_alternative_delimiter | ||
| 79 | TagList.delimiter = " " | ||
| 80 | |||
| 81 | assert_equal '"Crazy Animal" Question', TagList.new("Crazy Animal", "Question").to_s | ||
| 82 | ensure | ||
| 83 | TagList.delimiter = "," | ||
| 84 | end | ||
| 85 | |||
| 86 | def test_add | ||
| 87 | tag_list = TagList.new("One") | ||
| 88 | assert_equal %w(One), tag_list | ||
| 89 | |||
| 90 | assert_equal %w(One Two), tag_list.add("Two") | ||
| 91 | assert_equal %w(One Two Three), tag_list.add(["Three"]) | ||
| 92 | end | ||
| 93 | |||
| 94 | def test_remove | ||
| 95 | tag_list = TagList.new("One", "Two") | ||
| 96 | assert_equal %w(Two), tag_list.remove("One") | ||
| 97 | assert_equal %w(), tag_list.remove(["Two"]) | ||
| 98 | end | ||
| 99 | |||
| 100 | def test_new_with_parsing | ||
| 101 | assert_equal %w(One Two), TagList.new("One, Two", :parse => true) | ||
| 102 | end | ||
| 103 | |||
| 104 | def test_add_with_parsing | ||
| 105 | assert_equal %w(One Two), TagList.new.add("One, Two", :parse => true) | ||
| 106 | end | ||
| 107 | |||
| 108 | def test_remove_with_parsing | ||
| 109 | tag_list = TagList.from("Three, Four, Five") | ||
| 110 | assert_equal %w(Four), tag_list.remove("Three, Five", :parse => true) | ||
| 111 | end | ||
| 112 | |||
| 113 | def test_toggle | ||
| 114 | tag_list = TagList.new("One", "Two") | ||
| 115 | assert_equal %w(One Three), tag_list.toggle("Two", "Three") | ||
| 116 | assert_equal %w(), tag_list.toggle("One", "Three") | ||
| 117 | assert_equal %w(Four), tag_list.toggle("Four") | ||
| 118 | end | ||
| 119 | end | ||
diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/tag_test.rb b/vendor/plugins/acts_as_taggable_on_steroids/test/tag_test.rb new file mode 100644 index 0000000..97dd249 --- /dev/null +++ b/vendor/plugins/acts_as_taggable_on_steroids/test/tag_test.rb | |||
| @@ -0,0 +1,62 @@ | |||
| 1 | require File.dirname(__FILE__) + '/abstract_unit' | ||
| 2 | |||
| 3 | class TagTest < ActiveSupport::TestCase | ||
| 4 | def test_name_required | ||
| 5 | t = Tag.create | ||
| 6 | assert_match /blank/, t.errors[:name].to_s | ||
| 7 | end | ||
| 8 | |||
| 9 | def test_name_unique | ||
| 10 | t = Tag.create!(:name => "My tag") | ||
| 11 | duplicate = t.clone | ||
| 12 | |||
| 13 | assert !duplicate.save | ||
| 14 | assert_match /taken/, duplicate.errors[:name].to_s | ||
| 15 | end | ||
| 16 | |||
| 17 | def test_taggings | ||
| 18 | assert_equivalent [taggings(:jonathan_sky_good), taggings(:sam_flowers_good), taggings(:sam_flower_good), taggings(:ruby_good)], tags(:good).taggings | ||
| 19 | assert_equivalent [taggings(:sam_ground_bad), taggings(:jonathan_bad_cat_bad)], tags(:bad).taggings | ||
| 20 | end | ||
| 21 | |||
| 22 | def test_to_s | ||
| 23 | assert_equal tags(:good).name, tags(:good).to_s | ||
| 24 | end | ||
| 25 | |||
| 26 | def test_equality | ||
| 27 | assert_equal tags(:good), tags(:good) | ||
| 28 | assert_equal Tag.find(tags(:good).id), Tag.find(tags(:good).id) | ||
| 29 | assert_equal Tag.new(:name => 'A'), Tag.new(:name => 'A') | ||
| 30 | assert_not_equal Tag.new(:name => 'A'), Tag.new(:name => 'B') | ||
| 31 | end | ||
| 32 | |||
| 33 | def test_taggings_removed_when_tag_destroyed | ||
| 34 | assert_difference "Tagging.count", -Tagging.count(:conditions => { :tag_id => tags(:good).id }) do | ||
| 35 | assert tags(:good).destroy | ||
| 36 | end | ||
| 37 | end | ||
| 38 | |||
| 39 | def test_all_counts | ||
| 40 | assert_tag_counts Tag.counts, :good => 4, :bad => 2, :nature => 10, :question => 2, :animal => 3 | ||
| 41 | end | ||
| 42 | |||
| 43 | def test_all_counts_with_string_conditions | ||
| 44 | assert_tag_counts Tag.counts(:conditions => 'taggings.created_at >= \'2006-08-15\''), | ||
| 45 | :question => 1, :bad => 1, :animal => 1, :nature => 2, :good => 2 | ||
| 46 | end | ||
| 47 | |||
| 48 | def test_all_counts_with_array_conditions | ||
| 49 | assert_tag_counts Tag.counts(:conditions => ['taggings.created_at >= ?', '2006-08-15']), | ||
| 50 | :question => 1, :bad => 1, :animal => 1, :nature => 2, :good => 2 | ||
| 51 | end | ||
| 52 | |||
| 53 | def test_all_counts_with_hash_conditions | ||
| 54 | tag_counts = Tag.counts( | ||
| 55 | :conditions => { | ||
| 56 | :taggings => { :created_at => (DateTime.parse('2006-08-14 23:59') .. DateTime.parse('4000-01-01')) } | ||
| 57 | } | ||
| 58 | ) | ||
| 59 | |||
| 60 | assert_tag_counts tag_counts, :question => 1, :bad => 1, :animal => 1, :nature => 2, :good => 2 | ||
| 61 | end | ||
| 62 | end | ||
diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/tagging_test.rb b/vendor/plugins/acts_as_taggable_on_steroids/test/tagging_test.rb new file mode 100644 index 0000000..bea4583 --- /dev/null +++ b/vendor/plugins/acts_as_taggable_on_steroids/test/tagging_test.rb | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | require File.dirname(__FILE__) + '/abstract_unit' | ||
| 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 | ||
diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/tags_helper_test.rb b/vendor/plugins/acts_as_taggable_on_steroids/test/tags_helper_test.rb new file mode 100644 index 0000000..c482909 --- /dev/null +++ b/vendor/plugins/acts_as_taggable_on_steroids/test/tags_helper_test.rb | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | require File.dirname(__FILE__) + '/abstract_unit' | ||
| 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 | ||
diff --git a/vendor/plugins/acts_as_taggable_redux/README b/vendor/plugins/acts_as_taggable_redux/README deleted file mode 100644 index d2ea032..0000000 --- a/vendor/plugins/acts_as_taggable_redux/README +++ /dev/null | |||
| @@ -1,143 +0,0 @@ | |||
| 1 | ActsAsTaggableRedux | ||
| 2 | =================== | ||
| 3 | |||
| 4 | Allows for user owned tags to be added to multiple classes, and makes tags easier to work with. | ||
| 5 | |||
| 6 | |||
| 7 | Prerequisites | ||
| 8 | ============= | ||
| 9 | |||
| 10 | Install Edge Rails before you get started so you get RESTful routing. | ||
| 11 | |||
| 12 | ActsAsTaggableRedux depends on database tables to store tagging information. Create the migration for these tables with this command: | ||
| 13 | |||
| 14 | rake acts_as_taggable:db:create | ||
| 15 | |||
| 16 | Then run the migration to create the tables with this command: | ||
| 17 | |||
| 18 | rake db:migrate | ||
| 19 | |||
| 20 | Also you will need to add this to your user model: | ||
| 21 | acts_as_tagger | ||
| 22 | |||
| 23 | OPTIONAL: The helper functions assume the pressence of a tags controller, that is what the tag clouds and tags will link to. | ||
| 24 | |||
| 25 | OPTIONAL: To pretty up tag clouds and lists you can generate an example stylesheet with this command: | ||
| 26 | |||
| 27 | rake acts_as_taggable:stylesheet:create | ||
| 28 | |||
| 29 | and then include this in your layouts that have tag clouds: | ||
| 30 | |||
| 31 | <%= stylesheet_link_tag 'acts_as_taggable_stylesheet' %> | ||
| 32 | |||
| 33 | |||
| 34 | Example | ||
| 35 | ======= | ||
| 36 | |||
| 37 | The following is an example of how you might integrate tags with an Item model. | ||
| 38 | |||
| 39 | config/routes.rb | ||
| 40 | may.resource :items, :tags | ||
| 41 | |||
| 42 | |||
| 43 | app/views/items/new.erb | ||
| 44 | <h1>New Item</h1> | ||
| 45 | |||
| 46 | <% form_for(:item, @item) do |f| -%> | ||
| 47 | |||
| 48 | <%= error_message_for :item %> | ||
| 49 | |||
| 50 | <b>Tags:</b> <%= f.text_field :tag_list -%> | ||
| 51 | |||
| 52 | <%= submit_tag "Save" -%> | ||
| 53 | |||
| 54 | <% end -%> | ||
| 55 | |||
| 56 | if you want users to own taggings change the tags line to this | ||
| 57 | <b>Tags:</b> <%= f.text_field :tag_list, :value => @item.tag_list(user) -%> | ||
| 58 | and add this line beneath it | ||
| 59 | <%= f.hidden_field :user_id, :value => user.id -%> | ||
| 60 | |||
| 61 | app/views/items/show.erb | ||
| 62 | Item tagged with: | ||
| 63 | <% item.tags.each do |tag| -%> | ||
| 64 | <%= link_to_tag(tag) %> | ||
| 65 | <% end -%> | ||
| 66 | |||
| 67 | app/views/items/edit.erb | ||
| 68 | <h1>New Item</h1> | ||
| 69 | |||
| 70 | <% form_for(:item, @item, :html => { :method => :post }) do |f| -%> | ||
| 71 | |||
| 72 | <%= error_messages_for :item %> | ||
| 73 | |||
| 74 | <b>Tags:</b> <%= f.text_field :tag_list -%> | ||
| 75 | |||
| 76 | <%= submit_tag "Save" -%> | ||
| 77 | |||
| 78 | <% end -%> | ||
| 79 | |||
| 80 | |||
| 81 | app/controllers/items_controller.rb | ||
| 82 | class ItemController < ApplicationController | ||
| 83 | def new | ||
| 84 | @item = Item.new | ||
| 85 | end | ||
| 86 | |||
| 87 | def create | ||
| 88 | @item = Item.new(params[:item]) | ||
| 89 | |||
| 90 | respond_to do |format| | ||
| 91 | if @item.save | ||
| 92 | flash[:notice] = 'Item was successfully created.' | ||
| 93 | format.html { redirect_to item_url(@item) } | ||
| 94 | format.xml { head :created, :location => item_url(@item) } | ||
| 95 | else | ||
| 96 | format.html { render :action => "new" } | ||
| 97 | format.xml { render :xml => @item.errors.to_xml } | ||
| 98 | end | ||
| 99 | end | ||
| 100 | end | ||
| 101 | |||
| 102 | def show | ||
| 103 | @item = Item.find(params[:id], :include => :tags) | ||
| 104 | end | ||
| 105 | |||
| 106 | def edit | ||
| 107 | @item = Item.find(params[:id]) | ||
| 108 | end | ||
| 109 | |||
| 110 | def update | ||
| 111 | @item = Item.find(params[:id]) | ||
| 112 | |||
| 113 | respond_to do |format| | ||
| 114 | if @item.update_attributes(params[:item]) | ||
| 115 | flash[:notice] = 'Item was successfully updated.' | ||
| 116 | format.html { redirect_to item_url(@item) } | ||
| 117 | format.xml { head :updated, :location => item_url(@item) } | ||
| 118 | end | ||
| 119 | format.html { render :action => "edit"} | ||
| 120 | format.xml { render :xml => @item.errors.to_xml} | ||
| 121 | end | ||
| 122 | end | ||
| 123 | end | ||
| 124 | |||
| 125 | |||
| 126 | |||
| 127 | Tag clouds | ||
| 128 | ========== | ||
| 129 | |||
| 130 | Tag clouds are created by a helper function, and depend on the counter cache to get fast accurate counts. To ensure this keeps working properly, don't add new tags to a taggable in any way other than using the tag.tag(taggable) style. This will ensure that the caches don't lose track. Also, see the prerequisites for installing the stylesheet so that the tag cloud actually looks like a tag cloud. Otherwise, just pop into a view that you want the tag cloud to appear and type this: | ||
| 131 | |||
| 132 | <%= tag_cloud %> | ||
| 133 | |||
| 134 | |||
| 135 | |||
| 136 | Contributing | ||
| 137 | ============ | ||
| 138 | |||
| 139 | Welcoming all pull requests on github.com at http://github.com/monki/acts_as_taggable_redux/tree/master or git://github.com/monki/acts_as_taggable_redux.git | ||
| 140 | |||
| 141 | |||
| 142 | |||
| 143 | Copyright (c) 2008 monki(Wesley Beary), released under the MIT license \ No newline at end of file | ||
diff --git a/vendor/plugins/acts_as_taggable_redux/acts_as_taggable_redux.gemspec b/vendor/plugins/acts_as_taggable_redux/acts_as_taggable_redux.gemspec deleted file mode 100644 index 9ea8dc1..0000000 --- a/vendor/plugins/acts_as_taggable_redux/acts_as_taggable_redux.gemspec +++ /dev/null | |||
| @@ -1,44 +0,0 @@ | |||
| 1 | Gem::Specification.new do |s| | ||
| 2 | s.name = 'acts_as_taggable_redux' | ||
| 3 | s.version = '0.0.1' | ||
| 4 | s.date = '2008-12-06' | ||
| 5 | |||
| 6 | s.summary = 'Allows for user owned tags to be added to multiple classes, and makes tags easier to work with.' | ||
| 7 | s.description = 'Allows for user owned tags to be added to multiple classes, and makes tags easier to work with.' | ||
| 8 | |||
| 9 | s.authors = ['Wesley Beary'] | ||
| 10 | s.email = 'monki@geemus.com' | ||
| 11 | s.homepage = 'http://github.com/monki/acts_as_taggable_redux' | ||
| 12 | |||
| 13 | s.has_rdoc = false | ||
| 14 | s.files = [ | ||
| 15 | 'generators/acts_as_taggable_tables/templates/migration.rb', | ||
| 16 | 'generators/acts_as_taggable_tables/acts_as_taggable_tables_generator.rb', | ||
| 17 | 'generators/acts_as_taggable_stylesheet/templates/acts_as_taggable_stylesheet.css', | ||
| 18 | 'generators/acts_as_taggable_stylesheet/acts_as_taggable_stylesheet_generator.rb', | ||
| 19 | 'init.rb', | ||
| 20 | 'lib/acts_as_taggable.rb', | ||
| 21 | 'lib/acts_as_tagger.rb', | ||
| 22 | 'lib/acts_as_taggable_helper.rb', | ||
| 23 | 'lib/acts_as_taggable_redux.rb', | ||
| 24 | 'lib/tag.rb', | ||
| 25 | 'lib/tagging.rb', | ||
| 26 | 'MIT-LICENSE', | ||
| 27 | 'Rakefile', | ||
| 28 | 'README', | ||
| 29 | 'tasks/acts_as_taggable_tasks.rake', | ||
| 30 | 'test/tagging_test.rb', | ||
| 31 | 'test/debug.log', | ||
| 32 | 'test/test_helper.rb', | ||
| 33 | 'test/fixtures/users.yml', | ||
| 34 | 'test/fixtures/tags.yml', | ||
| 35 | 'test/fixtures/things.yml', | ||
| 36 | 'test/fixtures/thing.rb', | ||
| 37 | 'test/fixtures/taggings.yml', | ||
| 38 | 'test/fixtures/user.rb', | ||
| 39 | 'test/acts_as_taggable_test.rb', | ||
| 40 | 'test/tag_test.rb', | ||
| 41 | 'test/database.yml', | ||
| 42 | 'test/schema.rb' | ||
| 43 | ] | ||
| 44 | end | ||
diff --git a/vendor/plugins/acts_as_taggable_redux/generators/acts_as_taggable_stylesheet/acts_as_taggable_stylesheet_generator.rb b/vendor/plugins/acts_as_taggable_redux/generators/acts_as_taggable_stylesheet/acts_as_taggable_stylesheet_generator.rb deleted file mode 100644 index 5eb60b8..0000000 --- a/vendor/plugins/acts_as_taggable_redux/generators/acts_as_taggable_stylesheet/acts_as_taggable_stylesheet_generator.rb +++ /dev/null | |||
| @@ -1,7 +0,0 @@ | |||
| 1 | class ActsAsTaggableStylesheetGenerator < Rails::Generator::Base | ||
| 2 | def manifest | ||
| 3 | record do |m| | ||
| 4 | m.file "acts_as_taggable_stylesheet.css", "public/stylesheets/acts_as_taggable_stylesheet.css" | ||
| 5 | end | ||
| 6 | end | ||
| 7 | end \ No newline at end of file | ||
diff --git a/vendor/plugins/acts_as_taggable_redux/generators/acts_as_taggable_stylesheet/templates/acts_as_taggable_stylesheet.css b/vendor/plugins/acts_as_taggable_redux/generators/acts_as_taggable_stylesheet/templates/acts_as_taggable_stylesheet.css deleted file mode 100644 index b1c86de..0000000 --- a/vendor/plugins/acts_as_taggable_redux/generators/acts_as_taggable_stylesheet/templates/acts_as_taggable_stylesheet.css +++ /dev/null | |||
| @@ -1,7 +0,0 @@ | |||
| 1 | .hTagcloud .popularity { margin:0; padding:0; } | ||
| 2 | .hTagcloud .popularity li { display:inline; text-decoration:none; } | ||
| 3 | .hTagcloud .popularity .popular { font-size:1.0em; } | ||
| 4 | .hTagcloud .popularity .v-popular { font-size:1.2em; } | ||
| 5 | .hTagcloud .popularity .vv-popular { font-size:1.4em; } | ||
| 6 | .hTagcloud .popularity .vvv-popular { font-size:1.6em; } | ||
| 7 | .hTagcloud .popularity .vvvv-popular { font-size:1.8em; } \ No newline at end of file | ||
diff --git a/vendor/plugins/acts_as_taggable_redux/generators/acts_as_taggable_tables/acts_as_taggable_tables_generator.rb b/vendor/plugins/acts_as_taggable_redux/generators/acts_as_taggable_tables/acts_as_taggable_tables_generator.rb deleted file mode 100644 index f6d3e51..0000000 --- a/vendor/plugins/acts_as_taggable_redux/generators/acts_as_taggable_tables/acts_as_taggable_tables_generator.rb +++ /dev/null | |||
| @@ -1,7 +0,0 @@ | |||
| 1 | class ActsAsTaggableTablesGenerator < Rails::Generator::NamedBase | ||
| 2 | def manifest | ||
| 3 | record do |m| | ||
| 4 | m.migration_template 'migration.rb', 'db/migrate' | ||
| 5 | end | ||
| 6 | end | ||
| 7 | end \ No newline at end of file | ||
diff --git a/vendor/plugins/acts_as_taggable_redux/generators/acts_as_taggable_tables/templates/migration.rb b/vendor/plugins/acts_as_taggable_redux/generators/acts_as_taggable_tables/templates/migration.rb deleted file mode 100644 index 335ef6c..0000000 --- a/vendor/plugins/acts_as_taggable_redux/generators/acts_as_taggable_tables/templates/migration.rb +++ /dev/null | |||
| @@ -1,29 +0,0 @@ | |||
| 1 | class AddActsAsTaggableTables < ActiveRecord::Migration | ||
| 2 | def self.up | ||
| 3 | create_table :tags do |t| | ||
| 4 | t.column :name, :string | ||
| 5 | t.column :taggings_count, :integer, :default => 0, :null => false | ||
| 6 | end | ||
| 7 | add_index :tags, :name | ||
| 8 | add_index :tags, :taggings_count | ||
| 9 | |||
| 10 | create_table :taggings do |t| | ||
| 11 | t.column :tag_id, :integer | ||
| 12 | t.column :taggable_id, :integer | ||
| 13 | t.column :taggable_type, :string | ||
| 14 | t.column :user_id, :integer | ||
| 15 | end | ||
| 16 | |||
| 17 | # Find objects for a tag | ||
| 18 | add_index :taggings, [:tag_id, :taggable_type] | ||
| 19 | add_index :taggings, [:user_id, :tag_id, :taggable_type] | ||
| 20 | # Find tags for an object | ||
| 21 | add_index :taggings, [:taggable_id, :taggable_type] | ||
| 22 | add_index :taggings, [:user_id, :taggable_id, :taggable_type] | ||
| 23 | end | ||
| 24 | |||
| 25 | def self.down | ||
| 26 | drop_table :tags | ||
| 27 | drop_table :taggings | ||
| 28 | end | ||
| 29 | end \ No newline at end of file | ||
diff --git a/vendor/plugins/acts_as_taggable_redux/init.rb b/vendor/plugins/acts_as_taggable_redux/init.rb deleted file mode 100644 index bcc3499..0000000 --- a/vendor/plugins/acts_as_taggable_redux/init.rb +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | require 'acts_as_taggable_redux' | ||
diff --git a/vendor/plugins/acts_as_taggable_redux/lib/acts_as_taggable.rb b/vendor/plugins/acts_as_taggable_redux/lib/acts_as_taggable.rb deleted file mode 100644 index e070d2b..0000000 --- a/vendor/plugins/acts_as_taggable_redux/lib/acts_as_taggable.rb +++ /dev/null | |||
| @@ -1,137 +0,0 @@ | |||
| 1 | module ActiveRecord | ||
| 2 | module Acts #:nodoc: | ||
| 3 | module Taggable #:nodoc: | ||
| 4 | def self.included(base) | ||
| 5 | base.extend(ClassMethods) | ||
| 6 | end | ||
| 7 | |||
| 8 | module ClassMethods | ||
| 9 | def acts_as_taggable(options = {}) | ||
| 10 | has_many :taggings, :as => :taggable, :dependent => :destroy, :include => :tag | ||
| 11 | has_many :tags, :through => :taggings, :order => 'LOWER(name) asc', :select => "DISTINCT tags.*" | ||
| 12 | |||
| 13 | after_save :update_tags | ||
| 14 | |||
| 15 | extend ActiveRecord::Acts::Taggable::SingletonMethods | ||
| 16 | include ActiveRecord::Acts::Taggable::InstanceMethods | ||
| 17 | end | ||
| 18 | end | ||
| 19 | |||
| 20 | module SingletonMethods | ||
| 21 | # Pass a tag string, returns taggables that match the tag string. | ||
| 22 | # | ||
| 23 | # Options: | ||
| 24 | # :match - Match taggables matching :all or :any of the tags, defaults to :any | ||
| 25 | # :user - Limits results to those owned by a particular user | ||
| 26 | def find_tagged_with(tags, options = {}) | ||
| 27 | tagged_with_scope(tags, options) do | ||
| 28 | find(:all, :select => "DISTINCT #{table_name}.*") | ||
| 29 | end | ||
| 30 | end | ||
| 31 | |||
| 32 | def tagged_with_scope(tags, options={}) | ||
| 33 | options.assert_valid_keys([:match, :order, :user, :limit]) | ||
| 34 | |||
| 35 | tags = Tag.parse(tags) | ||
| 36 | return [] if tags.empty? | ||
| 37 | |||
| 38 | group = "#{table_name}_taggings.taggable_id HAVING COUNT(#{table_name}_taggings.taggable_id) >= #{tags.size}" if options[:match] == :all | ||
| 39 | conditions = sanitize_sql(["#{table_name}_tags.name IN (?)", tags]) | ||
| 40 | conditions += sanitize_sql([" AND #{table_name}_taggings.user_id = ?", options[:user]]) if options[:user] | ||
| 41 | |||
| 42 | find_parameters = { | ||
| 43 | :joins => "LEFT OUTER JOIN #{Tagging.table_name} #{table_name}_taggings ON #{table_name}_taggings.taggable_id = #{table_name}.#{primary_key} AND #{table_name}_taggings.taggable_type = '#{name}' " + | ||
| 44 | "LEFT OUTER JOIN #{Tag.table_name} #{table_name}_tags ON #{table_name}_tags.id = #{table_name}_taggings.tag_id", | ||
| 45 | :conditions => conditions, | ||
| 46 | :group => group, | ||
| 47 | :order => options[:order], | ||
| 48 | :limit => options[:limit] | ||
| 49 | } | ||
| 50 | |||
| 51 | with_scope(:find => find_parameters) { yield } | ||
| 52 | end | ||
| 53 | |||
| 54 | # Pass a tag string, returns taggables that match the tag string for a particular user. | ||
| 55 | # | ||
| 56 | # Options: | ||
| 57 | # :match - Match taggables matching :all or :any of the tags, defaults to :any | ||
| 58 | def find_tagged_with_by_user(tags, user, options = {}) | ||
| 59 | options.assert_valid_keys([:match, :order]) | ||
| 60 | find_tagged_with(tags, {:match => options[:match], :order => options[:order], :user => user}) | ||
| 61 | end | ||
| 62 | |||
| 63 | # Returns an array of related tags. | ||
| 64 | # Related tags are all the other tags that are found on the models tagged with the provided tags. | ||
| 65 | # | ||
| 66 | # Pass either a tag, string, or an array of strings or tags. | ||
| 67 | # | ||
| 68 | # Options: | ||
| 69 | # :order - SQL Order how to order the tags. Defaults to "count DESC, tags.name". | ||
| 70 | # :match - Match taggables matching :all or :any of the tags, defaults to :any | ||
| 71 | def find_related_tags(tags, options = {}) | ||
| 72 | #duplicated work, the tags are parsed twice. I need to elimidate this by making find_tagged_with | ||
| 73 | #accept an array of tags and not just a string | ||
| 74 | parsed_tags = Tag.parse(tags) | ||
| 75 | related_models = find_tagged_with(tags, :match => options.delete(:match)) | ||
| 76 | |||
| 77 | return [] if related_models.blank? | ||
| 78 | |||
| 79 | related_ids = related_models.to_s(:db) | ||
| 80 | |||
| 81 | Tag.find(:all, options.merge({ | ||
| 82 | :select => "#{Tag.table_name}.*, COUNT(#{Tag.table_name}.id) AS count", | ||
| 83 | :joins => "JOIN #{Tagging.table_name} ON #{Tagging.table_name}.taggable_type = '#{base_class.name}' | ||
| 84 | AND #{Tagging.table_name}.taggable_id IN (#{related_ids}) | ||
| 85 | AND #{Tagging.table_name}.tag_id = #{Tag.table_name}.id", | ||
| 86 | :order => options[:order] || "count DESC, #{Tag.table_name}.name", | ||
| 87 | :group => "#{Tag.table_name}.id, #{Tag.table_name}.name HAVING #{Tag.table_name}.name NOT IN (#{parsed_tags.map { |n| quote_value(n) }.join(",")})" | ||
| 88 | })) | ||
| 89 | end | ||
| 90 | end | ||
| 91 | |||
| 92 | module InstanceMethods | ||
| 93 | def tag_list=(new_tag_list) | ||
| 94 | unless tag_list == new_tag_list | ||
| 95 | @new_tag_list = new_tag_list | ||
| 96 | end | ||
| 97 | end | ||
| 98 | |||
| 99 | def user_id=(new_user_id) | ||
| 100 | @new_user_id = new_user_id | ||
| 101 | super(new_user_id) | ||
| 102 | end | ||
| 103 | |||
| 104 | def tag_list(user = nil) | ||
| 105 | unless user | ||
| 106 | result = tags.collect { |tag| tag.name.include?(" ") ? %("#{tag.name}") : tag.name }.join(" ") | ||
| 107 | else | ||
| 108 | #TODO: make it work if I pass in an int instead of a user object | ||
| 109 | tags.find(:all, :conditions => ["#{Tagging.table_name}.user_id = ?", user.id]).collect { |tag| tag.name.include?(" ") ? %("#{tag.name}") : tag.name }.uniq.join(" ") | ||
| 110 | end | ||
| 111 | end | ||
| 112 | |||
| 113 | def update_tags | ||
| 114 | if @new_tag_list | ||
| 115 | Tag.transaction do | ||
| 116 | unless @new_user_id | ||
| 117 | taggings.destroy_all | ||
| 118 | else | ||
| 119 | taggings.find(:all, :conditions => "user_id = #{@new_user_id}").each do |tagging| | ||
| 120 | tagging.destroy | ||
| 121 | end | ||
| 122 | end | ||
| 123 | |||
| 124 | Tag.parse(@new_tag_list).each do |name| | ||
| 125 | Tag.find_or_create_by_name(name).tag(self, @new_user_id) | ||
| 126 | end | ||
| 127 | |||
| 128 | tags.reset | ||
| 129 | taggings.reset | ||
| 130 | @new_tag_list = nil | ||
| 131 | end | ||
| 132 | end | ||
| 133 | end | ||
| 134 | end | ||
| 135 | end | ||
| 136 | end | ||
| 137 | end | ||
diff --git a/vendor/plugins/acts_as_taggable_redux/lib/acts_as_taggable_helper.rb b/vendor/plugins/acts_as_taggable_redux/lib/acts_as_taggable_helper.rb deleted file mode 100644 index 87bc29a..0000000 --- a/vendor/plugins/acts_as_taggable_redux/lib/acts_as_taggable_helper.rb +++ /dev/null | |||
| @@ -1,38 +0,0 @@ | |||
| 1 | module ActsAsTaggableHelper | ||
| 2 | # Create a link to the tag using restful routes and the rel-tag microformat | ||
| 3 | def link_to_tag(tag) | ||
| 4 | link_to(tag.name, tag_url(tag), :rel => 'tag') | ||
| 5 | end | ||
| 6 | |||
| 7 | # Generate a tag cloud of the top 100 tags by usage, uses the proposed hTagcloud microformat. | ||
| 8 | # | ||
| 9 | # Inspired by http://www.juixe.com/techknow/index.php/2006/07/15/acts-as-taggable-tag-cloud/ | ||
| 10 | def tag_cloud(options = {}) | ||
| 11 | options.assert_valid_keys(:limit, :conditions, :sort) | ||
| 12 | options.reverse_merge! :limit => 100, :sort => :name | ||
| 13 | sort = options.delete(:sort) | ||
| 14 | |||
| 15 | tags = Tag.find(:all, options.merge(:order => 'taggings_count DESC')).sort_by(&sort) | ||
| 16 | |||
| 17 | # TODO: add option to specify which classes you want and overide this if you want? | ||
| 18 | classes = %w(popular v-popular vv-popular vvv-popular vvvv-popular) | ||
| 19 | |||
| 20 | max, min = 0, 0 | ||
| 21 | tags.each do |tag| | ||
| 22 | max = tag.taggings_count if tag.taggings_count > max | ||
| 23 | min = tag.taggings_count if tag.taggings_count < min | ||
| 24 | end | ||
| 25 | |||
| 26 | divisor = ((max - min) / classes.size) + 1 | ||
| 27 | |||
| 28 | html = %(<div class="hTagcloud">\n) | ||
| 29 | html << %( <ul class="popularity">\n) | ||
| 30 | tags.each do |tag| | ||
| 31 | html << %( <li>) | ||
| 32 | html << link_to(tag.name, tag_url(tag), :class => classes[(tag.taggings_count - min) / divisor]) | ||
| 33 | html << %(</li> \n) | ||
| 34 | end | ||
| 35 | html << %( </ul>\n) | ||
| 36 | html << %(</div>\n) | ||
| 37 | end | ||
| 38 | end \ No newline at end of file | ||
diff --git a/vendor/plugins/acts_as_taggable_redux/lib/acts_as_taggable_redux.rb b/vendor/plugins/acts_as_taggable_redux/lib/acts_as_taggable_redux.rb deleted file mode 100644 index c5090ae..0000000 --- a/vendor/plugins/acts_as_taggable_redux/lib/acts_as_taggable_redux.rb +++ /dev/null | |||
| @@ -1,9 +0,0 @@ | |||
| 1 | require 'acts_as_taggable' | ||
| 2 | require 'acts_as_tagger' | ||
| 3 | |||
| 4 | ActiveRecord::Base.send(:include, ActiveRecord::Acts::Taggable) | ||
| 5 | ActiveRecord::Base.send(:include, ActiveRecord::Acts::Tagger) | ||
| 6 | ActionView::Base.send(:include, ActsAsTaggableHelper) | ||
| 7 | |||
| 8 | require 'tagging' | ||
| 9 | require 'tag' | ||
diff --git a/vendor/plugins/acts_as_taggable_redux/lib/acts_as_tagger.rb b/vendor/plugins/acts_as_taggable_redux/lib/acts_as_tagger.rb deleted file mode 100644 index 16fc654..0000000 --- a/vendor/plugins/acts_as_taggable_redux/lib/acts_as_tagger.rb +++ /dev/null | |||
| @@ -1,25 +0,0 @@ | |||
| 1 | module ActiveRecord | ||
| 2 | module Acts #:nodoc: | ||
| 3 | module Tagger #:nodoc: | ||
| 4 | def self.included(base) | ||
| 5 | base.extend(ClassMethods) | ||
| 6 | end | ||
| 7 | |||
| 8 | module ClassMethods | ||
| 9 | def acts_as_tagger(options = {}) | ||
| 10 | has_many :taggings | ||
| 11 | has_many :tags, :through => :taggings, :select => "DISTINCT #{Tag.table_name}.*", :order => "LOWER(name) asc" | ||
| 12 | |||
| 13 | extend ActiveRecord::Acts::Tagger::SingletonMethods | ||
| 14 | include ActiveRecord::Acts::Tagger::InstanceMethods | ||
| 15 | end | ||
| 16 | end | ||
| 17 | |||
| 18 | module SingletonMethods | ||
| 19 | end | ||
| 20 | |||
| 21 | module InstanceMethods | ||
| 22 | end | ||
| 23 | end | ||
| 24 | end | ||
| 25 | end | ||
diff --git a/vendor/plugins/acts_as_taggable_redux/lib/tag.rb b/vendor/plugins/acts_as_taggable_redux/lib/tag.rb deleted file mode 100644 index 30362fc..0000000 --- a/vendor/plugins/acts_as_taggable_redux/lib/tag.rb +++ /dev/null | |||
| @@ -1,73 +0,0 @@ | |||
| 1 | class Tag < ActiveRecord::Base | ||
| 2 | has_many :taggings | ||
| 3 | |||
| 4 | # Parse a text string into an array of tokens for use as tags | ||
| 5 | def self.parse(list) | ||
| 6 | tag_names = [] | ||
| 7 | |||
| 8 | return tag_names if list.blank? | ||
| 9 | |||
| 10 | # first, pull out the quoted tags | ||
| 11 | list.gsub!(/\"(.*?)\"\s*/) { tag_names << $1; "" } | ||
| 12 | |||
| 13 | # then, replace all commas with a space | ||
| 14 | list.gsub!(/,/, " ") | ||
| 15 | |||
| 16 | # then, get whatever is left | ||
| 17 | tag_names.concat(list.split(/\s/)) | ||
| 18 | |||
| 19 | # delete any blank tag names | ||
| 20 | tag_names = tag_names.delete_if { |t| t.empty? } | ||
| 21 | |||
| 22 | # downcase all tags | ||
| 23 | tag_names = tag_names.map! { |t| t.downcase } | ||
| 24 | |||
| 25 | # remove duplicates | ||
| 26 | tag_names = tag_names.uniq | ||
| 27 | |||
| 28 | return tag_names | ||
| 29 | end | ||
| 30 | |||
| 31 | # Grab a distinct list of tags only for a particular type of taggable. | ||
| 32 | # For example, if you had a taggable Foo, you could get all tags used on Foo via: | ||
| 33 | # | ||
| 34 | # Tag.with_type_scope('Foo') { Tag.find(:all) } | ||
| 35 | # | ||
| 36 | # If no parameter is given, the scope does not take effect. | ||
| 37 | # | ||
| 38 | # pass in a user id to have it scope by user_id as well | ||
| 39 | |||
| 40 | def self.with_type_scope(taggable_type, user = nil) | ||
| 41 | if taggable_type | ||
| 42 | conditions = sanitize_sql(["taggable_type = ?", taggable_type]) | ||
| 43 | conditions += sanitize_sql([" AND #{Tagging.table_name}.user_id = ?", user.id]) if user | ||
| 44 | with_scope(:find => {:select => "distinct #{Tag.table_name}.*", :joins => "left outer join #{Tagging.table_name} on #{Tagging.table_name}.tag_id = #{Tag.table_name}.id", :conditions => conditions, :group => "name"}) { yield } | ||
| 45 | else | ||
| 46 | yield | ||
| 47 | end | ||
| 48 | end | ||
| 49 | |||
| 50 | # Tag a taggable with this tag, optionally add user to add owner to tagging | ||
| 51 | def tag(taggable, user_id = nil) | ||
| 52 | taggings.create :taggable => taggable, :user_id => user_id | ||
| 53 | taggings.reset | ||
| 54 | @tagged = nil | ||
| 55 | end | ||
| 56 | |||
| 57 | # A list of all the objects tagged with this tag | ||
| 58 | def tagged | ||
| 59 | @tagged ||= taggings.collect(&:taggable) | ||
| 60 | end | ||
| 61 | |||
| 62 | # Compare tags by name | ||
| 63 | def ==(comparison_object) | ||
| 64 | super || name == comparison_object.to_s | ||
| 65 | end | ||
| 66 | |||
| 67 | # Return the tag's name | ||
| 68 | def to_s | ||
| 69 | name | ||
| 70 | end | ||
| 71 | |||
| 72 | validates_presence_of :name | ||
| 73 | end | ||
diff --git a/vendor/plugins/acts_as_taggable_redux/lib/tagging.rb b/vendor/plugins/acts_as_taggable_redux/lib/tagging.rb deleted file mode 100644 index cbdf8f5..0000000 --- a/vendor/plugins/acts_as_taggable_redux/lib/tagging.rb +++ /dev/null | |||
| @@ -1,5 +0,0 @@ | |||
| 1 | class Tagging < ActiveRecord::Base | ||
| 2 | belongs_to :tag, :counter_cache => true | ||
| 3 | belongs_to :taggable, :polymorphic => true | ||
| 4 | belongs_to :user | ||
| 5 | end \ No newline at end of file | ||
diff --git a/vendor/plugins/acts_as_taggable_redux/tasks/acts_as_taggable_tasks.rake b/vendor/plugins/acts_as_taggable_redux/tasks/acts_as_taggable_tasks.rake deleted file mode 100644 index db400c5..0000000 --- a/vendor/plugins/acts_as_taggable_redux/tasks/acts_as_taggable_tasks.rake +++ /dev/null | |||
| @@ -1,20 +0,0 @@ | |||
| 1 | namespace :acts_as_taggable do | ||
| 2 | namespace :db do | ||
| 3 | desc "Creates tag tables for use with acts_as_taggable" | ||
| 4 | task :create => :environment do | ||
| 5 | require 'rails_generator' | ||
| 6 | require 'rails_generator/scripts/generate' | ||
| 7 | raise "Task unavailable to this database (no migration support)" unless ActiveRecord::Base.connection.supports_migrations? | ||
| 8 | Rails::Generator::Scripts::Generate.new.run([ "acts_as_taggable_tables", "add_acts_as_taggable_tables" ]) | ||
| 9 | end | ||
| 10 | end | ||
| 11 | |||
| 12 | namespace :stylesheet do | ||
| 13 | desc "Create tag stylesheet for use with acts_as_taggable" | ||
| 14 | task :create => :environment do | ||
| 15 | require 'rails_generator' | ||
| 16 | require 'rails_generator/scripts/generate' | ||
| 17 | Rails::Generator::Scripts::Generate.new.run([ "acts_as_taggable_stylesheet" ]) | ||
| 18 | end | ||
| 19 | end | ||
| 20 | end | ||
diff --git a/vendor/plugins/acts_as_taggable_redux/test/acts_as_taggable_test.rb b/vendor/plugins/acts_as_taggable_redux/test/acts_as_taggable_test.rb deleted file mode 100644 index 6e63813..0000000 --- a/vendor/plugins/acts_as_taggable_redux/test/acts_as_taggable_test.rb +++ /dev/null | |||
| @@ -1,34 +0,0 @@ | |||
| 1 | require File.dirname(__FILE__) + "/test_helper" | ||
| 2 | |||
| 3 | class ActsAsTaggableTest < Test::Unit::TestCase | ||
| 4 | def test_find_tagged_with_any | ||
| 5 | assert_equal [things(:bear), things(:frog)].sort_by(&:id), Thing.find_tagged_with("animal") | ||
| 6 | assert_equal [things(:bear), things(:frog), things(:cactus)].sort_by(&:id), Thing.find_tagged_with("animal green") | ||
| 7 | assert_equal [], Thing.find_tagged_with("fake") | ||
| 8 | |||
| 9 | assert_equal [things(:bear), things(:frog)].sort_by(&:id), Thing.find_tagged_with("animal", :match => :any) | ||
| 10 | assert_equal [things(:bear), things(:frog), things(:cactus)].sort_by(&:id), Thing.find_tagged_with("animal green", :match => :any) | ||
| 11 | assert_equal [], Thing.find_tagged_with("fake", :match => :any) | ||
| 12 | end | ||
| 13 | |||
| 14 | def test_find_tagged_with_all | ||
| 15 | assert_equal [things(:bear), things(:frog)].sort_by(&:id), Thing.find_tagged_with("animal", :match => :all) | ||
| 16 | assert_equal [things(:frog)].sort_by(&:id), Thing.find_tagged_with("animal green", :match => :all) | ||
| 17 | assert_equal [], Thing.find_tagged_with("fake", :match => :all) | ||
| 18 | assert_equal [], Thing.find_tagged_with("animal plant", :match => :all) | ||
| 19 | end | ||
| 20 | |||
| 21 | def test_tag_list | ||
| 22 | assert_equal things(:bear).tag_list, "animal \"not green\"" | ||
| 23 | assert_equal things(:frog).tag_list, "animal green" | ||
| 24 | assert_not_equal things(:frog).tag_list, "animal \"not green\"" | ||
| 25 | end | ||
| 26 | |||
| 27 | def test_update_tags | ||
| 28 | assert_equal things(:bear).tag_list, "animal \"not green\"" | ||
| 29 | things(:bear).tag_list = 'animal "not green" favorite' | ||
| 30 | assert_equal things(:bear).tag_list, "animal \"not green\"" | ||
| 31 | things(:bear).update_tags | ||
| 32 | assert_equal things(:bear).tag_list, "animal favorite \"not green\"" | ||
| 33 | end | ||
| 34 | end \ No newline at end of file | ||
diff --git a/vendor/plugins/acts_as_taggable_redux/test/debug.log b/vendor/plugins/acts_as_taggable_redux/test/debug.log deleted file mode 100644 index b736308..0000000 --- a/vendor/plugins/acts_as_taggable_redux/test/debug.log +++ /dev/null | |||
| @@ -1,104 +0,0 @@ | |||
| 1 | # Logfile created on Thu May 15 14:17:58 -0500 2008 by logger.rb/1.5.2.9 | ||
| 2 | [4;36;1mSQL (0.000346)[0m [0;1mselect sqlite_version(*)[0m | ||
| 3 | [4;35;1mSQL (0.000000)[0m [0mSQLite3::SQLException: no such table: tags: DROP TABLE tags[0m | ||
| 4 | [4;36;1mSQL (0.000336)[0m [0;1mCREATE TABLE tags ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255) DEFAULT NULL, "taggings_count" integer DEFAULT 0 NOT NULL) [0m | ||
| 5 | [4;35;1mSQL (0.000171)[0m [0mCREATE INDEX "index_tags_on_name" ON tags ("name")[0m | ||
| 6 | [4;36;1mSQL (0.000153)[0m [0;1mCREATE INDEX "index_tags_on_taggings_count" ON tags ("taggings_count")[0m | ||
| 7 | [4;35;1mSQL (0.000000)[0m [0mSQLite3::SQLException: no such table: taggings: DROP TABLE taggings[0m | ||
| 8 | [4;36;1mSQL (0.000188)[0m [0;1mCREATE TABLE taggings ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "tag_id" integer DEFAULT NULL, "taggable_id" integer DEFAULT NULL, "taggable_type" varchar(255) DEFAULT NULL, "user_id" integer DEFAULT NULL) [0m | ||
| 9 | [4;35;1mSQL (0.000153)[0m [0mCREATE INDEX "index_taggings_on_tag_id_and_taggable_type" ON taggings ("tag_id", "taggable_type")[0m | ||
| 10 | [4;36;1mSQL (0.000166)[0m [0;1mCREATE INDEX "index_taggings_on_user_id_and_tag_id_and_taggable_type" ON taggings ("user_id", "tag_id", "taggable_type")[0m | ||
| 11 | [4;35;1mSQL (0.000156)[0m [0mCREATE INDEX "index_taggings_on_taggable_id_and_taggable_type" ON taggings ("taggable_id", "taggable_type")[0m | ||
| 12 | [4;36;1mSQL (0.000161)[0m [0;1mCREATE INDEX "index_taggings_on_user_id_and_taggable_id_and_taggable_type" ON taggings ("user_id", "taggable_id", "taggable_type")[0m | ||
| 13 | [4;35;1mSQL (0.000000)[0m [0mSQLite3::SQLException: no such table: things: DROP TABLE things[0m | ||
| 14 | [4;36;1mSQL (0.000176)[0m [0;1mCREATE TABLE things ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255) DEFAULT NULL) [0m | ||
| 15 | [4;35;1mSQL (0.000000)[0m [0mSQLite3::SQLException: no such table: users: DROP TABLE users[0m | ||
| 16 | [4;36;1mSQL (0.000177)[0m [0;1mCREATE TABLE users ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "username" varchar(255) DEFAULT NULL) [0m | ||
| 17 | [4;35;1mSQL (0.000184)[0m [0mCREATE TABLE schema_info (version integer)[0m | ||
| 18 | [4;36;1mSQL (0.000069)[0m [0;1mINSERT INTO schema_info (version) VALUES(0)[0m | ||
| 19 | [4;35;1mSQL (0.000082)[0m [0mUPDATE schema_info SET version = 0[0m | ||
| 20 | [4;36;1mThing Load (0.000163)[0m [0;1mSELECT * FROM things WHERE (things."id" = 1) [0m | ||
| 21 | [4;35;1mThing Load (0.000162)[0m [0mSELECT * FROM things WHERE (things."id" = 2) [0m | ||
| 22 | [4;36;1mThing Load (0.001725)[0m [0;1mSELECT DISTINCT things.* FROM things LEFT OUTER JOIN taggings things_taggings ON things_taggings.taggable_id = things.id AND things_taggings.taggable_type = 'Thing' LEFT OUTER JOIN tags things_tags ON things_tags.id = things_taggings.tag_id WHERE (things_tags.name IN ('animal')) GROUP BY things_taggings.taggable_id HAVING COUNT(things_taggings.taggable_id) = 1[0m | ||
| 23 | [4;35;1mThing Load (0.001072)[0m [0mSELECT DISTINCT things.* FROM things LEFT OUTER JOIN taggings things_taggings ON things_taggings.taggable_id = things.id AND things_taggings.taggable_type = 'Thing' LEFT OUTER JOIN tags things_tags ON things_tags.id = things_taggings.tag_id WHERE (things_tags.name IN ('animal','green')) GROUP BY things_taggings.taggable_id HAVING COUNT(things_taggings.taggable_id) = 2[0m | ||
| 24 | [4;36;1mThing Load (0.000946)[0m [0;1mSELECT DISTINCT things.* FROM things LEFT OUTER JOIN taggings things_taggings ON things_taggings.taggable_id = things.id AND things_taggings.taggable_type = 'Thing' LEFT OUTER JOIN tags things_tags ON things_tags.id = things_taggings.tag_id WHERE (things_tags.name IN ('fake')) GROUP BY things_taggings.taggable_id HAVING COUNT(things_taggings.taggable_id) = 1[0m | ||
| 25 | [4;35;1mThing Load (0.000893)[0m [0mSELECT DISTINCT things.* FROM things LEFT OUTER JOIN taggings things_taggings ON things_taggings.taggable_id = things.id AND things_taggings.taggable_type = 'Thing' LEFT OUTER JOIN tags things_tags ON things_tags.id = things_taggings.tag_id WHERE (things_tags.name IN ('animal','plant')) GROUP BY things_taggings.taggable_id HAVING COUNT(things_taggings.taggable_id) = 2[0m | ||
| 26 | [4;36;1mThing Load (0.000182)[0m [0;1mSELECT * FROM things WHERE (things."id" = 1) [0m | ||
| 27 | [4;35;1mThing Load (0.000160)[0m [0mSELECT * FROM things WHERE (things."id" = 2) [0m | ||
| 28 | [4;36;1mThing Load (0.000919)[0m [0;1mSELECT DISTINCT things.* FROM things LEFT OUTER JOIN taggings things_taggings ON things_taggings.taggable_id = things.id AND things_taggings.taggable_type = 'Thing' LEFT OUTER JOIN tags things_tags ON things_tags.id = things_taggings.tag_id WHERE (things_tags.name IN ('animal')) [0m | ||
| 29 | [4;35;1mThing Load (0.000181)[0m [0mSELECT * FROM things WHERE (things."id" = 3) [0m | ||
| 30 | [4;36;1mThing Load (0.000909)[0m [0;1mSELECT DISTINCT things.* FROM things LEFT OUTER JOIN taggings things_taggings ON things_taggings.taggable_id = things.id AND things_taggings.taggable_type = 'Thing' LEFT OUTER JOIN tags things_tags ON things_tags.id = things_taggings.tag_id WHERE (things_tags.name IN ('animal','green')) [0m | ||
| 31 | [4;35;1mThing Load (0.001076)[0m [0mSELECT DISTINCT things.* FROM things LEFT OUTER JOIN taggings things_taggings ON things_taggings.taggable_id = things.id AND things_taggings.taggable_type = 'Thing' LEFT OUTER JOIN tags things_tags ON things_tags.id = things_taggings.tag_id WHERE (things_tags.name IN ('fake')) [0m | ||
| 32 | [4;36;1mThing Load (0.000792)[0m [0;1mSELECT DISTINCT things.* FROM things LEFT OUTER JOIN taggings things_taggings ON things_taggings.taggable_id = things.id AND things_taggings.taggable_type = 'Thing' LEFT OUTER JOIN tags things_tags ON things_tags.id = things_taggings.tag_id WHERE (things_tags.name IN ('animal')) [0m | ||
| 33 | [4;35;1mThing Load (0.000842)[0m [0mSELECT DISTINCT things.* FROM things LEFT OUTER JOIN taggings things_taggings ON things_taggings.taggable_id = things.id AND things_taggings.taggable_type = 'Thing' LEFT OUTER JOIN tags things_tags ON things_tags.id = things_taggings.tag_id WHERE (things_tags.name IN ('animal','green')) [0m | ||
| 34 | [4;36;1mThing Load (0.000694)[0m [0;1mSELECT DISTINCT things.* FROM things LEFT OUTER JOIN taggings things_taggings ON things_taggings.taggable_id = things.id AND things_taggings.taggable_type = 'Thing' LEFT OUTER JOIN tags things_tags ON things_tags.id = things_taggings.tag_id WHERE (things_tags.name IN ('fake')) [0m | ||
| 35 | [4;35;1mThing Load (0.000173)[0m [0mSELECT * FROM things WHERE (things."id" = 1) [0m | ||
| 36 | [4;36;1mTag Load (0.010343)[0m [0;1mSELECT tags.* FROM tags INNER JOIN taggings ON tags.id = taggings.tag_id WHERE ((taggings.taggable_type = 'Thing') AND (taggings.taggable_id = 1)) ORDER BY name asc[0m | ||
| 37 | [4;35;1mThing Load (0.000226)[0m [0mSELECT * FROM things WHERE (things."id" = 2) [0m | ||
| 38 | [4;36;1mTag Load (0.000703)[0m [0;1mSELECT tags.* FROM tags INNER JOIN taggings ON tags.id = taggings.tag_id WHERE ((taggings.taggable_type = 'Thing') AND (taggings.taggable_id = 2)) ORDER BY name asc[0m | ||
| 39 | [4;35;1mThing Load (0.000232)[0m [0mSELECT * FROM things WHERE (things."id" = 1) [0m | ||
| 40 | [4;36;1mTag Load (0.000751)[0m [0;1mSELECT tags.* FROM tags INNER JOIN taggings ON tags.id = taggings.tag_id WHERE ((taggings.taggable_type = 'Thing') AND (taggings.taggable_id = 1)) ORDER BY name asc[0m | ||
| 41 | [4;35;1mTagging Load Including Associations (0.000550)[0m [0mSELECT taggings."id" AS t0_r0, taggings."tag_id" AS t0_r1, taggings."taggable_id" AS t0_r2, taggings."taggable_type" AS t0_r3, taggings."user_id" AS t0_r4, tags."id" AS t1_r0, tags."name" AS t1_r1, tags."taggings_count" AS t1_r2 FROM taggings LEFT OUTER JOIN tags ON tags.id = taggings.tag_id WHERE (taggings.taggable_id = 1 AND taggings.taggable_type = 'Thing') [0m | ||
| 42 | [4;36;1mTag Update (0.000111)[0m [0;1mUPDATE tags SET "taggings_count" = "taggings_count" - 1 WHERE ("id" = 1) [0m | ||
| 43 | [4;35;1mTag Update (0.000093)[0m [0mUPDATE tags SET "taggings_count" = "taggings_count" - 1 WHERE ("id" = 1) [0m | ||
| 44 | [4;36;1mTagging Destroy (0.000096)[0m [0;1m DELETE FROM taggings | ||
| 45 | WHERE "id" = 1 | ||
| 46 | [0m | ||
| 47 | [4;35;1mTag Update (0.000095)[0m [0mUPDATE tags SET "taggings_count" = "taggings_count" - 1 WHERE ("id" = 4) [0m | ||
| 48 | [4;36;1mTag Update (0.000092)[0m [0;1mUPDATE tags SET "taggings_count" = "taggings_count" - 1 WHERE ("id" = 4) [0m | ||
| 49 | [4;35;1mTagging Destroy (0.000088)[0m [0m DELETE FROM taggings | ||
| 50 | WHERE "id" = 2 | ||
| 51 | [0m | ||
| 52 | [4;36;1mTag Load (0.000196)[0m [0;1mSELECT * FROM tags WHERE (tags."name" = 'not green') LIMIT 1[0m | ||
| 53 | [4;35;1mTagging Create (0.000163)[0m [0mINSERT INTO taggings ("tag_id", "taggable_type", "taggable_id", "user_id") VALUES(4, 'Thing', 1, NULL)[0m | ||
| 54 | [4;36;1mTag Load (0.000240)[0m [0;1mSELECT * FROM tags WHERE (tags."id" = 4) [0m | ||
| 55 | [4;35;1mTag Update (0.000105)[0m [0mUPDATE tags SET "taggings_count" = "taggings_count" + 1 WHERE ("id" = 4) [0m | ||
| 56 | [4;36;1mTag Update (0.000097)[0m [0;1mUPDATE tags SET "taggings_count" = "taggings_count" + 1 WHERE ("id" = 4) [0m | ||
| 57 | [4;35;1mTag Load (0.000217)[0m [0mSELECT * FROM tags WHERE (tags."name" = 'animal') LIMIT 1[0m | ||
| 58 | [4;36;1mTagging Create (0.000175)[0m [0;1mINSERT INTO taggings ("tag_id", "taggable_type", "taggable_id", "user_id") VALUES(1, 'Thing', 1, NULL)[0m | ||
| 59 | [4;35;1mTag Load (0.000225)[0m [0mSELECT * FROM tags WHERE (tags."id" = 1) [0m | ||
| 60 | [4;36;1mTag Update (0.000102)[0m [0;1mUPDATE tags SET "taggings_count" = "taggings_count" + 1 WHERE ("id" = 1) [0m | ||
| 61 | [4;35;1mTag Update (0.000093)[0m [0mUPDATE tags SET "taggings_count" = "taggings_count" + 1 WHERE ("id" = 1) [0m | ||
| 62 | [4;36;1mTag Load (0.000186)[0m [0;1mSELECT * FROM tags WHERE (tags."name" = 'favorite') LIMIT 1[0m | ||
| 63 | [4;35;1mTagging Create (0.000114)[0m [0mINSERT INTO taggings ("tag_id", "taggable_type", "taggable_id", "user_id") VALUES(5, 'Thing', 1, NULL)[0m | ||
| 64 | [4;36;1mTag Load (0.000177)[0m [0;1mSELECT * FROM tags WHERE (tags."id" = 5) [0m | ||
| 65 | [4;35;1mTag Update (0.000097)[0m [0mUPDATE tags SET "taggings_count" = "taggings_count" + 1 WHERE ("id" = 5) [0m | ||
| 66 | [4;36;1mTag Update (0.000091)[0m [0;1mUPDATE tags SET "taggings_count" = "taggings_count" + 1 WHERE ("id" = 5) [0m | ||
| 67 | [4;35;1mTag Load (0.000787)[0m [0mSELECT tags.* FROM tags INNER JOIN taggings ON tags.id = taggings.tag_id WHERE ((taggings.taggable_type = 'Thing') AND (taggings.taggable_id = 1)) ORDER BY name asc[0m | ||
| 68 | [4;36;1mTag Load (0.000196)[0m [0;1mSELECT * FROM tags WHERE (tags."id" = 1) [0m | ||
| 69 | [4;35;1mTag Load (0.000176)[0m [0mSELECT * FROM tags WHERE (tags."id" = 1) [0m | ||
| 70 | [4;36;1mTag Load (0.000174)[0m [0;1mSELECT * FROM tags WHERE (tags."id" = 1) [0m | ||
| 71 | [4;35;1mTag Load (0.000208)[0m [0mSELECT * FROM tags WHERE (tags."id" = 5) [0m | ||
| 72 | [4;36;1mTagging Load (0.000101)[0m [0;1mSELECT * FROM taggings WHERE (taggings.tag_id = 5) [0m | ||
| 73 | [4;35;1mThing Load (0.000155)[0m [0mSELECT * FROM things WHERE (things."id" = 1) [0m | ||
| 74 | [4;36;1mTagging Create (0.000130)[0m [0;1mINSERT INTO taggings ("tag_id", "taggable_type", "taggable_id", "user_id") VALUES(5, 'Thing', 1, NULL)[0m | ||
| 75 | [4;35;1mTag Load (0.000187)[0m [0mSELECT * FROM tags WHERE (tags."id" = 5) [0m | ||
| 76 | [4;36;1mTag Update (0.000100)[0m [0;1mUPDATE tags SET "taggings_count" = "taggings_count" + 1 WHERE ("id" = 5) [0m | ||
| 77 | [4;35;1mTag Update (0.000093)[0m [0mUPDATE tags SET "taggings_count" = "taggings_count" + 1 WHERE ("id" = 5) [0m | ||
| 78 | [4;36;1mTagging Load (0.000212)[0m [0;1mSELECT * FROM taggings WHERE (taggings.tag_id = 5) [0m | ||
| 79 | [4;35;1mThing Load (0.000158)[0m [0mSELECT * FROM things WHERE (things."id" = 1) [0m | ||
| 80 | [4;36;1mThing Load (0.000169)[0m [0;1mSELECT * FROM things WHERE (things."id" = 1) [0m | ||
| 81 | [4;35;1mThing Load (0.000189)[0m [0mSELECT * FROM things WHERE (things."id" = 2) [0m | ||
| 82 | [4;36;1mTag Load (0.000175)[0m [0;1mSELECT * FROM tags WHERE (tags."id" = 1) [0m | ||
| 83 | [4;35;1mTagging Load (0.000343)[0m [0mSELECT * FROM taggings WHERE (taggings.tag_id = 1) [0m | ||
| 84 | [4;36;1mThing Load (0.000282)[0m [0;1mSELECT * FROM things WHERE (things."id" = 1) [0m | ||
| 85 | [4;35;1mThing Load (0.000176)[0m [0mSELECT * FROM things WHERE (things."id" = 2) [0m | ||
| 86 | [4;36;1mTag Load (0.000228)[0m [0;1mSELECT * FROM tags WHERE (tags."id" = 2) [0m | ||
| 87 | [4;35;1mTagging Load (0.000357)[0m [0mSELECT * FROM taggings WHERE (taggings.tag_id = 2) [0m | ||
| 88 | [4;36;1mThing Load (0.000180)[0m [0;1mSELECT * FROM things WHERE (things."id" = 3) [0m | ||
| 89 | [4;35;1mThing Load (0.000172)[0m [0mSELECT * FROM things WHERE (things."id" = 4) [0m | ||
| 90 | [4;36;1mTagging Load (0.000268)[0m [0;1mSELECT * FROM taggings WHERE (taggings."id" = 1) [0m | ||
| 91 | [4;35;1mTagging Load (0.000233)[0m [0mSELECT * FROM taggings WHERE (taggings."id" = 3) [0m | ||
| 92 | [4;36;1mTag Load (0.000204)[0m [0;1mSELECT * FROM tags WHERE (tags."id" = 1) [0m | ||
| 93 | [4;35;1mTagging Load (0.000623)[0m [0mSELECT * FROM taggings WHERE (taggings.tag_id = 1) [0m | ||
| 94 | [4;36;1mTagging Load (0.000215)[0m [0;1mSELECT * FROM taggings WHERE (taggings."id" = 5) [0m | ||
| 95 | [4;35;1mTagging Load (0.000207)[0m [0mSELECT * FROM taggings WHERE (taggings."id" = 7) [0m | ||
| 96 | [4;36;1mTag Load (0.000195)[0m [0;1mSELECT * FROM tags WHERE (tags."id" = 1) [0m | ||
| 97 | [4;35;1mTag Load (0.000344)[0m [0mSELECT * FROM tags WHERE (tags."id" = 1) [0m | ||
| 98 | [4;36;1mTagging Load (0.000212)[0m [0;1mSELECT * FROM taggings WHERE (taggings."id" = 1) [0m | ||
| 99 | [4;35;1mTag Load (0.000175)[0m [0mSELECT * FROM tags WHERE (tags."id" = 1) [0m | ||
| 100 | [4;36;1mTag Load (0.000180)[0m [0;1mSELECT * FROM tags WHERE (tags."id" = 2) [0m | ||
| 101 | [4;35;1mThing Load (0.000163)[0m [0mSELECT * FROM things WHERE (things."id" = 1) [0m | ||
| 102 | [4;36;1mTagging Load (0.000216)[0m [0;1mSELECT * FROM taggings WHERE (taggings."id" = 1) [0m | ||
| 103 | [4;35;1mThing Load (0.000168)[0m [0mSELECT * FROM things WHERE (things."id" = 1) [0m | ||
| 104 | [4;36;1mThing Load (0.000159)[0m [0;1mSELECT * FROM things WHERE (things."id" = 2) [0m | ||
diff --git a/vendor/plugins/acts_as_taggable_redux/test/fixtures/taggings.yml b/vendor/plugins/acts_as_taggable_redux/test/fixtures/taggings.yml deleted file mode 100644 index 5cd86a5..0000000 --- a/vendor/plugins/acts_as_taggable_redux/test/fixtures/taggings.yml +++ /dev/null | |||
| @@ -1,47 +0,0 @@ | |||
| 1 | bear_animal: | ||
| 2 | id: 1 | ||
| 3 | taggable_id: 1 | ||
| 4 | taggable_type: Thing | ||
| 5 | tag_id: 1 | ||
| 6 | |||
| 7 | bear_not_green: | ||
| 8 | id: 2 | ||
| 9 | taggable_id: 1 | ||
| 10 | taggable_type: Thing | ||
| 11 | tag_id: 4 | ||
| 12 | |||
| 13 | frog_animal: | ||
| 14 | id: 3 | ||
| 15 | taggable_id: 2 | ||
| 16 | taggable_type: Thing | ||
| 17 | tag_id: 1 | ||
| 18 | |||
| 19 | frog_green: | ||
| 20 | id: 4 | ||
| 21 | taggable_id: 2 | ||
| 22 | taggable_type: Thing | ||
| 23 | tag_id: 3 | ||
| 24 | |||
| 25 | cactus_plant: | ||
| 26 | id: 5 | ||
| 27 | taggable_id: 3 | ||
| 28 | taggable_type: Thing | ||
| 29 | tag_id: 2 | ||
| 30 | |||
| 31 | cactus_green: | ||
| 32 | id: 6 | ||
| 33 | taggable_id: 3 | ||
| 34 | taggable_type: Thing | ||
| 35 | tag_id: 3 | ||
| 36 | |||
| 37 | orange_plant: | ||
| 38 | id: 7 | ||
| 39 | taggable_id: 4 | ||
| 40 | taggable_type: Thing | ||
| 41 | tag_id: 2 | ||
| 42 | |||
| 43 | orange_not_green: | ||
| 44 | id: 8 | ||
| 45 | taggable_id: 4 | ||
| 46 | taggable_type: Thing | ||
| 47 | tag_id: 4 \ No newline at end of file | ||
diff --git a/vendor/plugins/acts_as_taggable_redux/test/fixtures/tags.yml b/vendor/plugins/acts_as_taggable_redux/test/fixtures/tags.yml deleted file mode 100644 index 141aea2..0000000 --- a/vendor/plugins/acts_as_taggable_redux/test/fixtures/tags.yml +++ /dev/null | |||
| @@ -1,24 +0,0 @@ | |||
| 1 | animal: | ||
| 2 | id: 1 | ||
| 3 | name: animal | ||
| 4 | taggings_count: 2 | ||
| 5 | |||
| 6 | plant: | ||
| 7 | id: 2 | ||
| 8 | name: plant | ||
| 9 | taggings_count: 2 | ||
| 10 | |||
| 11 | green: | ||
| 12 | id: 3 | ||
| 13 | name: green | ||
| 14 | taggings_count: 2 | ||
| 15 | |||
| 16 | not_green: | ||
| 17 | id: 4 | ||
| 18 | name: not green | ||
| 19 | taggings_count: 2 | ||
| 20 | |||
| 21 | favorite: | ||
| 22 | id: 5 | ||
| 23 | name: favorite | ||
| 24 | taggings_count: 0 \ No newline at end of file | ||
diff --git a/vendor/plugins/acts_as_taggable_redux/test/fixtures/thing.rb b/vendor/plugins/acts_as_taggable_redux/test/fixtures/thing.rb deleted file mode 100644 index 79de132..0000000 --- a/vendor/plugins/acts_as_taggable_redux/test/fixtures/thing.rb +++ /dev/null | |||
| @@ -1,3 +0,0 @@ | |||
| 1 | class Thing < ActiveRecord::Base | ||
| 2 | acts_as_taggable | ||
| 3 | end \ No newline at end of file | ||
diff --git a/vendor/plugins/acts_as_taggable_redux/test/fixtures/things.yml b/vendor/plugins/acts_as_taggable_redux/test/fixtures/things.yml deleted file mode 100644 index 7ff1581..0000000 --- a/vendor/plugins/acts_as_taggable_redux/test/fixtures/things.yml +++ /dev/null | |||
| @@ -1,15 +0,0 @@ | |||
| 1 | bear: | ||
| 2 | id: 1 | ||
| 3 | name: bear | ||
| 4 | |||
| 5 | frog: | ||
| 6 | id: 2 | ||
| 7 | name: frog | ||
| 8 | |||
| 9 | cactus: | ||
| 10 | id: 3 | ||
| 11 | name: cactus | ||
| 12 | |||
| 13 | orange: | ||
| 14 | id: 4 | ||
| 15 | name: orange \ No newline at end of file | ||
diff --git a/vendor/plugins/acts_as_taggable_redux/test/fixtures/user.rb b/vendor/plugins/acts_as_taggable_redux/test/fixtures/user.rb deleted file mode 100644 index ca0fd57..0000000 --- a/vendor/plugins/acts_as_taggable_redux/test/fixtures/user.rb +++ /dev/null | |||
| @@ -1,3 +0,0 @@ | |||
| 1 | class User < ActiveRecord::Base | ||
| 2 | acts_as_tagger | ||
| 3 | end \ No newline at end of file | ||
diff --git a/vendor/plugins/acts_as_taggable_redux/test/fixtures/users.yml b/vendor/plugins/acts_as_taggable_redux/test/fixtures/users.yml deleted file mode 100644 index 8f6b037..0000000 --- a/vendor/plugins/acts_as_taggable_redux/test/fixtures/users.yml +++ /dev/null | |||
| @@ -1,3 +0,0 @@ | |||
| 1 | monki: | ||
| 2 | id: 1 | ||
| 3 | username: monki \ No newline at end of file | ||
diff --git a/vendor/plugins/acts_as_taggable_redux/test/tag_test.rb b/vendor/plugins/acts_as_taggable_redux/test/tag_test.rb deleted file mode 100644 index 1ed8357..0000000 --- a/vendor/plugins/acts_as_taggable_redux/test/tag_test.rb +++ /dev/null | |||
| @@ -1,68 +0,0 @@ | |||
| 1 | require File.dirname(__FILE__) + "/test_helper" | ||
| 2 | |||
| 3 | class TagTest < Test::Unit::TestCase | ||
| 4 | def test_taggings | ||
| 5 | assert_equal [taggings(:bear_animal), taggings(:frog_animal)], tags(:animal).taggings | ||
| 6 | assert_not_equal [taggings(:cactus_plant), taggings(:orange_plant)], tags(:animal).taggings | ||
| 7 | end | ||
| 8 | |||
| 9 | def test_parse_does_not_change_param | ||
| 10 | list = 'a b c' | ||
| 11 | original = list.dup | ||
| 12 | Tag.parse(list) | ||
| 13 | assert_equal list, original | ||
| 14 | end | ||
| 15 | |||
| 16 | def test_parse_blank | ||
| 17 | assert_equal [], Tag.parse(nil) | ||
| 18 | assert_equal [], Tag.parse('') | ||
| 19 | end | ||
| 20 | |||
| 21 | def test_parse_single_tag | ||
| 22 | assert_equal ['a'], Tag.parse('a') | ||
| 23 | assert_equal ['a'], Tag.parse('"a"') | ||
| 24 | end | ||
| 25 | |||
| 26 | def test_parse_quoted_tags | ||
| 27 | assert_equal ['a b', 'c'], Tag.parse('"a b" c') | ||
| 28 | end | ||
| 29 | |||
| 30 | def test_parse_comma_dilineation | ||
| 31 | assert_equal ['a', 'b', 'c'], Tag.parse('a,b,c') | ||
| 32 | assert_equal ['a', 'b', 'c'], Tag.parse('a,b,c') | ||
| 33 | end | ||
| 34 | |||
| 35 | def test_parse_quotes_and_commas | ||
| 36 | assert_equal ['a,b', 'c'], Tag.parse('"a,b",c') | ||
| 37 | end | ||
| 38 | |||
| 39 | def test_parse_removes_whitespace | ||
| 40 | assert_equal ['a', 'b', 'c'], Tag.parse('a b, c') | ||
| 41 | end | ||
| 42 | |||
| 43 | def test_parse_removes_duplicates | ||
| 44 | assert_equal ['a', 'b', 'c'], Tag.parse('a b a c a b') | ||
| 45 | end | ||
| 46 | |||
| 47 | def test_tag | ||
| 48 | assert !tags(:favorite).tagged.include?(things(:bear)) | ||
| 49 | tags(:favorite).tag(things(:bear)) | ||
| 50 | assert tags(:favorite).tagged.include?(things(:bear)) | ||
| 51 | end | ||
| 52 | |||
| 53 | def test_tagged | ||
| 54 | assert_equal [things(:bear), things(:frog)], tags(:animal).tagged | ||
| 55 | assert_not_equal [things(:bear), things(:frog)], tags(:plant).tagged | ||
| 56 | end | ||
| 57 | |||
| 58 | def test_equality | ||
| 59 | assert_equal tags(:animal), tags(:animal) | ||
| 60 | assert_equal Tag.find(1), Tag.find(1) | ||
| 61 | assert_equal Tag.new(:name => 'mineral'), Tag.new(:name => 'mineral') | ||
| 62 | assert_not_equal Tag.new(:name => 'mineral'), tags(:animal) | ||
| 63 | end | ||
| 64 | |||
| 65 | def test_to_s | ||
| 66 | assert_equal tags(:animal).name, tags(:animal).to_s | ||
| 67 | end | ||
| 68 | end \ No newline at end of file | ||
diff --git a/vendor/plugins/acts_as_taggable_redux/test/tagging_test.rb b/vendor/plugins/acts_as_taggable_redux/test/tagging_test.rb deleted file mode 100644 index a3b8887..0000000 --- a/vendor/plugins/acts_as_taggable_redux/test/tagging_test.rb +++ /dev/null | |||
| @@ -1,13 +0,0 @@ | |||
| 1 | require File.dirname(__FILE__) + "/test_helper" | ||
| 2 | |||
| 3 | class TaggingTest < Test::Unit::TestCase | ||
| 4 | def test_taggable | ||
| 5 | assert_equal things(:bear), taggings(:bear_animal).taggable | ||
| 6 | assert_not_equal things(:frog), taggings(:bear_animal).taggable | ||
| 7 | end | ||
| 8 | |||
| 9 | def test_tag | ||
| 10 | assert_equal tags(:animal), taggings(:bear_animal).tag | ||
| 11 | assert_not_equal tags(:plant), taggings(:bear_animal).tag | ||
| 12 | end | ||
| 13 | end \ No newline at end of file | ||
diff --git a/vendor/plugins/acts_as_taggable_redux/test/test_helper.rb b/vendor/plugins/acts_as_taggable_redux/test/test_helper.rb deleted file mode 100644 index edef8aa..0000000 --- a/vendor/plugins/acts_as_taggable_redux/test/test_helper.rb +++ /dev/null | |||
| @@ -1,50 +0,0 @@ | |||
| 1 | ENV["RAILS_ENV"] = "test" | ||
| 2 | require File.expand_path(File.dirname(__FILE__) + "/../../../../config/environment") | ||
| 3 | require 'test_help' | ||
| 4 | require 'test/unit' | ||
| 5 | |||
| 6 | require File.dirname(__FILE__) + '/../lib/acts_as_taggable' | ||
| 7 | require File.dirname(__FILE__) + '/../lib/tag' | ||
| 8 | require File.dirname(__FILE__) + '/../lib/tagging' | ||
| 9 | |||
| 10 | ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + '/debug.log') | ||
| 11 | ActiveRecord::Base.configurations = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml')) | ||
| 12 | ActiveRecord::Base.establish_connection(ENV['DB'] || 'mysql') | ||
| 13 | |||
| 14 | load(File.dirname(__FILE__) + '/schema.rb') | ||
| 15 | |||
| 16 | Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + '/fixtures/' | ||
| 17 | $LOAD_PATH.unshift(Test::Unit::TestCase.fixture_path) | ||
| 18 | |||
| 19 | class Test::Unit::TestCase | ||
| 20 | # Transactional fixtures accelerate your tests by wrapping each test method | ||
| 21 | # in a transaction that's rolled back on completion. This ensures that the | ||
| 22 | # test database remains unchanged so your fixtures don't have to be reloaded | ||
| 23 | # between every test method. Fewer database queries means faster tests. | ||
| 24 | # | ||
| 25 | # Read Mike Clark's excellent walkthrough at | ||
| 26 | # http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting | ||
| 27 | # | ||
| 28 | # Every Active Record database supports transactions except MyISAM tables | ||
| 29 | # in MySQL. Turn off transactional fixtures in this case; however, if you | ||
| 30 | # don't care one way or the other, switching from MyISAM to InnoDB tables | ||
| 31 | # is recommended. | ||
| 32 | self.use_transactional_fixtures = true | ||
| 33 | |||
| 34 | # Instantiated fixtures are slow, but give you @david where otherwise you | ||
| 35 | # would need people(:david). If you don't want to migrate your existing | ||
| 36 | # test cases which use the @david style and don't mind the speed hit (each | ||
| 37 | # instantiated fixtures translates to a database query per test method), | ||
| 38 | # then set this back to true. | ||
| 39 | self.use_instantiated_fixtures = false | ||
| 40 | |||
| 41 | # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. | ||
| 42 | # If you need to control the loading order (due to foreign key constraints etc), you'll | ||
| 43 | # need to change this line to explicitly name the order you desire. | ||
| 44 | # | ||
| 45 | # Note: You'll currently still have to declare fixtures explicitly in integration tests | ||
| 46 | # -- they do not yet inherent this setting | ||
| 47 | fixtures :all | ||
| 48 | |||
| 49 | # Add more helper methods to be used by all tests here... | ||
| 50 | end \ No newline at end of file | ||
