Skip to content

Commit

Permalink
[api] move more webui logic to use API models
Browse files Browse the repository at this point in the history
  • Loading branch information
coolo committed Oct 20, 2013
1 parent b3de9ee commit 35d89c6
Show file tree
Hide file tree
Showing 68 changed files with 646 additions and 899 deletions.
74 changes: 0 additions & 74 deletions src/api/app/controllers/webui/packages_controller.rb

This file was deleted.

2 changes: 0 additions & 2 deletions src/api/app/controllers/webui/requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ def show
def by_class
if name = params[:project]
obj = Project.find_by_name! name
elsif login = params[:user]
obj = User.find_by_login! login
else
render_error :status => 400, :errorcode => 'require_filter',
:message => "This call requires at least one filter, either by user or project"
Expand Down
1 change: 0 additions & 1 deletion src/api/app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,6 @@ def request_ids_by_class
result
end


def self.fetch_field(person, field)
p = User.where(login: person).pluck(field)
p[0] || ''
Expand Down
3 changes: 0 additions & 3 deletions src/api/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,6 @@
end
end
resources :flags, :only => [:index]
member do
get 'rdiff'
end
end
end
resources :packages, :only => [], constraints: { :id => %r{[^\/]*} } do
Expand Down
11 changes: 1 addition & 10 deletions src/api/lib/activexml/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,8 @@ def find( *args )
find_priv(nil, *args )
end

def find_cached( *args )
expires_in = 30.minutes
if args.last.kind_of?(Hash) and args.last[:expires_in]
expires_in = args.last[:expires_in]
args.last.delete :expires_in
end
find_priv(expires_in, *args)
end

def find_hashed( *args )
ret = find_cached( *args )
ret = find( *args )
return Xmlhash::XMLHash.new({}) unless ret
ret.to_hash
end
Expand Down
2 changes: 0 additions & 2 deletions src/api/test/functional/webui/all_routes_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class Webui::AllRoutesTest < Webui::IntegrationTest
urls << webui_engine.patchinfo_new_patchinfo_path
urls << webui_engine.patchinfo_updatepatchinfo_path
urls << webui_engine.patchinfo_edit_patchinfo_path
urls << webui_engine.patchinfo_show_path
urls << webui_engine.patchinfo_read_patchinfo_path
urls << webui_engine.patchinfo_save_path
urls << webui_engine.patchinfo_remove_path
Expand Down Expand Up @@ -148,7 +147,6 @@ class Webui::AllRoutesTest < Webui::IntegrationTest
urls << webui_engine.user_delete_path
urls << webui_engine.user_tokens_path
urls << webui_engine.user_do_login_path
urls << webui_engine.group_show_path
urls << webui_engine.group_add_path
urls << webui_engine.group_save_path
urls << webui_engine.group_tokens_path
Expand Down
77 changes: 44 additions & 33 deletions src/api/test/functional/webui/package_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,73 +7,73 @@ def delete_and_recreate_kdelibs
delete_package 'kde4', 'kdelibs'

# now we need to recreate it again to avoid teardown to leave a mess in backend/API
find(:link, "Create package").click
fill_in "name", with: 'kdelibs'
fill_in "title", with: "blub" # see the fixtures!!
find_button("Save changes").click
find(:link, 'Create package').click
fill_in 'name', with: 'kdelibs'
fill_in 'title', with: 'blub' # see the fixtures!!
find_button('Save changes').click
page.must_have_selector '#delete-package'
end

test "show package binary as user" do
login_user("fred", "geröllheimer")
visit(webui_engine.package_binaries_path(package: "TestPack", project: "home:Iggy", repository: "10.2"))
test 'show package binary as user' do
login_user('fred', 'geröllheimer')
visit(webui_engine.package_binaries_path(package: 'TestPack', project: 'home:Iggy', repository: '10.2'))

