test/test_revision.rb in rack-revision-1.0.0 vs test/test_revision.rb in rack-revision-1.0.1

- old
+ new

@@ -44,10 +44,19 @@ assert_not_nil last_response.headers['X-REVISION'] assert_not_nil last_response.headers['X-Revision'] end + def test_blank + self.app = Rack::Revision.new(default_app, :header => false) + self.app.reset_revision + get app_url + + assert_nil last_response.headers['X-REVISION'] + assert_nil last_response.headers['X-Revision'] + end + def test_default_value self.app.reset_revision get app_url assert_equal "UNDEFINED", last_response.headers['X-Revision'] @@ -67,15 +76,50 @@ get app_url assert_not_nil last_response.headers['FOOBAR'] end - def test_default_filename + def test_custom_filename File.open('./test/tmp/REVISION', 'w') { |f| f.write('qwe123') } self.app = Rack::Revision.new(default_app, :filename => './test/tmp/REVISION') self.app.reset_revision get app_url assert_equal 'qwe123', last_response.headers['X-Revision'] end -end \ No newline at end of file + + def test_custom_filename_starting_from_root + File.open('./test/tmp/REVISION', 'w') { |f| f.write('qwe123') } + filename = File.expand_path("./test/tmp/REVISION") + + self.app = Rack::Revision.new(default_app, :filename => filename) + self.app.reset_revision + + get app_url + assert_equal 'qwe123', last_response.headers['X-Revision'] + end + + def test_env_is_present + self.app.reset_revision + get app_url + + assert_not_nil last_request.env['rack.app_revision'] + end + + def test_custom_env + self.app = Rack::Revision.new(default_app, :rack_env => 'rack.custom_env') + self.app.reset_revision + get app_url + + assert_nil last_request.env['rack.app_revision'] + assert_not_nil last_request.env['rack.custom_env'] + end + + def test_disable_env + self.app = Rack::Revision.new(default_app, :rack_env => false) + self.app.reset_revision + get app_url + + assert_nil last_request.env['rack.app_revision'] + end +end