-
Notifications
You must be signed in to change notification settings - Fork 1.1k
action_text-trix
: Add test coverage for Engine
#1258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
Gemfile.lock | ||
pkg | ||
tmp/ | ||
log/ | ||
storage/ | ||
vendor/ |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a reviewable file that was not generated by |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
require "bundler/gem_tasks" | ||
require "rake/clean" | ||
|
||
begin | ||
APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__) | ||
load "rails/tasks/engine.rake" rescue nil | ||
rescue LoadError | ||
# do nothing | ||
end | ||
Comment on lines
+4
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This |
||
|
||
task :sync do | ||
require "json" | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env ruby | ||
# This command will automatically be run when you run "rails" with Rails gems | ||
# installed from the root of your application. | ||
|
||
ENGINE_ROOT = File.expand_path('..', __dir__) | ||
ENGINE_PATH = File.expand_path('../lib/action_text/trix/engine.rb', __dir__) | ||
APP_PATH = File.expand_path('../test/dummy/config/application', __dir__) | ||
|
||
# Set up gems listed in the Gemfile. | ||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) | ||
require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"]) | ||
|
||
require "rails/all" | ||
require "rails/test_unit/railtie" | ||
require "rails/engine/commands" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
|
||
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase | ||
driven_by :cuprite, using: :chrome, options: { | ||
js_errors: true, | ||
headless: ENV["HEADLESS"] != "0" | ||
} | ||
end | ||
|
||
Capybara.server = :puma, { Silent: true } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Add your own tasks in files placed in lib/tasks ending in .rake, | ||
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. | ||
|
||
require_relative "config/application" | ||
|
||
Rails.application.load_tasks |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* This is a manifest file that'll be compiled into application.css, which will include all the files | ||
* listed below. | ||
* | ||
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, | ||
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path. | ||
* | ||
* You're free to add application-wide styles to this file and they'll appear at the bottom of the | ||
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS | ||
* files in this directory. Styles in this file should be added after the last require_* statement. | ||
* It is generally better to create a new file per style scope. | ||
* | ||
*= require_tree . | ||
*= require_self | ||
*/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class ApplicationController < ActionController::Base | ||
# Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has. | ||
allow_browser versions: :modern | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class MessagesController < ApplicationController | ||
def index | ||
@messages = Message.all | ||
end | ||
|
||
def new | ||
@message = Message.new | ||
end | ||
|
||
def create | ||
@message = Message.create!(message_params) | ||
|
||
redirect_to action: :index | ||
end | ||
|
||
private | ||
def message_params | ||
if params.respond_to?(:expect) | ||
params.expect(message: [ :subject, :content ]) | ||
else | ||
params.require(:message).permit(:subject, :content) | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails | ||
import "trix" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class ApplicationRecord < ActiveRecord::Base | ||
primary_abstract_class | ||
end |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a reviewable file that was not generated by |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class Message < ApplicationRecord | ||
has_rich_text :content | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<figure class="attachment attachment--<%= blob.representable? ? "preview" : "file" %> attachment--<%= blob.filename.extension %>"> | ||
<% if blob.representable? %> | ||
<%= image_tag blob.representation(resize_to_limit: local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ]) %> | ||
<% end %> | ||
|
||
<figcaption class="attachment__caption"> | ||
<% if caption = blob.try(:caption) %> | ||
<%= caption %> | ||
<% else %> | ||
<span class="attachment__name"><%= blob.filename %></span> | ||
<span class="attachment__size"><%= number_to_human_size blob.byte_size %></span> | ||
<% end %> | ||
</figcaption> | ||
</figure> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div class="trix-content"> | ||
<%= yield -%> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title><%= content_for(:title) || "Dummy" %></title> | ||
<meta name="viewport" content="width=device-width,initial-scale=1"> | ||
<meta name="apple-mobile-web-app-capable" content="yes"> | ||
<meta name="mobile-web-app-capable" content="yes"> | ||
<%= csrf_meta_tags %> | ||
<%= csp_meta_tag %> | ||
|
||
<%= yield :head %> | ||
|
||
<%# Enable PWA manifest for installable apps (make sure to enable in config/routes.rb too!) %> | ||
<%#= tag.link rel: "manifest", href: pwa_manifest_path(format: :json) %> | ||
|
||
<link rel="icon" href="/icon.png" type="image/png"> | ||
<link rel="icon" href="/icon.svg" type="image/svg+xml"> | ||
<link rel="apple-touch-icon" href="/icon.png"> | ||
|
||
<%# Includes all stylesheet files in app/assets/stylesheets %> | ||
<%= stylesheet_link_tag :app %> | ||
<%= javascript_importmap_tags %> | ||
</head> | ||
|
||
<body> | ||
<%= yield %> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | ||
<style> | ||
/* Email styles need to be inline */ | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<%= yield %> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%= yield %> |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a reviewable file that was not generated by |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<%= form_with(model: message) do |form| %> | ||
<%= form.label :subject %> <br> | ||
<%= form.text_field :subject %> <br> | ||
|
||
<%= form.label :content %> <br> | ||
<%= form.rich_text_area :content %> | ||
|
||
<%= form.submit %> | ||
<% end %> |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a reviewable file that was not generated by |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<h1>Messages</h1> | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<th>Subject</th> | ||
<th>Content</th> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
<% @messages.each do |message| %> | ||
<tr> | ||
<td><%= message.subject %></td> | ||
<td><%= message.content %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<h1>New Message</h1> | ||
|
||
<%= render "form", message: @message %> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "Dummy", | ||
"icons": [ | ||
{ | ||
"src": "/icon.png", | ||
"type": "image/png", | ||
"sizes": "512x512" | ||
}, | ||
{ | ||
"src": "/icon.png", | ||
"type": "image/png", | ||
"sizes": "512x512", | ||
"purpose": "maskable" | ||
} | ||
], | ||
"start_url": "/", | ||
"display": "standalone", | ||
"scope": "/", | ||
"description": "Dummy.", | ||
"theme_color": "red", | ||
"background_color": "red" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Add a service worker for processing Web Push notifications: | ||
// | ||
// self.addEventListener("push", async (event) => { | ||
// const { title, options } = await event.data.json() | ||
// event.waitUntil(self.registration.showNotification(title, options)) | ||
// }) | ||
// | ||
// self.addEventListener("notificationclick", function(event) { | ||
// event.notification.close() | ||
// event.waitUntil( | ||
// clients.matchAll({ type: "window" }).then((clientList) => { | ||
// for (let i = 0; i < clientList.length; i++) { | ||
// let client = clientList[i] | ||
// let clientPath = (new URL(client.url)).pathname | ||
// | ||
// if (clientPath == event.notification.data.path && "focus" in client) { | ||
// return client.focus() | ||
// } | ||
// } | ||
// | ||
// if (clients.openWindow) { | ||
// return clients.openWindow(event.notification.data.path) | ||
// } | ||
// }) | ||
// ) | ||
// }) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/usr/bin/env ruby | ||
exec "./bin/rails", "server", *ARGV |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require_relative "../config/application" | ||
require "importmap/commands" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env ruby | ||
APP_PATH = File.expand_path("../config/application", __dir__) | ||
require_relative "../config/boot" | ||
require "rails/commands" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env ruby | ||
require_relative "../config/boot" | ||
require "rake" | ||
Rake.application.run |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env ruby | ||
require "fileutils" | ||
|
||
APP_ROOT = File.expand_path("..", __dir__) | ||
|
||
def system!(*args) | ||
system(*args, exception: true) | ||
end | ||
|
||
FileUtils.chdir APP_ROOT do | ||
# This script is a way to set up or update your development environment automatically. | ||
# This script is idempotent, so that you can run it at any time and get an expectable outcome. | ||
# Add necessary setup steps to this file. | ||
|
||
puts "== Installing dependencies ==" | ||
system("bundle check") || system!("bundle install") | ||
|
||
# puts "\n== Copying sample files ==" | ||
# unless File.exist?("config/database.yml") | ||
# FileUtils.cp "config/database.yml.sample", "config/database.yml" | ||
# end | ||
|
||
puts "\n== Preparing database ==" | ||
system! "bin/rails db:prepare" | ||
|
||
puts "\n== Removing old logs and tempfiles ==" | ||
system! "bin/rails log:clear tmp:clear" | ||
|
||
unless ARGV.include?("--skip-server") | ||
puts "\n== Starting development server ==" | ||
STDOUT.flush # flush the output before exec(2) so that it displays | ||
exec "bin/dev" | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# This file is used by Rack-based servers to start the application. | ||
|
||
require_relative "config/environment" | ||
|
||
run Rails.application | ||
Rails.application.load_server |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a reviewable file that was not generated by
rails plugin new
.