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.
- checksums.yaml +4 -4
- data/.dummyrc +17 -0
- data/.github/workflows/ci.yml +158 -0
- data/.gitignore +2 -1
- data/CONTRIBUTING.md +5 -31
- data/README.md +3 -8
- 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 +13 -10
- metadata +27 -218
- 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
@@ -1,149 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe "Tagger" do
|
4
|
-
before(:each) do
|
5
|
-
@user = User.create
|
6
|
-
@taggable = TaggableModel.create(name: "Bob Jones")
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should have taggings" do
|
10
|
-
@user.tag(@taggable, with: "ruby,scheme", on: :tags)
|
11
|
-
expect(@user.owned_taggings.size).to eq(2)
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should have tags" do
|
15
|
-
@user.tag(@taggable, with: "ruby,scheme", on: :tags)
|
16
|
-
expect(@user.owned_tags.size).to eq(2)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should scope objects returned by tagged_with by owners" do
|
20
|
-
@taggable2 = TaggableModel.create(name: "Jim Jones")
|
21
|
-
@taggable3 = TaggableModel.create(name: "Jane Doe")
|
22
|
-
|
23
|
-
@user2 = User.new
|
24
|
-
@user.tag(@taggable, with: "ruby, scheme", on: :tags)
|
25
|
-
@user2.tag(@taggable2, with: "ruby, scheme", on: :tags)
|
26
|
-
@user2.tag(@taggable3, with: "ruby, scheme", on: :tags)
|
27
|
-
|
28
|
-
expect(TaggableModel.tagged_with(%w[ruby scheme], owned_by: @user).count).to eq(1)
|
29
|
-
expect(TaggableModel.tagged_with(%w[ruby scheme], owned_by: @user2).count).to eq(2)
|
30
|
-
end
|
31
|
-
|
32
|
-
it "only returns objects tagged by owned_by when any is true" do
|
33
|
-
@user2 = User.new
|
34
|
-
@taggable2 = TaggableModel.create(name: "Jim Jones")
|
35
|
-
@taggable3 = TaggableModel.create(name: "Jane Doe")
|
36
|
-
|
37
|
-
@user.tag(@taggable, with: "ruby", on: :tags)
|
38
|
-
@user.tag(@taggable2, with: "java", on: :tags)
|
39
|
-
@user2.tag(@taggable3, with: "ruby", on: :tags)
|
40
|
-
|
41
|
-
tags = TaggableModel.tagged_with(%w[ruby java], owned_by: @user, any: true)
|
42
|
-
expect(tags).to include(@taggable, @taggable2)
|
43
|
-
expect(tags.size).to eq(2)
|
44
|
-
end
|
45
|
-
|
46
|
-
it "only returns objects tagged by owned_by when exclude is true" do
|
47
|
-
@user2 = User.new
|
48
|
-
@taggable2 = TaggableModel.create(name: "Jim Jones")
|
49
|
-
@taggable3 = TaggableModel.create(name: "Jane Doe")
|
50
|
-
|
51
|
-
@user.tag(@taggable, with: "ruby", on: :tags)
|
52
|
-
@user.tag(@taggable2, with: "java", on: :tags)
|
53
|
-
@user2.tag(@taggable3, with: "java", on: :tags)
|
54
|
-
|
55
|
-
tags = TaggableModel.tagged_with(%w[ruby], owned_by: @user, exclude: true)
|
56
|
-
expect(tags).to eq([@taggable2])
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should not overlap tags from different taggers" do
|
60
|
-
@user2 = User.new
|
61
|
-
expect(-> {
|
62
|
-
@user.tag(@taggable, with: "ruby, scheme", on: :tags)
|
63
|
-
@user2.tag(@taggable, with: "java, python, lisp, ruby", on: :tags)
|
64
|
-
}).to change(MakeTaggable::Tagging, :count).by(6)
|
65
|
-
|
66
|
-
[@user, @user2, @taggable].each(&:reload)
|
67
|
-
|
68
|
-
expect(@user.owned_tags.map(&:name).sort).to eq(%w[ruby scheme].sort)
|
69
|
-
expect(@user2.owned_tags.map(&:name).sort).to eq(%w[java python lisp ruby].sort)
|
70
|
-
|
71
|
-
expect(@taggable.tags_from(@user).sort).to eq(%w[ruby scheme].sort)
|
72
|
-
expect(@taggable.tags_from(@user2).sort).to eq(%w[java lisp python ruby].sort)
|
73
|
-
|
74
|
-
expect(@taggable.all_tags_list.sort).to eq(%w[ruby scheme java python lisp].sort)
|
75
|
-
expect(@taggable.all_tags_on(:tags).size).to eq(5)
|
76
|
-
end
|
77
|
-
|
78
|
-
it "should not lose tags from different taggers" do
|
79
|
-
@user2 = User.create
|
80
|
-
@user2.tag(@taggable, with: "java, python, lisp, ruby", on: :tags)
|
81
|
-
@user.tag(@taggable, with: "ruby, scheme", on: :tags)
|
82
|
-
|
83
|
-
expect(-> {
|
84
|
-
@user2.tag(@taggable, with: "java, python, lisp", on: :tags)
|
85
|
-
}).to change(MakeTaggable::Tagging, :count).by(-1)
|
86
|
-
|
87
|
-
[@user, @user2, @taggable].each(&:reload)
|
88
|
-
|
89
|
-
expect(@taggable.tags_from(@user).sort).to eq(%w[ruby scheme].sort)
|
90
|
-
expect(@taggable.tags_from(@user2).sort).to eq(%w[java python lisp].sort)
|
91
|
-
|
92
|
-
expect(@taggable.all_tags_list.sort).to eq(%w[ruby scheme java python lisp].sort)
|
93
|
-
expect(@taggable.all_tags_on(:tags).length).to eq(5)
|
94
|
-
end
|
95
|
-
|
96
|
-
it "should not lose tags" do
|
97
|
-
@user2 = User.create
|
98
|
-
|
99
|
-
@user.tag(@taggable, with: "awesome", on: :tags)
|
100
|
-
@user2.tag(@taggable, with: "awesome, epic", on: :tags)
|
101
|
-
|
102
|
-
expect(-> {
|
103
|
-
@user2.tag(@taggable, with: "epic", on: :tags)
|
104
|
-
}).to change(MakeTaggable::Tagging, :count).by(-1)
|
105
|
-
|
106
|
-
@taggable.reload
|
107
|
-
expect(@taggable.all_tags_list).to include("awesome")
|
108
|
-
expect(@taggable.all_tags_list).to include("epic")
|
109
|
-
end
|
110
|
-
|
111
|
-
it "should not lose tags" do
|
112
|
-
@taggable.update(tag_list: "ruby")
|
113
|
-
@user.tag(@taggable, with: "ruby, scheme", on: :tags)
|
114
|
-
|
115
|
-
[@taggable, @user].each(&:reload)
|
116
|
-
expect(@taggable.tag_list).to eq(%w[ruby])
|
117
|
-
expect(@taggable.all_tags_list.sort).to eq(%w[ruby scheme].sort)
|
118
|
-
|
119
|
-
expect(-> {
|
120
|
-
@taggable.update(tag_list: "")
|
121
|
-
}).to change(MakeTaggable::Tagging, :count).by(-1)
|
122
|
-
|
123
|
-
expect(@taggable.tag_list).to be_empty
|
124
|
-
expect(@taggable.all_tags_list.sort).to eq(%w[ruby scheme].sort)
|
125
|
-
end
|
126
|
-
|
127
|
-
it "is tagger" do
|
128
|
-
expect(@user.is_tagger?).to be_truthy
|
129
|
-
end
|
130
|
-
|
131
|
-
it "should skip save if skip_save is passed as option" do
|
132
|
-
expect(-> {
|
133
|
-
@user.tag(@taggable, with: "epic", on: :tags, skip_save: true)
|
134
|
-
}).to_not change(MakeTaggable::Tagging, :count)
|
135
|
-
end
|
136
|
-
|
137
|
-
it "should change tags order in ordered taggable" do
|
138
|
-
@ordered_taggable = OrderedTaggableModel.create name: "hey!"
|
139
|
-
|
140
|
-
@user.tag @ordered_taggable, with: "tag, tag1", on: :tags
|
141
|
-
expect(@ordered_taggable.reload.tags_from(@user)).to eq(["tag", "tag1"])
|
142
|
-
|
143
|
-
@user.tag @ordered_taggable, with: "tag2, tag1", on: :tags
|
144
|
-
expect(@ordered_taggable.reload.tags_from(@user)).to eq(["tag2", "tag1"])
|
145
|
-
|
146
|
-
@user.tag @ordered_taggable, with: "tag1, tag2", on: :tags
|
147
|
-
expect(@ordered_taggable.reload.tags_from(@user)).to eq(["tag1", "tag2"])
|
148
|
-
end
|
149
|
-
end
|
@@ -1,115 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe MakeTaggable::Tagging do
|
4
|
-
before(:each) do
|
5
|
-
@tagging = MakeTaggable::Tagging.new
|
6
|
-
end
|
7
|
-
|
8
|
-
it "should not be valid with a invalid tag" do
|
9
|
-
@tagging.taggable = TaggableModel.create(name: "Bob Jones")
|
10
|
-
@tagging.tag = MakeTaggable::Tag.new(name: "")
|
11
|
-
@tagging.context = "tags"
|
12
|
-
|
13
|
-
expect(@tagging).to_not be_valid
|
14
|
-
|
15
|
-
expect(@tagging.errors[:tag_id]).to eq(["can't be blank"])
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should not create duplicate taggings" do
|
19
|
-
@taggable = TaggableModel.create(name: "Bob Jones")
|
20
|
-
@tag = MakeTaggable::Tag.create(name: "awesome")
|
21
|
-
|
22
|
-
expect(-> {
|
23
|
-
2.times { MakeTaggable::Tagging.create(taggable: @taggable, tag: @tag, context: "tags") }
|
24
|
-
}).to change(MakeTaggable::Tagging, :count).by(1)
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should not delete tags of other records" do
|
28
|
-
6.times { TaggableModel.create(name: "Bob Jones", tag_list: "very, serious, bug") }
|
29
|
-
expect(MakeTaggable::Tag.count).to eq(3)
|
30
|
-
taggable = TaggableModel.first
|
31
|
-
taggable.tag_list = "bug"
|
32
|
-
taggable.save
|
33
|
-
|
34
|
-
expect(taggable.tag_list).to eq(["bug"])
|
35
|
-
|
36
|
-
another_taggable = TaggableModel.where("id != ?", taggable.id).sample
|
37
|
-
expect(another_taggable.tag_list.sort).to eq(%w[very serious bug].sort)
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should destroy unused tags after tagging destroyed" do
|
41
|
-
previous_setting = MakeTaggable.remove_unused_tags
|
42
|
-
MakeTaggable.remove_unused_tags = true
|
43
|
-
MakeTaggable::Tag.destroy_all
|
44
|
-
@taggable = TaggableModel.create(name: "Bob Jones")
|
45
|
-
@taggable.update_attribute :tag_list, "aaa,bbb,ccc"
|
46
|
-
@taggable.update_attribute :tag_list, ""
|
47
|
-
expect(MakeTaggable::Tag.count).to eql(0)
|
48
|
-
MakeTaggable.remove_unused_tags = previous_setting
|
49
|
-
end
|
50
|
-
|
51
|
-
describe "context scopes" do
|
52
|
-
before do
|
53
|
-
@tagging_2 = MakeTaggable::Tagging.new
|
54
|
-
@tagging_3 = MakeTaggable::Tagging.new
|
55
|
-
|
56
|
-
@tagger = User.new
|
57
|
-
@tagger_2 = User.new
|
58
|
-
|
59
|
-
@tagging.taggable = TaggableModel.create(name: "Black holes")
|
60
|
-
@tagging.tag = MakeTaggable::Tag.create(name: "Physics")
|
61
|
-
@tagging.tagger = @tagger
|
62
|
-
@tagging.context = "Science"
|
63
|
-
@tagging.save
|
64
|
-
|
65
|
-
@tagging_2.taggable = TaggableModel.create(name: "Satellites")
|
66
|
-
@tagging_2.tag = MakeTaggable::Tag.create(name: "Technology")
|
67
|
-
@tagging_2.tagger = @tagger_2
|
68
|
-
@tagging_2.context = "Science"
|
69
|
-
@tagging_2.save
|
70
|
-
|
71
|
-
@tagging_3.taggable = TaggableModel.create(name: "Satellites")
|
72
|
-
@tagging_3.tag = MakeTaggable::Tag.create(name: "Engineering")
|
73
|
-
@tagging_3.tagger = @tagger_2
|
74
|
-
@tagging_3.context = "Astronomy"
|
75
|
-
@tagging_3.save
|
76
|
-
end
|
77
|
-
|
78
|
-
describe ".owned_by" do
|
79
|
-
it "should belong to a specific user" do
|
80
|
-
expect(MakeTaggable::Tagging.owned_by(@tagger).first).to eq(@tagging)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
describe ".by_context" do
|
85
|
-
it "should be found by context" do
|
86
|
-
expect(MakeTaggable::Tagging.by_context("Science").length).to eq(2)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
describe ".by_contexts" do
|
91
|
-
it "should find taggings by contexts" do
|
92
|
-
expect(MakeTaggable::Tagging.by_contexts(["Science", "Astronomy"]).first).to eq(@tagging)
|
93
|
-
expect(MakeTaggable::Tagging.by_contexts(["Science", "Astronomy"]).second).to eq(@tagging_2)
|
94
|
-
expect(MakeTaggable::Tagging.by_contexts(["Science", "Astronomy"]).third).to eq(@tagging_3)
|
95
|
-
expect(MakeTaggable::Tagging.by_contexts(["Science", "Astronomy"]).length).to eq(3)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
describe ".not_owned" do
|
100
|
-
before do
|
101
|
-
@tagging_4 = MakeTaggable::Tagging.new
|
102
|
-
@tagging_4.taggable = TaggableModel.create(name: "Gravity")
|
103
|
-
@tagging_4.tag = MakeTaggable::Tag.create(name: "Space")
|
104
|
-
@tagging_4.context = "Science"
|
105
|
-
@tagging_4.save
|
106
|
-
end
|
107
|
-
|
108
|
-
it "should found the taggings that do not have owner" do
|
109
|
-
expect(MakeTaggable::Tagging.all.length).to eq(4)
|
110
|
-
expect(MakeTaggable::Tagging.not_owned.length).to eq(1)
|
111
|
-
expect(MakeTaggable::Tagging.not_owned.first).to eq(@tagging_4)
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe MakeTaggable::TagsHelper do
|
4
|
-
before(:each) do
|
5
|
-
@bob = TaggableModel.create(name: "Bob Jones", language_list: "ruby, php")
|
6
|
-
@tom = TaggableModel.create(name: "Tom Marley", language_list: "ruby, java")
|
7
|
-
@eve = TaggableModel.create(name: "Eve Nodd", language_list: "ruby, c++")
|
8
|
-
|
9
|
-
@helper =
|
10
|
-
class Helper
|
11
|
-
include MakeTaggable::TagsHelper
|
12
|
-
end.new
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should yield the proper css classes" do
|
16
|
-
tags = {}
|
17
|
-
|
18
|
-
@helper.tag_cloud(TaggableModel.tag_counts_on(:languages), %w[sucky awesome]) do |tag, css_class|
|
19
|
-
tags[tag.name] = css_class
|
20
|
-
end
|
21
|
-
|
22
|
-
expect(tags["ruby"]).to eq("awesome")
|
23
|
-
expect(tags["java"]).to eq("sucky")
|
24
|
-
expect(tags["c++"]).to eq("sucky")
|
25
|
-
expect(tags["php"]).to eq("sucky")
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should handle tags with zero counts (build for empty)" do
|
29
|
-
MakeTaggable::Tag.create(name: "php")
|
30
|
-
MakeTaggable::Tag.create(name: "java")
|
31
|
-
MakeTaggable::Tag.create(name: "c++")
|
32
|
-
|
33
|
-
tags = {}
|
34
|
-
|
35
|
-
@helper.tag_cloud(MakeTaggable::Tag.all, %w[sucky awesome]) do |tag, css_class|
|
36
|
-
tags[tag.name] = css_class
|
37
|
-
end
|
38
|
-
|
39
|
-
expect(tags["java"]).to eq("sucky")
|
40
|
-
expect(tags["c++"]).to eq("sucky")
|
41
|
-
expect(tags["php"]).to eq("sucky")
|
42
|
-
end
|
43
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe MakeTaggable::Utils do
|
4
|
-
describe "#like_operator" do
|
5
|
-
it "should return 'ILIKE' when the adapter is PostgreSQL" do
|
6
|
-
allow(MakeTaggable::Utils.connection).to receive(:adapter_name) { "PostgreSQL" }
|
7
|
-
expect(MakeTaggable::Utils.like_operator).to eq("ILIKE")
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should return 'LIKE' when the adapter is not PostgreSQL" do
|
11
|
-
allow(MakeTaggable::Utils.connection).to receive(:adapter_name) { "MySQL" }
|
12
|
-
expect(MakeTaggable::Utils.like_operator).to eq("LIKE")
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe "#sha_prefix" do
|
17
|
-
it "should return a consistent prefix for a given word" do
|
18
|
-
expect(MakeTaggable::Utils.sha_prefix("kittens")).to eq(MakeTaggable::Utils.sha_prefix("kittens"))
|
19
|
-
expect(MakeTaggable::Utils.sha_prefix("puppies")).not_to eq(MakeTaggable::Utils.sha_prefix("kittens"))
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
data/spec/make_taggable_spec.rb
DELETED
data/spec/spec_helper.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# Configure Rails Environment
|
2
|
-
ENV["RAILS_ENV"] = "test"
|
3
|
-
|
4
|
-
require_relative "../spec/dummy/config/environment"
|
5
|
-
|
6
|
-
require "rspec/rails"
|
7
|
-
require "rails"
|
8
|
-
|
9
|
-
Dir["./spec/support/**/*.rb"].sort.each { |f| require f }
|
10
|
-
|
11
|
-
RSpec.configure do |config|
|
12
|
-
config.fixture_path = "spec/fixtures"
|
13
|
-
config.global_fixtures = :all
|
14
|
-
config.use_transactional_fixtures = true
|
15
|
-
config.infer_base_class_for_anonymous_controllers = true
|
16
|
-
end
|
data/spec/support/array.rb
DELETED
data/spec/support/helpers.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
def using_sqlite?
|
2
|
-
MakeTaggable::Utils.connection && MakeTaggable::Utils.connection.adapter_name == "SQLite"
|
3
|
-
end
|
4
|
-
|
5
|
-
def supports_concurrency?
|
6
|
-
!using_sqlite?
|
7
|
-
end
|
8
|
-
|
9
|
-
def using_postgresql?
|
10
|
-
MakeTaggable::Utils.using_postgresql?
|
11
|
-
end
|
12
|
-
|
13
|
-
def postgresql_version
|
14
|
-
if using_postgresql?
|
15
|
-
MakeTaggable::Utils.connection.execute("SHOW SERVER_VERSION").first["server_version"].to_f
|
16
|
-
else
|
17
|
-
0.0
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def postgresql_support_json?
|
22
|
-
postgresql_version >= 9.2
|
23
|
-
end
|
24
|
-
|
25
|
-
def using_mysql?
|
26
|
-
MakeTaggable::Utils.using_mysql?
|
27
|
-
end
|
28
|
-
|
29
|
-
def using_case_insensitive_collation?
|
30
|
-
using_mysql? && MakeTaggable::Utils.connection.collation =~ /_ci\Z/
|
31
|
-
end
|