rails-env 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 88a0628c82307f77ce43292c6944457555217adb
4
- data.tar.gz: fd260fbe6229e5fe68fe26b5b82515cfb180146f
3
+ metadata.gz: 54be7bfad6d607eb1031afc41ebd006000b28ccd
4
+ data.tar.gz: 7008dff976d48c3a821d6ee4ae97c6c111ffdc60
5
5
  SHA512:
6
- metadata.gz: 456fae20dd8fac5c4efcfc466b8cad56c3c4fe8383d15d4d81f99b908e0365f6d1d15be65052abf9a2ce3b4472bf5db04c03d1c54d7596630fdd39fd6ade1309
7
- data.tar.gz: 728c5ff0e8cf8f2f67f23c0309fc9705e3dca18a0298215cfef7086e8b28287a6cc697a22e9a85958e3e88f7eeea61af984dda3f6fd04c2bba70c4578bdae9f0
6
+ metadata.gz: 8fa0ca1dbe54d9d6b98b22096be6f5c9c7624121b177016b57ff2509140c628b44fddf3d3366b5fb77bc1f99b63a8ac8cdfc27e28ccc1156b867b1a49778006c
7
+ data.tar.gz: da0fdf44a876a8100ea0cdb69ddf1cfe315ec95040553686ca31794cb7d9557737c833fe97a40213df50a4deb1e17152d0f15d8beb553371b2bf53e8181f1c89
data/lib/rails-env.rb CHANGED
@@ -7,10 +7,35 @@ module RailsEnv
7
7
  end
8
8
  end
9
9
 
10
+ def self.propagate_configuration!
11
+ propagate(:action_mailer, '::ActionMailer::Base')
12
+ propagate(:active_record, '::ActiveRecord::Base')
13
+ propagate(:active_job, '::ActiveJob::Base')
14
+ propagate(:time_zone, '::Time', :zone)
15
+ propagate(:i18n, '::I18n')
16
+ end
17
+
18
+ def self.propagate(options_name, target_name, target_property = nil)
19
+ return unless Object.const_defined?(target_name)
20
+ return unless Rails.configuration.respond_to?(options_name)
21
+
22
+ target = Object.const_get(target_name)
23
+ options = Rails.configuration.public_send(options_name)
24
+
25
+ if options.kind_of?(Enumerable)
26
+ options.each do |key, value|
27
+ target.public_send("#{key}=", value) if target.respond_to?("#{key}=")
28
+ end
29
+ else
30
+ target.public_send("#{target_property}=", options)
31
+ end
32
+ end
33
+
10
34
  module Extension
11
35
  def on(*envs, &block)
12
36
  env_matched = envs.include?(:any) || envs.include?(Rails.env.to_sym)
13
37
  Rails.application.configure(&block) if env_matched
38
+ RailsEnv.propagate_configuration!
14
39
  end
15
40
  end
16
41
  end
@@ -1,3 +1,3 @@
1
1
  module RailsEnv
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ describe RailsEnv, '::ActionMailer' do
4
+ before do
5
+ Rails.env.on(:test) do
6
+ config.action_mailer.default_url_options = {host: 'localhost', port: 3000}
7
+ config.action_mailer.raise_delivery_errors = true
8
+ config.action_mailer.delivery_method = :letter_opener
9
+ config.time_zone = 'America/Sao_Paulo'
10
+ config.i18n.available_locales = ['pt-BR']
11
+ config.i18n.default_locale = 'pt-BR'
12
+ end
13
+ end
14
+
15
+ it 'sets url options' do
16
+ expect(ActionMailer::Base.default_url_options).to include(host: 'localhost', port: 3000)
17
+ end
18
+
19
+ it 'sets raise option' do
20
+ expect(ActionMailer::Base.raise_delivery_errors).to be_truthy
21
+ end
22
+
23
+ it 'sets delivery method' do
24
+ expect(ActionMailer::Base.delivery_method).to eq(:letter_opener)
25
+ end
26
+
27
+ it 'sets timezone' do
28
+ expect(Time.zone.name).to eq('America/Sao_Paulo')
29
+ end
30
+
31
+ it 'sets locale' do
32
+ expect(I18n.locale).to eq(:'pt-BR')
33
+ end
34
+
35
+ it 'sets available locales' do
36
+ expect(I18n.available_locales).to eq([:'pt-BR'])
37
+ end
38
+ end
data/spec/spec_helper.rb CHANGED
@@ -2,6 +2,7 @@ ENV['RAILS_ENV'] = 'test'
2
2
 
3
3
  require 'bundler/setup'
4
4
  require 'rails'
5
+ require 'action_mailer/railtie'
5
6
  require 'rails-env'
6
7
 
7
8
  class DummyApp < Rails::Application
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-env
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-08 00:00:00.000000000 Z
11
+ date: 2015-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -97,6 +97,7 @@ files:
97
97
  - lib/rails-env/version.rb
98
98
  - rails-env.gemspec
99
99
  - spec/rails-env_spec.rb
100
+ - spec/rails_spec.rb
100
101
  - spec/spec_helper.rb
101
102
  homepage: https://github.com/fnando/rails-env
102
103
  licenses:
@@ -118,10 +119,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
119
  version: '0'
119
120
  requirements: []
120
121
  rubyforge_project:
121
- rubygems_version: 2.4.6
122
+ rubygems_version: 2.4.5.1
122
123
  signing_key:
123
124
  specification_version: 4
124
125
  summary: Avoid environment detection on Rails
125
126
  test_files:
126
127
  - spec/rails-env_spec.rb
128
+ - spec/rails_spec.rb
127
129
  - spec/spec_helper.rb