make_taggable 0.7.0 → 0.7.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dummyrc +17 -0
- data/.github/workflows/ci.yml +140 -0
- data/.github/workflows/standard-ci.yml +27 -0
- data/.gitignore +2 -1
- data/CONTRIBUTING.md +5 -31
- data/README.md +20 -9
- data/Rakefile +2 -0
- data/gemfiles/rails_5.gemfile +9 -0
- data/gemfiles/rails_6.gemfile +9 -0
- data/gemfiles/rails_6_1.gemfile +9 -0
- data/gemfiles/rails_master.gemfile +9 -0
- data/lib/make_taggable.rb +1 -1
- data/lib/make_taggable/tag.rb +1 -1
- data/lib/make_taggable/version.rb +1 -1
- data/lib/tasks/setup_test_db.rake +5 -3
- data/make_taggable.gemspec +28 -16
- metadata +87 -248
- data/.github/workflows/mysql_tests.yml +0 -56
- data/.github/workflows/pg_tests.yml +0 -56
- data/.github/workflows/sqlite_tests.yml +0 -47
- data/.github/workflows/standardrb-check.yml +0 -37
- data/.standard.yml +0 -18
- data/.standard_todo.yml +0 -5
- data/LICENSE.txt +0 -21
- data/spec/dummy/README.md +0 -0
- 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 -5
- 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/taggable_model_with_json.rb +0 -6
- 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 -13
- 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 -7
- 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/mysql_database.yml.ci +0 -8
- data/spec/dummy/config/pg_database.yml.ci +0 -8
- 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/020201119220853_create_taggable_models.rb +0 -8
- data/spec/dummy/db/migrate/020201119221037_create_columns_override_models.rb +0 -9
- data/spec/dummy/db/migrate/020201119221121_create_non_standard_id_taggable_models.rb +0 -8
- data/spec/dummy/db/migrate/020201119221228_create_untaggable_models.rb +0 -8
- data/spec/dummy/db/migrate/020201119221247_create_cached_models.rb +0 -9
- data/spec/dummy/db/migrate/020201119221314_create_other_cached_models.rb +0 -11
- data/spec/dummy/db/migrate/020201119221343_create_companies.rb +0 -7
- data/spec/dummy/db/migrate/020201119221416_create_users.rb +0 -7
- data/spec/dummy/db/migrate/020201119221434_create_other_taggable_models.rb +0 -8
- data/spec/dummy/db/migrate/020201119221507_create_ordered_taggable_models.rb +0 -8
- data/spec/dummy/db/migrate/020201119221530_create_cache_methods_injected_models.rb +0 -7
- data/spec/dummy/db/migrate/020201119221629_create_other_cached_with_array_models.rb +0 -11
- data/spec/dummy/db/migrate/020201119221746_create_taggable_model_with_jsons.rb +0 -9
- 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 -135
- 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 -16
- data/spec/support/array.rb +0 -9
- data/spec/support/helpers.rb +0 -31
data/spec/dummy/config/puma.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
# Puma can serve each request in a thread from an internal thread pool.
|
2
|
-
# The `threads` method setting takes two numbers: a minimum and maximum.
|
3
|
-
# Any libraries that use thread pools should be configured to match
|
4
|
-
# the maximum value specified for Puma. Default is set to 5 threads for minimum
|
5
|
-
# and maximum; this matches the default thread size of Active Record.
|
6
|
-
#
|
7
|
-
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
|
8
|
-
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
|
9
|
-
threads min_threads_count, max_threads_count
|
10
|
-
|
11
|
-
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
|
12
|
-
#
|
13
|
-
port ENV.fetch("PORT") { 3000 }
|
14
|
-
|
15
|
-
# Specifies the `environment` that Puma will run in.
|
16
|
-
#
|
17
|
-
environment ENV.fetch("RAILS_ENV") { "development" }
|
18
|
-
|
19
|
-
# Specifies the `pidfile` that Puma will use.
|
20
|
-
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
|
21
|
-
|
22
|
-
# Specifies the number of `workers` to boot in clustered mode.
|
23
|
-
# Workers are forked web server processes. If using threads and workers together
|
24
|
-
# the concurrency of the application would be max `threads` * `workers`.
|
25
|
-
# Workers do not work on JRuby or Windows (both of which do not support
|
26
|
-
# processes).
|
27
|
-
#
|
28
|
-
# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
|
29
|
-
|
30
|
-
# Use the `preload_app!` method when specifying a `workers` number.
|
31
|
-
# This directive tells Puma to first boot the application and load code
|
32
|
-
# before forking the application. This takes advantage of Copy On Write
|
33
|
-
# process behavior so workers use less memory.
|
34
|
-
#
|
35
|
-
# preload_app!
|
36
|
-
|
37
|
-
# Allow puma to be restarted by `rails restart` command.
|
38
|
-
plugin :tmp_restart
|
data/spec/dummy/config/routes.rb
DELETED
data/spec/dummy/config/spring.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
test:
|
2
|
-
service: Disk
|
3
|
-
root: <%= Rails.root.join("tmp/storage") %>
|
4
|
-
|
5
|
-
local:
|
6
|
-
service: Disk
|
7
|
-
root: <%= Rails.root.join("storage") %>
|
8
|
-
|
9
|
-
# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
|
10
|
-
# amazon:
|
11
|
-
# service: S3
|
12
|
-
# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
|
13
|
-
# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
|
14
|
-
# region: us-east-1
|
15
|
-
# bucket: your_own_bucket
|
16
|
-
|
17
|
-
# Remember not to checkin your GCS keyfile to a repository
|
18
|
-
# google:
|
19
|
-
# service: GCS
|
20
|
-
# project: your_project
|
21
|
-
# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
|
22
|
-
# bucket: your_own_bucket
|
23
|
-
|
24
|
-
# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
|
25
|
-
# microsoft:
|
26
|
-
# service: AzureStorage
|
27
|
-
# storage_account_name: your_account_name
|
28
|
-
# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
|
29
|
-
# container: your_container_name
|
30
|
-
|
31
|
-
# mirror:
|
32
|
-
# service: Mirror
|
33
|
-
# primary: local
|
34
|
-
# mirrors: [ amazon, google, microsoft ]
|
@@ -1,11 +0,0 @@
|
|
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
|
@@ -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
|
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
|