suspenders 1.11.0 → 1.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 15e552d7d17ba6f3e6abcce8e48e7357f759b3d5
4
- data.tar.gz: cf5e84b547ccc981b720be0e0db2a853836fa557
3
+ metadata.gz: b73d9dd152a7c46d51d98d0855f6d9386be74344
4
+ data.tar.gz: 17e0abffef3c289c9554a22a7faa896f30cb4b58
5
5
  SHA512:
6
- metadata.gz: fc35351a500d302415077fcedc6809df78b8872c9988ba04c1b9cf1274f88063e412c0a20e84c9e56884ba409e19fb3967c7d3490152f36b38325eddcf632d89
7
- data.tar.gz: f689a5d0f922bb1ffcc8f7e152ffa664ad1275ace7ed67abb9f13526be6bb2c28cdb7d2255ee5e1ed8b4ddb0d096830a96c7263e7e4a892aabb1638d8b2a864f
6
+ metadata.gz: 3545288487aafdea1f0a80f4ec51bca609962b5e69bf59a3096c9e8516bf5d640aa6bc9d3b9d033927e58fc0dc719107a3f378b1a13b7fb25fa2c156db5df678
7
+ data.tar.gz: add7e9af12cab579a0e9a7f638e0f3d99125348484a709003957031132c6c8b98095854e4199df130bb4b858fe61ff2ca65cc7e4683b4ddc94c7695a68d6a359
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- suspenders (1.11.0)
4
+ suspenders (1.12.0)
5
5
  bundler (~> 1.3)
6
6
  rails (~> 4.1.0)
7
7
 
@@ -120,7 +120,7 @@ GEM
120
120
  treetop (1.4.15)
121
121
  polyglot
122
122
  polyglot (>= 0.3.1)
123
- tzinfo (1.1.0)
123
+ tzinfo (1.2.0)
124
124
  thread_safe (~> 0.1)
125
125
  xpath (2.0.0)
126
126
  nokogiri (~> 1.3)
data/NEWS.md CHANGED
@@ -1,3 +1,16 @@
1
+ 1.12.0 (May 26, 2014)
2
+
3
+ * Fix `rake dev:prime` now that Suspenders-generated apps require some `ENV`
4
+ variables to be set.
5
+ * Ensure `EMAIL_RECIPIENTS` is set on staging.
6
+ * Clear `ActionMailer` deliveries before every test.
7
+ * Include New Relic configuration file.
8
+ * Add Formulaic gem for integration testing HTML forms.
9
+ * Set up the Segment.io adapter for analytics and event tracking through
10
+ services such as Google Analytics and Intercom.
11
+ * Prepare staging and production environments to serve static assets through a
12
+ CDN.
13
+
1
14
  1.11.0 (May 17, 2014)
2
15
 
3
16
  * Generate a Rails 4.1.1 app and implement fixes for compatibility.
data/README.md CHANGED
@@ -47,9 +47,9 @@ It includes application gems like:
47
47
  avoid accidentally sending emails to real people from staging
