Skip to content

Commit

Permalink
Merge pull request #2291 from adrianschroeter/package_revert_fix_27
Browse files Browse the repository at this point in the history
Package revert fix
  • Loading branch information
bgeuken committed Nov 3, 2016
2 parents 7951e02 + 1e3f21f commit 88a2809
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/api/app/controllers/webui/package_controller.rb
Expand Up @@ -278,6 +278,7 @@ def submit_request
elsif params[:project].include?(':branches:')
opts[:sourceupdate] = 'update' # Avoid auto-removal of branch
end
opts[:source_rev] = params[:rev] if params[:rev]
action = BsRequestActionSubmit.new(opts)
req.bs_request_actions << action
action.bs_request = req
Expand Down
57 changes: 57 additions & 0 deletions src/api/test/functional/webui/package_controller_test.rb
Expand Up @@ -547,4 +547,61 @@ def test_trigger_rebuild_via_live_log
page.all(:link, 'Trigger Rebuild')[0].click
find('#flash-messages').must_have_text('Triggered rebuild for BaseDistro2.0/pack2.linked successfully.')
end

def test_revert_to_revision
use_js
login_king
# create test package
visit project_show_path(project: "BaseDistro2.0")
click_link "Create package"
fill_in 'name', with: 'tst_pack'
click_button "Save changes"

# add 6 new revision to source package
6.times { |i| put '/source/BaseDistro2.0/tst_pack/rev_file_test', "revision #{(i + 1)}" }
# check latest revision
visit project_show_path(project: "BaseDistro2.0")
click_link "tst_pack"
click_link "rev_file_test"
page.must_have_text "revision 6"

# go to revision page and select second last revision (rev5)
visit package_view_revisions_path(project: 'BaseDistro2.0', package: 'tst_pack', meta: '0')
within('div#commit_item_5') do
click_link "Files changed"
end

# create "revert to revision" submit request
page.must_have_text "Changes of Revision 5"
click_link "Revert BaseDistro2.0 / tst_pack to revision 5"

# use same project, but set different target package name
page.must_have_text "Create Submit Request"
fill_in 'targetproject', with: 'BaseDistro2.0'
fill_in 'targetpackage', with: 'tst_pack_rev5'
fill_in 'description', with: 'testing revert to revision 5'
click_button 'Ok'

# check that request was submitted
page.wont_have_selector '.dialog' # wait for the reload
requestid = flash_message.gsub(%r{Created submit request (\d*) to BaseDistro2.0}, '\1').to_i

# open request from project page and accept it
visit project_show_path(project: "BaseDistro2.0")
click_link "open request"
find("a[href='/request/show/#{requestid}']").click
page.must_have_text "testing revert to revision 5"
page.must_have_text "Submit package BaseDistro2.0 / tst_pack (revision 5) to package BaseDistro2.0 / tst_pack_rev5"
click_button "Accept request"

# go to reverted package
visit project_show_path(project: "BaseDistro2.0")
click_link "tst_pack_rev5"
page.must_have_text "testing revert to revision 5"

# verify that correct revision was reverted
click_link "rev_file_test"
page.wont_have_text "revision 6" # from the latest revision
page.must_have_text "revision 5" # from the reverted revision
end
end
2 changes: 1 addition & 1 deletion src/api/test/unit/code_quality_test.rb
Expand Up @@ -98,7 +98,7 @@ def setup
'User::find_with_credentials' => 131.43,
'UserLdapStrategy::render_grouplist_ldap' => 100.3,
'Webui::DriverUpdateController#save' => 91.69,
'Webui::PackageController#submit_request' => 95.89,
'Webui::PackageController#submit_request' => 101.98,
'Webui::PatchinfoController#save' => 240.1,
'Webui::ProjectController#check_devel_package_status' => 81.95,
'Webui::SearchController#set_parameters' => 98.04,
Expand Down

0 comments on commit 88a2809

Please sign in to comment.