find(:link, "Show").click
page.must_have_text "Maximal used disk space: 1005 Mbyte"
page.must_have_text "Maximal used memory: 288 Mbyte"
page.must_have_text "Total build: 503 s"
find(:link, 'Show').click
page.must_have_text 'Maximal used disk space: 1005 Mbyte'
page.must_have_text 'Maximal used memory: 288 Mbyte'
page.must_have_text 'Total build: 503 s'
end

test "delete package as user" do
login_user("fred", "geröllheimer")
test 'delete package as user' do
login_user('fred', 'geröllheimer')
delete_and_recreate_kdelibs
end

test "delete package as admin" do
test 'delete package as admin' do
login_king
delete_and_recreate_kdelibs
end

test "Iggy adds himself as reviewer" do
test 'Iggy adds himself as reviewer' do
login_Iggy
visit webui_engine.package_users_path(package: "TestPack", project: "home:Iggy")
visit webui_engine.package_users_path(package: 'TestPack', project: 'home:Iggy')
check('user_reviewer_Iggy')
# wait for it to be clickable again before switching pages
page.wont_have_xpath('.//input[@id="user_reviewer_Iggy"][@disabled="disabled"]')
click_link "Meta"
click_link 'Meta'
page.must_have_text '<person userid="Iggy" role="reviewer"/>'
end

test "Iggy removes himself as bugowner" do
test 'Iggy removes himself as bugowner' do
login_Iggy
visit webui_engine.package_meta_path(package: "TestPack", project: "home:Iggy")
visit webui_engine.package_meta_path(package: 'TestPack', project: 'home:Iggy')
page.must_have_text '<person userid="Iggy" role="bugowner"/>'
within '#package_tabs' do
click_link("Users")
click_link('Users')
end
uncheck('user_bugowner_Iggy')
# wait for it to be clickable again before switching pages
page.wont_have_xpath './/input[@id="user_bugowner_Iggy"][@disabled="disabled"]'
click_link "Meta"
click_link 'Meta'
page.wont_have_text '<person userid="Iggy" role="bugowner"/>'
end

def fill_comment
fill_in "title", with: "Comment Title"
fill_in "body", with: "Comment Body"
find_button("Add comment").click
find('#flash-messages').must_have_text "Comment added successfully "
fill_in 'title', with: 'Comment Title'
fill_in 'body', with: 'Comment Body'
find_button('Add comment').click
find('#flash-messages').must_have_text 'Comment added successfully '
end

test "succesful comment creation" do
test 'succesful comment creation' do
login_Iggy
visit "/webui2/package/show/home:Iggy/TestPack"
visit '/webui2/package/show/home:Iggy/TestPack'
fill_comment
end

test "another succesful comment creation" do
test 'another succesful comment creation' do
login_Iggy
visit "/webui2/package/show?project=home:Iggy&package=TestPack"
visit '/webui2/package/show?project=home:Iggy&package=TestPack'
fill_comment
end

Expand All @@ -84,13 +84,24 @@ def fill_comment
# fill_comment
# end

test "succesful reply comment creation" do
test 'succesful reply comment creation' do
login_Iggy
visit "/webui2/package/show/BaseDistro3/pack2"
visit '/webui2/package/show/BaseDistro3/pack2'
find(:id,'reply_link_id_201').click
fill_in "reply_body_201", with: "Comment Body"
fill_in 'reply_body_201', with: 'Comment Body'
find(:id,'add_reply_201').click
find('#flash-messages').must_have_text "Comment added successfully "
find('#flash-messages').must_have_text 'Comment added successfully '
end

test 'diff is empty' do
visit '/webui2/package/rdiff/BaseDistro2.0/pack2.linked?opackage=pack2&oproject=BaseDistro2.0'
find('#content').must_have_text 'No source changes!'
end

test 'revision is mepty' do
visit '/webui2/package/rdiff/BaseDistro2.0/pack2.linked?opackage=pack2&oproject=BaseDistro2.0&rev='
flash_message_type.must_equal :alert
flash_message.must_equal 'revision is empty'
end

end
Loading

0 comments on commit 35d89c6

Please sign in to comment.