diff options
author | Azul <azul@leap.se> | 2013-02-25 13:19:23 +0100 |
---|---|---|
committer | Azul <azul@leap.se> | 2013-02-25 13:31:58 +0100 |
commit | 9c4eb32c22e6bf49d84b6ac1fa4fc5cde5374a7a (patch) | |
tree | b302a527ce939dd498b68f4f87dbcd95bfb8cf26 /certs/test/functional | |
parent | 494ebdab860a4db792e1c61836f1efcb7593dfe7 (diff) |
tests refactored with with_config helper
also added test for getting paid certs if free certs are disabled
Diffstat (limited to 'certs/test/functional')
-rw-r--r-- | certs/test/functional/certs_controller_test.rb | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/certs/test/functional/certs_controller_test.rb b/certs/test/functional/certs_controller_test.rb index 70ca56d..7826dd6 100644 --- a/certs/test/functional/certs_controller_test.rb +++ b/certs/test/functional/certs_controller_test.rb @@ -20,13 +20,20 @@ class CertsControllerTest < ActionController::TestCase end test "login required if free certs disabled" do - begin - old_setting = APP_CONFIG[:free_certs_enabled] - APP_CONFIG[:free_certs_enabled] = false + with_config free_certs_enabled: false do get :show assert_response :redirect - ensure - APP_CONFIG[:free_certs_enabled] = old_setting + end + end + + test "get paid cert if free certs disabled" do + with_config free_certs_enabled: false do + login + cert = stub :to_s => "real cert" + ClientCertificate.expects(:new).with(free: false).returns(cert) + get :show + assert_response :success + assert_equal cert.to_s, @response.body end end |