зеркало из
https://github.com/rs-pro/activeadmin-quill_editor.git
synced 2026-09-07 20:15:51 +03:00
Merge pull request #59 from blocknotes/build/improve-dev-setup
Improve dev and test setup
Этот коммит содержится в:
23
.github/workflows/linters.yml
поставляемый
23
.github/workflows/linters.yml
поставляемый
@@ -2,38 +2,35 @@
|
|||||||
name: Linters
|
name: Linters
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
pull_request:
|
pull_request:
|
||||||
|
branches: [main]
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
reviewdog:
|
reviewdog:
|
||||||
name: reviewdog
|
name: Reviewdog
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
ruby: ['3.0']
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
RUBY_VERSION: ${{ matrix.ruby }}
|
RAILS_VERSION: 7.0
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check out code
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up Ruby
|
- name: Set up Ruby
|
||||||
uses: ruby/setup-ruby@v1
|
uses: ruby/setup-ruby@v1
|
||||||
with:
|
with:
|
||||||
ruby-version: ${{ matrix.ruby }}
|
ruby-version: 3.0
|
||||||
bundler-cache: true
|
bundler-cache: true
|
||||||
|
|
||||||
- uses: reviewdog/action-setup@v1
|
- name: Set up Reviewdog
|
||||||
|
uses: reviewdog/action-setup@v1
|
||||||
with:
|
with:
|
||||||
reviewdog_version: latest
|
reviewdog_version: latest
|
||||||
|
|
||||||
- name: Run reviewdog
|
- name: Run Reviewdog
|
||||||
env:
|
env:
|
||||||
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
20
.github/workflows/specs_rails61.yml
поставляемый
20
.github/workflows/specs_rails61.yml
поставляемый
@@ -1,24 +1,23 @@
|
|||||||
---
|
---
|
||||||
name: Specs Rails 6.1
|
name: Specs Rails 6.1 with ActiveAdmin 2.9
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches: [main]
|
||||||
- main
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
tests:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
ruby: ['3.0', '3.1']
|
ruby: ['3.0']
|
||||||
|
|
||||||
env:
|
env:
|
||||||
RAILS_VERSION: 6.1.0
|
RAILS_VERSION: 6.0
|
||||||
|
ACTIVEADMIN_VERSION: 2.9.0
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
@@ -30,6 +29,9 @@ jobs:
|
|||||||
ruby-version: ${{ matrix.ruby }}
|
ruby-version: ${{ matrix.ruby }}
|
||||||
bundler-cache: true
|
bundler-cache: true
|
||||||
|
|
||||||
|
- name: Database setup
|
||||||
|
run: bin/rails db:create db:migrate db:test:prepare
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: bundle exec rspec --profile
|
run: bundle exec rspec --profile
|
||||||
|
|
||||||
|
|||||||
17
.github/workflows/specs_rails70.yml
поставляемый
17
.github/workflows/specs_rails70.yml
поставляемый
@@ -2,23 +2,21 @@
|
|||||||
name: Specs Rails 7.0
|
name: Specs Rails 7.0
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches: [main]
|
||||||
- main
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
tests:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
ruby: ['3.1']
|
ruby: ['3.0', '3.2']
|
||||||
|
|
||||||
env:
|
env:
|
||||||
RAILS_VERSION: 7.0.0
|
RAILS_VERSION: 7.0
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
@@ -30,6 +28,9 @@ jobs:
|
|||||||
ruby-version: ${{ matrix.ruby }}
|
ruby-version: ${{ matrix.ruby }}
|
||||||
bundler-cache: true
|
bundler-cache: true
|
||||||
|
|
||||||
|
- name: Database setup
|
||||||
|
run: bin/rails db:create db:migrate db:test:prepare
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: bundle exec rspec --profile
|
run: bundle exec rspec --profile
|
||||||
|
|
||||||
|
|||||||
17
.github/workflows/specs_rails71.yml
поставляемый
17
.github/workflows/specs_rails71.yml
поставляемый
@@ -2,23 +2,21 @@
|
|||||||
name: Specs Rails 7.1
|
name: Specs Rails 7.1
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches: [main]
|
||||||
- main
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
tests:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
ruby: ['3.2']
|
ruby: ['3.2', '3.4']
|
||||||
|
|
||||||
env:
|
env:
|
||||||
RAILS_VERSION: 7.1.0
|
RAILS_VERSION: 7.1
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
@@ -30,6 +28,9 @@ jobs:
|
|||||||
ruby-version: ${{ matrix.ruby }}
|
ruby-version: ${{ matrix.ruby }}
|
||||||
bundler-cache: true
|
bundler-cache: true
|
||||||
|
|
||||||
|
- name: Database setup
|
||||||
|
run: bin/rails db:create db:migrate db:test:prepare
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: bundle exec rspec --profile
|
run: bundle exec rspec --profile
|
||||||
|
|
||||||
|
|||||||
15
.github/workflows/specs_rails72.yml
поставляемый
15
.github/workflows/specs_rails72.yml
поставляемый
@@ -2,15 +2,13 @@
|
|||||||
name: Specs Rails 7.2
|
name: Specs Rails 7.2
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches: [main]
|
||||||
- main
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
tests:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
@@ -18,7 +16,7 @@ jobs:
|
|||||||
ruby: ['3.2', '3.4']
|
ruby: ['3.2', '3.4']
|
||||||
|
|
||||||
env:
|
env:
|
||||||
RAILS_VERSION: 7.2.0
|
RAILS_VERSION: 7.2
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
@@ -30,6 +28,9 @@ jobs:
|
|||||||
ruby-version: ${{ matrix.ruby }}
|
ruby-version: ${{ matrix.ruby }}
|
||||||
bundler-cache: true
|
bundler-cache: true
|
||||||
|
|
||||||
|
- name: Database setup
|
||||||
|
run: bin/rails db:create db:migrate db:test:prepare
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: bundle exec rspec --profile
|
run: bundle exec rspec --profile
|
||||||
|
|
||||||
|
|||||||
17
.github/workflows/specs_rails80.yml
поставляемый
17
.github/workflows/specs_rails80.yml
поставляемый
@@ -2,23 +2,21 @@
|
|||||||
name: Specs Rails 8.0
|
name: Specs Rails 8.0
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches: [main]
|
||||||
- main
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
tests:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
ruby: ['3.2', '3.3', '3.4']
|
ruby: ['3.2', '3.4']
|
||||||
|
|
||||||
env:
|
env:
|
||||||
RAILS_VERSION: 8.0.0
|
RAILS_VERSION: 8.0
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
@@ -30,6 +28,9 @@ jobs:
|
|||||||
ruby-version: ${{ matrix.ruby }}
|
ruby-version: ${{ matrix.ruby }}
|
||||||
bundler-cache: true
|
bundler-cache: true
|
||||||
|
|
||||||
|
- name: Database setup
|
||||||
|
run: bin/rails db:create db:migrate db:test:prepare
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: bundle exec rspec --profile
|
run: bundle exec rspec --profile
|
||||||
|
|
||||||
|
|||||||
1
.gitignore
поставляемый
1
.gitignore
поставляемый
@@ -8,6 +8,7 @@
|
|||||||
/_misc/
|
/_misc/
|
||||||
/coverage/
|
/coverage/
|
||||||
/spec/dummy/db/*.sqlite3*
|
/spec/dummy/db/*.sqlite3*
|
||||||
|
/spec/dummy/db/schema-dev.rb
|
||||||
/spec/dummy/log/
|
/spec/dummy/log/
|
||||||
/spec/dummy/storage/
|
/spec/dummy/storage/
|
||||||
/spec/dummy/tmp/
|
/spec/dummy/tmp/
|
||||||
|
|||||||
25
Gemfile
25
Gemfile
@@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
source 'https://rubygems.org'
|
source 'https://rubygems.org'
|
||||||
|
|
||||||
|
def eval_version(dependency, version)
|
||||||
|
return [dependency] if version.empty?
|
||||||
|
|
||||||
|
version.count('.') < 2 ? [dependency, "~> #{version}.0"] : [dependency, version]
|
||||||
|
end
|
||||||
|
|
||||||
if ENV['DEVEL'] == '1'
|
if ENV['DEVEL'] == '1'
|
||||||
gem 'activeadmin_quill_editor', path: './'
|
gem 'activeadmin_quill_editor', path: './'
|
||||||
else
|
else
|
||||||
@@ -9,20 +15,22 @@ else
|
|||||||
end
|
end
|
||||||
|
|
||||||
ruby_ver = ENV.fetch('RUBY_VERSION', '')
|
ruby_ver = ENV.fetch('RUBY_VERSION', '')
|
||||||
rails_ver = ENV.fetch('RAILS_VERSION', '')
|
|
||||||
activeadmin_ver = ENV.fetch('ACTIVEADMIN_VERSION', '')
|
|
||||||
|
|
||||||
rails = rails_ver.empty? ? ['rails'] : ['rails', "~> #{rails_ver}"]
|
rails_ver = ENV.fetch('RAILS_VERSION', '')
|
||||||
|
rails = eval_version('rails', rails_ver)
|
||||||
gem(*rails)
|
gem(*rails)
|
||||||
|
|
||||||
activeadmin = activeadmin_ver.empty? ? ['activeadmin'] : ['activeadmin', "~> #{activeadmin_ver}"]
|
active_admin_ver = ENV.fetch('ACTIVEADMIN_VERSION', '')
|
||||||
gem(*activeadmin)
|
active_admin = eval_version('activeadmin', active_admin_ver)
|
||||||
|
gem(*active_admin)
|
||||||
|
|
||||||
ruby32 = Gem::Version.new(ruby_ver) >= Gem::Version.new('3.2')
|
ruby32 = ruby_ver.empty? || Gem::Version.new(ruby_ver) >= Gem::Version.new('3.2')
|
||||||
rails72 = Gem::Version.new(rails_ver) >= Gem::Version.new('7.2')
|
rails72 = rails_ver.empty? || Gem::Version.new(rails_ver) >= Gem::Version.new('7.2')
|
||||||
sqlite3 = ruby32 || rails72 ? ['sqlite3'] : ['sqlite3', '~> 1.4']
|
sqlite3 = ruby32 && rails72 ? ['sqlite3'] : ['sqlite3', '~> 1.4']
|
||||||
gem(*sqlite3)
|
gem(*sqlite3)
|
||||||
|
|
||||||
|
gem 'zeitwerk', '~> 2.6.18' unless ruby32
|
||||||
|
|
||||||
# NOTE: to avoid error: uninitialized constant ActiveSupport::LoggerThreadSafeLevel::Logger
|
# NOTE: to avoid error: uninitialized constant ActiveSupport::LoggerThreadSafeLevel::Logger
|
||||||
gem 'concurrent-ruby', '1.3.4'
|
gem 'concurrent-ruby', '1.3.4'
|
||||||
|
|
||||||
@@ -39,7 +47,6 @@ gem 'capybara'
|
|||||||
gem 'cuprite'
|
gem 'cuprite'
|
||||||
gem 'rspec_junit_formatter'
|
gem 'rspec_junit_formatter'
|
||||||
gem 'rspec-rails'
|
gem 'rspec-rails'
|
||||||
gem 'rspec-retry'
|
|
||||||
gem 'simplecov', require: false
|
gem 'simplecov', require: false
|
||||||
|
|
||||||
# Linters
|
# Linters
|
||||||
|
|||||||
18
Makefile
18
Makefile
@@ -1,7 +1,14 @@
|
|||||||
include extra/.env
|
include extra/.env
|
||||||
|
|
||||||
help:
|
help:
|
||||||
@echo "Main targets: build / specs / up / server / specs / shell"
|
@echo -e "${COMPOSE_PROJECT_NAME} - Main project commands:\n\
|
||||||
|
make up # starts the dev services (optional env vars: RUBY / RAILS / ACTIVEADMIN)\n\
|
||||||
|
make specs # run the tests (after up)\n\
|
||||||
|
make lint # run the linters (after up)\n\
|
||||||
|
make server # run the server (after up)\n\
|
||||||
|
make shell # open a shell (after up)\n\
|
||||||
|
make down # cleanup (after up)\n\
|
||||||
|
Example: RUBY=3.2 RAILS=7.1 ACTIVEADMIN=3.2.0 make up"
|
||||||
|
|
||||||
# System commands
|
# System commands
|
||||||
|
|
||||||
@@ -10,7 +17,7 @@ build:
|
|||||||
@docker compose -f extra/docker-compose.yml build
|
@docker compose -f extra/docker-compose.yml build
|
||||||
|
|
||||||
db_reset:
|
db_reset:
|
||||||
@docker compose -f extra/docker-compose.yml run --rm app bin/rails db:reset db:test:prepare
|
@docker compose -f extra/docker-compose.yml run --rm app bin/rails db:create db:migrate db:test:prepare
|
||||||
|
|
||||||
up: build db_reset
|
up: build db_reset
|
||||||
@docker compose -f extra/docker-compose.yml up
|
@docker compose -f extra/docker-compose.yml up
|
||||||
@@ -23,13 +30,16 @@ down:
|
|||||||
|
|
||||||
# App commands
|
# App commands
|
||||||
|
|
||||||
console:
|
seed:
|
||||||
|
@docker compose -f extra/docker-compose.yml exec app bin/rails db:seed
|
||||||
|
|
||||||
|
console: seed
|
||||||
@docker compose -f extra/docker-compose.yml exec app bin/rails console
|
@docker compose -f extra/docker-compose.yml exec app bin/rails console
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
@docker compose -f extra/docker-compose.yml exec app bin/rubocop
|
@docker compose -f extra/docker-compose.yml exec app bin/rubocop
|
||||||
|
|
||||||
server:
|
server: seed
|
||||||
@docker compose -f extra/docker-compose.yml exec app bin/rails server -b 0.0.0.0 -p ${SERVER_PORT}
|
@docker compose -f extra/docker-compose.yml exec app bin/rails server -b 0.0.0.0 -p ${SERVER_PORT}
|
||||||
|
|
||||||
specs:
|
specs:
|
||||||
|
|||||||
@@ -26,6 +26,6 @@ ENV ACTIVEADMIN_VERSION=$ACTIVEADMIN_VERSION
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . /app
|
COPY . /app
|
||||||
RUN bundle install
|
RUN bundle install
|
||||||
RUN mkdir -p /app/spec/dummy/db && chown -R app:app /app/spec/dummy/db /usr/local/bundle
|
RUN chown -R app:app /usr/local/bundle
|
||||||
|
|
||||||
RUN ln -s /app/extra/.bashrc /home/app/.bashrc
|
RUN ln -s /app/extra/.bashrc /home/app/.bashrc
|
||||||
|
|||||||
@@ -4,5 +4,3 @@ export DEVEL=1
|
|||||||
|
|
||||||
export RAILS_VERSION=7.2.2.1
|
export RAILS_VERSION=7.2.2.1
|
||||||
export ACTIVEADMIN_VERSION=3.3.0
|
export ACTIVEADMIN_VERSION=3.3.0
|
||||||
|
|
||||||
export RAILS_ENV=development
|
|
||||||
|
|||||||
@@ -1,29 +1,21 @@
|
|||||||
## Development
|
## Development
|
||||||
|
|
||||||
Overcommit can be used to ensure that Conventional commits are good.
|
|
||||||
|
|
||||||
### Dev setup
|
### Dev setup
|
||||||
|
|
||||||
There 2 ways to interact with this project:
|
There are 2 ways to interact with this project:
|
||||||
|
|
||||||
1) Using Docker:
|
1) Using Docker:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# Run rails server on the dummy app (=> http://localhost:3000 to access to ActiveAdmin):
|
make up # starts the dev services (optional env vars: RUBY / RAILS / ACTIVEADMIN)
|
||||||
make up
|
make specs # run the tests (after up)
|
||||||
# Enter in a Rails console (with the dummy app started):
|
make lint # run the linters (after up)
|
||||||
make console
|
make server # run the server (after up)
|
||||||
# Enter in a shell (with the dummy app started):
|
make shell # open a shell (after up)
|
||||||
make shell
|
make down # cleanup (after up)
|
||||||
# Run the linter on the project (with the dummy app started):
|
|
||||||
make lint
|
# Example using specific versions:
|
||||||
# Run the test suite (with the dummy app started):
|
RUBY=3.2 RAILS=7.1 ACTIVEADMIN=3.2.0 make up
|
||||||
make specs
|
|
||||||
# Remove container and image:
|
|
||||||
make cleanup
|
|
||||||
# To try different versions of Ruby/Rails/ActiveAdmin:
|
|
||||||
RUBY=3.2 RAILS=7.1.0 ACTIVEADMIN=3.2.0 make up
|
|
||||||
# For more commands please check the Makefile
|
|
||||||
```
|
```
|
||||||
|
|
||||||
2) With a local setup:
|
2) With a local setup:
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ services:
|
|||||||
context: ..
|
context: ..
|
||||||
dockerfile: extra/Dockerfile
|
dockerfile: extra/Dockerfile
|
||||||
args:
|
args:
|
||||||
ACTIVEADMIN_VERSION: ${ACTIVEADMIN:-}
|
|
||||||
BUNDLER_VERSION: ${BUNDLER_VERSION}
|
BUNDLER_VERSION: ${BUNDLER_VERSION}
|
||||||
RAILS_VERSION: ${RAILS:-}
|
|
||||||
RUBY_IMAGE: ruby:${RUBY:-3.4}-slim
|
RUBY_IMAGE: ruby:${RUBY:-3.4}-slim
|
||||||
|
RAILS_VERSION: ${RAILS:-}
|
||||||
|
ACTIVEADMIN_VERSION: ${ACTIVEADMIN:-}
|
||||||
UID: ${UID}
|
UID: ${UID}
|
||||||
user: ${UID}:${GID}
|
user: ${UID}:${GID}
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ ActiveAdmin.register Post do
|
|||||||
f.input :author
|
f.input :author
|
||||||
f.input :title
|
f.input :title
|
||||||
f.input :summary, as: :quill_editor, input_html: { data: { options: { modules: { toolbar: toolbar } } } }
|
f.input :summary, as: :quill_editor, input_html: { data: { options: { modules: { toolbar: toolbar } } } }
|
||||||
f.input :description, as: :quill_editor, input_html: { data: { options: { modules: { toolbar: toolbar } } } }
|
f.input :description, as: :quill_editor # using default options
|
||||||
f.input :category
|
f.input :category
|
||||||
f.input :dt
|
f.input :dt
|
||||||
f.input :position
|
f.input :position
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
ActiveAdmin.register Tag do
|
ActiveAdmin.register Tag do
|
||||||
|
permit_params :name
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Post < ApplicationRecord
|
class Post < ApplicationRecord
|
||||||
# enum state: %i[available unavailable arriving]
|
|
||||||
|
|
||||||
belongs_to :author, inverse_of: :posts, autosave: true
|
belongs_to :author, inverse_of: :posts, autosave: true
|
||||||
|
|
||||||
has_one :author_profile, through: :author, source: :profile
|
has_one :author_profile, through: :author, source: :profile
|
||||||
@@ -28,12 +26,12 @@ class Post < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def ransackable_attributes(auth_object = nil)
|
def ransackable_associations(_auth_object = nil)
|
||||||
%w[author_id category created_at description dt id position published summary title updated_at]
|
%w[author author_profile post_tags tags images_attachments images_blobs]
|
||||||
end
|
end
|
||||||
|
|
||||||
def ransackable_associations(auth_object = nil)
|
def ransackable_attributes(_auth_object = nil)
|
||||||
%w[author author_profile images_attachments images_blobs post_tags tags]
|
%w[author_id category created_at description dt id position published title summary updated_at]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,14 +3,12 @@
|
|||||||
class Profile < ApplicationRecord
|
class Profile < ApplicationRecord
|
||||||
belongs_to :author, inverse_of: :profile, touch: true
|
belongs_to :author, inverse_of: :profile, touch: true
|
||||||
|
|
||||||
# has_rich_text :description
|
def to_s
|
||||||
|
description
|
||||||
# def to_s
|
end
|
||||||
# description
|
|
||||||
# end
|
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def ransackable_associations(auth_object = nil)
|
def ransackable_associations(_auth_object = nil)
|
||||||
%w[author]
|
%w[author]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,26 +1,23 @@
|
|||||||
require_relative 'boot'
|
require_relative 'boot'
|
||||||
|
|
||||||
require 'rails/all'
|
require 'rails/all'
|
||||||
require 'sprockets/railtie'
|
|
||||||
|
|
||||||
Bundler.require(*Rails.groups)
|
Bundler.require(*Rails.groups)
|
||||||
|
|
||||||
module Dummy
|
module Dummy
|
||||||
class Application < Rails::Application
|
class Application < Rails::Application
|
||||||
# Initialize configuration defaults for originally generated Rails version.
|
config.load_defaults Rails::VERSION::STRING.to_f
|
||||||
config.load_defaults 6.0 if Rails::VERSION::MAJOR == 6
|
|
||||||
|
|
||||||
# Settings in config/environments/* take precedence over those specified here.
|
config.active_support.deprecation = :raise
|
||||||
# Application configuration can go into files in config/initializers
|
|
||||||
# -- all .rb files in that directory are automatically loaded after loading
|
|
||||||
# the framework and any gems in your application.
|
|
||||||
|
|
||||||
###
|
if Gem::Version.new(Rails.version) < Gem::Version.new('7.1')
|
||||||
|
config.active_record.legacy_connection_handling = false
|
||||||
config.active_record.legacy_connection_handling = false if Gem::Version.new(Rails.version) < Gem::Version.new('7.1')
|
end
|
||||||
|
|
||||||
|
if Gem::Version.new(Rails.version) > Gem::Version.new('7.0')
|
||||||
config.before_configuration do
|
config.before_configuration do
|
||||||
ActiveSupport::Cache.format_version = 7.0 if Gem::Version.new(Rails.version) > Gem::Version.new('7.0')
|
ActiveSupport::Cache.format_version = 7.0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ default: &default
|
|||||||
development:
|
development:
|
||||||
<<: *default
|
<<: *default
|
||||||
database: db/development.sqlite3
|
database: db/development.sqlite3
|
||||||
schema_dump: schema_development.rb
|
schema_dump: schema-dev.rb
|
||||||
|
|
||||||
test:
|
test:
|
||||||
<<: *default
|
<<: *default
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
ActiveSupport::Reloader.to_prepare do
|
Rails.application.reloader.to_prepare do
|
||||||
ActiveStorage::Attachment.class_eval do
|
ActiveStorage::Attachment.class_eval do
|
||||||
def self.ransackable_attributes(auth_object = nil)
|
class << self
|
||||||
|
def ransackable_attributes(auth_object = nil)
|
||||||
%w[blob_id created_at id name record_id record_type]
|
%w[blob_id created_at id name record_id record_type]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,99 +0,0 @@
|
|||||||
# This file is auto-generated from the current state of the database. Instead
|
|
||||||
# of editing this file, please use the migrations feature of Active Record to
|
|
||||||
# incrementally modify your database, and then regenerate this schema definition.
|
|
||||||
#
|
|
||||||
# This file is the source Rails uses to define your schema when running `bin/rails
|
|
||||||
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
|
|
||||||
# be faster and is potentially less error prone than running all of your
|
|
||||||
# migrations from scratch. Old migrations may fail to apply correctly if those
|
|
||||||
# migrations use external dependencies or application code.
|
|
||||||
#
|
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2018_06_07_053739) do
|
|
||||||
create_table "active_admin_comments", force: :cascade do |t|
|
|
||||||
t.string "namespace"
|
|
||||||
t.text "body"
|
|
||||||
t.string "resource_type"
|
|
||||||
t.integer "resource_id"
|
|
||||||
t.string "author_type"
|
|
||||||
t.integer "author_id"
|
|
||||||
t.datetime "created_at", null: false
|
|
||||||
t.datetime "updated_at", null: false
|
|
||||||
t.index ["author_type", "author_id"], name: "index_active_admin_comments_on_author_type_and_author_id"
|
|
||||||
t.index ["namespace"], name: "index_active_admin_comments_on_namespace"
|
|
||||||
t.index ["resource_type", "resource_id"], name: "index_active_admin_comments_on_resource_type_and_resource_id"
|
|
||||||
end
|
|
||||||
|
|
||||||
create_table "active_storage_attachments", force: :cascade do |t|
|
|
||||||
t.string "name", null: false
|
|
||||||
t.string "record_type", null: false
|
|
||||||
t.integer "record_id", null: false
|
|
||||||
t.integer "blob_id", null: false
|
|
||||||
t.datetime "created_at", precision: nil, null: false
|
|
||||||
t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id"
|
|
||||||
t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true
|
|
||||||
end
|
|
||||||
|
|
||||||
create_table "active_storage_blobs", force: :cascade do |t|
|
|
||||||
t.string "key", null: false
|
|
||||||
t.string "filename", null: false
|
|
||||||
t.string "content_type"
|
|
||||||
t.text "metadata"
|
|
||||||
t.bigint "byte_size", null: false
|
|
||||||
t.string "checksum", null: false
|
|
||||||
t.datetime "created_at", precision: nil, null: false
|
|
||||||
t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true
|
|
||||||
end
|
|
||||||
|
|
||||||
create_table "authors", force: :cascade do |t|
|
|
||||||
t.string "name"
|
|
||||||
t.integer "age"
|
|
||||||
t.string "email"
|
|
||||||
t.datetime "created_at", precision: nil, null: false
|
|
||||||
t.datetime "updated_at", precision: nil, null: false
|
|
||||||
end
|
|
||||||
|
|
||||||
create_table "post_tags", force: :cascade do |t|
|
|
||||||
t.integer "post_id"
|
|
||||||
t.integer "tag_id"
|
|
||||||
t.datetime "created_at", precision: nil, null: false
|
|
||||||
t.datetime "updated_at", precision: nil, null: false
|
|
||||||
t.index ["post_id"], name: "index_post_tags_on_post_id"
|
|
||||||
t.index ["tag_id"], name: "index_post_tags_on_tag_id"
|
|
||||||
end
|
|
||||||
|
|
||||||
create_table "posts", force: :cascade do |t|
|
|
||||||
t.string "title"
|
|
||||||
t.text "summary"
|
|
||||||
t.text "description"
|
|
||||||
t.integer "author_id"
|
|
||||||
t.string "category"
|
|
||||||
t.datetime "dt", precision: nil
|
|
||||||
t.float "position"
|
|
||||||
t.boolean "published"
|
|
||||||
t.datetime "created_at", precision: nil, null: false
|
|
||||||
t.datetime "updated_at", precision: nil, null: false
|
|
||||||
t.index ["author_id"], name: "index_posts_on_author_id"
|
|
||||||
end
|
|
||||||
|
|
||||||
create_table "profiles", force: :cascade do |t|
|
|
||||||
t.text "description"
|
|
||||||
t.integer "author_id"
|
|
||||||
t.datetime "created_at", precision: nil, null: false
|
|
||||||
t.datetime "updated_at", precision: nil, null: false
|
|
||||||
t.index ["author_id"], name: "index_profiles_on_author_id"
|
|
||||||
end
|
|
||||||
|
|
||||||
create_table "tags", force: :cascade do |t|
|
|
||||||
t.string "name"
|
|
||||||
t.datetime "created_at", precision: nil, null: false
|
|
||||||
t.datetime "updated_at", precision: nil, null: false
|
|
||||||
end
|
|
||||||
|
|
||||||
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
|
|
||||||
add_foreign_key "post_tags", "posts"
|
|
||||||
add_foreign_key "post_tags", "tags"
|
|
||||||
add_foreign_key "posts", "authors"
|
|
||||||
add_foreign_key "profiles", "authors"
|
|
||||||
end
|
|
||||||
@@ -7,7 +7,8 @@ end
|
|||||||
(11..20).each do |i|
|
(11..20).each do |i|
|
||||||
age = 21 + 3 * (i - 10)
|
age = 21 + 3 * (i - 10)
|
||||||
attrs = { name: "Author #{i}", age: age, email: "some@email#{i}.com" }
|
attrs = { name: "Author #{i}", age: age, email: "some@email#{i}.com" }
|
||||||
Author.find_or_create_by!(attrs) do |author|
|
Author.find_or_create_by!(name: "Author #{i}") do |author|
|
||||||
|
author.assign_attributes(attrs)
|
||||||
author.profile = Profile.new(description: "Profile description for Author #{i}") if (i % 3).zero?
|
author.profile = Profile.new(description: "Profile description for Author #{i}") if (i % 3).zero?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -19,6 +20,8 @@ tags = Tag.where.not(name: 'A test tag').pluck(:id)
|
|||||||
title: "Post #{i}",
|
title: "Post #{i}",
|
||||||
author_id: authors.sample,
|
author_id: authors.sample,
|
||||||
position: rand(100),
|
position: rand(100),
|
||||||
|
summary: "<p><em>Summary</em> for post #{i}</p>",
|
||||||
|
description: "<p><strong>Some bold</strong> <em>Some italic</em> <u>Some underline</u> [#{i}]</p>",
|
||||||
created_at: Time.now - rand(3600).seconds
|
created_at: Time.now - rand(3600).seconds
|
||||||
}
|
}
|
||||||
attrs[:category] = 'news' if (i % 4).zero?
|
attrs[:category] = 'news' if (i % 4).zero?
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require_relative '../../base_page'
|
|
||||||
|
|
||||||
module Admin
|
module Admin
|
||||||
module Authors
|
module Authors
|
||||||
class EditPage < BasePage
|
class EditPage < BasePage
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require_relative '../../base_page'
|
|
||||||
|
|
||||||
module Admin
|
module Admin
|
||||||
module Posts
|
module Posts
|
||||||
class EditPage < BasePage
|
class EditPage < BasePage
|
||||||
|
|||||||
@@ -12,4 +12,8 @@ class BasePage
|
|||||||
def load
|
def load
|
||||||
visit(path)
|
visit(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def lookup_editor(editor_container:)
|
||||||
|
@editor = Shared::QuillEditor.new(editor_container)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require_relative '../base_object'
|
module Shared
|
||||||
|
class HtmlEditor < BaseObject
|
||||||
class HtmlEditor < BaseObject
|
|
||||||
def content_element
|
def content_element
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
end
|
end
|
||||||
@@ -32,4 +31,5 @@ class HtmlEditor < BaseObject
|
|||||||
content_element.send_keys(content)
|
content_element.send_keys(content)
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class QuillEditor < HtmlEditor
|
module Shared
|
||||||
|
class QuillEditor < HtmlEditor
|
||||||
SELECTOR = '.ql-container'
|
SELECTOR = '.ql-container'
|
||||||
TOOLBAR_SELECTOR = '.ql-toolbar'
|
TOOLBAR_SELECTOR = '.ql-toolbar'
|
||||||
|
|
||||||
@@ -41,4 +42,5 @@ class QuillEditor < HtmlEditor
|
|||||||
def toggle_link
|
def toggle_link
|
||||||
find(control_selector(:link)).click
|
find(control_selector(:link)).click
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
require_relative 'spec_helper'
|
require_relative 'spec_helper'
|
||||||
|
|
||||||
|
require 'zeitwerk'
|
||||||
|
loader = Zeitwerk::Loader.new
|
||||||
|
loader.push_dir("#{__dir__}/page_objects")
|
||||||
|
loader.setup
|
||||||
|
|
||||||
ENV['RAILS_ENV'] = 'test'
|
ENV['RAILS_ENV'] = 'test'
|
||||||
|
|
||||||
require 'simplecov'
|
require 'simplecov'
|
||||||
@@ -13,13 +18,8 @@ abort('The Rails environment is running in production mode!') if Rails.env.produ
|
|||||||
|
|
||||||
require 'rspec/rails'
|
require 'rspec/rails'
|
||||||
require 'capybara/rails'
|
require 'capybara/rails'
|
||||||
require 'rspec/retry'
|
|
||||||
|
|
||||||
Rails.root.glob("../support/**/*.rb").each { |f| require_relative f }
|
Dir[File.expand_path('support/**/*.rb', __dir__)].each { |f| require_relative f }
|
||||||
Rails.root.glob("../page_objects/**/*.rb").each { |f| require_relative f }
|
|
||||||
|
|
||||||
# Force deprecations to raise an exception.
|
|
||||||
# ActiveSupport::Deprecation.behavior = :raise
|
|
||||||
|
|
||||||
# Checks for pending migrations and applies them before tests are run.
|
# Checks for pending migrations and applies them before tests are run.
|
||||||
# If you are not using ActiveRecord, you can remove these lines.
|
# If you are not using ActiveRecord, you can remove these lines.
|
||||||
@@ -31,6 +31,12 @@ rescue ActiveRecord::PendingMigrationError => e
|
|||||||
end
|
end
|
||||||
|
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
|
if Gem::Version.new(Rails.version) >= Gem::Version.new('7.1')
|
||||||
|
config.fixture_paths = [Rails.root.join('spec/fixtures')]
|
||||||
|
else
|
||||||
|
config.fixture_path = Rails.root.join('spec/fixtures')
|
||||||
|
end
|
||||||
|
|
||||||
config.infer_spec_type_from_file_location!
|
config.infer_spec_type_from_file_location!
|
||||||
config.filter_rails_from_backtrace!
|
config.filter_rails_from_backtrace!
|
||||||
|
|
||||||
@@ -38,8 +44,6 @@ RSpec.configure do |config|
|
|||||||
config.use_instantiated_fixtures = false
|
config.use_instantiated_fixtures = false
|
||||||
config.render_views = false
|
config.render_views = false
|
||||||
|
|
||||||
config.default_retry_count = 2
|
|
||||||
|
|
||||||
config.before(:suite) do
|
config.before(:suite) do
|
||||||
intro = ('-' * 80)
|
intro = ('-' * 80)
|
||||||
intro << "\n"
|
intro << "\n"
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ Capybara.register_driver(:capybara_cuprite) do |app|
|
|||||||
|
|
||||||
Capybara::Cuprite::Driver.new(
|
Capybara::Cuprite::Driver.new(
|
||||||
app,
|
app,
|
||||||
window_size: [1600, 1280],
|
window_size: [1600, 1024],
|
||||||
browser_options: browser_options,
|
browser_options: browser_options,
|
||||||
process_timeout: 20,
|
process_timeout: 30,
|
||||||
timeout: 20,
|
timeout: 30,
|
||||||
inspector: true,
|
inspector: true,
|
||||||
headless: !ENV['CUPRITE_HEADLESS'].in?(%w[n 0 no false])
|
headless: !ENV['CUPRITE_HEADLESS'].in?(%w[n 0 no false])
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
RSpec.describe 'Quill editor' do
|
RSpec.describe 'Quill editor' do
|
||||||
def lookup_editor(field:)
|
def lookup_editor(field:)
|
||||||
selector = ["##{field}_input.quill_editor", QuillEditor::SELECTOR].join(' ')
|
selector = ["##{field}_input.quill_editor", Shared::QuillEditor::SELECTOR].join(' ')
|
||||||
toolbar_selector = ["##{field}_input.quill_editor", QuillEditor::TOOLBAR_SELECTOR].join(' ')
|
toolbar_selector = ["##{field}_input.quill_editor", Shared::QuillEditor::TOOLBAR_SELECTOR].join(' ')
|
||||||
QuillEditor.new(selector: selector, toolbar_selector: toolbar_selector)
|
Shared::QuillEditor.new(selector: selector, toolbar_selector: toolbar_selector)
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:author) { Author.create!(email: 'some_email@example.com', name: 'John Doe', age: 30) }
|
let(:author) { Author.create!(email: 'some_email@example.com', name: 'John Doe', age: 30) }
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user