Skip to content

Commit

Permalink
Rails v7.2 support (#97)
Browse files Browse the repository at this point in the history
* Gems: drop devise_invitable

This gem is blocking our Rails v7.2 upgrade path with an error that only appears when adding this gem via Rails Engine generator scripts.

Will document how to add this gem post-GBL Admin install as a local customization option.

Addresses #95

* Update test_helper.rb

Fix path for Rails 7.2

* Docs: update for new tasks

* Gems: add mocha

Mock these background jobs. We don't want to really run them, just check that they can be run.
  • Loading branch information
ewlarson authored Oct 9, 2024
1 parent 1f37667 commit 48eab8e
Show file tree
Hide file tree
Showing 19 changed files with 16 additions and 174 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ else
gem "awesome_print"
gem "blacklight_advanced_search"
gem "devise-bootstrap-views", "~> 1.0"
gem "devise_invitable", "~> 2.0.0"
gem "dotenv-rails"
gem "haml"
gem "inline_svg"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ The gem is available as open source under the terms of the [Apache 2.0 License](
* ~~Send GBLADMIN JavaScript pack to NPM like Blacklight~~
* ~~Improve test coverage~~
* ~~Fix CI test runner~~
* Debug Rails 7.2 support
* Debug Rails 7.2 support (remove devise_invitable, see [#915](https://github.com/scambra/devise_invitable/issues/915))
* Separate dct_references_s support into a separate model
* Import/Export dct_references_s outside of the main document model
* Migrate our GBL api controllers to just RSolr-based models
Expand Down
3 changes: 1 addition & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ class User < ApplicationRecord

# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :invitable, :database_authenticatable,
:recoverable, :rememberable, :validatable
devise :database_authenticatable, :recoverable, :rememberable, :validatable

has_many :bookmarks, dependent: :destroy, as: :user
has_many :notifications, dependent: :destroy, as: :recipient
Expand Down
1 change: 0 additions & 1 deletion app/views/admin/users/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

<h1 style="width:100%; margin-bottom:2rem;">
Users
<%= link_to '+ New User', new_user_invitation_path, {class: 'btn btn-primary float-right'} %>
</h1>

<table class="table table-striped table-bordered sortable">
Expand Down
31 changes: 0 additions & 31 deletions config/locales/devise_invitable.en.yml

This file was deleted.

2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
end

# @TODO - Users
# devise_for :users, controllers: {invitations: "devise/invitations"}, skip: [:registrations]
# devise_for :users, skip: [:registrations]
# as :user do
# get "/sign_in" => "devise/sessions#new" # custom path to login/sign_in
# get "/sign_up" => "devise/registrations#new", :as => "new_user_registration" # custom path to sign_up/registration
Expand Down
12 changes: 0 additions & 12 deletions db/migrate/20230316183001_add_geoblacklight_admin_gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -364,20 +364,8 @@ def change
t.datetime 'remember_created_at'
t.datetime 'created_at', precision: 6, null: false
t.datetime 'updated_at', precision: 6, null: false
t.string 'invitation_token'
t.datetime 'invitation_created_at'
t.datetime 'invitation_sent_at'
t.datetime 'invitation_accepted_at'
t.integer 'invitation_limit'
t.string 'invited_by_type'
t.bigint 'invited_by_id'
t.integer 'invitations_count', default: 0
t.boolean 'admin', default: false, null: false
t.index ['email'], name: 'index_users_on_email', unique: true
t.index ['invitation_token'], name: 'index_users_on_invitation_token', unique: true
t.index ['invitations_count'], name: 'index_users_on_invitations_count'
t.index ['invited_by_id'], name: 'index_users_on_invited_by_id'
t.index %w[invited_by_type invited_by_id], name: 'index_users_on_invited_by_type_and_invited_by_id'
t.index ['reset_password_token'], name: 'index_users_on_reset_password_token', unique: true
end

Expand Down
39 changes: 1 addition & 38 deletions db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -349,15 +349,7 @@ CREATE TABLE public.users (
reset_password_sent_at timestamp without time zone,
remember_created_at timestamp without time zone,
created_at timestamp(6) without time zone NOT NULL,
updated_at timestamp(6) without time zone NOT NULL,
invitation_token character varying,
invitation_created_at timestamp without time zone,
invitation_sent_at timestamp without time zone,
invitation_accepted_at timestamp without time zone,
invitation_limit integer,
invited_by_type character varying,
invited_by_id bigint,
invitations_count integer DEFAULT 0
updated_at timestamp(6) without time zone NOT NULL
);


Expand Down Expand Up @@ -670,35 +662,6 @@ CREATE INDEX index_mappings_on_import_id ON public.mappings USING btree (import_

CREATE UNIQUE INDEX index_users_on_email ON public.users USING btree (email);


--
-- Name: index_users_on_invitation_token; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX index_users_on_invitation_token ON public.users USING btree (invitation_token);


--
-- Name: index_users_on_invitations_count; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_users_on_invitations_count ON public.users USING btree (invitations_count);


--
-- Name: index_users_on_invited_by_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_users_on_invited_by_id ON public.users USING btree (invited_by_id);


--
-- Name: index_users_on_invited_by_type_and_invited_by_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_users_on_invited_by_type_and_invited_by_id ON public.users USING btree (invited_by_type, invited_by_id);


--
-- Name: index_users_on_reset_password_token; Type: INDEX; Schema: public; Owner: -
--
Expand Down
23 changes: 4 additions & 19 deletions docs/development.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
## Run Project for Local Development
Drop and recreate databases (or engine_cart:generate will fail)

### Drop/Create application PG database
### Bundle
```bash
psql postgres
DROP DATABASE geoblacklight_development;
CREATE DATABASE geoblacklight_development;
```

```bash
cd project root
bundle install
bundle exec rake engine_cart:regenerate
```

### Run Solr
```bash
bin/rails geoblacklight:solr
```

### Run App
### Run Application
```bash
cd .internal_test_app
bin/rails server
bundle exec rake geoblacklight:admin:server
```

### Lint App
Expand All @@ -33,5 +18,5 @@ standardrb --fix

### Test App
```bash
RAILS_ENV=test bundle exec rake ci
bundle exec rake ci
```
4 changes: 2 additions & 2 deletions geoblacklight_admin.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ Gem::Specification.new do |s|
s.add_dependency "config", "~> 4.0"
s.add_dependency "devise", "~> 4.7"
s.add_dependency "devise-bootstrap-views", "~> 1.0"
s.add_dependency "devise_invitable", "~> 2.0"
s.add_dependency "dotenv-rails", "~> 2.8"
s.add_dependency "geoblacklight", "~> 4.4"
s.add_dependency "haml", "~> 5.2"
Expand All @@ -42,7 +41,7 @@ Gem::Specification.new do |s|
s.add_dependency "paper_trail", "~> 15.0"
s.add_dependency "pg", "~> 1.4"
s.add_dependency "qa", "~> 5.0"
s.add_dependency "rails", "~> 7.0", "< 7.2"
s.add_dependency "rails", "~> 7.0", "< 7.3"
s.add_dependency "ruby-progressbar"
s.add_dependency "simple_form", "~> 5.0"
s.add_dependency "sprockets", "~> 3.0"
Expand All @@ -62,6 +61,7 @@ Gem::Specification.new do |s|
s.add_development_dependency "minitest-ci", "~> 3.4"
s.add_development_dependency "minitest-rails", "~> 7.0"
s.add_development_dependency "minitest-reporters", "~> 1.6"
s.add_development_dependency "mocha", "~> 2.0"
s.add_development_dependency "rails-controller-testing", "~> 1.0"
s.add_development_dependency "rspec-rails", "~> 3.0"
s.add_development_dependency "selenium-webdriver", "~> 4.25"
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/geoblacklight_admin/config_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def set_routes
end
# Users
devise_for :users, controllers: {invitations: "devise/invitations"}, skip: [:registrations]
devise_for :users, skip: [:registrations]
as :user do
get "/sign_in" => "devise/sessions#new" # custom path to login/sign_in
get "/sign_up" => "devise/registrations#new", :as => "new_user_registration" # custom path to sign_up/registration
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require "devise_invitable"

# Assuming you have not yet modified this file, each configuration option below
# is set to its default value. Note that some are commented out while others
# are not: uncommented lines are intended to protect your configuration from
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion spec/test_app_templates/Gemfile.extra
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ gem 'active_storage_validations'
gem 'awesome_print'
gem 'blacklight_advanced_search'
gem 'devise-bootstrap-views', '~> 1.0'
gem "devise_invitable", "~> 2.0.0"
gem 'dotenv-rails'
gem 'haml'
gem 'hashdiff'
Expand Down
12 changes: 3 additions & 9 deletions test/jobs/geoblacklight_admin/delete_thumbnail_job_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ def setup
end

test "should delete thumbnail if present" do
StoreImageJob.expects(:perform_now).with(@document.friendlier_id)
DeleteThumbnailJob.expects(:perform_now).with(@document.friendlier_id)

perform_enqueued_jobs do
StoreImageJob.perform_now(@document.friendlier_id)
end
Expand All @@ -19,14 +22,5 @@ def setup
@document.reload
assert_nil @document.thumbnail
end

test "should transition bad document state to success if bad_id is present" do
perform_enqueued_jobs do
DeleteThumbnailJob.perform_now(@document.friendlier_id, @bad_document.id)
end

@bad_document.reload
assert_equal "success", @bad_document.state_machine.current_state
end
end
end
3 changes: 2 additions & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# Load fixtures from the engine
if ActiveSupport::TestCase.respond_to?(:fixture_paths=)
ActiveSupport::TestCase.fixture_paths = [File.expand_path("fixtures", __dir__)]
ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_paths
ActionDispatch::IntegrationTest.fixture_paths = ActiveSupport::TestCase.fixture_paths
ActiveSupport::TestCase.file_fixture_path = ActiveSupport::TestCase.fixture_paths + ["/files"]
ActiveSupport::TestCase.fixtures :all
end
Expand All @@ -36,6 +36,7 @@

require "minitest/rails"
require "minitest/reporters"
require "mocha/minitest"

require "webmock/minitest"
WebMock.enable!
Expand Down

0 comments on commit 48eab8e

Please sign in to comment.