Skip to content

Commit

Permalink
chore: Create new dummy app with Rails 5
Browse files Browse the repository at this point in the history
  • Loading branch information
toupeira committed Oct 5, 2016
1 parent 8a59442 commit 496cca0
Show file tree
Hide file tree
Showing 66 changed files with 656 additions and 680 deletions.
24 changes: 5 additions & 19 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
*.gem
*.rbc
.bundle
.config
.yardoc
Gemfile.lock
InstalledFiles
_yardoc
coverage
doc/
lib/bundler/man
pkg
rdoc
spec/dummy/log
spec/reports
test/tmp
test/version_tmp
tmp
.idea/
/.bundle
/Gemfile.lock
/spec/dummy/db/*.sqlite3
/spec/dummy/log/*.log
/spec/dummy/tmp/
1 change: 1 addition & 0 deletions doorkeeper-openid_connect.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency 'sandal', '~> 0.6'

spec.add_development_dependency 'rspec-rails'
spec.add_development_dependency 'factory_girl'
spec.add_development_dependency 'rails'
spec.add_development_dependency 'sqlite3'
end
2 changes: 2 additions & 0 deletions spec/dummy/.rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--color
--require spec_helper
5 changes: 2 additions & 3 deletions spec/dummy/Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env rake
# 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 File.expand_path('../config/application', __FILE__)
require_relative 'config/application'

Dummy::Application.load_tasks
Rails.application.load_tasks
3 changes: 3 additions & 0 deletions spec/dummy/app/assets/config/manifest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

//= link_tree ../images
//= link_directory ../stylesheets .css
File renamed without changes.
13 changes: 13 additions & 0 deletions spec/dummy/app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file. JavaScript code in this file should be added after the last require_* statement.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require_tree .
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, 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
*/
4 changes: 4 additions & 0 deletions spec/dummy/app/channels/application_cable/channel.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module ApplicationCable
class Channel < ActionCable::Channel::Base
end
end
4 changes: 4 additions & 0 deletions spec/dummy/app/channels/application_cable/connection.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module ApplicationCable
class Connection < ActionCable::Connection::Base
end
end
2 changes: 1 addition & 1 deletion spec/dummy/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class ApplicationController < ActionController::Base
protect_from_forgery
protect_from_forgery with: :exception
end
Empty file.

This file was deleted.

12 changes: 0 additions & 12 deletions spec/dummy/app/controllers/full_protected_resources_controller.rb

This file was deleted.

17 changes: 0 additions & 17 deletions spec/dummy/app/controllers/home_controller.rb

This file was deleted.

11 changes: 0 additions & 11 deletions spec/dummy/app/controllers/metal_controller.rb

This file was deleted.

11 changes: 0 additions & 11 deletions spec/dummy/app/controllers/semi_protected_resources_controller.rb

This file was deleted.

3 changes: 0 additions & 3 deletions spec/dummy/app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
module ApplicationHelper
def current_user
@current_user ||= User.find_by_id(session[:user_id])
end
end
2 changes: 2 additions & 0 deletions spec/dummy/app/jobs/application_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class ApplicationJob < ActiveJob::Base
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.
36 changes: 5 additions & 31 deletions spec/dummy/app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,31 +1,5 @@
# case DOORKEEPER_ORM
# when :active_record
# class User < ActiveRecord::Base
# end
# when :mongoid2, :mongoid3, :mongoid4
# class User
# include Mongoid::Document
# include Mongoid::Timestamps
#
# field :name, type: String
# field :password, type: String
# end
# when :mongo_mapper
# class User
# include MongoMapper::Document
# timestamps!
#
# key :name, String
# key :password, String
# end
# end
#
# class User
# if ::Rails.version.to_i < 4
# attr_accessible :name, :password
# end
#
# def self.authenticate!(name, password)
# User.where(name: name, password: password).first
# end
# end
class User < ActiveRecord::Base
def self.authenticate!(name, password)
User.where(name: name, password: password).first
end
end
14 changes: 0 additions & 14 deletions spec/dummy/app/views/layouts/application.html.erb

This file was deleted.

3 changes: 3 additions & 0 deletions spec/dummy/bin/bundle
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
load Gem.bin_path('bundler', 'bundle')
4 changes: 4 additions & 0 deletions spec/dummy/bin/rails
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'
4 changes: 4 additions & 0 deletions spec/dummy/bin/rake
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
34 changes: 34 additions & 0 deletions spec/dummy/bin/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env ruby
require 'pathname'
require 'fileutils'
include FileUtils

# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)

def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end

chdir APP_ROOT do
# This script is a starting point to setup your application.
# Add necessary setup steps to this file.

puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')

# puts "\n== Copying sample files =="
# unless File.exist?('config/database.yml')
# cp 'config/database.yml.sample', 'config/database.yml'
# end

puts "\n== Preparing database =="
system! 'bin/rails db:setup'

puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'

puts "\n== Restarting application server =="
system! 'bin/rails restart'
end
29 changes: 29 additions & 0 deletions spec/dummy/bin/update
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env ruby
require 'pathname'
require 'fileutils'
include FileUtils

# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)

def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end

chdir APP_ROOT do
# This script is a way to update your development environment automatically.
# Add necessary update steps to this file.

puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')

puts "\n== Updating database =="
system! 'bin/rails db:migrate'

puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'

puts "\n== Restarting application server =="
system! 'bin/rails restart'
end
5 changes: 3 additions & 2 deletions spec/dummy/config.ru
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment', __FILE__)
run Dummy::Application
require_relative 'config/environment'

run Rails.application
51 changes: 6 additions & 45 deletions spec/dummy/config/application.rb
Original file line number Diff line number Diff line change
@@ -1,55 +1,16 @@
require File.expand_path('../boot', __FILE__)
require_relative 'boot'

require 'action_controller/railtie'
require 'active_support/core_ext/numeric'
require 'sprockets/railtie'
# Pick the frameworks you want:
require "active_record/railtie"
require "action_controller/railtie"
require "action_view/railtie"

Bundler.require :default

# orm = if [:mongoid2, :mongoid3, :mongoid4].include?(DOORKEEPER_ORM)
# Mongoid.load!(File.join(File.dirname(File.expand_path(__FILE__)), "#{DOORKEEPER_ORM}.yml"))
# :mongoid
# else
# DOORKEEPER_ORM
# end
#
# require "#{orm}/railtie"
Bundler.require(*Rails.groups)

module Dummy
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.

# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]

# Activate observers that should always be running.
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer

# if defined?(ActiveRecord) && Rails.version.to_i < 4
# config.active_record.whitelist_attributes = true
# end

# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'

# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
config.i18n.load_path += Dir[Rails.root.join('../../', 'config/locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :en

# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = 'utf-8'

# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]

# Enable the asset pipeline
config.assets.enabled = true

# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
end
end
9 changes: 4 additions & 5 deletions spec/dummy/config/boot.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require 'rubygems'
require 'bundler/setup'
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)

DOORKEEPER_ORM = (ENV['orm'] || :active_record).to_sym unless defined?(DOORKEEPER_ORM)

$LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
$LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
Loading

0 comments on commit 496cca0

Please sign in to comment.