Skip to content

Commit

Permalink
add tests for ErrorReport#should_keep?
Browse files Browse the repository at this point in the history
  • Loading branch information
soberstadt committed Dec 10, 2013
1 parent a87d750 commit e2bfccb
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/notices_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def create
end
render :xml => api_xml
else
render :xml => "Notice for old app version ignored"
render :text => "Notice for old app version ignored"
end
else
render :text => "Your API key is unknown", :status => 422
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/notices_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
let(:notice) { Fabricate(:notice) }
let(:xml) { Rails.root.join('spec','fixtures','hoptoad_test_notice.xml').read }
let(:app) { Fabricate(:app) }
let(:error_report) { double(:valid? => true, :generate_notice! => true, :notice => notice) }
let(:error_report) { double(:valid? => true, :generate_notice! => true, :notice => notice, :should_keep? => true) }

context 'notices API' do
context "with all params" do
Expand Down
30 changes: 30 additions & 0 deletions spec/models/error_report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -230,5 +230,35 @@ def framework
end
end

describe "#should_keep?" do
context "with current app version not set" do
before do
error_report.app.current_app_version = nil
error_report.server_environment['app-version'] = '1.0'
end

it "return true" do
expect(error_report.should_keep?).to be true
end
end

context "with current app version set" do
before do
error_report.app.current_app_version = '1.0'
end

it "return true if current or newer" do
error_report.server_environment['app-version'] = '1.0'
expect(error_report.should_keep?).to be true
end

it "return false if older" do
error_report.server_environment['app-version'] = '0.9'
expect(error_report.should_keep?).to be false
end
end

end

end
end

0 comments on commit e2bfccb

Please sign in to comment.