make_taggable 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/.dummyrc +17 -0
  3. data/.github/workflows/ci.yml +158 -0
  4. data/.gitignore +2 -1
  5. data/CONTRIBUTING.md +5 -31
  6. data/README.md +3 -8
  7. data/Rakefile +2 -0
  8. data/gemfiles/rails_5.gemfile +9 -0
  9. data/gemfiles/rails_6.gemfile +9 -0
  10. data/gemfiles/rails_6_1.gemfile +9 -0
  11. data/gemfiles/rails_master.gemfile +9 -0
  12. data/lib/make_taggable.rb +1 -1
  13. data/lib/make_taggable/tag.rb +1 -1
  14. data/lib/make_taggable/version.rb +1 -1
  15. data/lib/tasks/setup_test_db.rake +5 -3
  16. data/make_taggable.gemspec +13 -10
  17. metadata +27 -218
  18. data/.github/workflows/mysql_tests.yml +0 -56
  19. data/.github/workflows/pg_tests.yml +0 -56
  20. data/.github/workflows/sqlite_tests.yml +0 -47
  21. data/.github/workflows/standardrb-check.yml +0 -37
  22. data/.standard.yml +0 -18
  23. data/.standard_todo.yml +0 -5
  24. data/LICENSE.txt +0 -21
  25. data/spec/dummy/README.md +0 -0
  26. data/spec/dummy/Rakefile +0 -6
  27. data/spec/dummy/app/assets/config/manifest.js +0 -2
  28. data/spec/dummy/app/channels/application_cable/channel.rb +0 -4
  29. data/spec/dummy/app/channels/application_cable/connection.rb +0 -4
  30. data/spec/dummy/app/controllers/application_controller.rb +0 -2
  31. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  32. data/spec/dummy/app/jobs/application_job.rb +0 -7
  33. data/spec/dummy/app/mailers/application_mailer.rb +0 -4
  34. data/spec/dummy/app/models/altered_inheriting_taggable_model.rb +0 -5
  35. data/spec/dummy/app/models/application_record.rb +0 -3
  36. data/spec/dummy/app/models/cached_model.rb +0 -3
  37. data/spec/dummy/app/models/cached_model_with_array.rb +0 -5
  38. data/spec/dummy/app/models/columns_override_model.rb +0 -5
  39. data/spec/dummy/app/models/company.rb +0 -15
  40. data/spec/dummy/app/models/concerns/.keep +0 -0
  41. data/spec/dummy/app/models/inheriting_taggable_model.rb +0 -4
  42. data/spec/dummy/app/models/market.rb +0 -2
  43. data/spec/dummy/app/models/non_standard_id_taggable_model.rb +0 -8
  44. data/spec/dummy/app/models/ordered_taggable_model.rb +0 -4
  45. data/spec/dummy/app/models/other_cached_model.rb +0 -3
  46. data/spec/dummy/app/models/other_taggable_model.rb +0 -4
  47. data/spec/dummy/app/models/student.rb +0 -4
  48. data/spec/dummy/app/models/taggable_model.rb +0 -14
  49. data/spec/dummy/app/models/taggable_model_with_json.rb +0 -6
  50. data/spec/dummy/app/models/untaggable_model.rb +0 -3
  51. data/spec/dummy/app/models/user.rb +0 -3
  52. data/spec/dummy/app/views/layouts/mailer.html.erb +0 -13
  53. data/spec/dummy/app/views/layouts/mailer.text.erb +0 -1
  54. data/spec/dummy/bin/rails +0 -4
  55. data/spec/dummy/bin/rake +0 -4
  56. data/spec/dummy/bin/setup +0 -33
  57. data/spec/dummy/config.ru +0 -5
  58. data/spec/dummy/config/application.rb +0 -13
  59. data/spec/dummy/config/boot.rb +0 -5
  60. data/spec/dummy/config/cable.yml +0 -10
  61. data/spec/dummy/config/credentials.yml.enc +0 -1
  62. data/spec/dummy/config/database.yml +0 -7
  63. data/spec/dummy/config/environment.rb +0 -5
  64. data/spec/dummy/config/environments/development.rb +0 -52
  65. data/spec/dummy/config/environments/production.rb +0 -105
  66. data/spec/dummy/config/environments/test.rb +0 -49
  67. data/spec/dummy/config/initializers/application_controller_renderer.rb +0 -8
  68. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  69. data/spec/dummy/config/initializers/cors.rb +0 -16
  70. data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  71. data/spec/dummy/config/initializers/inflections.rb +0 -16
  72. data/spec/dummy/config/initializers/mime_types.rb +0 -4
  73. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  74. data/spec/dummy/config/locales/en.yml +0 -33
  75. data/spec/dummy/config/master.key +0 -1
  76. data/spec/dummy/config/mysql_database.yml.ci +0 -8
  77. data/spec/dummy/config/pg_database.yml.ci +0 -8
  78. data/spec/dummy/config/puma.rb +0 -38
  79. data/spec/dummy/config/routes.rb +0 -3
  80. data/spec/dummy/config/spring.rb +0 -6
  81. data/spec/dummy/config/storage.yml +0 -34
  82. data/spec/dummy/db/migrate/020201119220853_create_taggable_models.rb +0 -8
  83. data/spec/dummy/db/migrate/020201119221037_create_columns_override_models.rb +0 -9
  84. data/spec/dummy/db/migrate/020201119221121_create_non_standard_id_taggable_models.rb +0 -8
  85. data/spec/dummy/db/migrate/020201119221228_create_untaggable_models.rb +0 -8
  86. data/spec/dummy/db/migrate/020201119221247_create_cached_models.rb +0 -9
  87. data/spec/dummy/db/migrate/020201119221314_create_other_cached_models.rb +0 -11
  88. data/spec/dummy/db/migrate/020201119221343_create_companies.rb +0 -7
  89. data/spec/dummy/db/migrate/020201119221416_create_users.rb +0 -7
  90. data/spec/dummy/db/migrate/020201119221434_create_other_taggable_models.rb +0 -8
  91. data/spec/dummy/db/migrate/020201119221507_create_ordered_taggable_models.rb +0 -8
  92. data/spec/dummy/db/migrate/020201119221530_create_cache_methods_injected_models.rb +0 -7
  93. data/spec/dummy/db/migrate/020201119221629_create_other_cached_with_array_models.rb +0 -11
  94. data/spec/dummy/db/migrate/020201119221746_create_taggable_model_with_jsons.rb +0 -9
  95. data/spec/dummy/lib/tasks/.keep +0 -0
  96. data/spec/dummy/log/.keep +0 -0
  97. data/spec/dummy/public/robots.txt +0 -1
  98. data/spec/dummy/storage/.keep +0 -0
  99. data/spec/dummy/test/channels/application_cable/connection_test.rb +0 -11
  100. data/spec/dummy/test/controllers/.keep +0 -0
  101. data/spec/dummy/test/fixtures/.keep +0 -0
  102. data/spec/dummy/test/fixtures/files/.keep +0 -0
  103. data/spec/dummy/test/integration/.keep +0 -0
  104. data/spec/dummy/test/mailers/.keep +0 -0
  105. data/spec/dummy/test/models/.keep +0 -0
  106. data/spec/dummy/test/test_helper.rb +0 -13
  107. data/spec/dummy/vendor/.keep +0 -0
  108. data/spec/make_taggable/acts_as_tagger_spec.rb +0 -112
  109. data/spec/make_taggable/caching_spec.rb +0 -123
  110. data/spec/make_taggable/default_parser_spec.rb +0 -45
  111. data/spec/make_taggable/dirty_spec.rb +0 -140
  112. data/spec/make_taggable/generic_parser_spec.rb +0 -13
  113. data/spec/make_taggable/make_taggable_spec.rb +0 -260
  114. data/spec/make_taggable/related_spec.rb +0 -93
  115. data/spec/make_taggable/single_table_inheritance_spec.rb +0 -220
  116. data/spec/make_taggable/tag_list_spec.rb +0 -169
  117. data/spec/make_taggable/tag_spec.rb +0 -135
  118. data/spec/make_taggable/taggable_spec.rb +0 -804
  119. data/spec/make_taggable/tagger_spec.rb +0 -149
  120. data/spec/make_taggable/tagging_spec.rb +0 -115
  121. data/spec/make_taggable/tags_helper_spec.rb +0 -43
  122. data/spec/make_taggable/utils_spec.rb +0 -22
  123. data/spec/make_taggable_spec.rb +0 -5
  124. data/spec/spec_helper.rb +0 -16
  125. data/spec/support/array.rb +0 -9
  126. data/spec/support/helpers.rb +0 -31
