Skip to content

Commit 236e0fe

Browse files
author
Joshua Wood
committed
Disable Rack::SSL middleware in Rails 3 test task
1 parent 76b5c53 commit 236e0fe

File tree

10 files changed

+260
-6
lines changed

10 files changed

+260
-6
lines changed

Appraisals

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
appraise 'rack' do
2-
gem 'rack'
3-
gem 'honeybadger', :path => '../'
4-
end
5-
61
appraise 'rails2.3' do
72
gem 'rails', '2.3.14'
83
gem 'rake', '0.9.5'
@@ -28,3 +23,18 @@ appraise 'rails4' do
2823
gem 'rails', '4.0.0.beta', :git => 'git://github.com/rails/rails.git'
2924
gem 'honeybadger', :path => '../'
3025
end
26+
27+
appraise 'rake' do
28+
gem 'sinatra'
29+
gem 'honeybadger', :path => '../'
30+
end
31+
32+
appraise 'rack' do
33+
gem 'rack'
34+
gem 'honeybadger', :path => '../'
35+
end
36+
37+
appraise 'sinatra' do
38+
gem 'sinatra'
39+
gem 'honeybadger', :path => '../'
40+
end

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
## Honeybadger 1.6.0 (unreleased) ##
22

3+
* Disable Rack::SSL middleware in Rails 3 test task. Rails'
4+
config.force_ssl setting otherwise prevents the request from reaching
5+
the controller.
6+
7+
*Joshua Wood*
8+
39
* Added a Changelog :)
410

511
*Joshua Wood*

Rakefile

+15
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,21 @@ end
6262
Cucumber::Rake::Task.new(:cucumber) do |t|
6363
t.fork = true
6464
t.cucumber_opts = ['--format', 'progress', '--tags', '~@pending']
65+
66+
unless ENV['BUNDLE_GEMFILE'] =~ /rails(3|4)/
67+
t.cucumber_opts << '--tags ~@rails_3'
68+
end
69+
70+
case ENV['BUNDLE_GEMFILE']
71+
when /rails/
72+
t.cucumber_opts << 'features/rails.feature features/metal.feature'
73+
when /rack/
74+
t.cucumber_opts << 'features/rack.feature'
75+
when /rake/
76+
t.cucumber_opts << 'features/rake.feature'
77+
when /sinatra/
78+
t.cucumber_opts << 'features/sinatra.feature'
79+
end unless ENV['FEATURE']
6580
end
6681

6782
desc "Generate RCov test coverage and open in your browser"

features/rails.feature

+11
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@ Feature: Install the Gem in a Rails application
4545
And I run the honeybadger generator with ""
4646
Then the output should contain "You must first remove the honeybadger plugin. Please run: script/plugin remove honeybadger"
4747

48+
@rails_3
49+
Scenario: Running the test task with config.force_ssl enabled
50+
When I configure Rails with:
51+
"""
52+
config.force_ssl = true
53+
"""
54+
And I configure the notifier to use "myapikey" as an API key
55+
And I configure my application to require Honeybadger
56+
And I run `rake honeybadger:test`
57+
Then I should receive a Honeybadger notification
58+
4859
Scenario: Rescue an exception in a controller
4960
When I configure my application to require Honeybadger
5061
And I configure Honeybadger with:

features/step_definitions/rails_steps.rb

