Log In
Log In
Places
All Projects
Status Monitor
Collapse sidebar
obs:server:fedora:2.6:testing
obs-server
obs-server-2.6.6-0012-api-webui-update-ruby.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File obs-server-2.6.6-0012-api-webui-update-ruby.patch of Package obs-server
From fdb4e75db4f5fabe5445b0d3104a2c732419168f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Schr=C3=B6ter?= <adrian@suse.de> Date: Thu, 18 Jun 2015 08:14:55 +0200 Subject: [PATCH 12/14] [api][webui] update ruby* including - ruby 2.1 -> 2.2.2 also fixing some conflicting keys fixing some places where the test case did leave the backend data modified --- src/api/Gemfile | 1 + src/api/app/models/build_container.rb | 2 +- src/api/app/models/group.rb | 2 +- src/api/app/models/role.rb | 2 +- .../functional/distributions_controller_test.rb | 3 +- src/api/test/functional/product_test.rb | 3 +- src/api/test/functional/search_controller_test.rb | 38 ++++++++++++++++++++++ src/api/test/functional/source_controller_test.rb | 15 +++++++++ src/api/test/test_helper.rb | 17 ++++++++++ 9 files changed, 77 insertions(+), 6 deletions(-) diff --git a/src/api/Gemfile b/src/api/Gemfile index 574b6ee..00935ea 100644 --- a/src/api/Gemfile +++ b/src/api/Gemfile @@ -63,6 +63,7 @@ group :test do # to update to 5.3.4, we need to fix randomization # see https://github.com/seattlerb/minitest/issues/431 gem 'minitest', '= 5.3.3' + gem 'test-unit' # to ensure a clean state for testing gem 'database_cleaner', '>= 1.0.1' # for jenkins diff --git a/src/api/app/models/build_container.rb b/src/api/app/models/build_container.rb index 85b1d99..0c3052b 100644 --- a/src/api/app/models/build_container.rb +++ b/src/api/app/models/build_container.rb @@ -42,7 +42,7 @@ class BuildContainer < ActiveRecord::Base raise NotFoundError.new( "Error: Package not valid." ) unless package.kind_of? String raise NotFoundError.new( "Error: Repository not valid." ) unless repository.kind_of? Repository raise NotFoundError.new( "Error: Architecture not valid." ) unless architecture.kind_of? Architecture - obj = self.joins(:repository_architecture).where(package_id: nil, local_project: project, remote_package: package, remote_package: package, repository_architectures: {repository_id: repository.id, architecture_id: architecture.id}) + obj = self.joins(:repository_architecture).where(package_id: nil, local_project: project, remote_package: package, repository_architectures: {repository_id: repository.id, architecture_id: architecture.id}) return nil if obj.empty? return obj.load diff --git a/src/api/app/models/group.rb b/src/api/app/models/group.rb index 820ef74..034c1c8 100644 --- a/src/api/app/models/group.rb +++ b/src/api/app/models/group.rb @@ -15,7 +15,7 @@ class Group < ActiveRecord::Base :with => %r{\A[\w\.\-]*\z}, :message => 'must not contain invalid characters.' validates_length_of :title, - :in => 2..100, :allow_nil => true, + :in => 2..100, :too_long => 'must have less than 100 characters.', :too_short => 'must have more than two characters.', :allow_nil => false diff --git a/src/api/app/models/role.rb b/src/api/app/models/role.rb index 505acf6..7da2d9c 100644 --- a/src/api/app/models/role.rb +++ b/src/api/app/models/role.rb @@ -17,7 +17,7 @@ class Role < ActiveRecord::Base :with => %r{\A\w*\z}, :message => 'must not contain invalid characters.' validates_length_of :title, - :in => 2..100, :allow_nil => true, + :in => 2..100, :too_long => 'must have less than 100 characters.', :too_short => 'must have more than two characters.', :allow_nil => false diff --git a/src/api/test/functional/distributions_controller_test.rb b/src/api/test/functional/distributions_controller_test.rb index 6f3887e..fbba735 100644 --- a/src/api/test/functional/distributions_controller_test.rb +++ b/src/api/test/functional/distributions_controller_test.rb @@ -7,8 +7,7 @@ class DistributionsControllerTest < ActionDispatch::IntegrationTest get distribution_path(id: distributions(:two).to_param) assert_response :success # the default XML renderer just s***s - assert_equal({"id"=>{"type"=>"integer", "_content"=>"2"}, - "id"=>{"type"=>"integer", "_content"=>"2"}, + assert_equal({ "id"=>{"type"=>"integer", "_content"=>"2"}, "link"=>"http://www.openbuildservice.org/", "name"=>"OBS Base 2.0", "project"=>"BaseDistro2.0", diff --git a/src/api/test/functional/product_test.rb b/src/api/test/functional/product_test.rb index a4b3e7c..9fd00c6 100644 --- a/src/api/test/functional/product_test.rb +++ b/src/api/test/functional/product_test.rb @@ -206,7 +206,8 @@ class ProductTests < ActionDispatch::IntegrationTest get "/source/home:tom:temporary/_product?view=productrepositories" assert_response :success assert_xml_tag :parent => { :tag => "repository", :attributes => { :path => 'BaseDistro2.0:/LinkedUpdateProject/BaseDistro2LinkedUpdateProject_repo' } }, - :tag => "update", + :tag => "update" + assert_xml_tag :parent => { :tag => "repository", :attributes => { :path => 'BaseDistro2.0:/LinkedUpdateProject/BaseDistro2LinkedUpdateProject_repo' } }, :tag => "zypp", :attributes => { :name => "basedistro2 update distribution", :alias => "basedistro2_alias" } assert_xml_tag :tag => "distrotarget", :attributes => { :arch => "x86_64" }, :content => "DiStroTarGet_x86" assert_xml_tag :tag => "distrotarget", :content => "DiStroTarGet" diff --git a/src/api/test/functional/search_controller_test.rb b/src/api/test/functional/search_controller_test.rb index a4021d2..78a31ac 100644 --- a/src/api/test/functional/search_controller_test.rb +++ b/src/api/test/functional/search_controller_test.rb @@ -434,6 +434,44 @@ class SearchControllerTest < ActionDispatch::IntegrationTest assert_response :success assert_xml_tag tag: 'collection', :children => { :count => 0 } + # lookup maintainers + get "/search/owner?project=home:Iggy" + assert_response :success + assert_xml_tag tag: 'collection', :children => { :count => 1 } + assert_xml_tag :parent => { tag: 'owner', :children => { :count => 2 }, + :attributes => { :rootproject => "", :project => "home:Iggy" }}, + tag: 'person', :attributes => { :name => "Iggy", :role => "maintainer" } + + get "/search/owner?project=home:Iggy&package=TestPack" + assert_xml_tag tag: 'collection', :children => { :count => 2 } + assert_xml_tag :parent => { tag: 'owner', :children => { :count => 4 }, + :attributes => { :project => "home:Iggy", :package => "TestPack" }}, + tag: 'person', :attributes => { :name => "fred", :role => "maintainer" } + assert_xml_tag :parent => { tag: 'owner', :children => { :count => 4 }, + :attributes => { :project => "home:Iggy", :package => "TestPack" }}, + tag: 'person', :attributes => { :name => "Iggy", :role => "bugowner" } + assert_xml_tag :parent => { tag: 'owner', :children => { :count => 4 }, + :attributes => { :project => "home:Iggy", :package => "TestPack" }}, + tag: 'person', :attributes => { :name => "Iggy", :role => "maintainer" } + assert_xml_tag :parent => { tag: 'owner', :children => { :count => 4 }, + :attributes => { :project => "home:Iggy", :package => "TestPack" }}, + tag: 'group', :attributes => { :name => "test_group_b", :role => "maintainer" } + assert_xml_tag :parent => { tag: 'owner', :children => { :count => 2 }, + :attributes => { :project => "home:Iggy" } }, + tag: 'person', :attributes => { :name => "hidden_homer", :role => "maintainer" } + + get "/search/owner?project=home:Iggy&package=TestPack&filter=bugowner" + # no bugowner defined for the project => no owner node for the project + assert_xml_tag tag: 'collection', :children => { :count => 1 } + assert_xml_tag :parent => { tag: 'owner', :children => { :count => 1 }, + :attributes => { :project => "home:Iggy", :package => "TestPack" }}, + tag: 'person', :attributes => { :name => "Iggy", :role => "bugowner" } + + get "/search/owner?project=home:coolo:test" + assert_xml_tag tag: 'collection', :children => { :count => 2 } + assert_xml_tag tag: 'owner', :children => { :count => 1 }, :attributes => { :project => "home:coolo:test" } + assert_xml_tag tag: 'owner', :children => { :count => 1 }, :attributes => { :project => "home:coolo" } + # some illegal searches get "/search/owner?user=INVALID&filter=bugowner" assert_response 404 diff --git a/src/api/test/functional/source_controller_test.rb b/src/api/test/functional/source_controller_test.rb index 5d3abc9..e1b380a 100644 --- a/src/api/test/functional/source_controller_test.rb +++ b/src/api/test/functional/source_controller_test.rb @@ -3264,6 +3264,14 @@ class SourceControllerTest < ActionDispatch::IntegrationTest end test 'have the same user role twice in package meta' do + login_tom + get '/source/home:Iggy/_meta' + assert_response :success + orig_prj_meta = @response.body + get '/source/home:Iggy/TestPack/_meta' + assert_response :success + orig_pkg_meta = @response.body + ret = duplicated_user_test('package', 'user', '/source/home:Iggy/TestPack/_meta') assert_equal({ 'name' => 'TestPack', 'project' => 'home:Iggy', @@ -3301,6 +3309,13 @@ class SourceControllerTest < ActionDispatch::IntegrationTest 'group' => [{ 'groupid' => 'test_group', 'role' => 'bugowner' }, { 'groupid' => 'test_group', 'role' => 'maintainer' }] }, ret) + + # restore (esp in backend) + login_king + put '/source/home:Iggy/_meta', orig_prj_meta + assert_response :success + put '/source/home:Iggy/TestPack/_meta', orig_pkg_meta + assert_response :success end test 'store invalid package' do diff --git a/src/api/test/test_helper.rb b/src/api/test/test_helper.rb index fc09f71..de5f750 100644 --- a/src/api/test/test_helper.rb +++ b/src/api/test/test_helper.rb @@ -70,6 +70,23 @@ def inject_build_job(project, package, repo, arch, extrabinary=nil) system("echo \"#{verifymd5} #{package}\" > #{jobfile}:dir/meta") end +module Minitest + def self.__run reporter, options + # there is no way to avoid the randomization of used suites, so we overload this method. + suites = Runnable.runnables #.shuffle <- disabled here + parallel, serial = suites.partition { |s| s.test_order == :parallel } + + serial.map { |suite| suite.run reporter, options } + + parallel.map { |suite| suite.run reporter, options } + end + # we should fix this first ... unfortunatly there seems to be no way to repeat the last order + # to find out what went wrong and to validate it :( + def self.sort_order + :sorted + end +end + + module ActionDispatch module Integration class Session -- 2.1.0
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Contact
Support
@OBShq
The Open Build Service is an
openSUSE project
.
Log In
Places
Places
All Projects
Status Monitor