make_taggable 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/ci.yml +47 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.standard.yml +18 -0
- data/.standard_todo.yml +5 -0
- data/.travis.yml +36 -0
- data/Appraisals +11 -0
- data/CHANGELOG.md +0 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/CONTRIBUTING.md +57 -0
- data/Gemfile +16 -0
- data/LICENSE.md +20 -0
- data/LICENSE.txt +21 -0
- data/README.md +478 -0
- data/Rakefile +7 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/db/migrate/1_create_make_taggable_tags.rb +10 -0
- data/db/migrate/2_create_make_taggable_taggings.rb +12 -0
- data/db/migrate/3_add_index_to_tags.rb +5 -0
- data/db/migrate/4_add_index_to_taggings.rb +12 -0
- data/gemfiles/rails_5.gemfile +9 -0
- data/gemfiles/rails_6.gemfile +9 -0
- data/gemfiles/rails_master.gemfile +9 -0
- data/lib/make_taggable.rb +134 -0
- data/lib/make_taggable/default_parser.rb +75 -0
- data/lib/make_taggable/engine.rb +4 -0
- data/lib/make_taggable/generic_parser.rb +19 -0
- data/lib/make_taggable/tag.rb +131 -0
- data/lib/make_taggable/tag_list.rb +102 -0
- data/lib/make_taggable/taggable.rb +100 -0
- data/lib/make_taggable/taggable/cache.rb +90 -0
- data/lib/make_taggable/taggable/collection.rb +183 -0
- data/lib/make_taggable/taggable/core.rb +323 -0
- data/lib/make_taggable/taggable/ownership.rb +137 -0
- data/lib/make_taggable/taggable/related.rb +71 -0
- data/lib/make_taggable/taggable/tag_list_type.rb +4 -0
- data/lib/make_taggable/taggable/tagged_with_query.rb +16 -0
- data/lib/make_taggable/taggable/tagged_with_query/all_tags_query.rb +111 -0
- data/lib/make_taggable/taggable/tagged_with_query/any_tags_query.rb +68 -0
- data/lib/make_taggable/taggable/tagged_with_query/exclude_tags_query.rb +81 -0
- data/lib/make_taggable/taggable/tagged_with_query/query_base.rb +61 -0
- data/lib/make_taggable/tagger.rb +89 -0
- data/lib/make_taggable/tagging.rb +32 -0
- data/lib/make_taggable/tags_helper.rb +15 -0
- data/lib/make_taggable/utils.rb +34 -0
- data/lib/make_taggable/version.rb +4 -0
- data/lib/tasks/tags_collate_utf8.rake +17 -0
- data/make_taggable.gemspec +26 -0
- data/spec/dummy/README.md +24 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/config/manifest.js +2 -0
- data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +2 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/jobs/application_job.rb +7 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/models/altered_inheriting_taggable_model.rb +5 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/models/cached_model.rb +3 -0
- data/spec/dummy/app/models/cached_model_with_array.rb +11 -0
- data/spec/dummy/app/models/columns_override_model.rb +5 -0
- data/spec/dummy/app/models/company.rb +15 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/models/inheriting_taggable_model.rb +4 -0
- data/spec/dummy/app/models/market.rb +2 -0
- data/spec/dummy/app/models/non_standard_id_taggable_model.rb +8 -0
- data/spec/dummy/app/models/ordered_taggable_model.rb +4 -0
- data/spec/dummy/app/models/other_cached_model.rb +3 -0
- data/spec/dummy/app/models/other_taggable_model.rb +4 -0
- data/spec/dummy/app/models/student.rb +4 -0
- data/spec/dummy/app/models/taggable_model.rb +14 -0
- data/spec/dummy/app/models/untaggable_model.rb +3 -0
- data/spec/dummy/app/models/user.rb +3 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +33 -0
- data/spec/dummy/config.ru +5 -0
- data/spec/dummy/config/application.rb +19 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/cable.yml +10 -0
- data/spec/dummy/config/credentials.yml.enc +1 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +52 -0
- data/spec/dummy/config/environments/production.rb +105 -0
- data/spec/dummy/config/environments/test.rb +49 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cors.rb +16 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +33 -0
- data/spec/dummy/config/master.key +1 -0
- data/spec/dummy/config/puma.rb +38 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/config/spring.rb +6 -0
- data/spec/dummy/config/storage.yml +34 -0
- data/spec/dummy/db/migrate/20201119220853_create_taggable_models.rb +8 -0
- data/spec/dummy/db/migrate/20201119221037_create_columns_override_models.rb +9 -0
- data/spec/dummy/db/migrate/20201119221121_create_non_standard_id_taggable_models.rb +8 -0
- data/spec/dummy/db/migrate/20201119221228_create_untaggable_models.rb +8 -0
- data/spec/dummy/db/migrate/20201119221247_create_cached_models.rb +9 -0
- data/spec/dummy/db/migrate/20201119221314_create_other_cached_models.rb +11 -0
- data/spec/dummy/db/migrate/20201119221343_create_companies.rb +7 -0
- data/spec/dummy/db/migrate/20201119221416_create_users.rb +7 -0
- data/spec/dummy/db/migrate/20201119221434_create_other_taggable_models.rb +8 -0
- data/spec/dummy/db/migrate/20201119221507_create_ordered_taggable_models.rb +8 -0
- data/spec/dummy/db/migrate/20201119221530_create_cache_methods_injected_models.rb +7 -0
- data/spec/dummy/db/migrate/20201119221629_create_other_cached_with_array_models.rb +11 -0
- data/spec/dummy/db/migrate/20201119221746_create_taggable_model_with_jsons.rb +9 -0
- data/spec/dummy/db/migrate/20201119222429_create_make_taggable_tags.make_taggable_engine.rb +11 -0
- data/spec/dummy/db/migrate/20201119222430_create_make_taggable_taggings.make_taggable_engine.rb +13 -0
- data/spec/dummy/db/migrate/20201119222431_add_index_to_tags.make_taggable_engine.rb +6 -0
- data/spec/dummy/db/migrate/20201119222432_add_index_to_taggings.make_taggable_engine.rb +13 -0
- data/spec/dummy/db/schema.rb +117 -0
- data/spec/dummy/db/seeds.rb +7 -0
- data/spec/dummy/lib/tasks/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/public/robots.txt +1 -0
- data/spec/dummy/storage/.keep +0 -0
- data/spec/dummy/test/channels/application_cable/connection_test.rb +11 -0
- data/spec/dummy/test/controllers/.keep +0 -0
- data/spec/dummy/test/fixtures/.keep +0 -0
- data/spec/dummy/test/fixtures/files/.keep +0 -0
- data/spec/dummy/test/integration/.keep +0 -0
- data/spec/dummy/test/mailers/.keep +0 -0
- data/spec/dummy/test/models/.keep +0 -0
- data/spec/dummy/test/test_helper.rb +13 -0
- data/spec/dummy/vendor/.keep +0 -0
- data/spec/make_taggable/acts_as_tagger_spec.rb +112 -0
- data/spec/make_taggable/caching_spec.rb +123 -0
- data/spec/make_taggable/default_parser_spec.rb +45 -0
- data/spec/make_taggable/dirty_spec.rb +140 -0
- data/spec/make_taggable/generic_parser_spec.rb +13 -0
- data/spec/make_taggable/make_taggable_spec.rb +260 -0
- data/spec/make_taggable/related_spec.rb +93 -0
- data/spec/make_taggable/single_table_inheritance_spec.rb +220 -0
- data/spec/make_taggable/tag_list_spec.rb +169 -0
- data/spec/make_taggable/tag_spec.rb +297 -0
- data/spec/make_taggable/taggable_spec.rb +804 -0
- data/spec/make_taggable/tagger_spec.rb +149 -0
- data/spec/make_taggable/tagging_spec.rb +115 -0
- data/spec/make_taggable/tags_helper_spec.rb +43 -0
- data/spec/make_taggable/utils_spec.rb +22 -0
- data/spec/make_taggable_spec.rb +5 -0
- data/spec/spec_helper.rb +18 -0
- data/spec/support/array.rb +9 -0
- data/spec/support/helpers.rb +31 -0
- metadata +391 -0
@@ -0,0 +1,11 @@
|
|
1
|
+
class CreateOtherCachedModels < ActiveRecord::Migration[5.2]
|
2
|
+
def change
|
3
|
+
create_table :other_cached_models do |t|
|
4
|
+
t.column :name, :string
|
5
|
+
t.column :type, :string
|
6
|
+
t.column :cached_language_list, :string
|
7
|
+
t.column :cached_status_list, :string
|
8
|
+
t.column :cached_glass_list, :string
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class CreateOtherCachedWithArrayModels < ActiveRecord::Migration[5.2]
|
2
|
+
def change
|
3
|
+
create_table :other_cached_with_array_models do |t|
|
4
|
+
t.column :name, :string
|
5
|
+
t.column :type, :string
|
6
|
+
t.column :cached_language_list, :string, array: true
|
7
|
+
t.column :cached_status_list, :string, array: true
|
8
|
+
t.column :cached_glass_list, :string, array: true
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# This migration comes from make_taggable_engine (originally 1)
|
2
|
+
class CreateMakeTaggableTags < ActiveRecord::Migration[5.2]
|
3
|
+
def change
|
4
|
+
create_table MakeTaggable.tags_table do |t|
|
5
|
+
t.string :name
|
6
|
+
t.integer :taggings_count, default: 0
|
7
|
+
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/spec/dummy/db/migrate/20201119222430_create_make_taggable_taggings.make_taggable_engine.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# This migration comes from make_taggable_engine (originally 2)
|
2
|
+
class CreateMakeTaggableTaggings < ActiveRecord::Migration[5.2]
|
3
|
+
def change
|
4
|
+
create_table MakeTaggable.taggings_table do |t|
|
5
|
+
t.references :tag, foreign_key: {to_table: MakeTaggable.tags_table}
|
6
|
+
t.references :taggable, polymorphic: true
|
7
|
+
t.references :tagger, polymorphic: true
|
8
|
+
t.string :context, limit: 128
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# This migration comes from make_taggable_engine (originally 4)
|
2
|
+
class AddIndexToTaggings < ActiveRecord::Migration[5.2]
|
3
|
+
def change
|
4
|
+
add_index MakeTaggable.taggings_table, :taggable_id
|
5
|
+
add_index MakeTaggable.taggings_table, :tagger_id
|
6
|
+
add_index MakeTaggable.taggings_table, :taggable_type
|
7
|
+
add_index MakeTaggable.taggings_table, :context
|
8
|
+
add_index MakeTaggable.taggings_table, [:tagger_id, :tagger_type]
|
9
|
+
add_index MakeTaggable.taggings_table, [:tag_id, :taggable_id, :taggable_type, :context, :tagger_id, :tagger_type], unique: true, name: "taggings_idx"
|
10
|
+
add_index MakeTaggable.taggings_table, [:taggable_id, :taggable_type, :context], name: "taggings_taggable_context_idx"
|
11
|
+
add_index MakeTaggable.taggings_table, [:taggable_id, :taggable_type, :tagger_id, :context], name: "taggings_idy"
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
# This file is auto-generated from the current state of the database. Instead
|
2
|
+
# of editing this file, please use the migrations feature of Active Record to
|
3
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
4
|
+
#
|
5
|
+
# This file is the source Rails uses to define your schema when running `rails
|
6
|
+
# db:schema:load`. When creating a new database, `rails db:schema:load` tends to
|
7
|
+
# be faster and is potentially less error prone than running all of your
|
8
|
+
# migrations from scratch. Old migrations may fail to apply correctly if those
|
9
|
+
# migrations use external dependencies or application code.
|
10
|
+
#
|
11
|
+
# It's strongly recommended that you check this file into your version control system.
|
12
|
+
|
13
|
+
ActiveRecord::Schema.define(version: 2020_11_19_222432) do
|
14
|
+
|
15
|
+
create_table "cache_methods_injected_models", force: :cascade do |t|
|
16
|
+
t.string "cached_tag_list"
|
17
|
+
end
|
18
|
+
|
19
|
+
create_table "cached_models", force: :cascade do |t|
|
20
|
+
t.string "name"
|
21
|
+
t.string "type"
|
22
|
+
t.string "cached_tag_list"
|
23
|
+
end
|
24
|
+
|
25
|
+
create_table "columns_override_models", force: :cascade do |t|
|
26
|
+
t.string "name"
|
27
|
+
t.string "type"
|
28
|
+
t.string "ignored_column"
|
29
|
+
end
|
30
|
+
|
31
|
+
create_table "companies", force: :cascade do |t|
|
32
|
+
t.string "name"
|
33
|
+
end
|
34
|
+
|
35
|
+
create_table "non_standard_id_taggable_models", primary_key: "an_id", force: :cascade do |t|
|
36
|
+
t.string "name"
|
37
|
+
t.string "type"
|
38
|
+
end
|
39
|
+
|
40
|
+
create_table "ordered_taggable_models", force: :cascade do |t|
|
41
|
+
t.string "name"
|
42
|
+
t.string "type"
|
43
|
+
end
|
44
|
+
|
45
|
+
create_table "other_cached_models", force: :cascade do |t|
|
46
|
+
t.string "name"
|
47
|
+
t.string "type"
|
48
|
+
t.string "cached_language_list"
|
49
|
+
t.string "cached_status_list"
|
50
|
+
t.string "cached_glass_list"
|
51
|
+
end
|
52
|
+
|
53
|
+
create_table "other_cached_with_array_models", force: :cascade do |t|
|
54
|
+
t.string "name"
|
55
|
+
t.string "type"
|
56
|
+
t.string "cached_language_list"
|
57
|
+
t.string "cached_status_list"
|
58
|
+
t.string "cached_glass_list"
|
59
|
+
end
|
60
|
+
|
61
|
+
create_table "other_taggable_models", force: :cascade do |t|
|
62
|
+
t.string "name"
|
63
|
+
t.string "type"
|
64
|
+
end
|
65
|
+
|
66
|
+
create_table "taggable_model_with_jsons", force: :cascade do |t|
|
67
|
+
t.string "name"
|
68
|
+
t.string "type"
|
69
|
+
t.json "opts"
|
70
|
+
end
|
71
|
+
|
72
|
+
create_table "taggable_models", force: :cascade do |t|
|
73
|
+
t.string "name"
|
74
|
+
t.string "type"
|
75
|
+
end
|
76
|
+
|
77
|
+
create_table "taggings", force: :cascade do |t|
|
78
|
+
t.integer "tag_id"
|
79
|
+
t.string "taggable_type"
|
80
|
+
t.integer "taggable_id"
|
81
|
+
t.string "tagger_type"
|
82
|
+
t.integer "tagger_id"
|
83
|
+
t.string "context", limit: 128
|
84
|
+
t.datetime "created_at", null: false
|
85
|
+
t.datetime "updated_at", null: false
|
86
|
+
t.index ["context"], name: "index_taggings_on_context"
|
87
|
+
t.index ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true
|
88
|
+
t.index ["tag_id"], name: "index_taggings_on_tag_id"
|
89
|
+
t.index ["taggable_id", "taggable_type", "context"], name: "taggings_taggable_context_idx"
|
90
|
+
t.index ["taggable_id", "taggable_type", "tagger_id", "context"], name: "taggings_idy"
|
91
|
+
t.index ["taggable_id"], name: "index_taggings_on_taggable_id"
|
92
|
+
t.index ["taggable_type", "taggable_id"], name: "index_taggings_on_taggable_type_and_taggable_id"
|
93
|
+
t.index ["taggable_type"], name: "index_taggings_on_taggable_type"
|
94
|
+
t.index ["tagger_id", "tagger_type"], name: "index_taggings_on_tagger_id_and_tagger_type"
|
95
|
+
t.index ["tagger_id"], name: "index_taggings_on_tagger_id"
|
96
|
+
t.index ["tagger_type", "tagger_id"], name: "index_taggings_on_tagger_type_and_tagger_id"
|
97
|
+
end
|
98
|
+
|
99
|
+
create_table "tags", force: :cascade do |t|
|
100
|
+
t.string "name"
|
101
|
+
t.integer "taggings_count", default: 0
|
102
|
+
t.datetime "created_at", null: false
|
103
|
+
t.datetime "updated_at", null: false
|
104
|
+
t.index ["name"], name: "index_tags_on_name", unique: true
|
105
|
+
end
|
106
|
+
|
107
|
+
create_table "untaggable_models", force: :cascade do |t|
|
108
|
+
t.integer "taggable_model_id"
|
109
|
+
t.string "name"
|
110
|
+
end
|
111
|
+
|
112
|
+
create_table "users", force: :cascade do |t|
|
113
|
+
t.string "name"
|
114
|
+
end
|
115
|
+
|
116
|
+
add_foreign_key "taggings", "tags"
|
117
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# This file should contain all the record creation needed to seed the database with its default values.
|
2
|
+
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
|
3
|
+
#
|
4
|
+
# Examples:
|
5
|
+
#
|
6
|
+
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
|
7
|
+
# Character.create(name: 'Luke', movie: movies.first)
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
# See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
ENV['RAILS_ENV'] ||= 'test'
|
2
|
+
require_relative '../config/environment'
|
3
|
+
require 'rails/test_help'
|
4
|
+
|
5
|
+
class ActiveSupport::TestCase
|
6
|
+
# Run tests in parallel with specified workers
|
7
|
+
parallelize(workers: :number_of_processors)
|
8
|
+
|
9
|
+
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
|
10
|
+
fixtures :all
|
11
|
+
|
12
|
+
# Add more helper methods to be used by all tests here...
|
13
|
+
end
|
File without changes
|
@@ -0,0 +1,112 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "acts_as_tagger" do
|
4
|
+
describe "Tagger Method Generation" do
|
5
|
+
before(:each) do
|
6
|
+
@tagger = User.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should add #is_tagger? query method to the class-side" do
|
10
|
+
expect(User).to respond_to(:is_tagger?)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should return true from the class-side #is_tagger?" do
|
14
|
+
expect(User.is_tagger?).to be_truthy
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should return false from the base #is_tagger?" do
|
18
|
+
expect(ActiveRecord::Base.is_tagger?).to be_falsy
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should add #is_tagger? query method to the singleton" do
|
22
|
+
expect(@tagger).to respond_to(:is_tagger?)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should add #tag method on the instance-side" do
|
26
|
+
expect(@tagger).to respond_to(:tag)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should generate an association for #owned_taggings and #owned_tags" do
|
30
|
+
expect(@tagger).to respond_to(:owned_taggings, :owned_tags)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#tag" do
|
35
|
+
context "when called with a non-existent tag context" do
|
36
|
+
before(:each) do
|
37
|
+
@tagger = User.new
|
38
|
+
@taggable = TaggableModel.new(name: "Richard Prior")
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should by default not throw an exception " do
|
42
|
+
expect(@taggable.tag_list_on(:foo)).to be_empty
|
43
|
+
expect(-> {
|
44
|
+
@tagger.tag(@taggable, with: "this, and, that", on: :foo)
|
45
|
+
}).to_not raise_error
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should by default create the tag context on-the-fly" do
|
49
|
+
expect(@taggable.tag_list_on(:here_ond_now)).to be_empty
|
50
|
+
@tagger.tag(@taggable, with: "that", on: :here_ond_now)
|
51
|
+
expect(@taggable.tag_list_on(:here_ond_now)).to_not include("that")
|
52
|
+
expect(@taggable.all_tags_list_on(:here_ond_now)).to include("that")
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should show all the tag list when both public and owned tags exist" do
|
56
|
+
@taggable.tag_list = "ruby, python"
|
57
|
+
@tagger.tag(@taggable, with: "java, lisp", on: :tags)
|
58
|
+
expect(@taggable.all_tags_on(:tags).map(&:name).sort).to eq(%w[ruby python java lisp].sort)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should not add owned tags to the common list" do
|
62
|
+
@taggable.tag_list = "ruby, python"
|
63
|
+
@tagger.tag(@taggable, with: "java, lisp", on: :tags)
|
64
|
+
expect(@taggable.tag_list).to eq(%w[ruby python])
|
65
|
+
@tagger.tag(@taggable, with: "", on: :tags)
|
66
|
+
expect(@taggable.tag_list).to eq(%w[ruby python])
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should throw an exception when the default is over-ridden" do
|
70
|
+
expect(@taggable.tag_list_on(:foo_boo)).to be_empty
|
71
|
+
expect(-> {
|
72
|
+
@tagger.tag(@taggable, with: "this, and, that", on: :foo_boo, force: false)
|
73
|
+
}).to raise_error(RuntimeError)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should not create the tag context on-the-fly when the default is over-ridden" do
|
77
|
+
expect(@taggable.tag_list_on(:foo_boo)).to be_empty
|
78
|
+
begin
|
79
|
+
@tagger.tag(@taggable, with: "this, and, that", on: :foo_boo, force: false)
|
80
|
+
rescue
|
81
|
+
expect(@taggable.tag_list_on(:foo_boo)).to be_empty
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "when called by multiple tagger's" do
|
87
|
+
before(:each) do
|
88
|
+
@user_x = User.create(name: "User X")
|
89
|
+
@user_y = User.create(name: "User Y")
|
90
|
+
@taggable = TaggableModel.create(name: "make_taggable", tag_list: "plugin")
|
91
|
+
|
92
|
+
@user_x.tag(@taggable, with: "ruby, rails", on: :tags)
|
93
|
+
@user_y.tag(@taggable, with: "ruby, plugin", on: :tags)
|
94
|
+
|
95
|
+
@user_y.tag(@taggable, with: "", on: :tags)
|
96
|
+
@user_y.tag(@taggable, with: "", on: :tags)
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should delete owned tags" do
|
100
|
+
expect(@user_y.owned_tags).to be_empty
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should not delete other taggers tags" do
|
104
|
+
expect(@user_x.owned_tags.count).to eq(2)
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should not delete original tags" do
|
108
|
+
expect(@taggable.all_tags_list_on(:tags)).to include("plugin")
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|