+18
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,21 @@
222222
"""
223223
}
224224
end
225+
226+
When /^I configure Rails with:$/ do |config|
227+
if rails2?
228+
fail 'This step definition requires Rails 3+. Please add support for Rails 2 if you need it.'
229+
else
230+
application_filename = File.join(rails_root, 'config', 'application.rb')
231+
application_lines = File.open(application_filename).readlines
232+
233+
application_definition_line = application_lines.detect { |line| line =~ /Application/ }
234+
application_definition_line_index = application_lines.index(application_definition_line)
235+
236+
application_lines.insert(application_definition_line_index + 1, config)
237+
238+
File.open(application_filename, "w") do |file|
239+
file.puts application_lines.join("\n")
240+
end
241+
end
242+
end

gemfiles/rake.gemfile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# This file was generated by Appraisal
2+
3+
source :rubygems
4+
5+
gem "sinatra"
6+
gem "honeybadger", :path=>"../"
7+
8+
gemspec :path=>"../"

gemfiles/rake.gemfile.lock

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
PATH
2+
remote: /Users/josh/code/honeybadger-ruby
3+
specs:
4+
honeybadger (1.5.0)
5+
json
6+
7+
GEM
8+
remote: http://rubygems.org/
9+
specs:
10+
appraisal (0.5.1)
11+
bundler
12+
rake
13+
aruba (0.5.1)
14+
childprocess (~> 0.3.6)
15+
cucumber (>= 1.1.1)
16+
rspec-expectations (>= 2.7.0)
17+
bourne (1.3.0)
18+
mocha (= 0.13.0)
19+
builder (3.1.4)
20+
capistrano (2.14.1)
21+
highline
22+
net-scp (>= 1.0.0)
23+
net-sftp (>= 2.0.0)
24+
net-ssh (>= 2.0.14)
25+
net-ssh-gateway (>= 1.1.0)
26+
childprocess (0.3.6)
27+
ffi (~> 1.0, >= 1.0.6)
28+
cucumber (1.2.1)
29+
builder (>= 2.1.2)
30+
diff-lcs (>= 1.1.3)
31+
gherkin (~> 2.11.0)
32+
json (>= 1.4.6)
33+
diff-lcs (1.1.3)
34+
fakeweb (1.3.0)
35+
ffi (1.3.1)
36+
gherkin (2.11.5)
37+
json (>= 1.4.6)
38+
highline (1.6.15)
39+
json (1.7.6)
40+
metaclass (0.0.1)
41+
mocha (0.13.0)
42+
metaclass (~> 0.0.1)
43+
net-scp (1.0.4)
44+
net-ssh (>= 1.99.1)
45+
net-sftp (2.0.5)
46+
net-ssh (>= 2.0.9)
47+
net-ssh (2.6.3)
48+
net-ssh-gateway (1.1.0)
49+
net-ssh (>= 1.99.1)
50+
rack (1.4.5)
51+
rack-protection (1.3.2)
52+
rack
53+
rake (10.0.3)
54+
rspec (2.12.0)
55+
rspec-core (~> 2.12.0)
56+
rspec-expectations (~> 2.12.0)
57+
rspec-mocks (~> 2.12.0)
58+
rspec-core (2.12.2)
59+
rspec-expectations (2.12.1)
60+
diff-lcs (~> 1.1.3)
61+
rspec-mocks (2.12.2)
62+
sham_rack (1.3.4)
63+
rack
64+
shoulda (2.11.3)
65+
sinatra (1.3.3)
66+
rack (~> 1.3, >= 1.3.6)
67+
rack-protection (~> 1.2)
68+
tilt (~> 1.3, >= 1.3.3)
69+
tilt (1.3.3)
70+
71+
PLATFORMS
72+
ruby
73+
74+
DEPENDENCIES
75+
appraisal
76+
aruba
77+
bourne (>= 1.0)
78+
capistrano
79+
cucumber (~> 1.2.1)
80+
fakeweb (~> 1.3.0)
81+
honeybadger!
82+
rake
83+
rspec (~> 2.12.0)
84+
sham_rack (~> 1.3.0)
85+
shoulda (~> 2.11.3)
86+
sinatra

gemfiles/sinatra.gemfile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# This file was generated by Appraisal
2+
3+
source :rubygems
4+
5+
gem "sinatra"
6+
gem "honeybadger", :path=>"../"
7+
8+
gemspec :path=>"../"

gemfiles/sinatra.gemfile.lock

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
PATH
2+
remote: /Users/josh/code/honeybadger-ruby
3+
specs:
4+
honeybadger (1.5.0)
5+
json
6+
7+
GEM
8+
remote: http://rubygems.org/
9+
specs:
10+
appraisal (0.5.1)
11+
bundler
12+
rake
13+
aruba (0.5.1)
14+
childprocess (~> 0.3.6)
15+
cucumber (>= 1.1.1)
16+
rspec-expectations (>= 2.7.0)
17+
bourne (1.3.0)
18+
mocha (= 0.13.0)
19+
builder (3.1.4)
20+
capistrano (2.14.1)
21+
highline
22+
net-scp (>= 1.0.0)
23+
net-sftp (>= 2.0.0)
24+
net-ssh (>= 2.0.14)
25+
net-ssh-gateway (>= 1.1.0)
26+
childprocess (0.3.6)
27+
ffi (~> 1.0, >= 1.0.6)
28+
cucumber (1.2.1)
29+
builder (>= 2.1.2)
30+
diff-lcs (>= 1.1.3)
31+
gherkin (~> 2.11.0)
32+
json (>= 1.4.6)
33+
diff-lcs (1.1.3)
34+
fakeweb (1.3.0)
35+
ffi (1.3.1)
36+
gherkin (2.11.5)
37+
json (>= 1.4.6)
38+
highline (1.6.15)
39+
json (1.7.6)
40+
metaclass (0.0.1)
41+
mocha (0.13.0)
42+
metaclass (~> 0.0.1)
43+
net-scp (1.0.4)
44+
net-ssh (>= 1.99.1)
45+
net-sftp (2.0.5)
46+
net-ssh (>= 2.0.9)
47+
net-ssh (2.6.3)
48+
net-ssh-gateway (1.1.0)
49+
net-ssh (>= 1.99.1)
50+
rack (1.4.5)
51+
rack-protection (1.3.2)
52+
rack
53+
rake (10.0.3)
54+
rspec (2.12.0)
55+
rspec-core (~> 2.12.0)
56+
rspec-expectations (~> 2.12.0)
57+
rspec-mocks (~> 2.12.0)
58+
rspec-core (2.12.2)
59+
rspec-expectations (2.12.1)
60+
diff-lcs (~> 1.1.3)
61+
rspec-mocks (2.12.2)
62+
sham_rack (1.3.4)
63+
rack
64+
shoulda (2.11.3)
65+
sinatra (1.3.3)
66+
rack (~> 1.3, >= 1.3.6)
67+
rack-protection (~> 1.2)
68+
tilt (~> 1.3, >= 1.3.3)
69+
tilt (1.3.3)
70+
71+
PLATFORMS
72+
ruby
73+
74+
DEPENDENCIES
75+
appraisal
76+
aruba
77+
bourne (>= 1.0)
78+
capistrano
79+
cucumber (~> 1.2.1)
80+
fakeweb (~> 1.3.0)
81+
honeybadger!
82+
rake
83+
rspec (~> 2.12.0)
84+
sham_rack (~> 1.3.0)
85+
shoulda (~> 2.11.3)
86+
sinatra

lib/honeybadger/rails3_tasks.rb

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace :honeybadger do
55
desc "Verify your gem installation by sending a test exception to the honeybadger service"
6-
task :test => :environment do
6+
task :test do
77
Rails.logger = if defined?(ActiveSupport::TaggedLogging)
88
ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
99
else
@@ -15,6 +15,12 @@
1515
config.logger = Rails.logger
1616
end
1717

18+
# Ensure force_ssl is disabled, otherwise we'll get a 301 when we
19+
# try to hit the /verify action
20+
Rails.configuration.middleware.delete 'Rack::SSL'
21+
22+
Rake::Task['environment'].invoke
23+
1824
# Suppress error logging in Rails' exception handling middleware. Rails 3.0
1925
# uses ActionDispatch::ShowExceptions to rescue/show exceptions, but does
2026
# not log anything but application trace. Rails 3.2 now falls back to

0 commit comments

Comments
 (0)