cirandas.net

ref: master

test/functional/my_profile_controller_test.rb


 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
32
33
34
35
36
require_relative '../test_helper'

class OnlyForPersonTestController < MyProfileController
  requires_profile_class Person
  def index
    render :text => '<div>something</div>'
  end
end

class MyProfileControllerTest < ActionController::TestCase

  all_fixtures
  def setup
    @controller = MyProfileController.new
  end

  def test_should_allow_person
    @controller = OnlyForPersonTestController.new
    person = create_user('random_joe')
    login_as('random_joe')

    get :index, :profile => 'random_joe'
    assert_response :success
  end

  def test_should_not_allow_bare_profile
    @controller = OnlyForPersonTestController.new
    org = Organization.create!(:identifier => 'hacking_institute', :name => 'Hacking Institute')
    create_user('random_joe')
    login_as('random_joe')

    get :index, :profile => 'hacking_institute'
    assert_response 403 # forbidden
  end

end