diff options
Diffstat (limited to 'certs/test/functional/certs_controller_test.rb')
-rw-r--r-- | certs/test/functional/certs_controller_test.rb | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/certs/test/functional/certs_controller_test.rb b/certs/test/functional/certs_controller_test.rb index 75256ca..7826dd6 100644 --- a/certs/test/functional/certs_controller_test.rb +++ b/certs/test/functional/certs_controller_test.rb @@ -1,21 +1,40 @@ require 'test_helper' class CertsControllerTest < ActionController::TestCase - setup do - end - test "should require login" do + test "send free cert without login" do + cert = stub :to_s => "free cert" + ClientCertificate.expects(:new).with(free: true).returns(cert) get :show - assert_response :redirect - assert_redirected_to login_url + assert_response :success + assert_equal cert.to_s, @response.body end - test "should send cert" do + test "send cert" do login - cert = stub :cert => "adsf", :key => "key" - ClientCertificate.expects(:new).returns(cert) + cert = stub :to_s => "real cert" + ClientCertificate.expects(:new).with(free: false).returns(cert) get :show assert_response :success - assert_equal cert.key + cert.cert, @response.body + assert_equal cert.to_s, @response.body + end + + test "login required if free certs disabled" do + with_config free_certs_enabled: false do + get :show + assert_response :redirect + 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 + end |