make_taggable 0.6.4 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.dummyrc +17 -0
- data/.github/workflows/ci.yml +132 -21
- data/.gitignore +4 -0
- data/Appraisals +4 -0
- data/CONTRIBUTING.md +5 -31
- data/README.md +61 -37
- data/Rakefile +3 -0
- data/UPGRADING.md +1 -1
- data/gemfiles/rails_6_1.gemfile +9 -0
- data/lib/make_taggable.rb +4 -4
- data/lib/make_taggable/tag.rb +1 -1
- data/lib/make_taggable/version.rb +1 -2
- data/lib/tasks/setup_test_db.rake +8 -0
- data/make_taggable.gemspec +28 -15
- metadata +85 -249
- data/.standard.yml +0 -18
- data/.standard_todo.yml +0 -5
- data/.travis.yml +0 -36
- data/LICENSE.txt +0 -21
- data/spec/dummy/README.md +0 -24
- data/spec/dummy/Rakefile +0 -6
- data/spec/dummy/app/assets/config/manifest.js +0 -2
- data/spec/dummy/app/channels/application_cable/channel.rb +0 -4
- data/spec/dummy/app/channels/application_cable/connection.rb +0 -4
- data/spec/dummy/app/controllers/application_controller.rb +0 -2
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/jobs/application_job.rb +0 -7
- data/spec/dummy/app/mailers/application_mailer.rb +0 -4
- data/spec/dummy/app/models/altered_inheriting_taggable_model.rb +0 -5
- data/spec/dummy/app/models/application_record.rb +0 -3
- data/spec/dummy/app/models/cached_model.rb +0 -3
- data/spec/dummy/app/models/cached_model_with_array.rb +0 -11
- data/spec/dummy/app/models/columns_override_model.rb +0 -5
- data/spec/dummy/app/models/company.rb +0 -15
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/models/inheriting_taggable_model.rb +0 -4
- data/spec/dummy/app/models/market.rb +0 -2
- data/spec/dummy/app/models/non_standard_id_taggable_model.rb +0 -8
- data/spec/dummy/app/models/ordered_taggable_model.rb +0 -4
- data/spec/dummy/app/models/other_cached_model.rb +0 -3
- data/spec/dummy/app/models/other_taggable_model.rb +0 -4
- data/spec/dummy/app/models/student.rb +0 -4
- data/spec/dummy/app/models/taggable_model.rb +0 -14
- data/spec/dummy/app/models/untaggable_model.rb +0 -3
- data/spec/dummy/app/models/user.rb +0 -3
- data/spec/dummy/app/views/layouts/mailer.html.erb +0 -13
- data/spec/dummy/app/views/layouts/mailer.text.erb +0 -1
- data/spec/dummy/bin/rails +0 -4
- data/spec/dummy/bin/rake +0 -4
- data/spec/dummy/bin/setup +0 -33
- data/spec/dummy/config.ru +0 -5
- data/spec/dummy/config/application.rb +0 -19
- data/spec/dummy/config/boot.rb +0 -5
- data/spec/dummy/config/cable.yml +0 -10
- data/spec/dummy/config/credentials.yml.enc +0 -1
- data/spec/dummy/config/database.yml +0 -25
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -52
- data/spec/dummy/config/environments/production.rb +0 -105
- data/spec/dummy/config/environments/test.rb +0 -49
- data/spec/dummy/config/initializers/application_controller_renderer.rb +0 -8
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/cors.rb +0 -16
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/dummy/config/initializers/inflections.rb +0 -16
- data/spec/dummy/config/initializers/mime_types.rb +0 -4
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -33
- data/spec/dummy/config/master.key +0 -1
- data/spec/dummy/config/puma.rb +0 -38
- data/spec/dummy/config/routes.rb +0 -3
- data/spec/dummy/config/spring.rb +0 -6
- data/spec/dummy/config/storage.yml +0 -34
- data/spec/dummy/db/migrate/20201119220853_create_taggable_models.rb +0 -8
- data/spec/dummy/db/migrate/20201119221037_create_columns_override_models.rb +0 -9
- data/spec/dummy/db/migrate/20201119221121_create_non_standard_id_taggable_models.rb +0 -8
- data/spec/dummy/db/migrate/20201119221228_create_untaggable_models.rb +0 -8
- data/spec/dummy/db/migrate/20201119221247_create_cached_models.rb +0 -9
- data/spec/dummy/db/migrate/20201119221314_create_other_cached_models.rb +0 -11
- data/spec/dummy/db/migrate/20201119221343_create_companies.rb +0 -7
- data/spec/dummy/db/migrate/20201119221416_create_users.rb +0 -7
- data/spec/dummy/db/migrate/20201119221434_create_other_taggable_models.rb +0 -8
- data/spec/dummy/db/migrate/20201119221507_create_ordered_taggable_models.rb +0 -8
- data/spec/dummy/db/migrate/20201119221530_create_cache_methods_injected_models.rb +0 -7
- data/spec/dummy/db/migrate/20201119221629_create_other_cached_with_array_models.rb +0 -11
- data/spec/dummy/db/migrate/20201119221746_create_taggable_model_with_jsons.rb +0 -9
- data/spec/dummy/db/migrate/20201121222007_create_make_taggable_tags.make_taggable_engine.rb +0 -11
- data/spec/dummy/db/migrate/20201121222008_create_make_taggable_taggings.make_taggable_engine.rb +0 -13
- data/spec/dummy/db/migrate/20201121222009_change_tag_name_collation_mysql.make_taggable_engine.rb +0 -8
- data/spec/dummy/db/migrate/20201121222010_add_index_to_tags.make_taggable_engine.rb +0 -6
- data/spec/dummy/db/migrate/20201121222011_add_index_to_taggings.make_taggable_engine.rb +0 -13
- data/spec/dummy/db/schema.rb +0 -117
- data/spec/dummy/db/seeds.rb +0 -7
- data/spec/dummy/lib/tasks/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/public/robots.txt +0 -1
- data/spec/dummy/storage/.keep +0 -0
- data/spec/dummy/test/channels/application_cable/connection_test.rb +0 -11
- 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 +0 -13
- data/spec/dummy/vendor/.keep +0 -0
- data/spec/make_taggable/acts_as_tagger_spec.rb +0 -112
- data/spec/make_taggable/caching_spec.rb +0 -123
- data/spec/make_taggable/default_parser_spec.rb +0 -45
- data/spec/make_taggable/dirty_spec.rb +0 -140
- data/spec/make_taggable/generic_parser_spec.rb +0 -13
- data/spec/make_taggable/make_taggable_spec.rb +0 -260
- data/spec/make_taggable/related_spec.rb +0 -93
- data/spec/make_taggable/single_table_inheritance_spec.rb +0 -220
- data/spec/make_taggable/tag_list_spec.rb +0 -169
- data/spec/make_taggable/tag_spec.rb +0 -297
- data/spec/make_taggable/taggable_spec.rb +0 -804
- data/spec/make_taggable/tagger_spec.rb +0 -149
- data/spec/make_taggable/tagging_spec.rb +0 -115
- data/spec/make_taggable/tags_helper_spec.rb +0 -43
- data/spec/make_taggable/utils_spec.rb +0 -22
- data/spec/make_taggable_spec.rb +0 -5
- data/spec/spec_helper.rb +0 -18
- data/spec/support/array.rb +0 -9
- data/spec/support/helpers.rb +0 -31
|
@@ -1,11 +0,0 @@
|
|
|
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
|
|
@@ -1,11 +0,0 @@
|
|
|
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/20201121222008_create_make_taggable_taggings.make_taggable_engine.rb
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
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
|
data/spec/dummy/db/migrate/20201121222009_change_tag_name_collation_mysql.make_taggable_engine.rb
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
# This migration comes from make_taggable_engine (originally 3)
|
|
2
|
-
class ChangeTagNameCollationMysql < ActiveRecord::Migration[5.2]
|
|
3
|
-
def change
|
|
4
|
-
if MakeTaggable::Utils.using_mysql?
|
|
5
|
-
execute("ALTER TABLE #{MakeTaggable.tags_table} MODIFY name varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;")
|
|
6
|
-
end
|
|
7
|
-
end
|
|
8
|
-
end
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# This migration comes from make_taggable_engine (originally 5)
|
|
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
|
data/spec/dummy/db/schema.rb
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
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_21_222011) 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
|
data/spec/dummy/db/seeds.rb
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
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)
|
data/spec/dummy/lib/tasks/.keep
DELETED
|
File without changes
|
data/spec/dummy/log/.keep
DELETED
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
|
data/spec/dummy/storage/.keep
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
data/spec/dummy/vendor/.keep
DELETED
|
File without changes
|
|
@@ -1,112 +0,0 @@
|
|
|
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
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
|
|
3
|
-
describe "Acts As Taggable On" do
|
|
4
|
-
describe "Caching" do
|
|
5
|
-
before(:each) do
|
|
6
|
-
@taggable = CachedModel.new(name: "Bob Jones")
|
|
7
|
-
@another_taggable = OtherCachedModel.new(name: "John Smith")
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
it "should add saving of tag lists and cached tag lists to the instance" do
|
|
11
|
-
expect(@taggable).to respond_to(:save_cached_tag_list)
|
|
12
|
-
expect(@another_taggable).to respond_to(:save_cached_tag_list)
|
|
13
|
-
|
|
14
|
-
expect(@taggable).to respond_to(:save_tags)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it "should add cached tag lists to the instance if cached column is not present" do
|
|
18
|
-
expect(TaggableModel.new(name: "Art Kram")).to_not respond_to(:save_cached_tag_list)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it "should generate a cached column checker for each tag type" do
|
|
22
|
-
expect(CachedModel).to respond_to(:caching_tag_list?)
|
|
23
|
-
expect(OtherCachedModel).to respond_to(:caching_language_list?)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
it "should not have cached tags" do
|
|
27
|
-
expect(@taggable.cached_tag_list).to be_blank
|
|
28
|
-
expect(@another_taggable.cached_language_list).to be_blank
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it "should cache tags" do
|
|
32
|
-
@taggable.update(tag_list: "awesome, epic")
|
|
33
|
-
expect(@taggable.cached_tag_list).to eq("awesome, epic")
|
|
34
|
-
|
|
35
|
-
@another_taggable.update(language_list: "ruby, .net")
|
|
36
|
-
expect(@another_taggable.cached_language_list).to eq("ruby, .net")
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
it "should keep the cache" do
|
|
40
|
-
@taggable.update(tag_list: "awesome, epic")
|
|
41
|
-
@taggable = CachedModel.find(@taggable.id)
|
|
42
|
-
@taggable.save!
|
|
43
|
-
expect(@taggable.cached_tag_list).to eq("awesome, epic")
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
it "should update the cache" do
|
|
47
|
-
@taggable.update(tag_list: "awesome, epic")
|
|
48
|
-
@taggable.update(tag_list: "awesome")
|
|
49
|
-
expect(@taggable.cached_tag_list).to eq("awesome")
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
it "should remove the cache" do
|
|
53
|
-
@taggable.update(tag_list: "awesome, epic")
|
|
54
|
-
@taggable.update(tag_list: "")
|
|
55
|
-
expect(@taggable.cached_tag_list).to be_blank
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
it "should have a tag list" do
|
|
59
|
-
@taggable.update(tag_list: "awesome, epic")
|
|
60
|
-
@taggable = CachedModel.find(@taggable.id)
|
|
61
|
-
expect(@taggable.tag_list.sort).to eq(%w[awesome epic].sort)
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
it "should keep the tag list" do
|
|
65
|
-
@taggable.update(tag_list: "awesome, epic")
|
|
66
|
-
@taggable = CachedModel.find(@taggable.id)
|
|
67
|
-
@taggable.save!
|
|
68
|
-
expect(@taggable.tag_list.sort).to eq(%w[awesome epic].sort)
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
it "should clear the cache on reset_column_information" do
|
|
72
|
-
CachedModel.column_names
|
|
73
|
-
CachedModel.reset_column_information
|
|
74
|
-
expect(CachedModel.instance_variable_get(:@make_taggable_cache_columns)).to eql(nil)
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
it "should not override a user-defined columns method" do
|
|
78
|
-
expect(ColumnsOverrideModel.columns.map(&:name)).not_to include("ignored_column")
|
|
79
|
-
ColumnsOverrideModel.acts_as_taggable
|
|
80
|
-
expect(ColumnsOverrideModel.columns.map(&:name)).not_to include("ignored_column")
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
describe "with a custom delimiter" do
|
|
85
|
-
before(:each) do
|
|
86
|
-
@taggable = CachedModel.new(name: "Bob Jones")
|
|
87
|
-
@another_taggable = OtherCachedModel.new(name: "John Smith")
|
|
88
|
-
MakeTaggable.delimiter = ";"
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
after(:all) do
|
|
92
|
-
MakeTaggable.delimiter = ","
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
it "should cache tags with custom delimiter" do
|
|
96
|
-
@taggable.update(tag_list: "awesome; epic")
|
|
97
|
-
expect(@taggable.tag_list).to eq(["awesome", "epic"])
|
|
98
|
-
expect(@taggable.cached_tag_list).to eq("awesome; epic")
|
|
99
|
-
|
|
100
|
-
@taggable = CachedModel.find_by_name("Bob Jones")
|
|
101
|
-
expect(@taggable.tag_list).to eq(["awesome", "epic"])
|
|
102
|
-
expect(@taggable.cached_tag_list).to eq("awesome; epic")
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
describe "Cache methods initialization on new models" do
|
|
107
|
-
before(:all) do
|
|
108
|
-
ActiveRecord::Base.connection.execute(
|
|
109
|
-
"INSERT INTO cache_methods_injected_models (cached_tag_list) VALUES ('ciao')"
|
|
110
|
-
)
|
|
111
|
-
class CacheMethodsInjectedModel < ActiveRecord::Base
|
|
112
|
-
acts_as_taggable
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
after(:all) { Object.send(:remove_const, :CacheMethodsInjectedModel) }
|
|
116
|
-
|
|
117
|
-
it "cached_tag_list_on? get injected correctly" do
|
|
118
|
-
expect {
|
|
119
|
-
CacheMethodsInjectedModel.first.tag_list
|
|
120
|
-
}.not_to raise_error
|
|
121
|
-
end
|
|
122
|
-
end
|
|
123
|
-
end
|