diff --git a/.codeclimate.yml b/.codeclimate.yml index 4112980..b8f2cec 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -30,6 +30,7 @@ exclude_paths: - app/assets/javascripts/app.js - bin/** - db/** + - config/** - public/assets/** - spec/** - UI/** diff --git a/Gemfile b/Gemfile index 6ff1d5b..bf2c3f7 100644 --- a/Gemfile +++ b/Gemfile @@ -27,6 +27,14 @@ gem 'lograge', '~> 0.4.1' gem 'omniauth-github', '~> 1.1.2' gem 'rake', '~> 10.5.0 ' +group :development do + gem 'dotenv-rails', '~> 2.0.0' + gem 'powder', '~> 0.3.0' + gem 'rails_best_practices', '~> 1.16.0' + gem 'spring', '~> 1.7.2' + gem 'spring-commands-rspec', '~> 1.0.4' +end + group :development, :test do gem 'capybara', '~> 2.4.4' gem 'capybara-webkit', '~> 1.4.1' @@ -37,17 +45,12 @@ group :development, :test do gem 'rspec-rails', '~> 3.5.1', require: false end -group :development do - gem 'dotenv-rails', '~> 2.0.0' - gem 'powder', '~> 0.3.0' - gem 'rails_best_practices', '~> 1.16.0' - gem 'spring', '~> 1.7.2' - gem 'spring-commands-rspec', '~> 1.0.4' -end - group :production do gem 'airbrake', '~> 5.4.3' gem 'newrelic_rpm', '~> 3.16.0.318' +end + +group :production, :review do gem 'rails_12factor', '~> 0.0.3' end diff --git a/Rakefile b/Rakefile index 3f4fbcc..a5989df 100644 --- a/Rakefile +++ b/Rakefile @@ -3,6 +3,6 @@ require File.expand_path('../config/application', __FILE__) -require 'rspec-rails' unless Rails.env.production? +require 'rspec-rails' unless Rails.env.in?(%w{production review}) Rails.application.load_tasks diff --git a/app.json b/app.json new file mode 100644 index 0000000..42a6a90 --- /dev/null +++ b/app.json @@ -0,0 +1,45 @@ +{ + "name": "wdt-stage", + "image": "heroku/ruby", + "scripts": { + "postdeploy": "rake db:migrate db:seed" + }, + "env": { + "GITHUB_APP_NAME": { + "required": true + }, + "GITHUB_CLIENT_ID": { + "required": true + }, + "GITHUB_CLIENT_SECRET": { + "required": true + }, + "GOOGLE_MAPS_API_KEY": { + "required": true + }, + "HEROKU_APP_NAME": { + "required": true + }, + "LANG": { + "required": true + }, + "MAINTENANCE_PAGE_URL": { + "required": true + }, + "RACK_ENV": { + "required": true + }, + "RAILS_ENV": "review", + "SECRET_KEY_BASE": { + "generator": "secret" + } + }, + "formation": { + "web": { + "quantity": 1 + } + }, + "addons": [ + "heroku-postgresql:hobby-dev" + ] +} diff --git a/config/environments/review.rb b/config/environments/review.rb new file mode 100644 index 0000000..c15015a --- /dev/null +++ b/config/environments/review.rb @@ -0,0 +1,90 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = true + + # Asset digests allow you to set far-future HTTP expiration dates on all assets, + # yet still be able to expire them through the digest params. + config.assets.digest = true + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Mount Action Cable outside main process or domain + # config.action_cable.mount_path = nil + # config.action_cable.url = 'wss://example.com/cable' + # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "wdt_#{Rails.env}" + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb index 4d42557..5513486 100644 --- a/config/initializers/omniauth.rb +++ b/config/initializers/omniauth.rb @@ -1,11 +1,19 @@ -WDT::Application.config.middleware.use OmniAuth::Builder do +Rails.application.config.middleware.use OmniAuth::Builder do configure do |config| config.path_prefix = '/admin/auth' end + options = { + scope: 'user:email,read:org' + } + + if Rails.env.review? + options[:redirect_uri] = "https://#{ENV.fetch('HEROKU_APP_NAME')}.herokuapp.com/admin/auth/github/callback" + end + provider :github, Rails.application.secrets.github_client_id, Rails.application.secrets.github_client_secret, - scope: 'user:email,read:org' + options end diff --git a/config/secrets.yml b/config/secrets.yml index e312fff..47d9b3d 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -12,5 +12,8 @@ production: <<: *development secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> +review: + <<: *development + test: <<: *development diff --git a/db/seeds.rb b/db/seeds.rb index 3d878c9..c89b384 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -2,36 +2,47 @@ Faker::Config.locale = 'es' puts 'Creating location' - location = Location.create! city: 'Colima', state: 'Colima', country: 'México' + location = Location.create!( + city: 'Colima', + state: 'Colima', + country: 'México' + ) puts 'Creating venue' - venue = Venue.create! location: location, - name: Faker::Company.name, - address: "#{Faker::Address.street_suffix} #{Faker::Address.street_address}, #{location.name}, #{Faker::Address.postcode}", - description: Faker::Lorem.paragraphs.join + venue = Venue.create!( + location: location, + name: Faker::Company.name, + address: "#{Faker::Address.street_suffix} #{Faker::Address.street_address}, #{location.name}, #{Faker::Address.postcode}", + description: Faker::Lorem.paragraphs.join + ) puts 'Creating event' - event = Event.create! venue: venue, - date: 15.days.from_now, - theme: "#{Faker::Hacker.adjective.titleize} #{Faker::Hacker.noun}" + event = Event.create!( + venue: venue, + date: 15.days.from_now, + theme: "#{Faker::Hacker.adjective.titleize} #{Faker::Hacker.noun}" + ) puts 'Creating speakers' speakers = [] 4.times do - u = User.create! name: Faker::Name.name, - email: Faker::Internet.email, - profile_photo_url: Faker::Avatar.image(nil, '200x200', 'jpg').gsub('http', 'https'), - twitter: Faker::Internet.user_name - speakers << u + speakers << User.create!( + name: Faker::Name.name, + email: Faker::Internet.email, + photo_url: Faker::Avatar.image(nil, '200x200', 'jpg').gsub('http', 'https'), + twitter: Faker::Internet.user_name + ) end puts 'Creating event talk proposals' speakers.each do |speaker| - speaker.talks.create! event: event, - title: "#{Faker::Hacker.ingverb.titleize} #{Faker::Hacker.adjective} #{Faker::Hacker.noun}", - description: Faker::Lorem.paragraphs.join, - status: :proposal + speaker.talks.create!( + event: event, + title: "#{Faker::Hacker.ingverb.titleize} #{Faker::Hacker.adjective} #{Faker::Hacker.noun}", + description: Faker::Lorem.paragraphs.join, + status: :proposal + ) end puts 'Accepting event talks'