make_taggable 0.6.6 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/mysql_tests.yml +56 -0
  3. data/.github/workflows/pg_tests.yml +56 -0
  4. data/.github/workflows/{ci.yml → sqlite_tests.yml} +10 -10
  5. data/.github/workflows/standardrb-check.yml +37 -0
  6. data/.gitignore +3 -0
  7. data/Appraisals +4 -0
  8. data/README.md +47 -27
  9. data/Rakefile +1 -0
  10. data/lib/make_taggable.rb +3 -3
  11. data/lib/make_taggable/version.rb +1 -2
  12. data/lib/tasks/setup_test_db.rake +6 -0
  13. data/make_taggable.gemspec +10 -8
  14. data/spec/dummy/README.md +0 -24
  15. data/spec/dummy/app/models/cached_model_with_array.rb +0 -6
  16. data/spec/dummy/app/models/taggable_model_with_json.rb +6 -0
  17. data/spec/dummy/config/application.rb +2 -8
  18. data/spec/dummy/config/database.yml +1 -19
  19. data/spec/dummy/config/mysql_database.yml.ci +8 -0
  20. data/spec/dummy/config/pg_database.yml.ci +8 -0
  21. data/spec/dummy/db/migrate/{20201119220853_create_taggable_models.rb → 020201119220853_create_taggable_models.rb} +0 -0
  22. data/spec/dummy/db/migrate/{20201119221037_create_columns_override_models.rb → 020201119221037_create_columns_override_models.rb} +0 -0
  23. data/spec/dummy/db/migrate/{20201119221121_create_non_standard_id_taggable_models.rb → 020201119221121_create_non_standard_id_taggable_models.rb} +0 -0
  24. data/spec/dummy/db/migrate/{20201119221228_create_untaggable_models.rb → 020201119221228_create_untaggable_models.rb} +0 -0
  25. data/spec/dummy/db/migrate/{20201119221247_create_cached_models.rb → 020201119221247_create_cached_models.rb} +0 -0
  26. data/spec/dummy/db/migrate/{20201119221314_create_other_cached_models.rb → 020201119221314_create_other_cached_models.rb} +0 -0
  27. data/spec/dummy/db/migrate/{20201119221343_create_companies.rb → 020201119221343_create_companies.rb} +0 -0
  28. data/spec/dummy/db/migrate/{20201119221416_create_users.rb → 020201119221416_create_users.rb} +0 -0
  29. data/spec/dummy/db/migrate/{20201119221434_create_other_taggable_models.rb → 020201119221434_create_other_taggable_models.rb} +0 -0
  30. data/spec/dummy/db/migrate/{20201119221507_create_ordered_taggable_models.rb → 020201119221507_create_ordered_taggable_models.rb} +0 -0
  31. data/spec/dummy/db/migrate/{20201119221530_create_cache_methods_injected_models.rb → 020201119221530_create_cache_methods_injected_models.rb} +0 -0
  32. data/spec/dummy/db/migrate/{20201119221629_create_other_cached_with_array_models.rb → 020201119221629_create_other_cached_with_array_models.rb} +0 -0
  33. data/spec/dummy/db/migrate/{20201119221746_create_taggable_model_with_jsons.rb → 020201119221746_create_taggable_model_with_jsons.rb} +0 -0
  34. data/spec/make_taggable/tag_spec.rb +88 -250
  35. data/spec/make_taggable/taggable_spec.rb +1 -1
  36. data/spec/spec_helper.rb +0 -2
  37. metadata +77 -59
  38. data/.travis.yml +0 -36
  39. data/gemfiles/rails_5.gemfile +0 -9
  40. data/gemfiles/rails_6.gemfile +0 -9
  41. data/gemfiles/rails_master.gemfile +0 -9
  42. data/spec/dummy/db/migrate/20201121222007_create_make_taggable_tags.make_taggable_engine.rb +0 -11
  43. data/spec/dummy/db/migrate/20201121222008_create_make_taggable_taggings.make_taggable_engine.rb +0 -13
  44. data/spec/dummy/db/migrate/20201121222009_change_tag_name_collation_mysql.make_taggable_engine.rb +0 -8
  45. data/spec/dummy/db/migrate/20201121222010_add_index_to_tags.make_taggable_engine.rb +0 -6
  46. data/spec/dummy/db/migrate/20201121222011_add_index_to_taggings.make_taggable_engine.rb +0 -13
  47. data/spec/dummy/db/schema.rb +0 -117
  48. data/spec/dummy/db/seeds.rb +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 492754c144e670799533ba98bf6870d05451845d02ee347b0cca8ee8c4f7bc36
