Revision b2b47290
Added by Petr Chalupa almost 12 years ago
- ID b2b4729059ff89327d7cd86d2e47664a2ce57c46
test/functional/api/v1/architectures_controller_test.rb | ||
---|---|---|
users(:one).roles = [Role.find_by_name('Anonymous'), Role.find_by_name('Viewer')]
|
||
end
|
||
|
||
def user_one_as_manager
|
||
users(:one).roles = [Role.find_by_name('Anonymous'), Role.find_by_name('Manager')]
|
||
end
|
||
|
||
test "should get index" do
|
||
as_user :admin do
|
||
as_user :admin do
|
||
get :index, {}
|
||
end
|
||
assert_response :success
|
||
... | ... | |
end
|
||
|
||
test "should show architecture" do
|
||
as_user :admin do
|
||
as_user :admin do
|
||
get :show, {:id => architectures(:x86_64).to_param}
|
||
end
|
||
assert_response :success
|
||
... | ... | |
end
|
||
|
||
test "should update architecture" do
|
||
as_user :admin do
|
||
as_user :admin do
|
||
put :update, {:id => architectures(:x86_64).to_param, :architecture => {} }
|
||
end
|
||
assert_response :success
|
||
... | ... | |
assert_response :forbidden
|
||
end
|
||
|
||
test "user with manager rights should success to update an architecture" do
|
||
user_one_as_manager
|
||
as_user :one do
|
||
put :update, {:id => architectures(:x86_64).to_param, :architecture => {} }
|
||
end
|
||
assert_response :success
|
||
end
|
||
|
||
test "user with viewer rights should succeed in viewing architectures" do
|
||
user_one_as_anonymous_viewer
|
||
as_user :one do
|
||
as_user :one do
|
||
get :index, {}
|
||
end
|
||
assert_response :success
|
Also available in: Unified diff
api v1 - render errors with rabl
better detection of permission failure in model
fix ApiConstraints
catch bad routes in api and return json