Skip to content

Commit

Permalink
Merge pull request #18 from weedySeaDragon/201216-rails5-old-changes-…
Browse files Browse the repository at this point in the history
…simplify

201216 rails5 old changes simplify
  • Loading branch information
weedySeaDragon authored Dec 16, 2020
2 parents eb5efbf + a904158 commit 18a5358
Show file tree
Hide file tree
Showing 107 changed files with 5,861 additions and 3,229 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.0
2.5.8
55 changes: 29 additions & 26 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
PATH
remote: .
specs:
surveyor (1.6.0)
formtastic (~> 2.2.1)
haml (~> 4.0)
surveyor (1.6.6)
formtastic (>= 2.2.1)
haml (>= 4.0)
mustache (~> 0.99)
rabl (~> 0.6)
rails (>= 4)
rails (~> 5)
sass
uuidtools (~> 2.1)

Expand Down Expand Up @@ -65,22 +65,23 @@ GEM
database_cleaner (1.2.0)
diff-lcs (1.3)
erubis (2.7.0)
factory_girl (4.4.0)
activesupport (>= 3.0.0)
ffi (1.9.18)
formtastic (2.2.1)
actionpack (>= 3.0)
factory_bot (6.1.0)
activesupport (>= 5.0.0)
ffi (1.13.1)
formtastic (3.1.5)
actionpack (>= 3.2.13)
globalid (0.4.0)
activesupport (>= 4.2.0)
haml (4.0.7)
haml (5.2.1)
temple (>= 0.8.0)
tilt
i18n (0.8.1)
json_spec (1.1.4)
multi_json (~> 1.0)
rspec (>= 2.0, < 4.0)
launchy (2.4.3)
addressable (~> 2.3)
libv8 (3.16.14.19-x86_64-darwin-15)
libv8 (3.16.14.19)
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.4)
Expand All @@ -96,13 +97,14 @@ GEM
nio4r (2.0.0)
nokogiri (1.7.1)
mini_portile2 (~> 2.1.0)
pg (0.21.0)
poltergeist (1.5.1)
capybara (~> 2.1)
cliver (~> 0.3.1)
multi_json (~> 1.0)
websocket-driver (>= 0.2.0)
public_suffix (2.0.5)
rabl (0.13.1)
rabl (0.14.3)
activesupport (>= 2.3.14)
rack (2.0.1)
rack-test (0.6.3)
Expand Down Expand Up @@ -131,9 +133,9 @@ GEM
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (12.0.0)
rb-fsevent (0.10.2)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
rb-fsevent (0.10.4)
rb-inotify (0.10.1)
ffi (~> 1.0)
ref (2.0.0)
rspec (3.5.0)
rspec-core (~> 3.5.0)
Expand All @@ -158,7 +160,7 @@ GEM
rspec-retry (0.5.3)
rspec-core (> 3.3, < 3.6)
rspec-support (3.5.0)
sass (3.5.2)
sass (3.7.4)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
Expand All @@ -170,16 +172,16 @@ GEM
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.13)
temple (0.8.2)
therubyracer (0.12.3)
libv8 (~> 3.16.14.15)
ref
thor (0.19.4)
thread_safe (0.3.6)
tilt (2.0.8)
tilt (2.0.10)
tzinfo (1.2.3)
thread_safe (~> 0.1)
uuidtools (2.1.5)
uuidtools (2.2.0)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
Expand All @@ -191,20 +193,21 @@ PLATFORMS
ruby

DEPENDENCIES
capybara (~> 2.2.1)
capybara (>= 2.2.1)
database_cleaner
factory_girl
factory_bot
json_spec
launchy (~> 2.4.2)
poltergeist (~> 1.5.0)
rails (~> 5.0.0)
launchy (>= 2.4.2)
pg
poltergeist (~> 1.5)
rails (~> 5)
rake
rspec (~> 3)
rspec-rails
rspec-retry
sqlite3
surveyor!
therubyracer
yard

