-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
409 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# frozen_string_literal: true | ||
|
||
module Cybele | ||
module Helpers | ||
module ErrorPages | ||
def configure_error_pages | ||
inject_into_file 'app/controllers/application_controller.rb', | ||
template_content('error_pages/error_control.erb'), | ||
after: 'class ApplicationController < ActionController::Base' | ||
|
||
inject_into_file 'app/controllers/application_controller.rb', | ||
template_content('error_pages/error_method.erb'), | ||
after: 'protect_from_forgery with: :exception' | ||
|
||
inject_into_file 'config/routes.rb', | ||
template_content('error_pages/error_route.erb'), | ||
before: /^end/ | ||
|
||
create_error_pages_files | ||
end | ||
|
||
private | ||
|
||
def create_error_pages_files | ||
# Server Error | ||
template 'error_pages/internal_server_error.html.haml', | ||
'app/views/errors/internal_server_error.html.haml', | ||
force: true | ||
|
||
# Not Found Error | ||
template 'error_pages/not_found.html.haml', | ||
'app/views/errors/not_found.html.haml', | ||
force: true | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
module ConfigTestHelper | ||
def config_test | ||
gemfile_file = content('Gemfile') | ||
expect(gemfile_file).to match(/^gem 'config'/) | ||
|
||
config_development_file_test | ||
config_staging_file_test | ||
config_production_file_test | ||
config_test_file_test | ||
end | ||
|
||
private | ||
|
||
def config_development_file_test | ||
config_development_file = content('config/environments/development.rb') | ||
expect(config_development_file).to match(/^Rails.application.configure/) | ||
end | ||
|
||
def config_staging_file_test | ||
config_staging_file = content('config/environments/staging.rb') | ||
expect(config_staging_file).to match(/^Rails.application.configure/) | ||
end | ||
|
||
def config_production_file_test | ||
config_production_file = content('config/environments/production.rb') | ||
expect(config_production_file).to match(/^Rails.application.configure/) | ||
end | ||
|
||
def config_test_file_test | ||
config_test_file = content('config/environments/test.rb') | ||
expect(config_test_file).to match(/^Rails.application.configure/) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# frozen_string_literal: true | ||
|
||
module DeviseTestHelper | ||
def devise_test | ||
gemfile_file = content('Gemfile') | ||
expect(gemfile_file).to match(/^gem 'devise'/) | ||
|
||
devise_initializers_test | ||
devise_route_file_test | ||
devise_model_file_test | ||
file_control_test | ||
end | ||
|
||
private | ||
|
||
def devise_initializers_test | ||
initializers_devise = content('config/initializers/devise.rb') | ||
expect(initializers_devise).to match('mailer') | ||
expect(initializers_devise).to match('mailer_sender') | ||
|
||
filter_parameter_logging = content('config/initializers/filter_parameter_logging.rb') | ||
expect(filter_parameter_logging).to match(':password') | ||
expect(filter_parameter_logging).to match(':password_confirmation') | ||
end | ||
|
||
def devise_route_file_test | ||
devise_route = content('config/routes.rb') | ||
expect(devise_route).to match('devise_for :users') | ||
end | ||
|
||
def devise_model_file_test # rubocop:disable Metrics/AbcSize | ||
devise_model_file = content('app/models/user.rb') | ||
expect(devise_model_file).to match(':database_authenticatable') | ||
expect(devise_model_file).to match(':registerable') | ||
expect(devise_model_file).to match(':recoverable') | ||
expect(devise_model_file).to match(':rememberable') | ||
expect(devise_model_file).to match(':trackable') | ||
expect(devise_model_file).to match(':validatable') | ||
end | ||
|
||
def file_control_test # rubocop:disable Metrics/AbcSize | ||
expect(File).to exist(file_project_path('app/views/devise/confirmations')) | ||
expect(File).to exist(file_project_path('app/views/devise/mailer')) | ||
expect(File).to exist(file_project_path('app/views/devise/passwords')) | ||
expect(File).to exist(file_project_path('app/views/devise/registrations')) | ||
expect(File).to exist(file_project_path('app/views/devise/sessions')) | ||
expect(File).to exist(file_project_path('app/views/devise/shared')) | ||
expect(File).to exist(file_project_path('app/views/devise/unlocks')) | ||
|
||
expect(File).not_to exist(file_project_path('config/locales/devise.en.yml')) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
module DotenvTestHelper | ||
def dotenv_test | ||
gemfile_file = content('Gemfile') | ||
expect(gemfile_file).to match(/^gem 'dotenv-rails'/) | ||
|
||
env_sample_file_test | ||
env_local_file_test | ||
env_staging_file_test | ||
env_production_file_test | ||
end | ||
|
||
private | ||
|
||
def env_sample_file_test | ||
env_sample_file = content('env.sample') | ||
expect(env_sample_file).to match('ROOT_PATH=http://localhost:3000') | ||
end | ||
|
||
def env_local_file_test | ||
env_local_file = content('.env.local') | ||
expect(env_local_file).to match('ROOT_PATH=http://localhost:3000') | ||
end | ||
|
||
def env_staging_file_test | ||
env_staging_file = content('.env.staging') | ||
expect(env_staging_file).to match('ROOT_PATH=https://staging-dummy_app.herokuapp.com') | ||
end | ||
|
||
def env_production_file_test | ||
env_production_file = content('.env.production') | ||
expect(env_production_file).to match('ROOT_PATH=https://dummy_app.herokuapp.com') | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# frozen_string_literal: true | ||
|
||
module ErrorPagesTestHelper | ||
def error_pages_test | ||
controller_file_test | ||
routes_file_test | ||
end | ||
|
||
private | ||
|
||
def controller_file_test # rubocop:disable Metrics/AbcSize | ||
application_controller_file = content('app/controllers/application_controller.rb') | ||
expect(application_controller_file).to match('rescue_from Exception') | ||
expect(application_controller_file).to match('rescue_from ActiveRecord::RecordNotFound') | ||
expect(application_controller_file).to match('rescue_from ActionController::RoutingError') | ||
expect(application_controller_file).to match('server_error') | ||
expect(application_controller_file).to match('page_not_found') | ||
end | ||
|
||
def routes_file_test | ||
route_file = content('config/routes.rb') | ||
expect(route_file).to match('unmatched_route') | ||
end | ||
end |
Oops, something went wrong.