Skip to content

Commit

Permalink
- Fixed Email Interceptor usage of Settings
Browse files Browse the repository at this point in the history
- Improved users controller tests
- Added coveralls
  • Loading branch information
vipulnsward committed May 17, 2015
1 parent 1582f9a commit 4f5190c
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 5 deletions.
5 changes: 4 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ gem 'browser'
gem 'haml-rails'

# intercepts outgoing emails in non-production environment
gem 'mail_interceptor', github: 'bigbinary/mail_interceptor', group: [:development, :staging]
gem 'mail_interceptor', github: 'bigbinary/mail_interceptor', group: [:development, :staging, :test]

# Adds prefix to the subject in emails
gem 'email_prefixer'
Expand Down Expand Up @@ -101,4 +101,7 @@ group :test do

# for test coverage report
gem 'simplecov', require: false

# Report test coverage
gem 'coveralls', require: false
end
22 changes: 22 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.9.1)
coveralls (0.8.0)
multi_json (~> 1.10)
rest-client (>= 1.6.8, < 2)
simplecov (~> 0.9.1)
term-ansicolor (~> 1.3)
thor (~> 0.19.1)
daemons (1.1.9)
debug_inspector (0.0.2)
delayed_job (4.0.6)
Expand All @@ -117,6 +123,8 @@ GEM
thread_safe (~> 0.1)
warden (~> 1.2.3)
docile (1.1.5)
domain_name (0.5.24)
unf (>= 0.0.5, < 1.0.0)
email_prefixer (1.1.0)
rails (>= 4.0)
email_validator (1.5.0)
Expand Down Expand Up @@ -152,6 +160,8 @@ GEM
haml (~> 4.0.0)
nokogiri (~> 1.6.0)
ruby_parser (~> 3.5)
http-cookie (1.0.2)
domain_name (~> 0.5)
i18n (0.7.0)
inherited_resources (1.6.0)
actionpack (>= 3.2, < 5)
Expand Down Expand Up @@ -185,6 +195,7 @@ GEM
minitest (>= 5.0)
ruby-progressbar
multi_json (1.11.0)
netrc (0.10.3)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
orm_adapter (0.5.0)
Expand Down Expand Up @@ -237,6 +248,10 @@ GEM
polyamorous (~> 1.1)
responders (2.1.0)
railties (>= 4.2.0, < 5)
rest-client (1.8.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
ruby-progressbar (1.7.1)
ruby_parser (3.6.4)
sexp_processor (~> 4.1)
Expand Down Expand Up @@ -272,18 +287,24 @@ GEM
sprockets (~> 2.8)
sprockets-strict-mode (1.0)
sprockets
term-ansicolor (1.3.0)
tins (~> 1.0)
thin (1.6.3)
daemons (~> 1.0, >= 1.0.9)
eventmachine (~> 1.0)
rack (~> 1.0)
thor (0.19.1)
thread_safe (0.3.5)
tilt (1.4.1)
tins (1.5.1)
tzinfo (1.2.2)
thread_safe (~> 0.1)
uglifier (2.7.1)
execjs (>= 0.3.0)
json (>= 1.8.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.1)
unicorn (4.8.3)
kgio (~> 2.6)
rack
Expand All @@ -305,6 +326,7 @@ DEPENDENCIES
bootstrap-sass (~> 3.3.3)
browser
carrierwave
coveralls
daemons
delayed_job_active_record
delayed_job_web (>= 1.2.10)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[![Circle CI](https://circleci.com/gh/bigbinary/wheel.png?style=badge)](https://circleci.com/gh/bigbinary/wheel)
[![Coverage Status](https://coveralls.io/repos/bigbinary/wheel/badge.svg)](https://coveralls.io/r/bigbinary/wheel)

#### Setup

Expand Down
4 changes: 2 additions & 2 deletions config/initializers/email_interceptor.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
if Settings.intercept_and_forward_emails_to.present?
options = { forward_emails_to: Settings.intercept_and_forward_emails_to,
if Rails.application.secrets.intercept_and_forward_emails_to.present?
options = { forward_emails_to: Rails.application.secrets.intercept_and_forward_emails_to,
deliver_emails_to: ['@example.com'] }

interceptor = MailInterceptor::Interceptor.new(options)
Expand Down
3 changes: 3 additions & 0 deletions config/secrets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ test:
<<: *default
secret_key_base: 08523cd7820d8e6232afb3a704c60a75feb024ab937de989322f4e64a3854b4d8dc8bb119faf8847adceb70aadce1288ff3193ce62de10f78da223e95760dd6c
mailer_delivery_method: :test
intercept_and_forward_emails_to:
- john@example.com
- adam@example.com
mailer:
smtp_settings:
user_name: <%= ENV['MANDRILLAPP_USERNAME'] %>
Expand Down
17 changes: 17 additions & 0 deletions test/controllers/superadmin/users_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,21 @@ def test_index_when_user_is_not_superadmin
assert_response :forbidden
end

def test_edit_user_modal_success_response
user = users :admin
sign_in user
get :edit, id: users(:nancy)
assert_response :success
end

def test_user_update_success
admin = users :admin
sign_in admin
nancy = users :nancy

post :update, id: nancy, user: {first_name: 'Jane'}
nancy.reload

assert 'Jane', nancy.first_name
end
end
7 changes: 5 additions & 2 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
def enable_test_coverage
require 'coveralls'
Coveralls.wear!

def enable_local_test_coverage
require 'simplecov'

SimpleCov.start do
Expand All @@ -14,7 +17,7 @@ def enable_test_coverage
end
end

enable_test_coverage if ENV['COVERAGE']
enable_local_test_coverage if ENV['COVERAGE']

ENV["RAILS_ENV"] ||= "test"

Expand Down

0 comments on commit 4f5190c

Please sign in to comment.