BUNDLED WITH
1.15.1
1.17.3
2 changes: 1 addition & 1 deletion Gemfile.rails_version
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ case env_rails_version
when "master"
{github: "rails/rails"}
when "default"
gem "rails", "~> 5.0.0"
gem "rails", "~> 5"
# A JS runtime is required for Rails 4.0+
gem 'therubyracer', platforms: :ruby
when /^3.2/
Expand Down
2 changes: 1 addition & 1 deletion MIT-LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2016-2017 Ashley Engelund
Copyright (c) 2016-2020 Ashley Engelund

Copyright (c) 2008-2016 Brian Chamberlain and Mark Yoon

Expand Down
83 changes: 72 additions & 11 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
$LOAD_PATH << File.expand_path('../lib', __FILE__)

require 'rake/task'
require 'fileutils'

require 'rspec/core/rake_task'

require 'tempfile'


###### RSPEC

#RSpec::Core::RakeTask.new(:spec)
Expand All @@ -13,54 +18,110 @@ require 'rspec/core/rake_task'

task :default => :spec



namespace :factory_bot do
desc "Lint factories: Verify that all FactoryBot factories are valid"
task :lint do
require 'active_record'

if Rails.env.test?
conn = ActiveRecord::Base.connection
conn.transaction do
FactoryBot.lint
raise ActiveRecord::Rollback
end
else
system("bundle exec rake factory_bot:lint RAILS_ENV='test'")
fail if $?.exitstatus.nonzero?
end
end
end


###### TESTBED

desc 'Set up the rails app that the specs and features use'
task :testbed => 'testbed:rebuild'


namespace :testbed do

TESTBED = 'dummy'
TESTBED_PATH = File.join(__dir__, 'spec', TESTBED)

desc 'Generate a minimal surveyor-using rails app'
task :generate do

Tempfile.open('surveyor_Rakefile') do |f|
f.write("application \"config.time_zone='Rome'\"\n")
f.write("application \"config.time_zone='Pacific Time (US & Canada)'\"\n")
f.flush
sh "bundle exec rails new testbed --skip-bundle -m #{f.path}" # don't run bundle install until the Gemfile modifications
sh "bundle exec rails new #{TESTBED_PATH} --skip-bundle --database=postgresql -m #{f.path}" # don't run bundle install until the Gemfile modifications
end
chdir('testbed') do

copy('Gemfile.rails_version', TESTBED_PATH)

testbed_gemfile_path = File.join(TESTBED_PATH, 'Gemfile')

