Skip to content

Commit

Permalink
Merge pull request #22 from dkniffin/add-test-application
Browse files Browse the repository at this point in the history
Add test application
  • Loading branch information
dkniffin authored Jul 11, 2024
2 parents 03a82f0 + 187f529 commit 81ba02a
Show file tree
Hide file tree
Showing 85 changed files with 1,812 additions and 3 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/rubyonrails.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow uses actions that are not certified by GitHub. They are
# provided by a third-party and are governed by separate terms of service,
# privacy policy, and support documentation.
#
# This workflow will install a prebuilt Ruby version, install dependencies, and
# run tests and linters.
name: "Ruby on Rails CI"
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
test:
runs-on: ubuntu-latest
env:
RAILS_ENV: test
steps:
- name: Checkout code
uses: actions/checkout@v4
# Add or replace dependency steps here
- name: Install Ruby and gems
uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0
with:
bundler-cache: true
# Add or replace database setup steps here
- name: Set up database schema
run: cd spec/dummy && bundle exec rails db:schema:load
# Add or replace test runners here
- name: Run tests
run: bundle exec rspec
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,11 @@ builds/*
Gemfile.lock
node_modules
*.gem
spec/dummy/db/*.sqlite3
spec/dummy/db/*.sqlite3-journal
spec/dummy/log/*.log
spec/dummy/tmp/
spec/dummy/.sass-cache
spec/dummy/public/system
spec/dummy/public/packs-test
spec/dummy/public/packs
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.1.4
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source 'https://rubygems.org'
source "https://rubygems.org"

gemspec
14 changes: 13 additions & 1 deletion activeadmin_reorderable.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,17 @@ Gem::Specification.new do |s|

s.files = `git ls-files`.split($/)

s.add_development_dependency "activeadmin", ">= 0.6"
s.add_development_dependency "activeadmin", "~> 3.0"
s.add_development_dependency "acts_as_list"
s.add_development_dependency "capybara"
s.add_development_dependency "database_cleaner"
s.add_development_dependency "factory_bot_rails"
s.add_development_dependency "pry"
s.add_development_dependency "puma"
s.add_development_dependency "rails", "~> 6.1", ">= 6.1.4.4"
s.add_development_dependency "rspec-rails"
s.add_development_dependency "selenium-webdriver", '~> 4.10'
s.add_development_dependency "site_prism"
s.add_development_dependency "sqlite3", "~> 1.4"
s.add_development_dependency "sassc-rails"
end
2 changes: 1 addition & 1 deletion app/assets/javascripts/activeadmin_reorderable.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ $.fn.reorderable = function (opts) {
$.post(url, {
position: index($row),
top_id: top_id,
bottom_id: bottom_id
bottom_id: bottom_id
});
}

Expand Down
1 change: 1 addition & 0 deletions spec/dummy/.ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby-3.1.4
24 changes: 24 additions & 0 deletions spec/dummy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# README

This README would normally document whatever steps are necessary to get the
application up and running.

Things you may want to cover:

* Ruby version

* System dependencies

* Configuration

* Database creation

* Database initialization

* How to run the test suite

* Services (job queues, cache servers, search engines, etc.)

* Deployment instructions

* ...
6 changes: 6 additions & 0 deletions spec/dummy/Rakefile
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
33 changes: 33 additions & 0 deletions spec/dummy/app/admin/dashboard.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true
ActiveAdmin.register_page "Dashboard" do
menu priority: 1, label: proc { I18n.t("active_admin.dashboard") }

content title: proc { I18n.t("active_admin.dashboard") } do
div class: "blank_slate_container", id: "dashboard_default_message" do
span class: "blank_slate" do
span I18n.t("active_admin.dashboard_welcome.welcome")
small I18n.t("active_admin.dashboard_welcome.call_to_action")
end
end

# Here is an example of a simple dashboard with columns and panels.
#
# columns do
# column do
# panel "Recent Posts" do
# ul do
# Post.recent(5).map do |post|
# li link_to(post.title, admin_post_path(post))
# end
# end
# end
# end

# column do
# panel "Info" do
# para "Welcome to ActiveAdmin."
# end
# end
# end
end # content
end
5 changes: 5 additions & 0 deletions spec/dummy/app/admin/item.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ActiveAdmin.register Item do
permit_params :id, :name, :description, :position, :item_queue_id

reorderable
end
14 changes: 14 additions & 0 deletions spec/dummy/app/admin/item_queue.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ActiveAdmin.register ItemQueue do
show do |item_queue|
attributes_table do
row :id
row :created_at
row :updated_at
end

reorderable_table_for item_queue.items do
column :name
column :description
end
end
end
2 changes: 2 additions & 0 deletions spec/dummy/app/assets/config/manifest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
//= link_tree ../images
//= link_directory ../stylesheets .css
Empty file.
2 changes: 2 additions & 0 deletions spec/dummy/app/assets/javascripts/active_admin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
//= require active_admin/base
//= require activeadmin_reorderable
19 changes: 19 additions & 0 deletions spec/dummy/app/assets/stylesheets/active_admin.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Sass variable overrides must be declared before loading up Active Admin's styles.
//
// To view the variables that Active Admin provides, take a look at
// `app/assets/stylesheets/active_admin/mixins/_variables.scss` in the
// Active Admin source.
//
// For example, to change the sidebar width:
// $sidebar-width: 242px;

// Active Admin's got SASS!
@import "active_admin/mixins";
@import "active_admin/base";

// Overriding any non-variable Sass must be done after the fact.
// For example, to change the default status-tag color:
//
// .status_tag { background: #6090DB; }

@import "activeadmin_reorderable";
15 changes: 15 additions & 0 deletions spec/dummy/app/assets/stylesheets/application.css
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, 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
*/
2 changes: 2 additions & 0 deletions spec/dummy/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class ApplicationController < ActionController::Base
end
Empty file.
2 changes: 2 additions & 0 deletions spec/dummy/app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module ApplicationHelper
end
8 changes: 8 additions & 0 deletions spec/dummy/app/javascript/packs/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// This file is automatically compiled by Webpack, along with any other files
// present in this directory. You're encouraged to place your actual application logic in
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.

