",
8 | "license": "MIT",
9 | "dependencies": {
10 | "trumbowyg": "^2.31.0"
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/spec/dummy/.ruby-version:
--------------------------------------------------------------------------------
1 | ruby-2.7.1
2 |
--------------------------------------------------------------------------------
/spec/dummy/Rakefile:
--------------------------------------------------------------------------------
1 | # Add your own tasks in files placed in lib/tasks ending in .rake,
2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3 |
4 | require_relative 'config/application'
5 |
6 | Rails.application.load_tasks
7 |
--------------------------------------------------------------------------------
/spec/dummy/app/admin/authors.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | ActiveAdmin.register Author do
4 | permit_params :name,
5 | :email,
6 | :age,
7 | :avatar,
8 | profile_attributes: %i[id description _destroy],
9 | posts_attributes: %i[id title description]
10 |
11 | index do
12 | selectable_column
13 | id_column
14 | column :name
15 | column :email
16 | column :created_at
17 | actions
18 | end
19 |
20 | filter :name
21 | filter :created_at
22 |
23 | show do
24 | attributes_table do
25 | row :name
26 | row :email
27 | row :age
28 | row :avatar do |record|
29 | image_tag url_for(record.avatar), style: 'max-width:800px;max-height:500px' if record.avatar.attached?
30 | end
31 | row :created_at
32 | row :updated_at
33 | row :profile
34 | row :posts
35 | end
36 | active_admin_comments
37 | end
38 |
39 | form do |f|
40 | f.inputs do
41 | f.input :name
42 | f.input :email
43 | f.input :age
44 | f.input :avatar,
45 | as: :file,
46 | hint: (object.avatar.attached? ? "Current: #{object.avatar.filename}" : nil)
47 | end
48 | f.has_many :profile, allow_destroy: true do |ff|
49 | ff.input :description
50 | end
51 | f.has_many :posts do |fp|
52 | fp.input :title
53 | fp.input :description, as: :trumbowyg
54 | end
55 | f.actions
56 | end
57 | end
58 |
--------------------------------------------------------------------------------
/spec/dummy/app/admin/dashboard.rb:
--------------------------------------------------------------------------------
1 | ActiveAdmin.register_page "Dashboard" do
2 | menu priority: 1, label: proc { I18n.t("active_admin.dashboard") }
3 |
4 | content title: proc { I18n.t("active_admin.dashboard") } do
5 | div class: "blank_slate_container", id: "dashboard_default_message" do
6 | span class: "blank_slate" do
7 | span I18n.t("active_admin.dashboard_welcome.welcome")
8 | small I18n.t("active_admin.dashboard_welcome.call_to_action")
9 | end
10 | end
11 |
12 | # Here is an example of a simple dashboard with columns and panels.
13 | #
14 | # columns do
15 | # column do
16 | # panel "Recent Posts" do
17 | # ul do
18 | # Post.recent(5).map do |post|
19 | # li link_to(post.title, admin_post_path(post))
20 | # end
21 | # end
22 | # end
23 | # end
24 |
25 | # column do
26 | # panel "Info" do
27 | # para "Welcome to ActiveAdmin."
28 | # end
29 | # end
30 | # end
31 | end # content
32 | end
33 |
--------------------------------------------------------------------------------
/spec/dummy/app/admin/posts.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | ActiveAdmin.register Post do
4 | permit_params :author_id, :title, :summary, :description, :category, :dt, :position, :published, tag_ids: []
5 |
6 | remove_filter :state, :summary
7 |
8 | index do
9 | selectable_column
10 | id_column
11 | column :title
12 | column :author
13 | column :published
14 | column :created_at
15 | actions
16 | end
17 |
18 | show do
19 | attributes_table do
20 | row :author
21 | row :title
22 | row :summary
23 | row :description
24 | row :category
25 | row :dt
26 | row :position
27 | row :published
28 | row :tags
29 | row :created_at
30 | row :updated_at
31 | end
32 | active_admin_comments
33 | end
34 |
35 | form do |f|
36 | buttons = %w[strong em underline link justifyRight]
37 |
38 | f.inputs 'Post' do
39 | f.input :author
40 | f.input :title
41 | f.input :summary, as: :trumbowyg # using default options
42 | f.input :description, as: :trumbowyg, input_html: { data: { options: { btns: buttons } } }
43 | f.input :category
44 | f.input :dt
45 | f.input :position
46 | f.input :published
47 | end
48 |
49 | f.inputs 'Tags' do
50 | f.input :tags
51 | end
52 |
53 | f.actions
54 | end
55 | end
56 |
--------------------------------------------------------------------------------
/spec/dummy/app/admin/tags.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | ActiveAdmin.register Tag do
4 | permit_params :name
5 | end
6 |
--------------------------------------------------------------------------------
/spec/dummy/app/assets/config/manifest.js:
--------------------------------------------------------------------------------
1 | //= link_tree ../images
2 | //= link_directory ../stylesheets .css
3 | // OFF link active_storage_db_manifest.js
4 |
--------------------------------------------------------------------------------
/spec/dummy/app/assets/images/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blocknotes/activeadmin_trumbowyg/3b169607851a9ab117ec11a255e61022b24d7987/spec/dummy/app/assets/images/.keep
--------------------------------------------------------------------------------
/spec/dummy/app/assets/javascripts/active_admin.js:
--------------------------------------------------------------------------------
1 | //= require active_admin/base
2 |
3 | //= require activeadmin/trumbowyg/trumbowyg
4 | //= require activeadmin/trumbowyg_input
5 |
--------------------------------------------------------------------------------
/spec/dummy/app/assets/stylesheets/active_admin.scss:
--------------------------------------------------------------------------------
1 | // SASS variable overrides must be declared before loading up Active Admin's styles.
2 | //
3 | // To view the variables that Active Admin provides, take a look at
4 | // `app/assets/stylesheets/active_admin/mixins/_variables.scss` in the
5 | // Active Admin source.
6 | //
7 | // For example, to change the sidebar width:
8 | // $sidebar-width: 242px;
9 |
10 | // Active Admin's got SASS!
11 | @import 'active_admin/mixins';
12 | @import 'active_admin/base';
13 |
14 | @import 'activeadmin/trumbowyg/trumbowyg';
15 | @import 'activeadmin/trumbowyg_input';
16 |
17 | // Overriding any non-variable SASS must be done after the fact.
18 | // For example, to change the default status-tag color:
19 | //
20 | // .status_tag { background: #6090DB; }
21 |
--------------------------------------------------------------------------------
/spec/dummy/app/assets/stylesheets/application.css:
--------------------------------------------------------------------------------
1 | /*
2 | * This is a manifest file that'll be compiled into application.css, which will include all the files
3 | * listed below.
4 | *
5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6 | * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7 | *
8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9 | * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10 | * files in this directory. Styles in this file should be added after the last require_* statement.
11 | * It is generally better to create a new file per style scope.
12 | *
13 | *= require_tree .
14 | *= require_self
15 | */
16 |
--------------------------------------------------------------------------------
/spec/dummy/app/channels/application_cable/channel.rb:
--------------------------------------------------------------------------------
1 | module ApplicationCable
2 | class Channel < ActionCable::Channel::Base
3 | end
4 | end
5 |
--------------------------------------------------------------------------------
/spec/dummy/app/channels/application_cable/connection.rb:
--------------------------------------------------------------------------------
1 | module ApplicationCable
2 | class Connection < ActionCable::Connection::Base
3 | end
4 | end
5 |
--------------------------------------------------------------------------------
/spec/dummy/app/controllers/application_controller.rb:
--------------------------------------------------------------------------------
1 | class ApplicationController < ActionController::Base
2 | end
3 |
--------------------------------------------------------------------------------
/spec/dummy/app/controllers/concerns/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blocknotes/activeadmin_trumbowyg/3b169607851a9ab117ec11a255e61022b24d7987/spec/dummy/app/controllers/concerns/.keep
--------------------------------------------------------------------------------
/spec/dummy/app/helpers/application_helper.rb:
--------------------------------------------------------------------------------
1 | module ApplicationHelper
2 | end
3 |
--------------------------------------------------------------------------------
/spec/dummy/app/javascript/packs/application.js:
--------------------------------------------------------------------------------
1 | // This is a manifest file that'll be compiled into application.js, which will include all the files
2 | // listed below.
3 | //
4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5 | // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6 | //
7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8 | // compiled file. JavaScript code in this file should be added after the last require_* statement.
9 | //
10 | // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11 | // about supported directives.
12 | //
13 | //= require rails-ujs
14 | //= require activestorage
15 | //= require_tree .
16 |
--------------------------------------------------------------------------------
/spec/dummy/app/jobs/application_job.rb:
--------------------------------------------------------------------------------
1 | class ApplicationJob < ActiveJob::Base
2 | # Automatically retry jobs that encountered a deadlock
3 | # retry_on ActiveRecord::Deadlocked
4 |
5 | # Most jobs are safe to ignore if the underlying records are no longer available
6 | # discard_on ActiveJob::DeserializationError
7 | end
8 |
--------------------------------------------------------------------------------
/spec/dummy/app/mailers/application_mailer.rb:
--------------------------------------------------------------------------------
1 | class ApplicationMailer < ActionMailer::Base
2 | default from: 'from@example.com'
3 | layout 'mailer'
4 | end
5 |
--------------------------------------------------------------------------------
/spec/dummy/app/models/application_record.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class ApplicationRecord < ActiveRecord::Base
4 | self.abstract_class = true
5 | end
6 |
--------------------------------------------------------------------------------
/spec/dummy/app/models/author.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class Author < ApplicationRecord
4 | has_many :posts
5 | has_many :published_posts, -> { published }, class_name: 'Post'
6 | has_many :recent_posts, -> { recents }, class_name: 'Post'
7 |
8 | has_many :tags, through: :posts
9 |
10 | has_one :profile, inverse_of: :author, dependent: :destroy
11 |
12 | has_one_attached :avatar
13 |
14 | accepts_nested_attributes_for :profile, allow_destroy: true
15 | accepts_nested_attributes_for :posts, allow_destroy: true
16 |
17 | validates :email, format: { with: /\A[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\z/i, message: 'Invalid email' }
18 |
19 | validate -> {
20 | errors.add( :base, 'Invalid age' ) if !age || age.to_i % 3 == 1
21 | }
22 |
23 | def to_s
24 | "#{name} (#{age})"
25 | end
26 |
27 | class << self
28 | def ransackable_attributes(auth_object = nil)
29 | %w[age created_at email id name updated_at]
30 | end
31 | end
32 | end
33 |
--------------------------------------------------------------------------------
/spec/dummy/app/models/concerns/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blocknotes/activeadmin_trumbowyg/3b169607851a9ab117ec11a255e61022b24d7987/spec/dummy/app/models/concerns/.keep
--------------------------------------------------------------------------------
/spec/dummy/app/models/post.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class Post < ApplicationRecord
4 | if Gem::Version.new(Rails.version) >= Gem::Version.new('8.0')
5 | enum :state, %i[available unavailable arriving]
6 | else
7 | enum state: %i[available unavailable arriving]
8 | end
9 |
10 | belongs_to :author, inverse_of: :posts, autosave: true
11 |
12 | has_one :author_profile, through: :author, source: :profile
13 |
14 | has_many :post_tags, inverse_of: :post, dependent: :destroy
15 | has_many :tags, through: :post_tags
16 |
17 | validates :title, allow_blank: false, presence: true
18 |
19 | scope :published, -> { where(published: true) }
20 | scope :recents, -> { where('created_at > ?', Date.today - 8.month) }
21 |
22 | def short_title
23 | title.truncate 10
24 | end
25 |
26 | def upper_title
27 | title.upcase
28 | end
29 |
30 | class << self
31 | def ransackable_associations(auth_object = nil)
32 | %w[author author_profile post_tags tags]
33 | end
34 |
35 | def ransackable_attributes(auth_object = nil)
36 | %w[author_id category created_at description dt id position published title updated_at]
37 | end
38 | end
39 | end
40 |
--------------------------------------------------------------------------------
/spec/dummy/app/models/post_tag.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class PostTag < ApplicationRecord
4 | belongs_to :post, inverse_of: :post_tags
5 | belongs_to :tag, inverse_of: :post_tags
6 |
7 | validates :post, presence: true
8 | validates :tag, presence: true
9 |
10 | class << self
11 | def ransackable_attributes(auth_object = nil)
12 | %w[created_at id post_id tag_id updated_at]
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/spec/dummy/app/models/profile.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class Profile < ApplicationRecord
4 | belongs_to :author, inverse_of: :profile, touch: true
5 |
6 | def to_s
7 | description
8 | end
9 |
10 | class << self
11 | def ransackable_attributes(auth_object = nil)
12 | %w[author_id created_at description id updated_at]
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/spec/dummy/app/models/tag.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class Tag < ApplicationRecord
4 | has_many :post_tags, inverse_of: :tag, dependent: :destroy
5 | has_many :posts, through: :post_tags
6 |
7 | def self.ransackable_associations(auth_object = nil)
8 | %w[post_tags posts]
9 | end
10 |
11 | def self.ransackable_attributes(auth_object = nil)
12 | %w[created_at id name updated_at]
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/spec/dummy/app/views/layouts/application.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Dummy
5 | <%= csrf_meta_tags %>
6 | <%= csp_meta_tag %>
7 |
8 | <%= stylesheet_link_tag 'application', media: 'all' %>
9 |
10 |
11 |
12 | <%= yield %>
13 |
14 |
15 |
--------------------------------------------------------------------------------
/spec/dummy/app/views/layouts/mailer.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
10 |
11 | <%= yield %>
12 |
13 |
14 |
--------------------------------------------------------------------------------
/spec/dummy/app/views/layouts/mailer.text.erb:
--------------------------------------------------------------------------------
1 | <%= yield %>
2 |
--------------------------------------------------------------------------------
/spec/dummy/bin/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | APP_PATH = File.expand_path('../config/application', __dir__)
3 | require_relative '../config/boot'
4 | require 'rails/commands'
5 |
--------------------------------------------------------------------------------
/spec/dummy/bin/rake:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require_relative '../config/boot'
3 | require 'rake'
4 | Rake.application.run
5 |
--------------------------------------------------------------------------------
/spec/dummy/bin/setup:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'fileutils'
3 |
4 | # path to your application root.
5 | APP_ROOT = File.expand_path('..', __dir__)
6 |
7 | def system!(*args)
8 | system(*args) || abort("\n== Command #{args} failed ==")
9 | end
10 |
11 | FileUtils.chdir APP_ROOT do
12 | # This script is a way to setup or update your development environment automatically.
13 | # This script is idempotent, so that you can run it at anytime and get an expectable outcome.
14 | # Add necessary setup steps to this file.
15 |
16 | puts '== Installing dependencies =='
17 | system! 'gem install bundler --conservative'
18 | system('bundle check') || system!('bundle install')
19 |
20 | # puts "\n== Copying sample files =="
21 | # unless File.exist?('config/database.yml')
22 | # FileUtils.cp 'config/database.yml.sample', 'config/database.yml'
23 | # end
24 |
25 | puts "\n== Preparing database =="
26 | system! 'bin/rails db:prepare'
27 |
28 | puts "\n== Removing old logs and tempfiles =="
29 | system! 'bin/rails log:clear tmp:clear'
30 |
31 | puts "\n== Restarting application server =="
32 | system! 'bin/rails restart'
33 | end
34 |
--------------------------------------------------------------------------------
/spec/dummy/config.ru:
--------------------------------------------------------------------------------
1 | # This file is used by Rack-based servers to start the application.
2 |
3 | require_relative 'config/environment'
4 |
5 | run Rails.application
6 |
--------------------------------------------------------------------------------
/spec/dummy/config/application.rb:
--------------------------------------------------------------------------------
1 | require_relative 'boot'
2 |
3 | require 'rails/all'
4 |
5 | Bundler.require(*Rails.groups)
6 |
7 | module Dummy
8 | class Application < Rails::Application
9 | config.load_defaults Rails::VERSION::STRING.to_f
10 |
11 | config.active_support.deprecation = :raise
12 |
13 | if Gem::Version.new(Rails.version) < Gem::Version.new('7.1')
14 | config.active_record.legacy_connection_handling = false
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/spec/dummy/config/boot.rb:
--------------------------------------------------------------------------------
1 | # Set up gems listed in the Gemfile.
2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
3 |
4 | require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5 | $LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
6 |
--------------------------------------------------------------------------------
/spec/dummy/config/cable.yml:
--------------------------------------------------------------------------------
1 | development:
2 | adapter: async
3 |
4 | test:
5 | adapter: test
6 |
7 | production:
8 | adapter: redis
9 | url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
10 | channel_prefix: dummy_production
11 |
--------------------------------------------------------------------------------
/spec/dummy/config/database.yml:
--------------------------------------------------------------------------------
1 | default: &default
2 | adapter: sqlite3
3 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
4 | timeout: 5000
5 |
6 | test:
7 | <<: *default
8 | database: db/test.sqlite3
9 |
10 | development:
11 | <<: *default
12 | database: db/development.sqlite3
13 | schema_dump: schema-dev.rb
14 |
--------------------------------------------------------------------------------
/spec/dummy/config/environment.rb:
--------------------------------------------------------------------------------
1 | # Load the Rails application.
2 | require_relative 'application'
3 |
4 | # Initialize the Rails application.
5 | Rails.application.initialize!
6 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/application_controller_renderer.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # ActiveSupport::Reloader.to_prepare do
4 | # ApplicationController.renderer.defaults.merge!(
5 | # http_host: 'example.org',
6 | # https: false
7 | # )
8 | # end
9 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/assets.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Version of your assets, change this if you want to expire all your assets.
4 | Rails.application.config.assets.version = '1.0'
5 |
6 | # Add additional assets to the asset load path.
7 | # Rails.application.config.assets.paths << Emoji.images_path
8 |
9 | # Precompile additional assets.
10 | # application.js, application.css, and all non-JS/CSS in the app/assets
11 | # folder are already added.
12 | # Rails.application.config.assets.precompile += %w( admin.js admin.css )
13 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/backtrace_silencers.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5 |
6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7 | # Rails.backtrace_cleaner.remove_silencers!
8 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/content_security_policy.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Define an application-wide content security policy
4 | # For further information see the following documentation
5 | # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
6 |
7 | # Rails.application.config.content_security_policy do |policy|
8 | # policy.default_src :self, :https
9 | # policy.font_src :self, :https, :data
10 | # policy.img_src :self, :https, :data
11 | # policy.object_src :none
12 | # policy.script_src :self, :https
13 | # policy.style_src :self, :https
14 |
15 | # # Specify URI for violation reports
16 | # # policy.report_uri "/csp-violation-report-endpoint"
17 | # end
18 |
19 | # If you are using UJS then enable automatic nonce generation
20 | # Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
21 |
22 | # Set the nonce only to specific directives
23 | # Rails.application.config.content_security_policy_nonce_directives = %w(script-src)
24 |
25 | # Report CSP violations to a specified URI
26 | # For further information see the following documentation:
27 | # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
28 | # Rails.application.config.content_security_policy_report_only = true
29 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/cookies_serializer.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Specify a serializer for the signed and encrypted cookie jars.
4 | # Valid options are :json, :marshal, and :hybrid.
5 | Rails.application.config.action_dispatch.cookies_serializer = :json
6 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/filter_parameter_logging.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Configure sensitive parameters which will be filtered from the log file.
4 | Rails.application.config.filter_parameters += [:password]
5 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/inflections.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new inflection rules using the following format. Inflections
4 | # are locale specific, and you may define rules for as many different
5 | # locales as you wish. All of these examples are active by default:
6 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
7 | # inflect.plural /^(ox)$/i, '\1en'
8 | # inflect.singular /^(ox)en/i, '\1'
9 | # inflect.irregular 'person', 'people'
10 | # inflect.uncountable %w( fish sheep )
11 | # end
12 |
13 | # These inflection rules are supported but not enabled by default:
14 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
15 | # inflect.acronym 'RESTful'
16 | # end
17 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/mime_types.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new mime types for use in respond_to blocks:
4 | # Mime::Type.register "text/richtext", :rtf
5 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/wrap_parameters.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # This file contains settings for ActionController::ParamsWrapper which
4 | # is enabled by default.
5 |
6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7 | ActiveSupport.on_load(:action_controller) do
8 | wrap_parameters format: [:json]
9 | end
10 |
11 | # To enable root element in JSON for ActiveRecord objects.
12 | # ActiveSupport.on_load(:active_record) do
13 | # self.include_root_in_json = true
14 | # end
15 |
--------------------------------------------------------------------------------
/spec/dummy/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Files in the config/locales directory are used for internationalization
2 | # and are automatically loaded by Rails. If you want to use locales other
3 | # than English, add the necessary files in this directory.
4 | #
5 | # To use the locales, use `I18n.t`:
6 | #
7 | # I18n.t 'hello'
8 | #
9 | # In views, this is aliased to just `t`:
10 | #
11 | # <%= t('hello') %>
12 | #
13 | # To use a different locale, set it with `I18n.locale`:
14 | #
15 | # I18n.locale = :es
16 | #
17 | # This would use the information in config/locales/es.yml.
18 | #
19 | # The following keys must be escaped otherwise they will not be retrieved by
20 | # the default I18n backend:
21 | #
22 | # true, false, on, off, yes, no
23 | #
24 | # Instead, surround them with single quotes.
25 | #
26 | # en:
27 | # 'true': 'foo'
28 | #
29 | # To learn more, please read the Rails Internationalization guide
30 | # available at https://guides.rubyonrails.org/i18n.html.
31 |
32 | en:
33 | hello: "Hello world"
34 |
--------------------------------------------------------------------------------
/spec/dummy/config/routes.rb:
--------------------------------------------------------------------------------
1 | Rails.application.routes.draw do
2 | ActiveAdmin.routes(self)
3 |
4 | root to: redirect('/admin')
5 | end
6 |
--------------------------------------------------------------------------------
/spec/dummy/config/spring.rb:
--------------------------------------------------------------------------------
1 | Spring.watch(
2 | ".ruby-version",
3 | ".rbenv-vars",
4 | "tmp/restart.txt",
5 | "tmp/caching-dev.txt"
6 | )
7 |
--------------------------------------------------------------------------------
/spec/dummy/config/storage.yml:
--------------------------------------------------------------------------------
1 | test:
2 | service: Disk
3 | root: <%= Rails.root.join("tmp/storage") %>
4 |
5 | local:
6 | service: Disk
7 | root: <%= Rails.root.join("storage") %>
8 |
--------------------------------------------------------------------------------
/spec/dummy/db/migrate/20170806125915_create_active_storage_tables.active_storage.rb:
--------------------------------------------------------------------------------
1 | # This migration comes from active_storage (originally 20170806125915)
2 | class CreateActiveStorageTables < ActiveRecord::Migration[5.2]
3 | def change
4 | create_table :active_storage_blobs do |t|
5 | t.string :key, null: false
6 | t.string :filename, null: false
7 | t.string :content_type
8 | t.text :metadata
9 | t.bigint :byte_size, null: false
10 | t.string :checksum, null: false
11 | t.datetime :created_at, null: false
12 |
13 | t.index [ :key ], unique: true
14 | end
15 |
16 | create_table :active_storage_attachments do |t|
17 | t.string :name, null: false
18 | t.references :record, null: false, polymorphic: true, index: false
19 | t.references :blob, null: false
20 |
21 | t.datetime :created_at, null: false
22 |
23 | t.index [ :record_type, :record_id, :name, :blob_id ], name: "index_active_storage_attachments_uniqueness", unique: true
24 | t.foreign_key :active_storage_blobs, column: :blob_id
25 | end
26 | end
27 | end
28 |
--------------------------------------------------------------------------------
/spec/dummy/db/migrate/20180101010101_create_active_admin_comments.rb:
--------------------------------------------------------------------------------
1 | class CreateActiveAdminComments < ActiveRecord::Migration[6.0]
2 | def self.up
3 | create_table :active_admin_comments do |t|
4 | t.string :namespace
5 | t.text :body
6 | t.references :resource, polymorphic: true
7 | t.references :author, polymorphic: true
8 | t.timestamps
9 | end
10 | add_index :active_admin_comments, [:namespace]
11 | end
12 |
13 | def self.down
14 | drop_table :active_admin_comments
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/dummy/db/migrate/20180607053251_create_authors.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class CreateAuthors < ActiveRecord::Migration[5.2]
4 | def change
5 | create_table :authors do |t|
6 | t.string :name
7 | t.integer :age
8 | t.string :email
9 |
10 | t.timestamps
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/spec/dummy/db/migrate/20180607053254_create_profiles.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class CreateProfiles < ActiveRecord::Migration[5.2]
4 | def change
5 | create_table :profiles do |t|
6 | t.text :description
7 | t.belongs_to :author, foreign_key: true
8 |
9 | t.timestamps
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/spec/dummy/db/migrate/20180607053255_create_tags.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class CreateTags < ActiveRecord::Migration[5.2]
4 | def change
5 | create_table :tags do |t|
6 | t.string :name
7 |
8 | t.timestamps
9 | end
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/spec/dummy/db/migrate/20180607053257_create_post_tags.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class CreatePostTags < ActiveRecord::Migration[5.2]
4 | def change
5 | create_table :post_tags do |t|
6 | t.belongs_to :post, foreign_key: true
7 | t.belongs_to :tag, foreign_key: true
8 |
9 | t.timestamps
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/spec/dummy/db/migrate/20180607053739_create_posts.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class CreatePosts < ActiveRecord::Migration[5.2]
4 | def change
5 | create_table :posts do |t|
6 | t.string :title
7 | t.string :state
8 | t.text :summary
9 | t.text :description
10 | t.belongs_to :author, foreign_key: true
11 | t.string :category
12 | t.datetime :dt
13 | t.float :position
14 | t.boolean :published
15 |
16 | t.timestamps
17 | end
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/spec/dummy/db/seeds.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | (11..16).each do |i|
4 | Tag.find_or_create_by!(name: "Tag #{i}")
5 | end
6 |
7 | (11..20).each do |i|
8 | age = 21 + 3 * (i - 10)
9 | attrs = { name: "Author #{i}", age: age, email: "some@email#{i}.com" }
10 | Author.find_or_create_by!(name: "Author #{i}") do |author|
11 | author.assign_attributes(attrs)
12 | author.profile = Profile.new(description: "Profile description for Author #{i}") if (i % 3).zero?
13 | end
14 | end
15 |
16 | authors = Author.pluck(:id)
17 | tags = Tag.where.not(name: 'A test tag').pluck(:id)
18 | (11..40).each do |i|
19 | attrs = {
20 | title: "Post #{i}",
21 | author_id: authors.sample,
22 | position: rand(100),
23 | summary: "Summary for post #{i}
",
24 | description: "Some bold Some italic Some underline [#{i}]
",
25 | created_at: Time.now - rand(3600).seconds
26 | }
27 | attrs[:category] = 'news' if (i % 4).zero?
28 | attrs[:dt] = Time.now - rand(30).days if (i % 3).zero?
29 |
30 | Post.find_or_create_by!(title: "Post #{i}") do |post|
31 | post.assign_attributes(attrs)
32 | post.tags = Tag.where(id: tags.sample(2)) if (i % 2).zero?
33 | end
34 | end
35 |
36 | Author.find_or_create_by!(name: 'A test author', email: 'aaa@bbb.ccc', age: 30)
37 | Tag.find_or_create_by!(name: 'A test tag')
38 |
39 | puts '> Seeds: done.'
40 |
--------------------------------------------------------------------------------
/spec/dummy/lib/assets/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blocknotes/activeadmin_trumbowyg/3b169607851a9ab117ec11a255e61022b24d7987/spec/dummy/lib/assets/.keep
--------------------------------------------------------------------------------
/spec/dummy/public/apple-touch-icon-precomposed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blocknotes/activeadmin_trumbowyg/3b169607851a9ab117ec11a255e61022b24d7987/spec/dummy/public/apple-touch-icon-precomposed.png
--------------------------------------------------------------------------------
/spec/dummy/public/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blocknotes/activeadmin_trumbowyg/3b169607851a9ab117ec11a255e61022b24d7987/spec/dummy/public/apple-touch-icon.png
--------------------------------------------------------------------------------
/spec/dummy/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blocknotes/activeadmin_trumbowyg/3b169607851a9ab117ec11a255e61022b24d7987/spec/dummy/public/favicon.ico
--------------------------------------------------------------------------------
/spec/page_objects/admin/authors/edit_page.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | module Admin
4 | module Authors
5 | class EditPage < BasePage
6 | include Capybara::DSL
7 | end
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/spec/page_objects/admin/posts/edit_page.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | module Admin
4 | module Posts
5 | class EditPage < BasePage
6 | include Capybara::DSL
7 | end
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/spec/page_objects/base_object.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class BaseObject
4 | include Capybara::DSL
5 |
6 | attr_reader :element, :selector
7 |
8 | def initialize(selector:)
9 | @selector = selector
10 | @element = find(selector)
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/spec/page_objects/base_page.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class BasePage
4 | include Capybara::DSL
5 |
6 | attr_reader :path
7 |
8 | def initialize(path:)
9 | @path = path
10 | end
11 |
12 | def load = visit(path)
13 |
14 | def lookup_editor(editor_container:)
15 | @editor = Shared::TrumbowygEditor.new(editor_container)
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/spec/page_objects/shared/html_editor.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | module Shared
4 | class HtmlEditor < BaseObject
5 | def content_element
6 | raise NotImplementedError
7 | end
8 |
9 | def clear
10 | select_all
11 | content_element.send_keys(:delete)
12 | self
13 | end
14 |
15 | # @return [self]
16 | def open_dropdown
17 | raise NotImplementedError
18 | end
19 |
20 | def select_all
21 | content_element.send_keys([:control, "a"])
22 | self
23 | end
24 |
25 | def toolbar_control(control, ...)
26 | send(:"toggle_#{control}", ...)
27 | self
28 | end
29 |
30 | def <<(content)
31 | content_element.send_keys(content)
32 | self
33 | end
34 | end
35 | end
36 |
--------------------------------------------------------------------------------
/spec/page_objects/shared/trumbowyg_editor.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | module Shared
4 | class TrumbowygEditor < HtmlEditor
5 | attr_reader :editor_selector
6 |
7 | def initialize(container)
8 | @editor_selector = "#{container} .trumbowyg-box"
9 | super(selector: editor_selector)
10 | end
11 |
12 | def content = content_element['innerHTML']
13 |
14 | def content_element
15 | @content_element ||= find("#{editor_selector} [contenteditable]")
16 | end
17 |
18 | def toggle_bold = find("#{editor_selector} .trumbowyg-strong-button").click
19 |
20 | def toggle_delete = find("#{editor_selector} .trumbowyg-del-button").click
21 |
22 | def toggle_italic = find("#{editor_selector} .trumbowyg-em-button").click
23 |
24 | def toggle_underline = find("#{editor_selector} .trumbowyg-underline-button").click
25 | end
26 | end
27 |
--------------------------------------------------------------------------------
/spec/rails_helper.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require_relative 'spec_helper'
4 |
5 | require 'zeitwerk'
6 | loader = Zeitwerk::Loader.new
7 | loader.push_dir("#{__dir__}/page_objects")
8 | loader.setup
9 |
10 | ENV['RAILS_ENV'] = 'test'
11 |
12 | require File.expand_path('dummy/config/environment.rb', __dir__)
13 |
14 | abort('The Rails environment is running in production mode!') if Rails.env.production?
15 |
16 | require 'rspec/rails'
17 | require 'capybara/rails'
18 |
19 | Dir[File.expand_path('support/**/*.rb', __dir__)].each { |f| require_relative f }
20 |
21 | # Checks for pending migrations and applies them before tests are run.
22 | # If you are not using ActiveRecord, you can remove these lines.
23 | begin
24 | ActiveRecord::Migration.maintain_test_schema!
25 | rescue ActiveRecord::PendingMigrationError => e
26 | puts e.to_s.strip
27 | exit 1
28 | end
29 |
30 | RSpec.configure do |config|
31 | if Gem::Version.new(Rails.version) >= Gem::Version.new('7.1')
32 | config.fixture_paths = [Rails.root.join('spec/fixtures')]
33 | else
34 | config.fixture_path = Rails.root.join('spec/fixtures')
35 | end
36 |
37 | config.infer_spec_type_from_file_location!
38 | config.filter_rails_from_backtrace!
39 |
40 | config.use_transactional_fixtures = true
41 | config.use_instantiated_fixtures = false
42 | config.render_views = false
43 |
44 | config.before(:suite) do
45 | intro = ('-' * 80)
46 | intro << "\n"
47 | intro << "- Ruby: #{RUBY_VERSION}\n"
48 | intro << "- Rails: #{Rails.version}\n"
49 | intro << "- ActiveAdmin: #{ActiveAdmin::VERSION}\n"
50 | intro << ('-' * 80)
51 |
52 | RSpec.configuration.reporter.message(intro)
53 | end
54 | end
55 |
--------------------------------------------------------------------------------
/spec/spec_helper.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | RSpec.configure do |config|
4 | config.disable_monkey_patching!
5 | config.filter_run focus: true
6 | config.filter_run_excluding changes_filesystem: true
7 | config.run_all_when_everything_filtered = true
8 |
9 | config.color = true
10 | config.tty = true
11 |
12 | config.example_status_persistence_file_path = '.rspec_failures'
13 | config.order = :random
14 | config.shared_context_metadata_behavior = :apply_to_host_groups
15 |
16 | config.expect_with :rspec do |expectations|
17 | expectations.include_chain_clauses_in_custom_matcher_descriptions = true
18 | end
19 | config.mock_with :rspec do |mocks|
20 | mocks.verify_partial_doubles = true
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/spec/support/capybara.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'capybara/cuprite'
4 |
5 | Capybara.register_driver(:capybara_cuprite) do |app|
6 | browser_options = {}.tap do |opts|
7 | opts['no-sandbox'] = nil if ENV['DEVEL']
8 | end
9 |
10 | Capybara::Cuprite::Driver.new(
11 | app,
12 | window_size: [1600, 1280],
13 | browser_options: browser_options,
14 | process_timeout: 20,
15 | timeout: 20,
16 | inspector: true,
17 | headless: !ENV['CUPRITE_HEADLESS'].in?(%w[n 0 no false])
18 | )
19 | end
20 |
21 | # Capybara.server = :puma
22 | Capybara.default_driver = Capybara.javascript_driver = :capybara_cuprite
23 |
24 | RSpec.configure do |config|
25 | config.prepend_before(:each, type: :system) do
26 | driven_by Capybara.javascript_driver
27 | end
28 | end
29 |
--------------------------------------------------------------------------------
/spec/support/string_clean_multiline.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | module StringCleanMultiline
4 | refine String do
5 | def clean_multiline
6 | # Get rid of newlines and indentation spaces
7 | strip.gsub(/\s*\n\s*/, "")
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/spec/system/trumbowyg_js_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | RSpec.describe 'Trumbowyg JS' do
4 | it 'defines a Javascript object for the editor', :aggregate_failures do
5 | visit '/admin/posts'
6 |
7 | expect(page.evaluate_script('typeof jQuery.trumbowyg')).to eq 'object'
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/yarn.lock:
--------------------------------------------------------------------------------
1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2 | # yarn lockfile v1
3 |
4 |
5 | trumbowyg@^2.31.0:
6 | version "2.31.0"
7 | resolved "https://registry.yarnpkg.com/trumbowyg/-/trumbowyg-2.31.0.tgz#377959f76a4fcafd947570720cc986c843434df2"
8 | integrity sha512-I+DMiluTpLDx3yn6LR0TIVR7xIOjgtBQmpEE6Ofd+2yl5ruzY63q/yA/DfBuRVxdK7yDYSBe9FXpVjM1P2NdtA==
9 |
--------------------------------------------------------------------------------