Skip to content

Commit

Permalink
[webui] give an error for relationships added twice
Browse files Browse the repository at this point in the history
  • Loading branch information
coolo committed Dec 8, 2013
1 parent fd10094 commit 335b625
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/api/app/mixins/webui/manage_relationships.rb
Expand Up @@ -15,8 +15,11 @@ def save_person
main_object.api_obj.add_role(load_obj, Role.find_by_title!(params[:role]))
rescue User::NotFound => e
flash[:error] = e.to_s
redirect_to add_path(:add_person)
return
redirect_to add_path(:add_person) and return
rescue ActiveRecord::RecordInvalid => e
Rails.logger.debug e.inspect
flash[:error] = e.to_s
redirect_to add_path(:add_person) and return
end
respond_to do |format|
format.js { render json: 'ok' }
Expand Down
5 changes: 5 additions & 0 deletions src/api/test/functional/webui/users_test.rb
Expand Up @@ -51,6 +51,10 @@ def add_user user, role, options = {}
assert curl, page.current_url
# go back manually
visit @userspath
elsif options[:expect] == :already_exists
flash_message_type.must_equal :alert
flash_message.must_equal 'Validation failed: Role Relationship already exists'
visit @userspath
else
raise ArgumentError
end
Expand Down Expand Up @@ -133,6 +137,7 @@ def delete_user user

add_user 'user6', 'reviewer'
add_user 'user6', 'downloader'
add_user 'user6', 'downloader', expect: :already_exists

add_user 'sadasxsacxsacsa', 'reader', :expect => :unknown_user
add_user '', 'maintainer', :expect => :unknown_user
Expand Down

0 comments on commit 335b625

Please sign in to comment.