summaryrefslogtreecommitdiff
path: root/users/test/functional/keys_controller_test.rb
blob: 9cc88d1898d568d11c850a8939b29110f0d13228 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require 'test_helper'

class KeysControllerTest < ActionController::TestCase

  test "get existing public key" do
    public_key = 'my public key'
    @user = stub_record :user, :public_key => public_key
    User.stubs(:find_by_login).with(@user.login).returns(@user)
    get :show, :login => @user.login
    assert_response :success
    assert_equal "text/html", response.content_type
    assert_equal public_key, response.body
  end

  test "get non-existing public key for user" do
    @user = stub_record :user
    User.stubs(:find_by_login).with(@user.login).returns(@user)
    get :show, :login => @user.login
    assert_response :success
    assert_equal "text/html", response.content_type
    assert_equal '', response.body.strip
  end

  test "get public key for non-existing user" do
    get :show, :login => 'asdkljslksjfdlskfj'
    assert_response :success
    assert_equal "text/html", response.content_type
    assert_equal '', response.body.strip
  end

end