summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2013-12-29 19:25:05 -0800
committerelijah <elijah@riseup.net>2013-12-29 19:25:05 -0800
commitf619178085d0c2729e275fa4f46f9cd981189d3e (patch)
treee6c715c21723e54d2742bf97238e2e01abe8fc2a /test
parent314d6cce723558497165103658cbf013f1eb8e9a (diff)
Return 'provider.json' via a controller, to better be able to control the response headers (in particular, 'X-Minimum-Client-Version'). It must now be placed in config/provider/provider.json
Diffstat (limited to 'test')
-rw-r--r--test/files/provider.json3
-rw-r--r--test/functional/static_config_controller_test.rb27
-rw-r--r--test/test_helper.rb5
3 files changed, 35 insertions, 0 deletions
diff --git a/test/files/provider.json b/test/files/provider.json
new file mode 100644
index 0000000..7f45293
--- /dev/null
+++ b/test/files/provider.json
@@ -0,0 +1,3 @@
+{
+ "name": "test provider"
+} \ No newline at end of file
diff --git a/test/functional/static_config_controller_test.rb b/test/functional/static_config_controller_test.rb
new file mode 100644
index 0000000..9c2cfef
--- /dev/null
+++ b/test/functional/static_config_controller_test.rb
@@ -0,0 +1,27 @@
+require 'test_helper'
+
+# use minitest for stubbing, rather than bloated mocha
+require 'minitest/stub_const'
+
+class StaticConfigControllerTest < ActionController::TestCase
+
+ def setup
+ end
+
+ def test_provider_success
+ StaticConfigController.stub_const(:PROVIDER_JSON, file_path('provider.json')) do
+ get :provider, format: :json
+ assert_equal 'application/json', @response.content_type
+ assert_response :success
+ end
+ end
+
+ def test_provider_not_modified
+ StaticConfigController.stub_const(:PROVIDER_JSON, file_path('provider.json')) do
+ request.env["HTTP_IF_MODIFIED_SINCE"] = File.mtime(file_path('provider.json')).rfc2822()
+ get :provider, format: :json
+ assert_response 304
+ end
+ end
+
+end
diff --git a/test/test_helper.rb b/test/test_helper.rb
index b2f674d..3e301e7 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -9,6 +9,11 @@ Dir["#{File.dirname(__FILE__)}/../*/test/support/**/*.rb"].each { |f| require f
class ActiveSupport::TestCase
# Add more helper methods to be used by all tests here...
+
+ def file_path(name)
+ File.join(Rails.root, 'test', 'files', name)
+ end
+
end
require 'capybara/poltergeist'