From b8341f67ffdcbb4b06dd69e336d689bef0414a20 Mon Sep 17 00:00:00 2001 From: shino Date: Sun, 8 Jun 2025 11:09:56 +0900 Subject: [PATCH 01/16] =?UTF-8?q?chore:=20Rails7.1=E3=81=AB=E5=AF=BE?= =?UTF-8?q?=E5=BF=9C=E3=81=95=E3=81=9B=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- imyou.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imyou.gemspec b/imyou.gemspec index b683472..57ea266 100644 --- a/imyou.gemspec +++ b/imyou.gemspec @@ -25,7 +25,7 @@ Gem::Specification.new do |spec| spec.require_paths = ['lib'] spec.required_ruby_version = '>= 2.6' - spec.add_dependency 'activerecord', '< 7.1.0', '>= 5.0.0' + spec.add_dependency 'activerecord', '< 7.2.0', '>= 5.0.0' spec.add_development_dependency 'database_cleaner', '~> 2.0' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rubocop', '~> 1.24' From 9a416b603e675137a9a9fb500bae21ed642f8625 Mon Sep 17 00:00:00 2001 From: shino Date: Wed, 11 Jun 2025 13:52:58 +0900 Subject: [PATCH 02/16] =?UTF-8?q?chore:=20concurrent-ruby=20gem1.3.5?= =?UTF-8?q?=E3=81=A7=E3=81=AFLogger=E9=96=A2=E9=80=A3=E3=81=AE=E5=87=A6?= =?UTF-8?q?=E7=90=86=E3=81=AB=E5=A4=89=E6=9B=B4=E3=81=8C=E5=85=A5=E3=81=A3?= =?UTF-8?q?=E3=81=9F=E3=81=93=E3=81=A8=E3=81=A7=E3=82=A8=E3=83=A9=E3=83=BC?= =?UTF-8?q?=E3=81=AB=E3=81=AA=E3=81=A3=E3=81=9F=E3=81=AE=E3=81=A7=E3=80=81?= =?UTF-8?q?1.3.4=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- imyou.gemspec | 1 + 1 file changed, 1 insertion(+) diff --git a/imyou.gemspec b/imyou.gemspec index 57ea266..3243625 100644 --- a/imyou.gemspec +++ b/imyou.gemspec @@ -33,5 +33,6 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rubocop-performance', '~> 1.13' spec.add_development_dependency 'rubocop-rake', '~> 0.6' spec.add_development_dependency 'sqlite3', '~> 1.3' + spec.add_development_dependency 'concurrent-ruby', '1.3.4' spec.metadata['rubygems_mfa_required'] = 'true' end From b63e24f2efab946df973958f0c6e8438ae621755 Mon Sep 17 00:00:00 2001 From: shino Date: Wed, 11 Jun 2025 13:53:46 +0900 Subject: [PATCH 03/16] =?UTF-8?q?test:=20=E3=83=87=E3=83=BC=E3=82=BF?= =?UTF-8?q?=E3=83=99=E3=83=BC=E3=82=B9=E3=81=AE=E5=86=85=E5=AE=B9=E3=82=92?= =?UTF-8?q?=E3=82=AF=E3=83=AA=E3=82=A2=E3=81=99=E3=82=8B=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E3=81=8Ctransaction=E3=81=AE=E5=A0=B4=E5=90=88=E3=80=81SQLite3?= =?UTF-8?q?Adapter=E3=81=AB=E3=81=AFlock=E3=83=A1=E3=82=BD=E3=83=83?= =?UTF-8?q?=E3=83=89=E3=81=8C=E5=AD=98=E5=9C=A8=E3=81=97=E3=81=AA=E3=81=84?= =?UTF-8?q?=E3=81=A8=E3=81=84=E3=81=86=E3=82=A8=E3=83=A9=E3=83=BC=E3=81=AB?= =?UTF-8?q?=E3=81=AA=E3=82=8B=E3=81=9F=E3=82=81=E3=80=81truncation?= =?UTF-8?q?=E3=81=AE=E6=96=B9=E6=B3=95=E3=81=AB=E5=A4=89=E6=9B=B4=E3=81=97?= =?UTF-8?q?=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/test_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_helper.rb b/test/test_helper.rb index af4087b..2462757 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -34,7 +34,7 @@ create_table :no_name_users, force: true end -DatabaseCleaner.strategy = :transaction +DatabaseCleaner.strategy = :truncation module Minitest class Spec From db6c631145e83663f3412608baad44fd09698c65 Mon Sep 17 00:00:00 2001 From: shino Date: Wed, 11 Jun 2025 13:54:11 +0900 Subject: [PATCH 04/16] =?UTF-8?q?test:=20minitest=20gem5.19.0=E3=82=88?= =?UTF-8?q?=E3=82=8A=E3=80=8CMiniTest=E3=80=8D=E3=81=A8=E3=81=84=E3=81=86?= =?UTF-8?q?=E5=90=8D=E5=89=8D=E7=A9=BA=E9=96=93=E3=81=AF=E5=89=8A=E9=99=A4?= =?UTF-8?q?=E3=81=95=E3=82=8C=E3=81=9F=E3=81=9F=E3=82=81=E3=80=81=E3=80=8C?= =?UTF-8?q?Minitest=E3=80=8D=E3=81=AB=E5=A4=89=E6=9B=B4=E3=81=97=E3=81=9F?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/test_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_helper.rb b/test/test_helper.rb index 2462757..11cf487 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -49,7 +49,7 @@ class Spec end # @see https://stackoverflow.com/questions/20329387/how-to-assert-the-contents-of-an-array-indifferent-of-the-ordering -module MiniTest +module Minitest module Assertions def assert_matched_arrays(exp, act) exp_ary = exp.to_ary @@ -61,7 +61,7 @@ def assert_matched_arrays(exp, act) end end -module MiniTest +module Minitest module Expectations infect_an_assertion :assert_matched_arrays, :must_match_array end From 4981b13e90daf56e018e8b453b02f4bbb3dcc580 Mon Sep 17 00:00:00 2001 From: shino Date: Wed, 11 Jun 2025 13:55:23 +0900 Subject: [PATCH 05/16] =?UTF-8?q?ci:chore:=20Rails7.1=E3=81=AE=E3=83=86?= =?UTF-8?q?=E3=82=B9=E3=83=88=E8=BF=BD=E5=8A=A0=E3=80=81Ruby3.2,3.3,3.4?= =?UTF-8?q?=E3=81=AE=E3=83=86=E3=82=B9=E3=83=88=E3=83=91=E3=82=BF=E3=83=BC?= =?UTF-8?q?=E3=83=B3=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test.yml | 24 ++++++++++++++++++++++-- gemfiles/rails_7.1.gemfile | 8 ++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 gemfiles/rails_7.1.gemfile diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 09eda75..8028045 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,11 +11,13 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby: ['2.6', '2.7', '3.0', '3.1'] - gemfile: ['rails_5.0', 'rails_5.1', 'rails_5.2', 'rails_6.0', 'rails_6.1', 'rails_7.0'] + ruby: ['2.6', '2.7', '3.0', '3.1', '3.2', '3.3', '3.4'] + gemfile: ['rails_5.0', 'rails_5.1', 'rails_5.2', 'rails_6.0', 'rails_6.1', 'rails_7.0', 'rails_7.1'] exclude: - ruby: '2.6' gemfile: 'rails_7.0' + - ruby: '2.6' + gemfile: 'rails_7.1' - ruby: '3.0' gemfile: 'rails_5.0' - ruby: '3.0' @@ -28,6 +30,24 @@ jobs: gemfile: 'rails_5.1' - ruby: '3.1' gemfile: 'rails_5.2' + - ruby: '3.2' + gemfile: 'rails_5.0' + - ruby: '3.2' + gemfile: 'rails_5.1' + - ruby: '3.2' + gemfile: 'rails_5.2' + - ruby: '3.3' + gemfile: 'rails_5.0' + - ruby: '3.3' + gemfile: 'rails_5.1' + - ruby: '3.3' + gemfile: 'rails_5.2' + - ruby: '3.4' + gemfile: 'rails_5.0' + - ruby: '3.4' + gemfile: 'rails_5.1' + - ruby: '3.4' + gemfile: 'rails_5.2' env: BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile diff --git a/gemfiles/rails_7.1.gemfile b/gemfiles/rails_7.1.gemfile new file mode 100644 index 0000000..d00cf09 --- /dev/null +++ b/gemfiles/rails_7.1.gemfile @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +source 'https://rubygems.org' + +gem 'activerecord', '~> 7.1.0' +gem 'sqlite3', '~> 1.4' + +gemspec path: '../' From ed708df48e0c3797181bc3ecd32c8b9295f6dc6a Mon Sep 17 00:00:00 2001 From: shino Date: Wed, 11 Jun 2025 13:55:37 +0900 Subject: [PATCH 06/16] =?UTF-8?q?chore:=20Ruby3.4=E3=81=8B=E3=82=89bundled?= =?UTF-8?q?=20gem=E3=81=A7=E3=81=AF=E3=81=AA=E3=81=8F=E3=81=AA=E3=81=A3?= =?UTF-8?q?=E3=81=9Fgem=E3=82=92=E6=98=8E=E7=A4=BA=E7=9A=84=E3=81=AB?= =?UTF-8?q?=E6=8C=87=E5=AE=9A=E3=81=97=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- imyou.gemspec | 3 +++ 1 file changed, 3 insertions(+) diff --git a/imyou.gemspec b/imyou.gemspec index 3243625..0aced50 100644 --- a/imyou.gemspec +++ b/imyou.gemspec @@ -34,5 +34,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rubocop-rake', '~> 0.6' spec.add_development_dependency 'sqlite3', '~> 1.3' spec.add_development_dependency 'concurrent-ruby', '1.3.4' + spec.add_development_dependency 'mutex_m' + spec.add_development_dependency 'bigdecimal' + spec.add_development_dependency 'base64' spec.metadata['rubygems_mfa_required'] = 'true' end From 28254d19d9ec58252688c2b4efcb6f84a2b945f7 Mon Sep 17 00:00:00 2001 From: shino Date: Wed, 11 Jun 2025 13:57:05 +0900 Subject: [PATCH 07/16] =?UTF-8?q?test:chore:=20Ruby3.2,=20Rails6=E7=B3=BB?= =?UTF-8?q?=E3=81=A7scope=E3=81=A7=E3=82=AD=E3=83=BC=E3=83=AF=E3=83=BC?= =?UTF-8?q?=E3=83=89=E5=BC=95=E6=95=B0=E3=81=AF=E3=82=A8=E3=83=A9=E3=83=BC?= =?UTF-8?q?=E3=81=AB=E3=81=AA=E3=82=8B=E3=81=A8=E3=81=84=E3=81=86=E6=83=85?= =?UTF-8?q?=E5=A0=B1=E3=81=8C=E3=81=82=E3=82=8A=E3=80=81=E5=AE=9F=E9=9A=9B?= =?UTF-8?q?=E3=81=AB=E3=83=86=E3=82=B9=E3=83=88=E3=81=A7=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E3=81=AB=E3=81=AA=E3=81=A3=E3=81=9F=E3=81=9F=E3=82=81?= =?UTF-8?q?=E3=80=81=E3=83=8F=E3=83=83=E3=82=B7=E3=83=A5=E3=81=A7=E5=BC=95?= =?UTF-8?q?=E6=95=B0=E3=82=92=E5=8F=97=E3=81=91=E5=8F=96=E3=82=8B=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E3=81=AB=E5=A4=89=E6=9B=B4=E3=81=97=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/imyou/models.rb | 8 ++++++-- test/nickname_test.rb | 22 +++++++++++----------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/lib/imyou/models.rb b/lib/imyou/models.rb index 19d6d2d..9c3174b 100644 --- a/lib/imyou/models.rb +++ b/lib/imyou/models.rb @@ -18,7 +18,9 @@ def has_imyou(name_column = nil) scope :with_nicknames, -> { preload(:imyou_nicknames) } - scope :match_by_nickname, lambda { |nickname, with_name_column: true| + scope :match_by_nickname, lambda { |options = {}| + nickname = options[:nickname] + with_name_column = options.fetch(:with_name_column, true) if Gem::Version.new(ActiveRecord.version) >= Gem::Version.new(5) records = left_outer_joins(:imyou_nicknames).where(Imyou::Nickname.arel_table[:name].eq(nickname)) unless name_column.nil? || with_name_column == false @@ -49,7 +51,9 @@ def has_imyou(name_column = nil) records } - scope :partial_match_by_nickname, lambda { |nickname, with_name_column: true| + scope :partial_match_by_nickname, lambda { |options = {}| + nickname = options[:nickname] + with_name_column = options.fetch(:with_name_column, true) if Gem::Version.new(ActiveRecord.version) >= Gem::Version.new(5) records = left_outer_joins(:imyou_nicknames). where(Imyou::Nickname.arel_table[:name]. diff --git a/test/nickname_test.rb b/test/nickname_test.rb index 20d5ca8..8b3a0ec 100644 --- a/test/nickname_test.rb +++ b/test/nickname_test.rb @@ -51,38 +51,38 @@ describe '#match_by_nickname' do it 'should exists' do - expect(User.match_by_nickname('baz')).must_be :exists? - expect(User.match_by_nickname('az')).wont_be :exists? + expect(User.match_by_nickname(nickname: 'baz')).must_be :exists? + expect(User.match_by_nickname(nickname: 'az')).wont_be :exists? - expect(NoNameUser.match_by_nickname('baz')).must_be :exists? - expect(NoNameUser.match_by_nickname('az')).wont_be :exists? + expect(NoNameUser.match_by_nickname(nickname: 'baz')).must_be :exists? + expect(NoNameUser.match_by_nickname(nickname: 'az')).wont_be :exists? end it 'should search by users.name' do - expect(User.match_by_nickname('user_name')).must_be :exists? + expect(User.match_by_nickname(nickname: 'user_name')).must_be :exists? end describe 'If with_name_column = false' do it 'should not search by users.name' do - expect(User.match_by_nickname('user_name', with_name_column: false)).wont_be :exists? + expect(User.match_by_nickname(nickname: "user_name", with_name_column: false)).wont_be :exists? end end end describe '#partial_match_by_nickname' do it 'should exists' do - expect(User.partial_match_by_nickname('az')).must_be :exists? - expect(NoNameUser.partial_match_by_nickname('az')).must_be :exists? + expect(User.partial_match_by_nickname(nickname: 'az')).must_be :exists? + expect(NoNameUser.partial_match_by_nickname(nickname: 'az')).must_be :exists? end it 'should search by users.name' do - expect(User.partial_match_by_nickname('user')).must_be :exists? - expect(User.partial_match_by_nickname('er_na')).must_be :exists? + expect(User.partial_match_by_nickname(nickname: 'user')).must_be :exists? + expect(User.partial_match_by_nickname(nickname: 'er_na')).must_be :exists? end describe 'If with_name_column = false' do it 'should not search by users.name' do - expect(User.partial_match_by_nickname('user', with_name_column: false)).wont_be :exists? + expect(User.partial_match_by_nickname(nickname: 'user', with_name_column: false)).wont_be :exists? end end end From 9d3fea2c0629eb95c3df37f88f682cf36a04507f Mon Sep 17 00:00:00 2001 From: shino Date: Wed, 11 Jun 2025 22:46:54 +0900 Subject: [PATCH 08/16] =?UTF-8?q?chore:=20=E4=BE=9D=E5=AD=98=E9=96=A2?= =?UTF-8?q?=E4=BF=82=E3=81=AB=E5=AF=BE=E3=81=97=E3=81=A6warning=E3=81=8C?= =?UTF-8?q?=E5=87=BA=E3=82=8B=E3=81=AE=E3=81=A7=E5=AE=9A=E7=BE=A9=E3=81=97?= =?UTF-8?q?=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- imyou.gemspec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/imyou.gemspec b/imyou.gemspec index 0aced50..84372fc 100644 --- a/imyou.gemspec +++ b/imyou.gemspec @@ -34,8 +34,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rubocop-rake', '~> 0.6' spec.add_development_dependency 'sqlite3', '~> 1.3' spec.add_development_dependency 'concurrent-ruby', '1.3.4' - spec.add_development_dependency 'mutex_m' - spec.add_development_dependency 'bigdecimal' - spec.add_development_dependency 'base64' + spec.add_development_dependency 'mutex_m', '~> 0.1' + spec.add_development_dependency 'bigdecimal', '~> 3.0' + spec.add_development_dependency 'base64', '~> 0.1' spec.metadata['rubygems_mfa_required'] = 'true' end From 40decc6ba81d3e606f0e738d92b44a75cd9528ea Mon Sep 17 00:00:00 2001 From: shino Date: Wed, 11 Jun 2025 22:50:00 +0900 Subject: [PATCH 09/16] =?UTF-8?q?test:=20=E3=83=87=E3=83=BC=E3=82=BF?= =?UTF-8?q?=E3=83=99=E3=83=BC=E3=82=B9=E3=82=AF=E3=83=AA=E3=82=A2=E3=82=92?= =?UTF-8?q?=E3=80=8Crails=5F5.0.gemfile=E3=80=8D=E3=81=A7=E3=81=AF?= =?UTF-8?q?=E3=80=8Ctruncation=E3=80=8D=E3=81=AB=E3=81=97=E3=80=81?= =?UTF-8?q?=E3=81=9D=E3=82=8C=E4=BB=A5=E5=A4=96=E3=81=AF=E3=80=8Ctransacti?= =?UTF-8?q?on=E3=80=8D=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/test_helper.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/test_helper.rb b/test/test_helper.rb index 11cf487..922ec1f 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -34,7 +34,11 @@ create_table :no_name_users, force: true end -DatabaseCleaner.strategy = :truncation +if ENV['BUNDLE_GEMFILE'].include?("rails_5.0.gemfile") + DatabaseCleaner.strategy = :truncation +else + DatabaseCleaner.strategy = :transaction +end module Minitest class Spec From 7e1f43747ab5980ddc9807bb5fd4f55eefee42f0 Mon Sep 17 00:00:00 2001 From: shino Date: Wed, 11 Jun 2025 22:51:51 +0900 Subject: [PATCH 10/16] =?UTF-8?q?chore:=20Rails5.1=E3=81=A7=E3=81=AFtransa?= =?UTF-8?q?ction=E3=81=A7=E3=83=87=E3=83=BC=E3=82=BF=E3=83=99=E3=83=BC?= =?UTF-8?q?=E3=82=B9=E3=82=AF=E3=83=AA=E3=82=A2=E3=81=95=E3=81=9B=E3=82=8B?= =?UTF-8?q?=E3=81=9F=E3=82=81=E3=81=ABsqlite3=E3=82=921.4=E7=B3=BB?= =?UTF-8?q?=E3=81=AB=E5=9B=BA=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gemfiles/rails_5.1.gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gemfiles/rails_5.1.gemfile b/gemfiles/rails_5.1.gemfile index 1f35e25..0bbf01f 100644 --- a/gemfiles/rails_5.1.gemfile +++ b/gemfiles/rails_5.1.gemfile @@ -3,6 +3,6 @@ source 'https://rubygems.org' gem 'activerecord', '~> 5.1.0' -gem 'sqlite3', '~> 1.3.0' +gem 'sqlite3', '~> 1.4.0' gemspec path: '../' From 91cb72e22db0936bbf7edc700be359b813439151 Mon Sep 17 00:00:00 2001 From: shino Date: Thu, 12 Jun 2025 10:25:20 +0900 Subject: [PATCH 11/16] =?UTF-8?q?test:=20=E3=83=86=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=81=A7=E3=81=AE=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E3=81=AE?= =?UTF-8?q?=E5=BC=95=E6=95=B0=E3=82=92=E3=82=82=E3=81=A8=E3=81=AB=E6=88=BB?= =?UTF-8?q?=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/nickname_test.rb | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/test/nickname_test.rb b/test/nickname_test.rb index 8b3a0ec..029acbd 100644 --- a/test/nickname_test.rb +++ b/test/nickname_test.rb @@ -51,38 +51,38 @@ describe '#match_by_nickname' do it 'should exists' do - expect(User.match_by_nickname(nickname: 'baz')).must_be :exists? - expect(User.match_by_nickname(nickname: 'az')).wont_be :exists? + expect(User.match_by_nickname('baz')).must_be :exists? + expect(User.match_by_nickname('az')).wont_be :exists? - expect(NoNameUser.match_by_nickname(nickname: 'baz')).must_be :exists? - expect(NoNameUser.match_by_nickname(nickname: 'az')).wont_be :exists? + expect(NoNameUser.match_by_nickname('baz')).must_be :exists? + expect(NoNameUser.match_by_nickname('az')).wont_be :exists? end it 'should search by users.name' do - expect(User.match_by_nickname(nickname: 'user_name')).must_be :exists? + expect(User.match_by_nickname('user_name')).must_be :exists? end describe 'If with_name_column = false' do it 'should not search by users.name' do - expect(User.match_by_nickname(nickname: "user_name", with_name_column: false)).wont_be :exists? + expect(User.match_by_nickname("user_name", with_name_column: false)).wont_be :exists? end end end describe '#partial_match_by_nickname' do it 'should exists' do - expect(User.partial_match_by_nickname(nickname: 'az')).must_be :exists? - expect(NoNameUser.partial_match_by_nickname(nickname: 'az')).must_be :exists? + expect(User.partial_match_by_nickname('az')).must_be :exists? + expect(NoNameUser.partial_match_by_nickname('az')).must_be :exists? end it 'should search by users.name' do - expect(User.partial_match_by_nickname(nickname: 'user')).must_be :exists? - expect(User.partial_match_by_nickname(nickname: 'er_na')).must_be :exists? + expect(User.partial_match_by_nickname('user')).must_be :exists? + expect(User.partial_match_by_nickname('er_na')).must_be :exists? end describe 'If with_name_column = false' do it 'should not search by users.name' do - expect(User.partial_match_by_nickname(nickname: 'user', with_name_column: false)).wont_be :exists? + expect(User.partial_match_by_nickname('user', with_name_column: false)).wont_be :exists? end end end From 2f96431234c2f5f98786cdbb2e3838bbb78cc5bc Mon Sep 17 00:00:00 2001 From: shino Date: Thu, 12 Jun 2025 10:27:11 +0900 Subject: [PATCH 12/16] =?UTF-8?q?chore:=20define=5Fsingleton=5Fmethod?= =?UTF-8?q?=E3=81=A7=E5=AF=BE=E8=B1=A1=E3=82=AF=E3=83=A9=E3=82=B9=E3=81=AB?= =?UTF-8?q?=E3=82=AF=E3=83=A9=E3=82=B9=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89?= =?UTF-8?q?=E3=81=A8=E3=81=97=E3=81=A6=E5=AE=9A=E7=BE=A9=E3=81=97=E3=81=9F?= =?UTF-8?q?=E3=80=82=20=E3=83=BBklass=E3=81=AFhas=5Fimyou=E3=83=A1?= =?UTF-8?q?=E3=82=BD=E3=83=83=E3=83=89=E3=82=92=E5=91=BC=E3=81=B3=E5=87=BA?= =?UTF-8?q?=E3=81=97=E3=81=9F=E3=82=AF=E3=83=A9=E3=82=B9=E3=80=82=E5=88=86?= =?UTF-8?q?=E3=81=8B=E3=82=8A=E3=82=84=E3=81=99=E3=81=84=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E3=81=82=E3=81=88=E3=81=A6=E6=98=8E=E7=A4=BA=E7=9A=84?= =?UTF-8?q?=E3=81=AB=E3=81=97=E3=81=A6=E3=81=84=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/imyou/models.rb | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/imyou/models.rb b/lib/imyou/models.rb index 9c3174b..4a94e41 100644 --- a/lib/imyou/models.rb +++ b/lib/imyou/models.rb @@ -7,6 +7,7 @@ def has_imyou? end def has_imyou(name_column = nil) + klass = self class_eval do has_many :imyou_nicknames, lambda { order(id: :asc) @@ -18,9 +19,7 @@ def has_imyou(name_column = nil) scope :with_nicknames, -> { preload(:imyou_nicknames) } - scope :match_by_nickname, lambda { |options = {}| - nickname = options[:nickname] - with_name_column = options.fetch(:with_name_column, true) + klass.define_singleton_method(:match_by_nickname) do |nickname, with_name_column: true| if Gem::Version.new(ActiveRecord.version) >= Gem::Version.new(5) records = left_outer_joins(:imyou_nicknames).where(Imyou::Nickname.arel_table[:name].eq(nickname)) unless name_column.nil? || with_name_column == false @@ -49,11 +48,9 @@ def has_imyou(name_column = nil) end end records - } + end - scope :partial_match_by_nickname, lambda { |options = {}| - nickname = options[:nickname] - with_name_column = options.fetch(:with_name_column, true) + klass.define_singleton_method(:partial_match_by_nickname) do |nickname, with_name_column: true| if Gem::Version.new(ActiveRecord.version) >= Gem::Version.new(5) records = left_outer_joins(:imyou_nicknames). where(Imyou::Nickname.arel_table[:name]. @@ -86,7 +83,7 @@ def has_imyou(name_column = nil) end end records - } + end alias_method :save_with_nicknames, :save alias_method :save_with_nicknames!, :save! From 620052bc6418b24be1e36068a85a58ae69bed91c Mon Sep 17 00:00:00 2001 From: patorash Date: Thu, 12 Jun 2025 14:06:53 +0900 Subject: [PATCH 13/16] =?UTF-8?q?chore:=20database=5Fcleaner=E3=81=A8sqlit?= =?UTF-8?q?e3=E3=81=AE=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7=E3=83=B3?= =?UTF-8?q?=E3=81=8C=E5=90=88=E3=81=86=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gemfiles/rails_5.0.gemfile | 1 + gemfiles/rails_5.1.gemfile | 2 +- gemfiles/rails_7.1.gemfile | 4 ++-- imyou.gemspec | 4 ++-- test/test_helper.rb | 11 +++++------ 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/gemfiles/rails_5.0.gemfile b/gemfiles/rails_5.0.gemfile index 7fe582a..925b34b 100644 --- a/gemfiles/rails_5.0.gemfile +++ b/gemfiles/rails_5.0.gemfile @@ -4,5 +4,6 @@ source 'https://rubygems.org' gem 'activerecord', '~> 5.0.0' gem 'sqlite3', '~> 1.3.0' +gem 'database_cleaner', '~> 1.99' gemspec path: '../' diff --git a/gemfiles/rails_5.1.gemfile b/gemfiles/rails_5.1.gemfile index 0bbf01f..dc5db07 100644 --- a/gemfiles/rails_5.1.gemfile +++ b/gemfiles/rails_5.1.gemfile @@ -3,6 +3,6 @@ source 'https://rubygems.org' gem 'activerecord', '~> 5.1.0' -gem 'sqlite3', '~> 1.4.0' +gem 'sqlite3', '~> 1.4' gemspec path: '../' diff --git a/gemfiles/rails_7.1.gemfile b/gemfiles/rails_7.1.gemfile index d00cf09..3d98371 100644 --- a/gemfiles/rails_7.1.gemfile +++ b/gemfiles/rails_7.1.gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' -gem 'activerecord', '~> 7.1.0' -gem 'sqlite3', '~> 1.4' +gem 'activerecord', '~> 7.1.3' +gem 'sqlite3', '~> 2.0' gemspec path: '../' diff --git a/imyou.gemspec b/imyou.gemspec index 84372fc..6511509 100644 --- a/imyou.gemspec +++ b/imyou.gemspec @@ -26,13 +26,13 @@ Gem::Specification.new do |spec| spec.required_ruby_version = '>= 2.6' spec.add_dependency 'activerecord', '< 7.2.0', '>= 5.0.0' - spec.add_development_dependency 'database_cleaner', '~> 2.0' + spec.add_development_dependency 'database_cleaner', '< 3.0', '>= 1.99.0' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rubocop', '~> 1.24' spec.add_development_dependency 'rubocop-minitest', '~> 0.17' spec.add_development_dependency 'rubocop-performance', '~> 1.13' spec.add_development_dependency 'rubocop-rake', '~> 0.6' - spec.add_development_dependency 'sqlite3', '~> 1.3' + spec.add_development_dependency 'sqlite3', '< 3.0', '>= 1.3' spec.add_development_dependency 'concurrent-ruby', '1.3.4' spec.add_development_dependency 'mutex_m', '~> 0.1' spec.add_development_dependency 'bigdecimal', '~> 3.0' diff --git a/test/test_helper.rb b/test/test_helper.rb index 922ec1f..cede272 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -3,7 +3,8 @@ require 'minitest/autorun' require 'active_record' -require 'database_cleaner/active_record' +# database_cleaner 1~2系のどちらでも動くようにするため、パスを修正 +require 'database_cleaner' require 'imyou' Dir["#{Dir.pwd}/test/internal/app/models/*.rb"].sort.each { |f| require f } @@ -34,11 +35,7 @@ create_table :no_name_users, force: true end -if ENV['BUNDLE_GEMFILE'].include?("rails_5.0.gemfile") - DatabaseCleaner.strategy = :truncation -else - DatabaseCleaner.strategy = :transaction -end +DatabaseCleaner.strategy = :transaction module Minitest class Spec @@ -57,8 +54,10 @@ module Minitest module Assertions def assert_matched_arrays(exp, act) exp_ary = exp.to_ary + assert_kind_of Array, exp_ary act_ary = act.to_ary + assert_kind_of Array, act_ary assert_equal exp_ary.sort, act_ary.sort end From 314096c0a71d0f997012f2e66e1c14f3a4574227 Mon Sep 17 00:00:00 2001 From: patorash Date: Thu, 12 Jun 2025 14:39:33 +0900 Subject: [PATCH 14/16] =?UTF-8?q?chore:=20Ruby=E3=81=AE=E3=83=90=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E3=83=A7=E3=83=B3=E3=81=AB=E3=82=88=E3=81=A3=E3=81=A6?= =?UTF-8?q?sqlite3=E3=81=AE=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7=E3=83=B3?= =?UTF-8?q?=E3=82=92=E5=88=87=E3=82=8A=E6=9B=BF=E3=81=88=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gemfiles/rails_7.1.gemfile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gemfiles/rails_7.1.gemfile b/gemfiles/rails_7.1.gemfile index 3d98371..7f6612a 100644 --- a/gemfiles/rails_7.1.gemfile +++ b/gemfiles/rails_7.1.gemfile @@ -3,6 +3,11 @@ source 'https://rubygems.org' gem 'activerecord', '~> 7.1.3' -gem 'sqlite3', '~> 2.0' + +if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0') + gem 'sqlite3', '~> 2.0' +else + gem 'sqlite3', '~> 1.4' +end gemspec path: '../' From 2ce3fa0e6b980671bd2052348844387ee7dbcbab Mon Sep 17 00:00:00 2001 From: patorash Date: Thu, 12 Jun 2025 15:46:35 +0900 Subject: [PATCH 15/16] =?UTF-8?q?refactor:=20class=5Feval=E3=81=97?= =?UTF-8?q?=E3=81=A6=E3=81=84=E3=82=8B=E3=81=AE=E3=81=A7=E3=80=81=E3=81=9D?= =?UTF-8?q?=E3=81=AE=E3=81=BE=E3=81=BEdefine=5Fsingleton=5Fmethod=E3=81=8C?= =?UTF-8?q?=E4=BD=BF=E3=81=88=E3=82=8B=E3=80=82scope=E3=82=92=E4=BD=BF?= =?UTF-8?q?=E3=82=8F=E3=81=9A=E3=81=AB=E4=BF=AE=E6=AD=A3=E3=81=97=E3=81=9F?= =?UTF-8?q?=E7=90=86=E7=94=B1=E3=81=AB=E3=81=A4=E3=81=84=E3=81=A6=E3=82=B3?= =?UTF-8?q?=E3=83=A1=E3=83=B3=E3=83=88=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/imyou/models.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/imyou/models.rb b/lib/imyou/models.rb index 4a94e41..e3197d0 100644 --- a/lib/imyou/models.rb +++ b/lib/imyou/models.rb @@ -7,7 +7,6 @@ def has_imyou? end def has_imyou(name_column = nil) - klass = self class_eval do has_many :imyou_nicknames, lambda { order(id: :asc) @@ -19,7 +18,11 @@ def has_imyou(name_column = nil) scope :with_nicknames, -> { preload(:imyou_nicknames) } - klass.define_singleton_method(:match_by_nickname) do |nickname, with_name_column: true| + # 本来はscopeで定義するべきだが、Ruby 3.2以降とActiveRecord 6.1系ではエラーになるため、 + # 苦肉の策で特異メソッドとして定義する。 + # Rails 6.1のサポートを終了したら、scopeに戻すこと。 + # @see https://qiita.com/usk0513/items/c2968733415c806f56fc + define_singleton_method(:match_by_nickname) do |nickname, with_name_column: true| if Gem::Version.new(ActiveRecord.version) >= Gem::Version.new(5) records = left_outer_joins(:imyou_nicknames).where(Imyou::Nickname.arel_table[:name].eq(nickname)) unless name_column.nil? || with_name_column == false @@ -50,7 +53,7 @@ def has_imyou(name_column = nil) records end - klass.define_singleton_method(:partial_match_by_nickname) do |nickname, with_name_column: true| + define_singleton_method(:partial_match_by_nickname) do |nickname, with_name_column: true| if Gem::Version.new(ActiveRecord.version) >= Gem::Version.new(5) records = left_outer_joins(:imyou_nicknames). where(Imyou::Nickname.arel_table[:name]. From 2fa631bf9cffc7d2ed4240565251cb47deadbd98 Mon Sep 17 00:00:00 2001 From: shino Date: Thu, 19 Jun 2025 09:51:32 +0900 Subject: [PATCH 16/16] =?UTF-8?q?chore:=20=E3=83=90=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E3=83=A7=E3=83=B3=E3=82=921.4.4=E3=81=AB=E3=81=97=E3=81=9F?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/imyou/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/imyou/version.rb b/lib/imyou/version.rb index 091e888..c9dd834 100644 --- a/lib/imyou/version.rb +++ b/lib/imyou/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Imyou - VERSION = '1.4.3' + VERSION = '1.4.4' end