admin_panel_controller_test.rb
1.39 KB
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
37
38
39
40
41
42
require File.dirname(__FILE__) + '/../test_helper'
require 'admin_panel_controller'
# Re-raise errors caught by the controller.
class AdminPanelController; def rescue_action(e) raise e end; end
class AdminPanelControllerTest < Test::Unit::TestCase
  all_fixtures
  def setup
    @controller = AdminPanelController.new
    @request    = ActionController::TestRequest.new
    @response   = ActionController::TestResponse.new
    login_as(create_admin_user(Environment.default))
  end
  def test_index
    get :index
    assert_template 'index'
    assert_tag :tag => 'a', :attributes => { :href => /site_info/ }
    assert_tag :tag => 'a', :attributes => { :href => /categories/ }
    assert_tag :tag => 'a', :attributes => { :href => /edit_template/ }
    assert_tag :tag => 'a', :attributes => { :href => /features/ }
    assert_tag :tag => 'a', :attributes => { :href => /role/ }
    assert_tag :tag => 'a', :attributes => { :href => /region_validators/ }
  end
  
  should 'display form for editing site info' do
    get :site_info
    assert_template 'site_info'
    assert_tag :tag => 'textarea', :attributes => { :name => 'environment[description]'}
  end
  should 'save site description' do
    post :site_info, :environment => { :description => "This is my new environment" }
    assert_redirected_to :action => 'index'
    assert_equal "This is my new environment", Environment.default.description
  end
end