Adds functional tests for MembersController.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7990 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
b0fe7415d1
commit
1e7c4488b9
|
@ -49,38 +49,22 @@ class MembersControllerTest < ActionController::TestCase
|
|||
assert User.find(7).member_of?(Project.find(1))
|
||||
end
|
||||
|
||||
context "post :new in JS format" do
|
||||
context "with successful saves" do
|
||||
should "add membership for each user" do
|
||||
post :new, :format => "js", :id => 1, :member => {:role_ids => [1], :user_ids => [7, 8, 9]}
|
||||
|
||||
assert User.find(7).member_of?(Project.find(1))
|
||||
assert User.find(8).member_of?(Project.find(1))
|
||||
assert User.find(9).member_of?(Project.find(1))
|
||||
end
|
||||
|
||||
should "replace the tab with RJS" do
|
||||
post :new, :format => "js", :id => 1, :member => {:role_ids => [1], :user_ids => [7, 8, 9]}
|
||||
|
||||
assert_select_rjs :replace_html, 'tab-content-members'
|
||||
end
|
||||
|
||||
def test_xhr_create
|
||||
assert_difference 'Member.count', 3 do
|
||||
post :new, :format => "js", :id => 1, :member => {:role_ids => [1], :user_ids => [7, 8, 9]}
|
||||
end
|
||||
assert_select_rjs :replace_html, 'tab-content-members'
|
||||
assert User.find(7).member_of?(Project.find(1))
|
||||
assert User.find(8).member_of?(Project.find(1))
|
||||
assert User.find(9).member_of?(Project.find(1))
|
||||
end
|
||||
|
||||
context "with a failed save" do
|
||||
should "not replace the tab with RJS" do
|
||||
post :new, :format => "js", :id => 1, :member => {:role_ids => [], :user_ids => [7, 8, 9]}
|
||||
|
||||
assert_select '#tab-content-members', 0
|
||||
end
|
||||
|
||||
should "open an error message" do
|
||||
post :new, :format => "js", :id => 1, :member => {:role_ids => [], :user_ids => [7, 8, 9]}
|
||||
|
||||
assert @response.body.match(/alert/i), "Alert message not sent"
|
||||
end
|
||||
def test_xhr_create_with_failure
|
||||
assert_no_difference 'Member.count' do
|
||||
post :new, :format => "js", :id => 1, :member => {:role_ids => [], :user_ids => [7, 8, 9]}
|
||||
end
|
||||
|
||||
assert_select '#tab-content-members', 0
|
||||
assert @response.body.match(/alert/i), "Alert message not sent"
|
||||
end
|
||||
|
||||
def test_edit
|
||||
|
@ -90,6 +74,16 @@ class MembersControllerTest < ActionController::TestCase
|
|||
assert_redirected_to '/projects/ecookbook/settings/members'
|
||||
end
|
||||
|
||||
def test_xhr_edit
|
||||
assert_no_difference 'Member.count' do
|
||||
xhr :post, :edit, :id => 2, :member => {:role_ids => [1], :user_id => 3}
|
||||
end
|
||||
assert_select_rjs :replace_html, 'tab-content-members'
|
||||
member = Member.find(2)
|
||||
assert_equal [1], member.role_ids
|
||||
assert_equal 3, member.user_id
|
||||
end
|
||||
|
||||
def test_destroy
|
||||
assert_difference 'Member.count', -1 do
|
||||
post :destroy, :id => 2
|
||||
|
@ -98,6 +92,13 @@ class MembersControllerTest < ActionController::TestCase
|
|||
assert !User.find(3).member_of?(Project.find(1))
|
||||
end
|
||||
|
||||
def test_xhr_destroy
|
||||
assert_difference 'Member.count', -1 do
|
||||
xhr :post, :destroy, :id => 2
|
||||
end
|
||||
assert_select_rjs :replace_html, 'tab-content-members'
|
||||
end
|
||||
|
||||
def test_autocomplete_for_member
|
||||
get :autocomplete_for_member, :id => 1, :q => 'mis'
|
||||
assert_response :success
|
||||
|
|
Loading…
Reference in New Issue