cd(TESTBED_PATH) do
gem_file_contents = File.read('Gemfile')
gem_file_contents.sub!(/^(gem 'rails'.*)$/, %Q{# \\1\nplugin_root = File.expand_path('../..', __FILE__)\neval(File.read File.join(plugin_root, 'Gemfile.rails_version'))\ngem 'surveyor', :path => plugin_root})
File.open('Gemfile', 'w'){|f| f.write(gem_file_contents) }
gem_file_contents.sub!(/^(gem 'rails'.*)$/, %Q{# \\1\nplugin_root = File.expand_path('../../..', __FILE__)\neval(File.read 'Gemfile.rails_version')\ngem 'surveyor', :path => plugin_root})
File.open(testbed_gemfile_path, 'w') { |f| f.write(gem_file_contents) }

Bundler.with_clean_env do
sh 'bundle install' # run bundle install after Gemfile modifications
sh 'bundle install' # run bundle install after Gemfile modifications
end
end

end


desc 'create and migrate the dummy test database'
task :create_dbdb do

chdir(TESTBED_PATH) do
sh 'bundle exec rails db:environment:set RAILS_ENV=test'
# installing surveyor will copy the db/migrate files, etc.
sh 'bundle exec rails generate surveyor:install'
sh 'bundle exec rails db:drop RAILS_ENV=test'
sh 'bundle exec rails db:create RAILS_ENV=test'
sh 'bundle exec rails db:migrate RAILS_ENV=test'
end
end


desc 'Prepare the databases for the testbed'
task :migrate do
chdir('testbed') do
cd(TESTBED_PATH) do
Bundler.with_clean_env do
sh 'bundle exec rails generate surveyor:install'
sh 'bundle exec rake db:migrate db:test:prepare'
# sh 'bundle exec rails generate surveyor:install'
sh 'bundle exec rails db:environment:set RAILS_ENV=test'
sh 'bundle exec rails db:drop RAILS_ENV=test'
sh 'bundle exec rails db:create RAILS_ENV=test'
sh 'bundle exec rake db:migrate RAILS_ENV=test'
sh 'bundle exec rake db:test:prepare RAILS_ENV=test'
end
end
end


desc 'Remove the testbed entirely'
task :remove do
rm_rf 'testbed'
rm_rf "#{TESTBED_PATH}"
end


task :rebuild => [:remove, :generate, :migrate]

desc 'Load all the sample surveys into the testbed instance'
task :surveys do
cd('testbed') do
cd(TESTBED_PATH) do
Dir[File.join('surveys', '*.rb')].each do |fn|
puts "Installing #{fn} into the testbed"
system("rake surveyor FILE='#{fn}'")
end
end
end


end
Empty file removed app/models/.keep
Empty file.
14 changes: 8 additions & 6 deletions config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ default: &default
# For details on connection pooling, see rails configuration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling
pool: 5
username: ashleyengelund


development:
<<: *default
database: base-r428-devise-pundit-boots_development
database: ae-surveyor_development

# The specified database role being used to connect to postgres.
# To create additional roles in postgres see `$ createuser --help`.
Expand Down Expand Up @@ -57,7 +59,7 @@ development:
# Do not set this db to the same as development or production.
test: &test
<<: *default
database: base-r428-devise-pundit-boots_test
database: ae-surveyor_test

# As with config/secrets.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
Expand All @@ -76,13 +78,13 @@ test: &test
# You can use this database configuration with:
#
# production:
# url: <%= ENV['DATABASE_URL'] %>
# url: <%= ENV['AE-SURVEYOR_DATABASE_URL'] %>
#
production:
<<: *default
database: base-r428-devise-pundit-boots_production
username: base-r428-devise-pundit-boots
password: <%= ENV['BASE-R428-DEVISE-PUNDIT-BOOTS_DATABASE_PASSWORD'] %>
database: <%= ENV['AE-SURVEYOR_DATABASE_DBNAME'] %>
username: <%= ENV['AE-SURVEYOR_DATABASE_USERNAME'] %>
password: <%= ENV['AE-SURVEYOR_DATABASE_PASSWORD'] %>

cucumber:
<<: *test
8 changes: 6 additions & 2 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false


# Configure static file server for tests with Cache-Control for performance.
config.serve_static_files = true
config.static_cache_control = 'public, max-age=3600'
# config.serve_static_files = true
config.public_file_server.enabled = true

# config.static_cache_control = 'public, max-age=3600'
config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }

# Show full error reports and disable caching.
config.consider_all_requests_local = true
Expand Down
32 changes: 32 additions & 0 deletions db/migrate/20170402095627_create_surveys.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# encoding: UTF-8
class CreateSurveys < ActiveRecord::Migration[5.0]
def self.up
create_table :surveys do |t|
# Content
t.string :title
t.text :description

# Reference
t.string :access_code
t.string :reference_identifier # from paper
t.string :data_export_identifier # data export
t.string :common_namespace # maping to a common vocab
t.string :common_identifier # maping to a common vocab

# Expiry
t.datetime :active_at
t.datetime :inactive_at

# Display
t.string :css_url

t.string :custom_class

t.timestamps
end
end

def self.down
drop_table :surveys
end
end
Loading

0 comments on commit 18a5358

Please sign in to comment.