import Rails from "@rails/ujs"

Rails.start()
7 changes: 7 additions & 0 deletions spec/dummy/app/jobs/application_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class ApplicationJob < ActiveJob::Base
# Automatically retry jobs that encountered a deadlock
# retry_on ActiveRecord::Deadlocked

# Most jobs are safe to ignore if the underlying records are no longer available
# discard_on ActiveJob::DeserializationError
end
4 changes: 4 additions & 0 deletions spec/dummy/app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class ApplicationMailer < ActionMailer::Base
default from: 'from@example.com'
layout 'mailer'
end
3 changes: 3 additions & 0 deletions spec/dummy/app/models/application_record.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
Empty file.
14 changes: 14 additions & 0 deletions spec/dummy/app/models/item.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require "acts_as_list"

class Item < ApplicationRecord
belongs_to :item_queue
acts_as_list scope: :item_queue

def self.ransackable_attributes(auth_object = nil)
["created_at", "description", "id", "name", "position", "updated_at"]
end

def self.ransackable_associations(auth_object = nil)
["item_queue"]
end
end
11 changes: 11 additions & 0 deletions spec/dummy/app/models/item_queue.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class ItemQueue < ApplicationRecord
has_many :items, -> { order(position: :asc) }

def self.ransackable_attributes(auth_object = nil)
["created_at", "id", "updated_at"]
end

def self.ransackable_associations(auth_object = nil)
["items"]
end
end
16 changes: 16 additions & 0 deletions spec/dummy/app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<title>Dummy</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= stylesheet_link_tag 'application', media: 'all' %>
<%= javascript_pack_tag 'application' %>
</head>

<body>
<%= yield %>
</body>
</html>
13 changes: 13 additions & 0 deletions spec/dummy/app/views/layouts/mailer.html.erb
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>
1 change: 1 addition & 0 deletions spec/dummy/app/views/layouts/mailer.text.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= yield %>
Loading

0 comments on commit 81ba02a

Please sign in to comment.