4
- data.tar.gz: 2641b641d09c7a99ef706f6b446d568ddc1d9de24d9a7d1c9f007dafb5079288
3
+ metadata.gz: 511214c161094fadf92adb61f5735dc86af08370b92d492634170494fc5d4d8a
4
+ data.tar.gz: c20794c8e81c9eba4163763b86aaf1545022947d7a863f99bd3f14c8a2b6d0df
5
5
  SHA512:
6
- metadata.gz: 24385c88d803dd0b4d222b998b14f6b7f9e4f2f7e84b59dd7eacf0a3ba0739e35eacda6c9ef4238b27da342c12dc75ce42f714f1ed701f3f2a70d28d4ea0d7ed
7
- data.tar.gz: bf6030ccd267d19db82a6b08072ded0740f6e9674faa05cb974053289438bcc144f7da6ac97ff875fc5be8f6f585d289739ae2a80f63250fefec7eb5f658b826
6
+ metadata.gz: 0e10cad86c423641043013316807a1cf62eedb55be1521425bfd3d7cb235c76bf89bf832e07f520982263578c5a095ecf36f8817a5d1847df71b06f1185a98e7
7
+ data.tar.gz: 0d58d6f106d4031dcded133e0716577649f51c975d75675a8dc357833946d282fff3776932fe4626714fc2c92c29d213c0dd5eb361f524efef9f6a45c020b9b6
@@ -0,0 +1,56 @@
1
+ ---
2
+ name: MySQL Tests
3
+
4
+ on:
5
+ pull_request:
6
+ branches:
7
+ - '*'
8
+ push:
9
+ branches:
10
+ - master
11
+ jobs:
12
+ mysql:
13
+ runs-on: ubuntu-latest
14
+ strategy:
15
+ matrix:
16
+ ruby: ['2.5', '2.6', '2.7']
17
+
18
+ services:
19
+ mysql:
20
+ image: mysql:8
21
+ env:
22
+ MYSQL_ROOT_PASSWORD: password
23
+ MSQL_DATABASE: my_sql_test_db
24
+ ports: ['3306:3306']
25
+ options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
26
+
27
+ steps:
28
+ - uses: actions/checkout@master
29
+
30
+ - name: Set up Ruby ${{ matrix.ruby }}
31
+ uses: ruby/setup-ruby@v1
32
+ with:
33
+ ruby-version: ${{ matrix.ruby }}
34
+
35
+ - name: Cache gems
36
+ uses: actions/cache@v2
37
+ with:
38
+ path: vendor/bundle
39
+ key: ${{ runner.os }}-${{ matrix.ruby }}-gem-${{ hashFiles('**/Gemfile.lock') }}
40
+ restore-keys: |
41
+ ${{ runner.os }}-${{ matrix.ruby }}-gem-
42
+
43
+ - name: Install dependencies
44
+ run: |
45
+ gem install bundler
46
+ bundle install --jobs 4 --retry 3
47
+ bundle exec appraisal install
48
+
49
+ - name: Run tests
50
+ env:
51
+ DATABASE_URL: mysql2://root:password@127.0.0.1:3306/my_sql_test_db
52
+ RAILS_ENV: test
53
+ run: |
54
+ cp spec/dummy/config/mysql_database.yml.ci spec/dummy/config/database.yml
55
+ bundle exec rake test_app
56
+ bundle exec appraisal rake
@@ -0,0 +1,56 @@
1
+ ---
2
+ name: Postgres Tests
3
+
4
+ on:
5
+ pull_request:
6
+ branches:
7
+ - '*'
8
+ push:
9
+ branches:
10
+ - master
11
+ jobs:
12
+ postgres:
13
+ runs-on: ubuntu-latest
14
+ strategy:
15
+ matrix:
16
+ ruby: ['2.5', '2.6', '2.7']
17
+
18
+ services:
19
+ postgres:
20
+ image: postgres:12
21
+ env:
22
+ POSTGRES_USER: postgres
23
+ POSTGRES_PASSWORD: password
24
+ POSTGRES_DB: pg_test
25
+ ports: ['5432:5432']
26
+
27
+ steps:
28
+ - uses: actions/checkout@master
29
+
30
+ - name: Set up Ruby ${{ matrix.ruby }}
31
+ uses: ruby/setup-ruby@v1
32
+ with:
33
+ ruby-version: ${{ matrix.ruby }}
34
+
35
+ - name: Cache gems
36
+ uses: actions/cache@v2
37
+ with:
38
+ path: vendor/bundle
39
+ key: ${{ runner.os }}-${{ matrix.ruby }}-gem-${{ hashFiles('**/Gemfile.lock') }}
40
+ restore-keys: |
41
+ ${{ runner.os }}-${{ matrix.ruby }}-gem-
42
+
43
+ - name: Install dependencies
44
+ run: |
45
+ gem install bundler
46
+ bundle install --jobs 4 --retry 3
47
+ bundle exec appraisal install
48
+
49
+ - name: Run tests
50
+ env:
51
+ DATABASE_URL: postgres://postgres:password@localhost:5432/pg_test
52
+ RAILS_ENV: test
53
+ run: |
54
+ cp spec/dummy/config/pg_database.yml.ci spec/dummy/config/database.yml
55
+ bundle exec rake test_app
56
+ bundle exec appraisal rake
@@ -1,4 +1,5 @@
1
- name: Tests
1
+ ---
2
+ name: SQLite Tests
2
3
 
