diff options
author | azul <azul@riseup.net> | 2013-02-26 07:25:12 -0800 |
---|---|---|
committer | azul <azul@riseup.net> | 2013-02-26 07:25:12 -0800 |
commit | 5dbbf733a6abe809a38667e8b3277fd06db24788 (patch) | |
tree | 14f60e6facd88dc5d218aec14175a59fdf5834ad /certs/test/functional/certs_controller_test.rb | |
parent | 1023cac35016bb1a89864d10ac89acabe86cf227 (diff) | |
parent | 2eafc17ea68e75e6b040b6c6677e5eebd3371f0e (diff) |
Merge pull request #27 from leapcode/feature/free-certs
Enable free certs
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 |