Class | CreatingSitesAndWikisTest
In: | test/integration/creating_sites_and_wikis_test.rb
Parent: | ActionController::IntegrationTest

Copyright (c) 2006 Logica

### Methods

setup teardown test_create_site

### Classes and Modules

Module CreatingSitesAndWikisTest::TestingDSL

### Public Instance methods

setup()

[Source]

        # File test/integration/creating_sites_and_wikis_test.rb, line 28
    28:   def setup
    29:     logger.debug "Test Case: #{name}"
    30:     @wiki = create_templates
    31:     @wiki.reload
    32:     @bp = @wiki.baseline_process
    33:     @george = users(:george) # central admin
    34:     @tony = users(:tony) # user
    35:   end

teardown()

[Source]

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

test_create_site()

Shows:

1. user makes a change (checkout, checkin) (about_base_concepts)
2. user makes a change (checkout, checkin) (any_role) and marks versions done
3. user creates a checkout and saves a change (determine_architectural_feasibility)
4. user create a checkout and saves a change (requirements)
5. openup is updated to "openup0728"
6. changes to "about_page_concepts" are still there,

        the page was not harvested (there are version marked 'todo'

7. changes to any_role are gone, the page was harvested
8. changes to feasibility are gone, but they remain in checked-out version, of course
9. changes to requirements are gone, but they remain in checked-out version, of course
10. user checks in feasibility
11. undo of checkout requirements, changes are lost, there are no unharvested versions
12. undo of page with unharvested changes of another baseline (update to "openup0825"), feasibility
13. checkout of "about_page_concepts" creates version 1

TODO blog.finalist.com/2007/02/12/test-driven-development-met-ruby-on-rails/

[Source]

         # File test/integration/creating_sites_and_wikis_test.rb, line 61
     61:   def test_create_site
     62:     get '/'
     63:     get 'portal/home'
     64:     assert_response :success
     65:     assert_no_errors
     66:     @tony.confirmed_on = Time.now
     67:     @tony.password = 'Tony Clifton'
     68:     @tony.save!
     69:     user = login(@tony)
     70:     # 1
     71:     @page1 = WikiPage.find_by_presentation_name('Toolmentor Template')
     72:     user.post 'pages/checkout', :version => {:version_id => @page1.current_version.id, :note => 'Changing toolmentor template'}
     73:     user.assert_redirected_to :action => 'edit', :checkout_id => @page1.checkout.id
     74:     assert_not_nil @page1.checkout
     75:     html = @page1.html
     76:     assert_not_nil html
     77:     html = html.gsub('type of guidance', 'novel, novel, novel, aspects')
     78:     user.post 'pages/checkin', :checkout_id => @page1.checkout.id, :html => html
     79:     #assert_equal PagesController::FLASH_CHECKIN_SUCCESS, user.flash['success'] # TODO can't test this because we use flash.now, this only works without 'now'
     80:     assert_equal 1, @page1.current_version.version
     81:     assert_nil @page1.checkout
     82:     assert @page1.html.include?('novel, novel, novel, aspects')
     83:     # 2
     84:     page2 = WikiPage.find_by_presentation_name('Checklist Template')
     85:     user.post 'pages/checkout', :version => {:version_id => page2.current_version.id, :note => 'Changing checklist template'}
     86:     user.assert_redirected_to :action => 'edit', :checkout_id => page2.checkout.id
     87:     assert_equal 0, page2.checkout.version.source_version.version
     88:     html = page2.html
     89:     assert_not_nil html
     90:     html = html.gsub('completed or verified', 'by any, any, any one')
     91:     user.post 'pages/checkin', :checkout_id => page2.checkout.id, :html => html
     92:     #assert_equal PagesController::FLASH_CHECKIN_SUCCESS, user.flash['success'] can't test for flash now
     93:     assert_equal 2, page2.versions.size
     94:     assert_nil page2.checkout
     95:     page2.versions.each do |v|
     96:       if v.version == 0
     97:         assert_equal 'Y', v.done
     98:       else
     99:         assert_equal 'N', v.done
    100:         v.done = 'Y'
    101:         assert v.save
    102:       end
    103:     end
    104:     # 3
    105:     page3 = WikiPage.find_by_presentation_name('Practice Template')
    106:     user.post 'pages/checkout', :version => {:version_id => page3.current_version.id, :note => 'Changing feasibility'}
    107:     user.assert_redirected_to :action => 'edit', :checkout_id => page3.checkout.id
    108:     assert_equal 0, page3.checkout.version.source_version.version
    109:     html = page3.html
    110:     assert_not_nil html
    111:     html = html.gsub('a proven way or strategy of doing work', 'Confirm, confirm, confirm that the project')
    112:     user.post 'pages/save', :checkout_id => page3.checkout.id, :html => html
    113:     assert_not_nil page3.checkout
    114:     # 4
    115:     page4 = WikiPage.find_by_presentation_name('Report Template')
    116:     user.post 'pages/checkout', :version => {:version_id => page4.current_version.id, :note => 'Changing requirements'}
    117:     user.assert_redirected_to :action => 'edit', :checkout_id => page4.checkout.id
    118:     assert_equal 0, page4.checkout.version.source_version.version
    119:     html = page4.html
    120:     assert_not_nil html
    121:     html = html.gsub('predefined template of a result', 'list, list, list of work')
    122:     user.post 'pages/save', :checkout_id => page4.checkout.id, :html => html
    123:     assert_not_nil page4.checkout
    124:     assert_equal 1, page4.versions.size # NOTE checkout.version is not counted by page4.versions
    125:     # 5
    126:     # TODO test for sending of email
    127:     cv_before = @page1.current_version
    128:     update = Update.new(:wiki => @wiki, :user => @george, :baseline_process => @bp)
    129:     assert update.save
    130:     update.do_update
    131:     # 6
    132:     #assert @page1.html.index('novel, novel, novel, aspects') todo activate
    133:     cv_after = @page1.current_version
    134:     assert_equal cv_before, cv_after # same version
    135:     assert cv_after.current # marked current
    136:     # 7
    137:     assert !page2.html.index('by any, any, any one')
    138:     # 8
    139:     assert !page3.html.index('Confirm, confirm, confirm that the project')
    140:     assert page3.checkout.version.html.index('Confirm, confirm, confirm that the project')
    141:     # 9
    142:     assert !page4.html.index('list, list, list of work')
    143:     assert page4.checkout.version.html.index('list, list, list of work')
    144:     # 10
    145:     co = page3.checkout
    146:     user.post 'pages/checkin', :checkout_id => co.id # is checked in on baseline OpenUP-Basic_published_20060728test!
    147:     page3.reload
    148:     assert_nil page3.checkout
    149:     assert page3.html.index('Confirm, confirm, confirm that the project')
    150:     page3.reload
    151:     v0, v1, v2 = page3.versions[0], page3.versions[1], page3.versions[2]
    152:     assert_equal ['BaselineProcessVersion', 'BaselineProcessVersion', 'UserVersion'],[v0.class.name, v1.class.name, v2.class.name]
    153:     assert_equal [[0,@bp.title],[1,@bp.title], [2,nil]],
    154:     [  [v0.version, v0.baseline_process.title],
    155:     [v1.version, v1.baseline_process.title],
    156:     [v2.version, v2.baseline_process_id]]
    157:     assert_equal 3, page3.versions.size # previous 2, current 2 versions
    158:     version = page3.current_version
    159:     # 11
    160:     checkout = page4.checkout
    161:     user.post 'pages/undocheckout', :checkout_id => checkout.id
    162:     page4.reload
    163:     assert_nil page4.checkout
    164:     version = page4.current_version
    165:     assert_equal 1, version.version
    166:     assert !version.current
    167:     # 12
    168:     # create checkout
    169:     user.post 'pages/checkout',:version => {:version_id => page3.current_version.id, :note => 'Changing stuff'}
    170:     user.assert_redirected_to :action => 'edit', :checkout_id => page3.checkout.id
    171:     assert_equal 2, page3.checkout.version.source_version.version
    172:     v = page3.current_version
    173:     lv = page3.last_version
    174:     assert_equal 'N', v.done # version is not harvested
    175:     assert !v.current # also not current, it doesn't need to be, because there is a checkout
    176:     assert v = lv
    177:     assert_equal 2, lv.version
    178:     assert_equal 2, v.version
    179:     assert_equal v.id, page3.checkout.version.source_version.id
    180:     html = page3.html
    181:     assert_not_nil html
    182:     assert html.index('Confirm, confirm, confirm that')
    183:     # update wiki
    184:     update = Update.new(:wiki => @wiki, :user => @george, :baseline_process => @bp)
    185:     assert update.save
    186:     update.do_update
    187:     version = page3.current_version
    188:     # undo checkout
    189:     user.post 'pages/undocheckout', :checkout_id => page3.checkout.id
    190:     version.reload
    191:     assert_equal version, page3.current_version
    192:     # 13
    193:     version = @page1.current_version
    194:     assert version.current # explicitly set version as there were unharvested versions during update
    195:     assert_not_nil @page1.current_version
    196:     user.post 'pages/checkout',:version => {:version_id => @page1.current_version.id, :note => 'Changing stuff'}
    197:     version.reload
    198:     assert version.current # version remains current
    199:     checkout = @page1.checkout
    200:     assert_not_nil checkout
    201:     assert_equal version, checkout.version.source_version # current version was selected as the source version
    202:   end

[Validate]