3
4
  on:
4
5
  pull_request:
@@ -8,26 +9,27 @@ on:
8
9
  branches:
9
10
  - master
10
11
  jobs:
11
- test:
12
+ sqlite:
12
13
  runs-on: ubuntu-latest
13
14
  strategy:
14
15
  matrix:
15
- ruby: [ '2.7', '2.6', '2.5' ]
16
+ ruby: ['2.5', '2.6', '2.7']
16
17
  steps:
17
18
  - uses: actions/checkout@master
18
19
 
19
- - name: Set up Ruby
20
+ - name: Set up Ruby ${{ matrix.ruby }}
20
21
  uses: ruby/setup-ruby@v1
21
22
  with:
22
23
  ruby-version: ${{ matrix.ruby }}
23
24
 
24
25
  - name: Cache gems
25
- uses: actions/cache@v1
26
+ uses: actions/cache@v2
26
27
  with:
27
28
  path: vendor/bundle
28
- key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
29
+ key: ${{ runner.os }}-${{ matrix.ruby }}-gem-${{ hashFiles('**/Gemfile.lock') }}
29
30
  restore-keys: |
30
- ${{ runner.os }}-gem-
31
+ ${{ runner.os }}-${{ matrix.ruby }}-gem-
32
+
31
33
  - name: Install dependencies
32
34
  run: |
33
35
  sudo apt-get update
@@ -37,11 +39,9 @@ jobs:
37
39
  bundle install --jobs 4 --retry 3
38
40
  bundle exec appraisal install
39
41
 
40
- - name: StandardRb check
41
- run: bundle exec standardrb
42
-
43
42
  - name: Run tests
44
43
  env:
45
44
  RAILS_ENV: test
46
45
  run: |
46
+ bundle exec rake test_app
47
47
  bundle exec appraisal rake