@@ -1,45 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe MakeTaggable::DefaultParser do
4
- it "#parse should return empty array if empty array is passed" do
5
- parser = MakeTaggable::DefaultParser.new([])
6
- expect(parser.parse).to be_empty
7
- end
8
-
9
- describe "Multiple Delimiter" do
10
- before do
11
- @old_delimiter = MakeTaggable.delimiter
12
- end
13
-
14
- after do
15
- MakeTaggable.delimiter = @old_delimiter
16
- end
17
-
18
- it "should separate tags by delimiters" do
19
- MakeTaggable.delimiter = [",", " ", '\|']
20
- parser = MakeTaggable::DefaultParser.new("cool, data|I have")
21
- expect(parser.parse.to_s).to eq("cool, data, I, have")
22
- end
23
-
24
- it "should escape quote" do
25
- MakeTaggable.delimiter = [",", " ", '\|']
26
- parser = MakeTaggable::DefaultParser.new("'I have'|cool, data")
27
- expect(parser.parse.to_s).to eq('"I have", cool, data')
28
-
29
- parser = MakeTaggable::DefaultParser.new('"I, have"|cool, data')
30
- expect(parser.parse.to_s).to eq('"I, have", cool, data')
31
- end
32
-
33
- it "should work for utf8 delimiter and long delimiter" do
34
- MakeTaggable.delimiter = [",", "的", "可能是"]
35
- parser = MakeTaggable::DefaultParser.new("我的东西可能是不见了,还好有备份")
36
- expect(parser.parse.to_s).to eq("我, 东西, 不见了, 还好有备份")
37
- end
38
-
39
- it "should work for multiple quoted tags" do
40
- MakeTaggable.delimiter = [","]
41
- parser = MakeTaggable::DefaultParser.new('"Ruby Monsters","eat Katzenzungen"')
42
- expect(parser.parse.to_s).to eq("Ruby Monsters, eat Katzenzungen")
43
- end
44
- end
45
- end
@@ -1,140 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "Dirty behavior of taggable objects" do
4
- context "with un-contexted tags" do
5
- before(:each) do
6
- @taggable = TaggableModel.create(tag_list: "awesome, epic")
7
- end
8
-
9
- context "when tag_list changed" do
10
- before(:each) do
11
- expect(@taggable.changes).to be_empty
12
- @taggable.tag_list = "one"
13
- end
14
-
15
- it "should show changes of dirty object" do
16
- expect(@taggable.changes).to eq({"tag_list" => [["awesome", "epic"], ["one"]]})
17
- end
18
-
19
- it "should show changes of freshly initialized dirty object" do
20
- taggable = TaggableModel.find(@taggable.id)
21
- taggable.tag_list = "one"
22
- expect(taggable.changes).to eq({"tag_list" => [["awesome", "epic"], ["one"]]})
23
- end
24
-
25
- if Rails.version >= "5.1"
26
- it "flags tag_list as changed" do
27
- expect(@taggable.will_save_change_to_tag_list?).to be_truthy
28
- end
29
- end
30
-
31
- it "preserves original value" do
32
- expect(@taggable.tag_list_was).to eq(["awesome", "epic"])
33
- end
34
-
35
- it "shows what the change was" do
36
- expect(@taggable.tag_list_change).to eq([["awesome", "epic"], ["one"]])
37
- end
38
-
39
- context "without order" do
40
- it "should not mark attribute if order change " do
41
- taggable = TaggableModel.create(name: "Dirty Harry", tag_list: %w[d c b a])
42
- taggable.tag_list = %w[a b c d]
43
- expect(taggable.tag_list_changed?).to be_falsey
44
- end
45
- end
46
-
47
- context "with order" do
48
- it "should mark attribute if order change" do
49
- taggable = OrderedTaggableModel.create(name: "Clean Harry", tag_list: "d,c,b,a")
50
- taggable.save
51
- taggable.tag_list = %w[a b c d]
52
- expect(taggable.tag_list_changed?).to be_truthy
53
- end
54
- end
55
- end
56
-
57
- context "when tag_list is the same" do
58
- before(:each) do
59
- @taggable.tag_list = "awesome, epic"
60
- end
61
-
62
- it "is not flagged as changed" do
63
- expect(@taggable.tag_list_changed?).to be_falsy
64
- end
65
-
66
- it "does not show any changes to the taggable item" do
67
- expect(@taggable.changes).to be_empty
68
- end
69
-
70
- context "and using a delimiter different from a ','" do
71
- before do
72
- @old_delimiter = MakeTaggable.delimiter
73
- MakeTaggable.delimiter = ";"
74
- end
75
-
76
- after do
77
- MakeTaggable.delimiter = @old_delimiter
78
- end
79
-
80
- it "does not show any changes to the taggable item when using array assignments" do
81
- @taggable.tag_list = %w[awesome epic]
82
- expect(@taggable.changes).to be_empty
83
- end
84
- end
85
- end
86
- end
87
-
88
- context "with context tags" do
89
- before(:each) do
90
- @taggable = TaggableModel.create("language_list" => "awesome, epic")
91
- end
92
-
93
- context "when language_list changed" do
94
- before(:each) do
95
- expect(@taggable.changes).to be_empty
96
- @taggable.language_list = "one"
97
- end
98
-
99
- it "should show changes of dirty object" do
100
- expect(@taggable.changes).to eq({"language_list" => [["awesome", "epic"], ["one"]]})
101
- end
102
-
103
- it "flags language_list as changed" do
104
- expect(@taggable.language_list_changed?).to be_truthy
105
- end
106
-
107
- it "preserves original value" do
108
- expect(@taggable.language_list_was).to eq(["awesome", "epic"])
109
- end
110
-
111
- it "shows what the change was" do
112
- expect(@taggable.language_list_change).to eq([["awesome", "epic"], ["one"]])
113
- end
114
- end
115
-
116
- context "when language_list is the same" do
117
- before(:each) do
118
- @taggable.language_list = "awesome, epic"
119
- end
120
-
121
- it "is not flagged as changed" do
122
- expect(@taggable.language_list_changed?).to be_falsy
123
- end
124
-
125
- it "does not show any changes to the taggable item" do
126
- expect(@taggable.changes).to be_empty
127
- end
128
- end
129
-
130
- context "when language_list changed by association" do
131
- let(:tag) { MakeTaggable::Tag.new(name: "one") }
132
-
133
- it "flags language_list as changed" do
134
- expect(@taggable.changes).to be_empty
135
- @taggable.languages << tag
136
- expect(@taggable.language_list_changed?).to be_truthy
137
- end
138
- end
139
- end
140
- end
@@ -1,13 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe MakeTaggable::GenericParser do
4
- it "#parse should return empty array if empty tag string is passed" do
5
- tag_list = MakeTaggable::GenericParser.new("")
6
- expect(tag_list.parse).to be_empty
7
- end
8
-
9
- it "#parse should separate tags by comma" do
10
- tag_list = MakeTaggable::GenericParser.new("cool,data,,I,have")
11
- expect(tag_list.parse).to eq(%w[cool data I have])
12
- end
13
- end
@@ -1,260 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "Acts As Taggable On" do
4
- it "should provide a class method 'taggable?' that is false for untaggable models" do
5
- expect(UntaggableModel).to_not be_taggable
6
- end
7
-
8
- describe "Taggable Method Generation To Preserve Order" do
9
- before(:each) do
10
- TaggableModel.tag_types = []
11
- TaggableModel.preserve_tag_order = false
12
- TaggableModel.acts_as_ordered_taggable_on(:ordered_tags)
13
- @taggable = TaggableModel.new(name: "Bob Jones")
14
- end
15
-
16
- it "should respond 'true' to preserve_tag_order?" do
17
- expect(@taggable.class.preserve_tag_order?).to be_truthy
18
- end
19
- end
20
-
21
- describe "Taggable Method Generation" do
22
- before(:each) do
23
- TaggableModel.tag_types = []
24
- TaggableModel.make_taggable(:tags, :languages, :skills, :needs, :offerings)
25
- @taggable = TaggableModel.new(name: "Bob Jones")
26
- end
27
-
28
- it "should respond 'true' to taggable?" do
29
- expect(@taggable.class).to be_taggable
30
- end
31
-
32
- it "should create a class attribute for tag types" do
33
- expect(@taggable.class).to respond_to(:tag_types)
34
- end
35
-
36
- it "should create an instance attribute for tag types" do
37
- expect(@taggable).to respond_to(:tag_types)
38
- end
39
-
40
- it "should have all tag types" do
41
- expect(@taggable.tag_types).to eq([:tags, :languages, :skills, :needs, :offerings])
42
- end
43
-
44
- it "should create a class attribute for preserve tag order" do
45
- expect(@taggable.class).to respond_to(:preserve_tag_order?)
46
- end
47
-
48
- it "should create an instance attribute for preserve tag order" do
49
- expect(@taggable).to respond_to(:preserve_tag_order?)
50
- end
51
-
52
- it "should respond 'false' to preserve_tag_order?" do
53
- expect(@taggable.class.preserve_tag_order?).to be_falsy
54
- end
55
-
56
- it "should generate an association for each tag type" do
57
- expect(@taggable).to respond_to(:tags, :skills, :languages)
58
- end
59
-
60
- it "should add tagged_with and tag_counts to singleton" do
61
- expect(TaggableModel).to respond_to(:tagged_with, :tag_counts)
62
- end
63
-
64
- it "should generate a tag_list accessor/setter for each tag type" do
65
- expect(@taggable).to respond_to(:tag_list, :skill_list, :language_list)
66
- expect(@taggable).to respond_to(:tag_list=, :skill_list=, :language_list=)
67
- end
68
-
69
- it "should generate a tag_list accessor, that includes owned tags, for each tag type" do
70
- expect(@taggable).to respond_to(:all_tags_list, :all_skills_list, :all_languages_list)
71
- end
72
- end
73
-
74
- describe "Matching Contexts" do
75
- it "should find objects with tags of matching contexts" do
76
- taggable1 = TaggableModel.create!(name: "Taggable 1")
77
- taggable2 = TaggableModel.create!(name: "Taggable 2")
78
- taggable3 = TaggableModel.create!(name: "Taggable 3")
79
-
80
- taggable1.offering_list = "one, two"
81
- taggable1.save!
82
-
83
- taggable2.need_list = "one, two"
84
- taggable2.save!
85
-
86
- taggable3.offering_list = "one, two"
87
- taggable3.save!
88
-
89
- expect(taggable1.find_matching_contexts(:offerings, :needs)).to include(taggable2)
90
- expect(taggable1.find_matching_contexts(:offerings, :needs)).to_not include(taggable3)
91
- end
92
-
93
- it "should find other related objects with tags of matching contexts" do
94
- taggable1 = TaggableModel.create!(name: "Taggable 1")
95
- taggable2 = OtherTaggableModel.create!(name: "Taggable 2")
96
- taggable3 = OtherTaggableModel.create!(name: "Taggable 3")
97
-
98
- taggable1.offering_list = "one, two"
99
- taggable1.save
100
-
101
- taggable2.need_list = "one, two"
102
- taggable2.save
103
-
104
- taggable3.offering_list = "one, two"
105
- taggable3.save
106
-
107
- expect(taggable1.find_matching_contexts_for(OtherTaggableModel, :offerings, :needs)).to include(taggable2)
108
- expect(taggable1.find_matching_contexts_for(OtherTaggableModel, :offerings, :needs)).to_not include(taggable3)
109
- end
110
-
111
- it "should not include the object itself in the list of related objects with tags of matching contexts" do
112
- taggable1 = TaggableModel.create!(name: "Taggable 1")
113
- taggable2 = TaggableModel.create!(name: "Taggable 2")
114
-
115
- taggable1.offering_list = "one, two"
116
- taggable1.need_list = "one, two"
117
- taggable1.save
118
-
119
- taggable2.need_list = "one, two"
120
- taggable2.save
121
-
122
- expect(taggable1.find_matching_contexts_for(TaggableModel, :offerings, :needs)).to include(taggable2)
123
- expect(taggable1.find_matching_contexts_for(TaggableModel, :offerings, :needs)).to_not include(taggable1)
124
- end
125
-
126
- it "should ensure joins to multiple taggings maintain their contexts when aliasing" do
127
- taggable1 = TaggableModel.create!(name: "Taggable 1")
128
-
129
- taggable1.offering_list = "one"
130
- taggable1.need_list = "two"
131
-
132
- taggable1.save
133
-
134
- column = TaggableModel.connection.quote_column_name("context")
135
- offer_alias = TaggableModel.connection.quote_table_name(MakeTaggable.taggings_table)
136
- need_alias = TaggableModel.connection.quote_table_name("need_taggings_taggable_models_join")
137
-
138
- expect(TaggableModel.joins(:offerings, :needs).to_sql).to include "#{offer_alias}.#{column}"
139
- expect(TaggableModel.joins(:offerings, :needs).to_sql).to include "#{need_alias}.#{column}"
140
- end
141
- end
142
-
143
- describe "Tagging Contexts" do
144
- it "should eliminate duplicate tagging contexts " do
145
- TaggableModel.make_taggable(:skills, :skills)
146
- expect(TaggableModel.tag_types.freq[:skills]).to eq(1)
147
- end
148
-
149
- it "should not contain embedded/nested arrays" do
150
- TaggableModel.make_taggable([:array], [:array])
151
- expect(TaggableModel.tag_types.freq[[:array]]).to eq(0)
152
- end
153
-
154
- it "should _flatten_ the content of arrays" do
155
- TaggableModel.make_taggable([:array], [:array])
156
- expect(TaggableModel.tag_types.freq[:array]).to eq(1)
157
- end
158
-
159
- it "should not raise an error when passed nil" do
160
- expect(-> {
161
- TaggableModel.make_taggable
162
- }).to_not raise_error
163
- end
164
-
165
- it "should not raise an error when passed [nil]" do
166
- expect(-> {
167
- TaggableModel.make_taggable([nil])
168
- }).to_not raise_error
169
- end
170
-
171
- it "should include dynamic contexts in tagging_contexts" do
172
- taggable = TaggableModel.create!(name: "Dynamic Taggable")
173
- taggable.set_tag_list_on :colors, "tag1, tag2, tag3"
174
- expect(taggable.tagging_contexts).to eq(%w[tags languages skills needs offerings array colors])
175
- taggable.save
176
- taggable = TaggableModel.where(name: "Dynamic Taggable").first
177
- expect(taggable.tagging_contexts).to eq(%w[tags languages skills needs offerings array colors])
178
- end
179
- end
180
-
181
- context 'when tagging context ends in an "s" when singular (ex. "status", "glass", etc.)' do
182
- describe "caching" do
183
- before { @taggable = OtherCachedModel.new(name: "John Smith") }
184
- subject { @taggable }
185
-
186
- it { should respond_to(:save_cached_tag_list) }
187
-
188
- it { expect(@taggable.cached_language_list).to eq nil }
189
- it { expect(@taggable.cached_status_list).to eq nil }
190
- it { expect(@taggable.cached_glass_list).to eq nil }
191
-
192
- context "language taggings cache after update" do
193
- before { @taggable.update(language_list: "ruby, .net") }
194
- subject { @taggable }
195
-
196
- it { expect(@taggable.language_list).to eq ["ruby", ".net"] }
197
- it { expect(@taggable.cached_language_list).to eq "ruby, .net" }
198
- end
199
-
200
- context "status taggings cache after update" do
201
- before { @taggable.update(status_list: "happy, married") }
202
- subject { @taggable }
203
-
204
- it { expect(@taggable.status_list).to eq ["happy", "married"] }
205
- it { expect(@taggable.cached_status_list).to eq "happy, married" }
206
- end
207
-
208
- context "glass taggings cache after update" do
209
- before do
210
- @taggable.update(glass_list: "rectangle, aviator")
211
- end
212
-
213
- subject { @taggable }
214
- it { expect(@taggable.glass_list).to eq ["rectangle", "aviator"] }
215
- it { expect(@taggable.cached_glass_list).to eq "rectangle, aviator" }
216
- end
217
- end
218
- end
219
-
220
- describe "taggings" do
221
- before(:each) do
222
- @taggable = TaggableModel.new(name: "Art Kram")
223
- end
224
-
225
- it "should return no taggings" do
226
- expect(@taggable.taggings).to be_empty
227
- end
228
- end
229
-
230
- describe "@@remove_unused_tags" do
231
- before do
232
- @taggable = TaggableModel.create(name: "Bob Jones")
233
- @tag = MakeTaggable::Tag.create(name: "awesome")
234
-
235
- @tagging = MakeTaggable::Tagging.create(taggable: @taggable, tag: @tag, context: "tags")
236
- end
237
-
238
- context "if set to true" do
239
- before do
240
- MakeTaggable.remove_unused_tags = true
241
- end
242
-
243
- it "should remove unused tags after removing taggings" do
244
- @tagging.destroy
245
- expect(MakeTaggable::Tag.find_by_name("awesome")).to be_nil
246
- end
247
- end
248
-
249
- context "if set to false" do
250
- before do
251
- MakeTaggable.remove_unused_tags = false
252
- end
253
-
254
- it "should not remove unused tags after removing taggings" do
255
- @tagging.destroy
256
- expect(MakeTaggable::Tag.find_by_name("awesome")).to eq(@tag)
257
- end
258
- end
259
- end
260
- end