diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 5b5f702..8e26b7f 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -36,9 +36,9 @@ def interested unless @ref.blank? # Increment RCOUNT for referrer if referral code is present begin list_members = mailchimp.lists.members("#{MAILCHIMP_LIST_ID}") - referring_member = list_members['data'].detect{ |member| member['merges']['RCODE'] == "#{@ref}" } + referring_member = list_members['data'].detect { |member| member['merges']['RCODE'] == "#{@ref}" } new_count = referring_member['merges']['RCOUNT'] + 1 - mailchimp.lists.update_member("#{MAILCHIMP_LIST_ID}", {"euid" => "#{referring_member['id']}"}, 'RCOUNT' => "1") + mailchimp.lists.update_member("#{MAILCHIMP_LIST_ID}", {'euid' => "#{referring_member['id']}"}, 'RCOUNT' => '1') rescue => e flash.now[:alert] = 'There was a problem updating the referral at MailChimp' return render :index @@ -47,7 +47,7 @@ def interested begin mailchimp.lists.subscribe("#{MAILCHIMP_LIST_ID}", - {"email" => "#{email}"}, + {'email' => "#{email}"}, {'RCODE' => "#{@referral_code}", 'RCOUNT' => "0"}) rescue => e flash.now[:alert] = 'There was a problem subscribing you to the list on MailChimp' diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb index ef05d7e..dd46ead 100644 --- a/spec/controllers/home_controller_spec.rb +++ b/spec/controllers/home_controller_spec.rb @@ -1,23 +1,23 @@ require 'spec_helper' describe HomeController do - describe "GET index" do - it "renders index" do + describe 'GET index' do + it 'renders index' do get :index response.should be_success end end - describe "GET interested" do - context "with an email address" do - it "renders interested" do + describe 'GET interested' do + context 'with an email address' do + it 'renders interested' do get 'interested', {:email => Faker::Internet.email} response.should be_success end end - context "without an email address" do - it "redirects to the homepage" do + context 'without an email address' do + it 'redirects to the homepage' do get 'interested' response.should redirect_to(root_url) end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b960be0..bf0b282 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -17,8 +17,8 @@ # need to restart spork for it take effect. # This file is copied to spec/ when you run 'rails generate rspec:install' - ENV["RAILS_ENV"] ||= 'test' - require File.expand_path("../../config/environment", __FILE__) + ENV['RAILS_ENV'] ||= 'test' + require File.expand_path('../../config/environment', __FILE__) require 'rspec/rails' require 'rspec/autorun' require 'capybara/rspec' @@ -27,7 +27,7 @@ # Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories. - Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} + Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } RSpec.configure do |config| # ## Mock Framework @@ -56,9 +56,9 @@ # order dependency and want to debug it, you can fix the order by providing # the seed, which is printed after each run. # --seed 1234 - config.order = "random" + config.order = 'random' - config.include Capybara::DSL, :type => :request + config.include Capybara::DSL, type: :request config.include FactoryGirl::Syntax::Methods # https://ariejan.net/2011/09/24/rspec-speed-up-by-tweaking-ruby-garbage-collection diff --git a/spec/support/deferred_garbage_collection.rb b/spec/support/deferred_garbage_collection.rb index 7bee5b8..b9498da 100644 --- a/spec/support/deferred_garbage_collection.rb +++ b/spec/support/deferred_garbage_collection.rb @@ -1,5 +1,4 @@ # https://ariejan.net/2011/09/24/rspec-speed-up-by-tweaking-ruby-garbage-collection - class DeferredGarbageCollection DEFERRED_GC_THRESHOLD = (ENV['DEFER_GC'] || 15.0).to_f @@ -17,5 +16,4 @@ def self.reconsider @@last_gc_run = Time.now end end - end