48
48
  * [Simple Form](https://github.com/plataformatec/simple_form) for form markup
49
49
  and style
50
- * [Unicorn](https://github.com/defunkt/unicorn) to serve HTTP requests
51
50
  * [Title](https://github.com/calebthompson/title) for storing titles in
52
51
  translations
52
+ * [Unicorn](https://github.com/defunkt/unicorn) to serve HTTP requests
53
53
 
54
54
  And gems only for staging and production like:
55
55
 
@@ -70,6 +70,8 @@ And testing gems like:
70
70
  [Capybara Webkit](https://github.com/thoughtbot/capybara-webkit) for
71
71
  integration testing
72
72
  * [Factory Girl](https://github.com/thoughtbot/factory_girl) for test data
73
+ * [Formulaic](https://github.com/thoughtbot/formulaic) for integration testing
74
+ HTML forms
73
75
  * [RSpec](https://github.com/rspec/rspec) for unit testing
74
76
  * [RSpec Mocks](https://github.com/rspec/rspec-mocks) for stubbing and spying
75
77
  * [Shoulda Matchers](https://github.com/thoughtbot/shoulda-matchers) for common
@@ -92,6 +94,8 @@ Suspenders also comes with:
92
94
  * An automatically-created `SECRET_KEY_BASE` environment variable in all
93
95
  environments.
94
96
  * Configuration for [Travis Pro][travis] continuous integration.
97
+ * The analytics adapter [Segment.io][segment] (and therefore config for Google
98
+ Analytics, Intercom, Facebook Ads, Twitter Ads, etc.).
95
99
 
96
100
  [bin]: http://robots.thoughtbot.com/bin-setup
97
101
  [compress]: http://robots.thoughtbot.com/content-compression-with-rack-deflater/
@@ -100,6 +104,7 @@ Suspenders also comes with:
100
104
  [binstub]: https://github.com/thoughtbot/suspenders/pull/282
101
105
  [i18n]: https://github.com/thoughtbot/suspenders/pull/304
102
106
  [travis]: http://docs.travis-ci.com/user/travis-pro/
107
+ [segment]: https://segment.io
103
108
 
104
109
  Heroku
105
110
  ------
@@ -21,15 +21,5 @@ module Suspenders
21
21
  before: "\nend"
22
22
  )
23
23
  end
24
-
25
- def download_file(uri_string, destination)
26
- uri = URI.parse(uri_string)
27
- http = Net::HTTP.new(uri.host, uri.port)
28
- http.use_ssl = true if uri_string =~ /^https/
29
- request = Net::HTTP::Get.new(uri.path)
30
- contents = http.request(request).body
31
- path = File.join(destination_root, destination)
32
- File.open(path, "w") { |file| file.write(contents) }
33
- end
34
24
  end
35
25
  end
@@ -55,6 +55,10 @@ module Suspenders
55
55
  copy_file 'factory_girl_rspec.rb', 'spec/support/factory_girl.rb'
56
56
  end
57
57
 
58
+ def configure_newrelic
59
+ template 'newrelic.yml.erb', 'config/newrelic.yml'
60
+ end
61
+
58
62
  def configure_smtp
59
63
  copy_file 'smtp.rb', 'config/smtp.rb'
60
64
 
@@ -82,6 +86,20 @@ module Suspenders
82
86
  :after => "config.serve_static_assets = false\n"
83
87
  end
84
88
 
89
+ def setup_asset_host
90
+ replace_in_file 'config/environments/production.rb',
91
+ '# config.action_controller.asset_host = "http://assets.example.com"',
92
+ "config.action_controller.asset_host = ENV.fetch('ASSET_HOST')"
93
+
94
+ replace_in_file 'config/environments/production.rb',
95
+ "config.assets.version = '1.0'",
96
+ "config.assets.version = ENV.fetch('ASSETS_VERSION')"
97
+
98
+ replace_in_file 'config/environments/production.rb',
99
+ 'config.serve_static_assets = false',
100
+ 'config.static_cache_control = "public, max-age=#{1.year.to_i}"'
101
+ end
102
+
85
103
  def setup_staging_environment
86
104
  staging_file = 'config/environments/staging.rb'
87
105
  copy_file 'staging.rb', staging_file
@@ -174,6 +192,10 @@ end
174
192
  run 'rails g delayed_job:active_record'
175
193
  end
176
194
 
195
+ def configure_action_mailer_in_specs
196
+ copy_file 'action_mailer.rb', 'spec/support/action_mailer.rb'
197
+ end
198
+
177
199
  def configure_time_zone
178
200
  config = <<-RUBY
179
201
  config.active_record.default_timezone = :utc
@@ -278,6 +300,11 @@ heroku join --app #{app_name}-production
278
300
  run "#{path_addition} hub create #{repo_name}"
279
301
  end
280
302
 
303
+ def setup_segment_io
304
+ copy_file '_analytics.html.erb',
305
+ 'app/views/application/_analytics.html.erb'
306
+ end
307
+
281
308
  def copy_miscellaneous_files
282
309
  copy_file 'errors.rb', 'config/initializers/errors.rb'
283
310
  end
@@ -38,6 +38,7 @@ module Suspenders
38
38
  invoke :setup_database
39
39
  invoke :create_heroku_apps
40
40
  invoke :create_github_repo
41
+ invoke :setup_segment_io
41
42
  invoke :outro
42
43
  end
43
44
 
@@ -81,12 +82,15 @@ module Suspenders
81
82
  build :configure_spec_support_features
82
83
  build :configure_travis
83
84
  build :configure_i18n_in_specs
85
+ build :configure_action_mailer_in_specs
84
86
  end
85
87
 
86
88
  def setup_production_environment
87
89
  say 'Setting up the production environment'
90
+ build :configure_newrelic
88
91
  build :configure_smtp
89
92
  build :enable_rack_deflater
93
+ build :setup_asset_host
90
94
  end
91
95
 
92
96
  def setup_staging_environment
@@ -154,6 +158,11 @@ module Suspenders
154
158
  end
155
159
  end
156
160
 
161
+ def setup_segment_io
162
+ say 'Setting up Segment.io'
163
+ build :setup_segment_io
164
+ end
165
+
157
166
  def setup_gitignore
158
167
  build :gitignore_files
159
168
  end
@@ -1,4 +1,4 @@
1
1
  module Suspenders
2
2
  RUBY_VERSION = IO.read("#{File.dirname(__FILE__)}/../../.ruby-version").strip
3
- VERSION = '1.11.0'
3
+ VERSION = '1.12.0'
4
4
  end
@@ -16,6 +16,7 @@ feature 'Suspend a new project with default configuration' do
16
16
 
17
17
  staging_file = IO.read("#{project_path}/config/environments/staging.rb")
18
18
  config_stub = "Rails.application.configure do"
19
+
19
20
  expect(staging_file).to match(/^require_relative 'production'/)
20
21
  expect(staging_file).to match(/#{config_stub}/), staging_file
21
22
  end
@@ -24,6 +25,7 @@ feature 'Suspend a new project with default configuration' do
24
25
  run_suspenders
25
26
 
26
27
  ruby_version_file = IO.read("#{project_path}/.ruby-version")
28
+
27
29
  expect(ruby_version_file).to eq "#{RUBY_VERSION}\n"
28
30
  end
29
31
 
@@ -31,6 +33,37 @@ feature 'Suspend a new project with default configuration' do
31
33
  run_suspenders
32
34
 
33
35
  secrets_file = IO.read("#{project_path}/config/secrets.yml")
36
+
34
37
  expect(secrets_file).to match(/secret_key_base: <%= ENV\['SECRET_KEY_BASE'\] %>/)
35
38
  end
39
+
40
+
41
+ scenario 'action mailer support file is added' do
42
+ run_suspenders
43
+
44
+ expect(File).to exist("#{project_path}/spec/support/action_mailer.rb")
45
+ end
46
+
47
+ scenario 'newrelic.yml reads NewRelic license from env' do
48
+ run_suspenders
49
+
50
+ newrelic_file = IO.read("#{project_path}/config/newrelic.yml")
51
+
52
+ expect(newrelic_file).to match(
53
+ /license_key: '<%= ENV\['NEW_RELIC_LICENSE_KEY'\] %>'/
54
+ )
55
+ end
56
+
57
+ scenario 'records pageviews through Segment.io if ENV variable set' do
58
+ run_suspenders
59
+
60
+ expect(analytics_partial).
61
+ to include("<% if ENV['SEGMENT_IO_KEY'] %>")
62
+ expect(analytics_partial).
63
+ to include("window.analytics.load('<%= ENV['SEGMENT_IO_KEY'] %>');")
64
+ end
65
+
66
+ def analytics_partial
67
+ IO.read("#{project_path}/app/views/application/_analytics.html.erb")
68
+ end
36
69
  end
@@ -38,6 +38,7 @@ end
38
38
  group :test do
39
39
  gem 'capybara-webkit', '>= 1.0.0'
40
40
  gem 'database_cleaner'
41
+ gem 'formulaic'
41
42
  gem 'launchy'
42
43
  gem 'shoulda-matchers', require: false
43
44
  gem 'simplecov', require: false
@@ -0,0 +1,7 @@
1
+ <% if ENV['SEGMENT_IO_KEY'] %>
2
+ <script type="text/javascript">
3
+ window.analytics=window.analytics||[],window.analytics.methods=["identify","group","track","page","pageview","alias","ready","on","once","off","trackLink","trackForm","trackClick","trackSubmit"],window.analytics.factory=function(t){return function(){var a=Array.prototype.slice.call(arguments);return a.unshift(t),window.analytics.push(a),window.analytics}};for(var i=0;i<window.analytics.methods.length;i++){var key=window.analytics.methods[i];window.analytics[key]=window.analytics.factory(key)}window.analytics.load=function(t){if(!document.getElementById("analytics-js")){var a=document.createElement("script");a.type="text/javascript",a.id="analytics-js",a.async=!0,a.src=("https:"===document.location.protocol?"https://":"http://")+"cdn.segment.io/analytics.js/v1/"+t+"/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(a,n)}},window.analytics.SNIPPET_VERSION="2.0.9",
4
+ window.analytics.load('<%= ENV['SEGMENT_IO_KEY'] %>');
5
+ window.analytics.page();
6
+ </script>
7
+ <% end %>
@@ -2,6 +2,8 @@
2
2
 
3
3
  <%= yield :javascript %>
4
4
 
5
+ <%= render 'analytics' %>
6
+
5
7
  <% if Rails.env.test? %>
6
8
  <%= javascript_tag do %>
7
9
  $.fx.off = true;
@@ -0,0 +1,5 @@
1
+ RSpec.configure do |config|
2
+ config.before(:each) do
3
+ ActionMailer::Base.deliveries.clear
4
+ end
5
+ end
data/templates/bin_setup CHANGED
@@ -9,17 +9,17 @@ set -e
9
9
  # Set up Ruby dependencies via Bundler
10
10
  bundle install
11
11
 
12
+ # Set up configurable environment variables
13
+ if [ ! -f .env ]; then
14
+ cp .sample.env .env
15
+ fi
16
+
12
17
  # Set up database and add any development seed data
13
18
  bundle exec rake dev:prime
14
19
 
15
20
  # Add binstubs to PATH via export PATH=".git/safe/../../bin:$PATH" in ~/.zshenv
16
21
  mkdir -p .git/safe
17
22
 
18
- # Set up configurable environment variables
19
- if [ ! -f .env ]; then
20
- cp .sample.env .env
21
- fi
22
-
23
23
  # Pick a port for Foreman
24
24
  echo "port: 7000" > .foreman
25
25
 
@@ -0,0 +1,34 @@
1
+ common: &default_settings
2
+ app_name: '<%= app_name %>'
3
+ audit_log:
4
+ enabled: false
5
+ browser_monitoring:
6
+ auto_instrument: true
7
+ capture_params: false
8
+ developer_mode: false
9
+ error_collector:
10
+ capture_source: true
11
+ enabled: true
12
+ ignore_errors: 'ActionController::RoutingError,Sinatra::NotFound'
13
+ license_key: '<%%= ENV['NEW_RELIC_LICENSE_KEY'] %>'
14
+ log_level: info
15
+ monitor_mode: true
16
+ transaction_tracer:
17
+ enabled: true
18
+ record_sql: obfuscated
19
+ stack_trace_threshold: 0.500
20
+ transaction_threshold: apdex_f
21
+ development:
22
+ <<: *default_settings
23
+ monitor_mode: false
24
+ developer_mode: true
25
+ test:
26
+ <<: *default_settings
27
+ monitor_mode: false
28
+ production:
29
+ <<: *default_settings
30
+ monitor_mode: true
31
+ staging:
32
+ <<: *default_settings
33
+ app_name: '<%= app_name %> (Staging)'
34
+ monitor_mode: true
@@ -21,6 +21,8 @@ RSpec.configure do |config|
21
21
  end
22
22
 
23
23
  config.include Features, type: :feature
24
+ config.include Formulaic::Dsl, type: :feature
25
+
24
26
  config.infer_base_class_for_anonymous_controllers = false
25
27
  config.order = 'random'
26
28
  config.treat_symbols_as_metadata_keys_with_true_values = true
data/templates/staging.rb CHANGED
@@ -1,3 +1,5 @@
1
1
  require_relative 'production'
2
2
 
3
- Mail.register_interceptor RecipientInterceptor.new(ENV['EMAIL_RECIPIENTS'])
3
+ Mail.register_interceptor(
4
+ RecipientInterceptor.new(ENV.fetch('EMAIL_RECIPIENTS'))
5
+ )
@@ -27,3 +27,5 @@ notifications:
27
27
  - false
28
28
  rvm:
29
29
  - <%= Suspenders::RUBY_VERSION %>
30
+ addons:
31
+ postgresql: "9.3"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: suspenders
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.0
4
+ version: 1.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thoughtbot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-17 00:00:00.000000000 Z
11
+ date: 2014-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -139,8 +139,10 @@ files:
139
139
  - templates/Gemfile.erb
140
140
  - templates/Procfile
141
141
  - templates/README.md.erb
142
+ - templates/_analytics.html.erb
142
143
  - templates/_flashes.html.erb
143
144
  - templates/_javascript.html.erb
145
+ - templates/action_mailer.rb
144
146
  - templates/application.css.scss
145
147
  - templates/background_jobs_rspec.rb
146
148
  - templates/bin_setup
@@ -151,6 +153,7 @@ files:
151
153
  - templates/errors.rb
152
154
  - templates/factory_girl_rspec.rb
153
155
  - templates/i18n.rb
156
+ - templates/newrelic.yml.erb
154
157
  - templates/postgresql_database.yml.erb
155
158
  - templates/rack_timeout.rb
156
159
  - templates/sample.env