@@ -0,0 +1,37 @@
1
+ name: Standard Rb
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - '*'
7
+ push:
8
+ branches:
9
+ - master
10
+
11
+ jobs:
12
+ standard:
13
+ name: StandardRB Check Action
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@master
17
+
18
+ - name: Set up Ruby 2.7
19
+ uses: actions/setup-ruby@v1
20
+ with:
21
+ ruby-version: 2.7.x
22
+
23
+ - uses: actions/cache@v1
24
+ with:
25
+ path: vendor/bundle
26
+ key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
27
+ restore-keys: |
28
+ ${{ runner.os }}-gems-
29
+
30
+ - name: Bundle install
31
+ run: |
32
+ gem install bundler
33
+ bundle config path vendor/bundle
34
+ bundle install --jobs 4 --retry 3
35
+
36
+ - name: Run StandardRB
37
+ run: bundle exec standardrb --format progress
data/.gitignore CHANGED
@@ -11,3 +11,6 @@ tmp
11
11
  *.lock
12
12
  *.iml
13
13
  /.idea
14
+ spec/dummy/db/schema.rb
15
+ spec/dummy/db/migrate/[!0]*
16
+ /gemfiles/*
data/Appraisals CHANGED
@@ -6,6 +6,10 @@ appraise "rails-6" do
6
6
  gem "rails", "~> 6.0.0"
7
7
  end
8
8
 
9
+ appraise "rails-6-1" do
10
+ gem "rails", "~> 6.1.0"
11
+ end
12
+
9
13
  appraise "rails-master" do
10
14
  gem "rails", github: "rails/rails"
11
15
  end
data/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # MakeTaggable
2
2
  [![Gem Version](https://badge.fury.io/rb/make_taggable.svg)](https://badge.fury.io/rb/make_taggable)
3
- [![Build Status](https://travis-ci.com/MatthewKennedy/make_taggable.svg?branch=master)](https://travis-ci.com/MatthewKennedy/make_taggable)
4
- [![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard)
3
+ ![Postgres Tests](https://github.com/MatthewKennedy/make_taggable/workflows/Postgres%20Tests/badge.svg)
4
+ ![MySQL Tests](https://github.com/MatthewKennedy/make_taggable/workflows/MySQL%20Tests/badge.svg)
5
+ ![SQLite Tests](https://github.com/MatthewKennedy/make_taggable/workflows/SQLite%20Tests/badge.svg)
6
+ ![Standard Rb](https://github.com/MatthewKennedy/make_taggable/workflows/Standard%20Rb/badge.svg)
5
7
 
6
- MakeTaggable is a fork of acts-as-taggable-on v6.5 with code updates and a new set of migrations. All credit goes to those who contributed before acts-as-taggable-on became MakeTaggable: Michael Bleigh & Joost Baaij.
8
+ MakeTaggable is a fork of Acts-As-Taggable-On with code updates, fresh migrations that work on MySQL, and tested against a dummy Rails app.
7
9
 
8
- Why fork acts-as-taggable-on? Act As Taggable On appears stuck with a set of legacy migrations from rails pre [4.2] that added and removed indexes so much that the migrations do not run on a fresh install using MySQL.
9
-
10
- For the PostgreSQL users, this is not an issue, but if you have an app or gem that used acts-as-taggable-on, you can no longer test against MySQL, so it seems a fresh start would be useful to clear out any legacy issues and move forward.
10
+ All credit goes to those who contributed to Acts-As-Taggable-On: Michael Bleigh & Joost Baaij.
11
11
 
12
12
  ## Installation
13
13
 
@@ -22,23 +22,22 @@ bundle add make_taggable
22
22
  Install migrations
23
23
 
24
24
  ```shell
25
- # For the latest versions :
26
25
  rails make_taggable_engine:install:migrations
27
26
  ```
28
27
 
29
- Review the generated migrations then migrate :
28
+ Review the generated migrations then migrate:
30
29
  ```shell
31
30
  rails db:migrate
32
31
  ```
33
32
 
34
33
  #### For MySql users
35
- You can circumvent at any time the problem of special characters [issue 623](https://github.com/mbleigh/acts-as-taggable-on/issues/623) by setting in an initializer file:
34
+ To make MySQL play nice with spÉcial characters you can setting the following line in an initializer file:
36
35
 
37
36
  ```ruby
38
37
  MakeTaggable.force_binary_collation = true
39
38
  ```
40
39
 
41
- Or by running this rake task:
40
+ Or by run this rake task:
42
41
 
43
42
  ```shell
44
43
  rails make_taggable_engine:tag_names:collate_bin
@@ -46,6 +45,7 @@ rails make_taggable_engine:tag_names:collate_bin
46
45
 
47
46
  See the Configuration section for more details.
48
47
 
48
+
49
49
  ## Usage
50
50
 
51
51
  Setup
@@ -176,7 +176,7 @@ MakeTaggable::Tag.least_used(10)
176
176
 
177
177
  ### Finding Tagged Objects
178
178
 
179
- Make Taggable uses scopes to create an association for tags.
179
+ MakeTaggable uses scopes to create an association for tags.
180
180
  This way you can mix and match to filter down your results.
181
181
 
182
182
  ```ruby
@@ -405,6 +405,7 @@ CSS:
405
405
  .css4 { font-size: 1.6em; }
406
406
  ```
407
407
 
408
+
408
409
  ## Configuration
409
410
 
410
411
  If you would like to remove unused tag objects after removing taggings, add:
@@ -453,35 +454,54 @@ MakeTaggable.delimiter = ','
453
454
  *NOTE 1: SQLite by default can't upcase or downcase multibyte characters, resulting in unwanted behavior. Load the SQLite ICU extension for proper handle of such characters. [See docs](http://www.sqlite.org/src/artifact?ci=trunk&filename=ext/icu/README.txt)*
454
455
 
455
456
 
456
- #### Upgrading
457
+ ## Upgrading
457
458
 
458
- see [UPGRADING](UPGRADING.md)
459
+ Install new migrations by running:
459
460
 
460
- ## Contributors
461
-
462
- We have a long list of valued contributors. [Check them all](https://github.com/mbleigh/acts-as-taggable-on/contributors)
461
+ ```shell
462
+ rails make_taggable_engine:install:migrations
463
+ ```
463
464
 
464
465
  ## Compatibility
465
466
 
466
- Versions 0.6.x is compatible with Ruby 2.5 + and Rails 6.
467
-
467
+ Version 0.7.x is compatible with Ruby 2.5 > and Rails 5.2 >
468
468
 
469
- ## TODO
470
- - Review migrations indexes they seem excessive looking at the schema.
471
- - See if the newer version of ActiveRecord or arel can be used instead of the MySQL workarounds.
472
469
 
473
470
  ## Testing
474
471
 
475
- Make Taggable uses RSpec for its test coverage. Inside the gem
476
- directory, you can run the specs with:
472
+ MakeTaggable uses RSpec for its test coverage. Inside the gem directory, you can run the specs by following the steps below:
473
+
474
+ Install the rquired gems:
475
+
476
+ ```shell
477
+ bundle install
478
+ ```
479
+
480
+ Setup the dummy test app:
477
481
 
478
482
  ```shell
479
- bundle
480
- rake spec
483
+ bundle exec rake test_app
481
484
  ```
482
485
 
483
- You can run all the tests across all the Rails versions by running `rake appraise`. If you'd also like to [run the tests across all rubies and databases as configured for Travis CI, install and run `wwtd`](https://github.com/grosser/wwtd).
486
+ Run the spec tests against SQLite use the followiong command.
487
+
488
+ ```shell
489
+ bundle exec rake
490
+ ```
491
+
492
+ You can also run all the tests across all the Rails versions by running:
493
+
494
+ ```shell
495
+ bundle exec appraisal install
496
+
497
+ bundle exec appraisal rake
498
+ ```
499
+
500
+
501
+ ## Contributors
502
+
503
+ List of valued contributors From Acts-As-Taggable-On: [Check them all](https://github.com/mbleigh/acts-as-taggable-on/contributors)
484
504
 
485
505
 
486
506
  ## License
487
- MIT
507
+ This gem is available as open source under the terms of the [MIT License](https://github.com/MatthewKennedy/make_taggable/blob/master/LICENSE.txt).
data/Rakefile CHANGED
@@ -8,3 +8,4 @@ require "rspec/core/rake_task"
8
8
  RSpec::Core::RakeTask.new(:spec)
9
9
  task default: :spec
10
10
 
11
+ load "lib/tasks/setup_test_db.rake"
@@ -111,10 +111,10 @@ module MakeTaggable
111
111
 
112
112
  def self.apply_binary_collation(bincoll)
113
113
  if Utils.using_mysql?
114
- coll = "utf8_general_ci"
115
- coll = "utf8_bin" if bincoll
114
+ coll = "utf8mb4_general_ci"
115
+ coll = "utf8mb4_bin" if bincoll
116
116
  begin
117
- ActiveRecord::Migration.execute("ALTER TABLE #{Tag.table_name} MODIFY name varchar(255) CHARACTER SET utf8 COLLATE #{coll};")
117
+ ActiveRecord::Migration.execute("ALTER TABLE #{Tag.table_name} MODIFY name varchar(255) CHARACTER SET utf8mb4 COLLATE #{coll};")
118
118
  rescue => e
119
119
  puts "Trapping #{e.class}: collation parameter ignored while migrating for the first time."
120
120
  end
@@ -1,4 +1,3 @@
1
- # Acts As Taggable With Updates
2
1
  module MakeTaggable
3
- VERSION = "0.6.6"
2
+ VERSION = "0.7.0"
4
3
  end
@@ -0,0 +1,6 @@
1
+ require "fileutils"
2
+
3
+ desc "Set up the test app for"
4
+ task :test_app do
5
+ exec "cd spec/dummy && rake make_taggable_engine:install:migrations && rake db:create RAILS_ENV=test && rake db:migrate RAILS_ENV=test"
6
+ end
@@ -6,25 +6,27 @@ Gem::Specification.new do |spec|
6
6
  spec.name = "make_taggable"
7
7
  spec.version = MakeTaggable::VERSION
8
8
  spec.authors = ["Matthew Kennedy", "Michael Bleigh", "Joost Baaij"]
9
- spec.email = %w[m.kennedy@me.com michael@intridea.com joost@spacebabies.nl]
10
- spec.description = "A fork of acts-as-taggable-on v6.5 with code updates and a new set of migrations."
9
+ spec.email = %w[m.kennedy@me.com]
10
+ spec.description = "MakeTaggable is a fork of Acts-As-Taggable-On with code updates & fresh migrations"
11
11
  spec.summary = "Advanced Tagging For Rails"
12
12
  spec.homepage = "https://github.com/MatthewKennedy/make_taggable"
13
13
  spec.license = "MIT"
14
14
 
15
- if File.exist?('UPGRADING.md')
16
- spec.post_install_message = File.read('UPGRADING.md')
15
+ if File.exist?("UPGRADING.md")
16
+ spec.post_install_message = File.read("UPGRADING.md")
17
17
  end
18
18
 
19
19
  spec.files = `git ls-files`.split($/)
20
20
  spec.test_files = spec.files.grep(%r{^spec/})
21
21
  spec.require_paths = ["lib"]
22
22
 
23
- spec.add_dependency "rails", ">= 5.2"
23
+ spec.add_dependency "rails"
24
24
 
25
- spec.add_development_dependency "rspec", ">=3.0"
25
+ spec.add_development_dependency "appraisal"
26
+ spec.add_development_dependency "mysql2"
27
+ spec.add_development_dependency "pg"
28
+ spec.add_development_dependency "rspec"
26
29
  spec.add_development_dependency "rspec-rails"
27
- spec.add_development_dependency "sqlite3"
28
30
  spec.add_development_dependency "standard"
29
- spec.add_development_dependency "appraisal"
31
+ spec.add_development_dependency "sqlite3"
30
32
  end