Class | VersionsControllerTest
In: | test/functional/versions_controller_test.rb
Parent: | Test::Unit::TestCase

### Methods

setup teardown test_show_and_diff

### Public Instance methods

setup()

[Source]

        # File test/functional/versions_controller_test.rb, line 25
    25:   def setup
    26:     logger.debug "Test Case: #{name}"
    27:     @controller = VersionsController.new
    28:     @request    = ActionController::TestRequest.new
    29:     @response   = ActionController::TestResponse.new
    30:     #@oup_20060721 = create_oup_20060721
    31:     #@oup_wiki = create_oup_wiki(@oup_20060721)
    32:     @andy = users(:andy) # admin
    33:     @george = users(:george) # central admin
    34:     @tony = users(:tony) # user
    35:     @admin = users(:admin)
    36:   end

teardown()

[Source]

        # File test/functional/versions_controller_test.rb, line 38
    38:   def teardown
    39:     [ENV['EPFWIKI_SITES_PATH'], ENV['EPFWIKI_WIKIS_PATH']].each do |p|
    40:       FileUtils.rm_r(p) if File.exists?(p)
    41:       File.makedirs(p)
    42:     end
    43:   end

test_show_and_diff()

     Shows
     1. Login required
     2. All users can access version details
     3. Get diif of equal versions
     4. Post diff of equal versions
     5. Post diff of versions with differences

show, diff, text, note

[Source]

        # File test/functional/versions_controller_test.rb, line 52
    52:   def test_show_and_diff
    53:     create_templates
    54:     p = WikiPage.find(:first)
    55:     create_some_data(p)
    56:     # 1
    57:     version = Version.find(:first)
    58:     assert_not_nil version
    59:     get :show, :id => version.id
    60:     assert_tologin
    61:     # 2
    62:     [@andy, @george, @tony].each do |user|
    63:       session['user'] = user
    64:       Version.find(:all).each do |v|
    65:         get :show, :id => v.id
    66:         # 2
    67:         assert_response :success
    68:         assert_not_nil assigns(:version)
    69:       end
    70:     end
    71:     assert_equal 17, p.versions.size
    72:     v1 = p.versions[14]
    73:     v2 = p.versions[15]
    74:     # 3
    75:     get :diff, :id => v2.id
    76:     assert_response :success
    77:     assert_not_nil assigns(:version)
    78:     assert_equal v1, assigns(:version).source_version
    79:     assert_equal assigns(:versions), p.versions
    80:     assert_equal p, assigns(:page)
    81:     assert_equal p.site, assigns(:wiki)
    82:     # 4
    83:     post :diff, :version => {:id => v2.id, :version_id => v1.id}
    84:     assert_response :success
    85:     assert_equal assigns(:versions), p.versions
    86:     assert_equal p, assigns(:page)
    87:     assert_equal p.site, assigns(:wiki)
    88:     # 5
    89:     v2.html = v2.html.gsub('</body>','a change</body>')
    90:     post :diff, :version => {:id => v2.id, :version_id => v1.id}
    91:     assert_response :success
    92:     assert_equal assigns(:versions), p.versions
    93:     assert_equal p, assigns(:page)
    94:     assert_equal p.site, assigns(:wiki)
    95:   end

[Validate]