Skip to content

Commit

Permalink
KBP-138 #time 1.5h - added ssl control staging and production
Browse files Browse the repository at this point in the history
  • Loading branch information
FatihAvsan committed Nov 21, 2017
1 parent 5abb135 commit 7015df2
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/cybele/app_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ def add_gems
append_file('Gemfile', template_content('Gemfile.erb'))
end

def force_ssl_setting
gsub_file 'config/environments/production.rb',
/# config.force_ssl = true/, "config.force_ssl = ENV['RAILS_FORCE_SSL'].present?"
gsub_file 'config/environments/staging.rb',
/# config.force_ssl = true/, "config.force_ssl = ENV['RAILS_FORCE_SSL'].present?"
end

def add_editor_config
copy_file 'editorconfig', '.editorconfig'
end
Expand Down
5 changes: 5 additions & 0 deletions lib/cybele/generators/app_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ def setup_bullet_config
build :configure_bullet
end

def force_ssl
say 'Add ssl control into staging.rb and production.rb', :green
build :force_ssl_setting
end

def setup_paperclip_and_add_aws
say 'Setting up paperclip, editing settings.yml and env files', :green
build :configure_paperclip
Expand Down
4 changes: 4 additions & 0 deletions spec/features/new_default_project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,8 @@
it 'uses devise' do
devise_test_helper
end

it 'uses ssl_setting' do
force_ssl
end
end
4 changes: 4 additions & 0 deletions spec/features/new_not_default_project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,8 @@
it 'uses devise' do
devise_test_helper
end

it 'uses ssl_setting' do
force_ssl
end
end
9 changes: 9 additions & 0 deletions spec/support/gem_test_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,13 @@ def config_test_helper
config_test_file = content('config/environments/test.rb')
expect(config_test_file).to match(/^Rails.application.configure/)
end

def force_ssl
config_staging_file = content('config/environments/staging.rb')
expect(config_staging_file).to match('config.force_ssl')

config_production_file = content('config/environments/staging.rb')
expect(config_production_file).to match('config.force_ssl')
end

end

0 comments on commit 7015df2

Please sign in to comment.