end
def test_new_user_membership
- get :new, :params => {
- :user_id => 7
- }
+ get(:new, :params => {:user_id => 7})
assert_response :success
assert_select 'label', :text => 'eCookbook' do
assert_select 'input[name=?][value="1"]:not([disabled])', 'membership[project_ids][]'
def test_new_user_membership_should_disable_user_projects
Member.create!(:user_id => 7, :project_id => 1, :role_ids => [1])
- get :new, :params => {
- :user_id => 7
- }
+ get(:new, :params => {:user_id => 7})
assert_response :success
assert_select 'label', :text => 'eCookbook' do
assert_select 'input[name=?][value="1"][disabled=disabled]', 'membership[project_ids][]'
end
def test_xhr_new_user_membership
- get :new, :params => {
- :user_id => 7
- },
- :xhr => true
+ get(:new, :params => {:user_id => 7}, :xhr => true)
assert_response :success
assert_equal 'text/javascript', response.media_type
end
def test_create_user_membership
assert_difference 'Member.count' do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:user_id => 7,
:membership => {
:project_ids => [3],
:role_ids => [2]
}
}
+ )
end
assert_redirected_to '/users/7/edit?tab=memberships'
member = Member.order('id DESC').first
def test_create_user_membership_with_multiple_roles
assert_difference 'Member.count' do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:user_id => 7,
:membership => {
:project_ids => [3],
:role_ids => [2, 3]
}
}
+ )
end
member = Member.order('id DESC').first
assert_equal User.find(7), member.principal
def test_create_user_membership_with_multiple_projects_and_roles
assert_difference 'Member.count', 2 do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:user_id => 7,
:membership => {
:project_ids => [1, 3],
:role_ids => [2, 3]
}
}
+ )
end
members = Member.order('id DESC').limit(2).sort_by(&:project_id)
assert_equal 1, members[0].project_id
def test_xhr_create_user_membership
assert_difference 'Member.count' do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:user_id => 7,
:membership => {
:project_ids => [3],
:format => 'js'
},
:xhr => true
+ )
assert_response :success
assert_equal 'text/javascript', response.media_type
end
def test_xhr_create_user_membership_with_failure
assert_no_difference 'Member.count' do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:user_id => 7,
:membership => {
:project_ids => [3]
:format => 'js'
},
:xhr => true
+ )
assert_response :success
assert_equal 'text/javascript', response.media_type
end
end
def test_edit_user_membership
- get :edit, :params => {
+ get(
+ :edit,
+ :params => {
:user_id => 2,
:id => 1
}
+ )
assert_response :success
assert_select 'input[name=?][value=?][checked=checked]', 'membership[role_ids][]', '1'
end
def test_xhr_edit_user_membership
- get :edit, :params => {
+ get(
+ :edit,
+ :params => {
:user_id => 2,
:id => 1
},
:xhr => true
+ )
assert_response :success
end
def test_update_user_membership
assert_no_difference 'Member.count' do
- put :update, :params => {
+ put(
+ :update,
+ :params => {
:user_id => 2,
:id => 1,
:membership => {
:role_ids => [2]
}
}
+ )
assert_redirected_to '/users/2/edit?tab=memberships'
end
assert_equal [2], Member.find(1).role_ids
def test_xhr_update_user_membership
assert_no_difference 'Member.count' do
- put :update, :params => {
+ put(
+ :update,
+ :params => {
:user_id => 2,
:id => 1,
:membership => {
:format => 'js'
},
:xhr => true
+ )
assert_response :success
assert_equal 'text/javascript', response.media_type
end
def test_destroy_user_membership
assert_difference 'Member.count', -1 do
- delete :destroy, :params => {
+ delete(
+ :destroy,
+ :params => {
:user_id => 2,
:id => 1
}
+ )
end
assert_redirected_to '/users/2/edit?tab=memberships'
assert_nil Member.find_by_id(1)
def test_xhr_destroy_user_membership_js_format
assert_difference 'Member.count', -1 do
- delete :destroy, :params => {
+ delete(
+ :destroy,
+ :params => {
:user_id => 2,
:id => 1
},
:xhr => true
+ )
assert_response :success
assert_equal 'text/javascript', response.media_type
end
end
def test_xhr_new_group_membership
- get :new, :params => {
- :group_id => 10
- },
- :xhr => true
+ get(:new, :params => {:group_id => 10}, :xhr => true)
assert_response :success
assert_equal 'text/javascript', response.media_type
end
def test_create_group_membership
assert_difference 'Group.find(10).members.count' do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:group_id => 10,
:membership => {
:project_ids => [2],
:role_ids => ['1', '2']
}
}
+ )
end
end
def test_xhr_create_group_membership
assert_difference 'Group.find(10).members.count' do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:group_id => 10,
:membership => {
:project_ids => [2],
}
},
:xhr => true
+ )
assert_response :success
assert_equal 'text/javascript', response.media_type
end
def test_xhr_create_group_membership_with_failure
assert_no_difference 'Group.find(10).members.count' do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:group_id => 10,
:membership => {
:project_ids => [999],
}
},
:xhr => true
+ )
assert_response :success
assert_equal 'text/javascript', response.media_type
end
def test_update_group_membership
assert_no_difference 'Group.find(10).members.count' do
- put :update, :params => {
+ put(
+ :update,
+ :params => {
:group_id => 10,
:id => 6,
:membership => {
:role_ids => ['1', '3']
}
}
+ )
end
end
def test_xhr_update_group_membership
assert_no_difference 'Group.find(10).members.count' do
- post :update, :params => {
+ post(
+ :update,
+ :params => {
:group_id => 10,
:id => 6,
:membership => {
}
},
:xhr => true
+ )
assert_response :success
assert_equal 'text/javascript', response.media_type
end
def test_destroy_group_membership
assert_difference 'Group.find(10).members.count', -1 do
- delete :destroy, :params => {
+ delete(
+ :destroy,
+ :params => {
:group_id => 10,
:id => 6
}
+ )
end
end
def test_xhr_destroy_group_membership
assert_difference 'Group.find(10).members.count', -1 do
- delete :destroy, :params => {
+ delete(
+ :destroy,
+ :params => {
:group_id => 10,
:id => 6
},
:xhr => true
+ )
assert_response :success
assert_equal 'text/javascript', response.media_type
end