From 0bad7a8c3ac521f2c332ddc5b2d6b1d459e1d428 Mon Sep 17 00:00:00 2001 From: Denys Metelov Date: Mon, 9 May 2022 18:50:26 +0300 Subject: [PATCH 1/3] Fix npm package downloads counter badge in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c2610c8..f41ffb9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![Gem Version](https://badge.fury.io/rb/active_admin_datetimepicker.svg)](http://badge.fury.io/rb/active_admin_datetimepicker) [![NPM Version](https://badge.fury.io/js/@activeadmin-plugins%2Factive_admin_datetimepicker.svg)](https://badge.fury.io/js/@activeadmin-plugins%2Factive_admin_datetimepicker) -[![npm](https://img.shields.io/npm/dm/active_admin_datetimepicker.svg)](https://www.npmjs.com/package/@activeadmin-plugins/active_admin_datetimepicker) +![npm](https://img.shields.io/npm/dm/@activeadmin-plugins/active_admin_datetimepicker) [![Build Status](https://img.shields.io/travis/activeadmin-plugins/active_admin_datetimepicker.svg)](https://travis-ci.org/activeadmin-plugins/active_admin_datetimepicker) [![Coverage](https://coveralls.io/repos/activeadmin-plugins/active_admin_datetimepicker/badge.svg?branch=master)](https://coveralls.io/r/activeadmin-plugins/active_admin_datetimepicker) From a5fccff96f2febdc6154942bfd33f63daed59dea Mon Sep 17 00:00:00 2001 From: Igor Gonchar Date: Tue, 26 Dec 2023 22:27:00 +0200 Subject: [PATCH 2/3] update ruby/rails/activeadmin matrix (#84) * update ruby/rails/activeadmin matrix --------- Co-authored-by: Gena --- .github/workflows/ci.yml | 29 +++++++----- Gemfile | 9 ++-- active_admin_datetimepicker.gemspec | 2 +- spec/filter_form_spec.rb | 18 ++++---- spec/spec_helper.rb | 2 +- spec/support/admin.rb | 7 +-- spec/support/rails_template.rb | 68 +++++++++++++++++++++++------ 7 files changed, 93 insertions(+), 42 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 809eb11..d79b49c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,25 +11,30 @@ jobs: strategy: matrix: ruby: - - 2.5 - - 2.6 + - '3.0.0' + - '3.1.0' + - '3.2.0' + - '3.3.0' rails: - - '5.2.0' - - '6.0.0' + - '6.1.0' + - '7.0.0' + - '7.1.0' activeadmin: - - '2.0.0' - - '2.6.0' + - '2.14.0' + - '3.0.0' + - '3.1.0' + - '3.2.0' exclude: - - rails: '5.2.0' - activeadmin: '2.6.0' - - rails: '6.0.0' - activeadmin: '2.0.0' + - rails: '7.1.0' + activeadmin: '2.14.0' + - rails: '7.1.0' + activeadmin: '3.0.0' env: RAILS: ${{ matrix.rails }} AA: ${{ matrix.activeadmin }} steps: - - uses: actions/checkout@v2 - - uses: actions/setup-ruby@v1 + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} - name: Run tests diff --git a/Gemfile b/Gemfile index 0607cf3..f27e674 100644 --- a/Gemfile +++ b/Gemfile @@ -4,15 +4,15 @@ source 'https://rubygems.org' gemspec group :test do - default_rails_version = '6.0.0' - default_activeadmin_version = '2.6.0' + default_rails_version = '7.1.0' + default_activeadmin_version = '3.1.0' gem 'rails', "~> #{ENV['RAILS'] || default_rails_version}" gem 'activeadmin', "~> #{ENV['AA'] || default_activeadmin_version}" - gem 'sprockets-rails', '3.0.4' + gem 'sprockets-rails' gem 'rspec-rails' - gem 'coveralls', require: false # Test coverage website. Go to https://coveralls.io + gem 'coveralls_reborn', require: false gem 'sass-rails' gem 'sqlite3', '~> 1.4.0' gem 'launchy' @@ -20,4 +20,5 @@ group :test do gem 'capybara' gem 'webdrivers' gem 'byebug' + gem 'webrick', require: false end diff --git a/active_admin_datetimepicker.gemspec b/active_admin_datetimepicker.gemspec index bf8311c..98646ce 100644 --- a/active_admin_datetimepicker.gemspec +++ b/active_admin_datetimepicker.gemspec @@ -19,5 +19,5 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.add_dependency "activeadmin", ">= 2.0", "< 3.a" + spec.add_dependency "activeadmin", ">= 2.14.0", "< 4.0" end diff --git a/spec/filter_form_spec.rb b/spec/filter_form_spec.rb index 131605f..409cd5b 100644 --- a/spec/filter_form_spec.rb +++ b/spec/filter_form_spec.rb @@ -49,11 +49,11 @@ before do Author.create!(name: "Ren", last_name: "from-20-day-of-month", - created_at: (Time.now.change(day: 20) - 1.hour).to_s(:db)) + created_at: (Time.now.change(day: 20) - 1.hour).to_formatted_s(:db)) Author.create!(name: "Rey", last_name: "from-the-future", - created_at: (Time.now.change(day: 20) + 2.hours).to_s(:db)) + created_at: (Time.now.change(day: 20) + 2.hours).to_formatted_s(:db)) # chose 01 and 20 day of the current month @@ -94,10 +94,11 @@ end context 'filter by virtual attribute last_seen_at - without column&type properties (search by updated_at)' do - let!(:first_author) { Author.create!(name: 'Ren', last_name: 'current', updated_at: Time.now.to_s(:db)) } - let!(:second_author) { Author.create!(name: 'Rey', last_name: 'future', updated_at: 21.days.from_now.to_s(:db)) } - before do + Author.create!(name: 'Ren', last_name: 'One', updated_at: (Time.now.change(day: 1) + 1.hour).to_formatted_s(:db)) + Author.create!(name: 'Ron', last_name: 'Two', updated_at: (Time.now.change(day: 20) - 1.hour).to_formatted_s(:db)) + Author.create!(name: 'Rey', last_name: 'future', updated_at: Time.now.change(day: 21).to_formatted_s(:db)) + # chose 01 and 20 day of the current month page.find('input#q_last_seen_at_gteq_datetime_picker').click page.find('.xdsoft_datetimepicker', visible: true) @@ -118,9 +119,10 @@ page.has_css?('h4', text: 'Current filters:') end - it 'should filter records properly' do - expect(page).to have_text(first_author.name) - expect(page).not_to have_text(second_author.name) + it 'finds the first and second authors, but not the third one, because he is outside of the filtered dates' do + expect(page).to have_text('Ren') + expect(page).to have_text('Ron') + expect(page).not_to have_text('Rey') end it 'input#value and placeholder is the same as before form submit' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c523fb4..5418252 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -14,7 +14,7 @@ ENV['RAILS'] = Rails.version ENV['RAILS_ROOT'] = File.expand_path("../rails/rails-#{ENV['RAILS']}", __FILE__) # Create the test app if it doesn't exists -unless File.exists?(ENV['RAILS_ROOT']) +unless File.exist?(ENV['RAILS_ROOT']) system 'rake setup' end diff --git a/spec/support/admin.rb b/spec/support/admin.rb index 45da288..131fce8 100644 --- a/spec/support/admin.rb +++ b/spec/support/admin.rb @@ -1,6 +1,7 @@ def add_author_resource(options = {}, &block) - ActiveAdmin.register Author do + permit_params :name, :birthday + config.filters = true filter :birthday, as: :date_time_range @@ -8,7 +9,7 @@ def add_author_resource(options = {}, &block) filter :last_seen_at, as: :date_time_range form do |f| - f.semantic_errors *f.object.errors.keys + f.semantic_errors f.inputs 'General' do f.input :name @@ -18,6 +19,6 @@ def add_author_resource(options = {}, &block) f.actions end end - Rails.application.reload_routes! + Rails.application.reload_routes! end diff --git a/spec/support/rails_template.rb b/spec/support/rails_template.rb index 2c72a49..b1d3ef9 100644 --- a/spec/support/rails_template.rb +++ b/spec/support/rails_template.rb @@ -3,17 +3,59 @@ generate :model, 'author name:string{10}:uniq last_name:string birthday:date' generate :model, 'post title:string:uniq body:text author:references' -#Add validation -inject_into_file "app/models/author.rb", " validates_presence_of :name\n validates_uniqueness_of :last_name\n\n attr_accessor :last_seen_at\n ransacker :last_seen_at do\n Arel.sql('updated_at')\n end\n", after: "ApplicationRecord\n" -inject_into_file "app/models/post.rb", " validates_presence_of :author\n", after: ":author\n" +# Compatibility with old ransack +inject_into_file "app/models/application_record.rb", after: "primary_abstract_class\n" do + <<-STRING + + def self.ransackable_attributes(auth_object=nil) + if respond_to?(:authorizable_ransackable_attributes) + authorizable_ransackable_attributes + else + super + end + end + + def self.ransackable_associations(auth_object=nil) + if respond_to?(:authorizable_ransackable_associations) + authorizable_ransackable_associations + else + super + end + end + STRING +end + +# Virtual attributes +inject_into_file "app/models/author.rb", after: "ApplicationRecord\n" do + <<-STRING + validates_presence_of :name + validates_uniqueness_of :last_name + + def self.ransackable_attributes(auth_object=nil) + if respond_to?(:authorizable_ransackable_attributes) + authorizable_ransackable_attributes + else + %w(birthday created_at last_seen_at updated_at) + end + end + + attr_accessor :last_seen_at + + ransacker :last_seen_at do + Arel.sql('updated_at') + end + STRING +end # Configure default_url_options in test environment -inject_into_file "config/environments/test.rb", " config.action_mailer.default_url_options = { :host => 'example.com' }\n", after: "config.cache_classes = true\n" +inject_into_file "config/environments/test.rb", after: "config.cache_classes = true\n" do + " config.action_mailer.default_url_options = { :host => 'example.com' }\n" +end # Add our local Active Admin to the load path -inject_into_file "config/environment.rb", - "\n$LOAD_PATH.unshift('#{File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib'))}')\nrequire \"active_admin\"\n", - after: "require File.expand_path('../application', __FILE__)" +inject_into_file "config/environment.rb", after: "require File.expand_path('../application', __FILE__)" do + "\n$LOAD_PATH.unshift('#{File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib'))}')\nrequire \"active_admin\"\n" +end run "rm Gemfile" @@ -23,13 +65,13 @@ generate :'formtastic:install' # Install active_admin_date_time_datetimepicker assets -inject_into_file "app/assets/stylesheets/active_admin.scss", - "@import \"active_admin_datetimepicker\";\n", - after: "@import \"active_admin/base\";\n" +inject_into_file "app/assets/stylesheets/active_admin.scss" do + "@import \"active_admin_datetimepicker\";\n" +end -inject_into_file "app/assets/javascripts/active_admin.js", - "//= require active_admin_datetimepicker\n", - after: "//= require active_admin/base\n" +inject_into_file "app/assets/javascripts/active_admin.js" do + "//= require active_admin_datetimepicker\n" +end run "rm -r test" run "rm -r spec" From d318dfb6946143c32f717812dfe3b85e74a063ab Mon Sep 17 00:00:00 2001 From: Igor Gonchar Date: Tue, 26 Dec 2023 22:31:33 +0200 Subject: [PATCH 3/3] bump v1.1.0 (#86) --- lib/active_admin_datetimepicker/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/active_admin_datetimepicker/version.rb b/lib/active_admin_datetimepicker/version.rb index e17679c..b93fa0b 100644 --- a/lib/active_admin_datetimepicker/version.rb +++ b/lib/active_admin_datetimepicker/version.rb @@ -1,3 +1,3 @@ module ActiveAdminDatetimepicker - VERSION = "1.0.0" + VERSION = "1.1.0" end