def test_create
assert_difference 'IssueRelation.count' do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:issue_id => 1,
:relation => {
:issue_to_id => '2',
:delay => ''
}
}
+ )
end
relation = IssueRelation.order('id DESC').first
assert_equal 1, relation.issue_from_id
def test_create_on_invalid_issue
assert_no_difference 'IssueRelation.count' do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:issue_id => 999,
:relation => {
:issue_to_id => '2',
:delay => ''
}
}
+ )
assert_response 404
end
end
def test_create_xhr
assert_difference 'IssueRelation.count' do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:issue_id => 3,
:relation => {
:issue_to_id => '1',
}
},
:xhr => true
+ )
assert_response :success
assert_equal 'text/javascript', response.media_type
end
def test_create_should_accept_id_with_hash
assert_difference 'IssueRelation.count' do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:issue_id => 1,
:relation => {
:issue_to_id => '#2',
:delay => ''
}
}
+ )
end
relation = IssueRelation.order('id DESC').first
assert_equal 2, relation.issue_to_id
def test_create_should_strip_id
assert_difference 'IssueRelation.count' do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:issue_id => 1,
:relation => {
:issue_to_id => ' 2 ',
:delay => ''
}
}
+ )
end
relation = IssueRelation.order('id DESC').first
assert_equal 2, relation.issue_to_id
def test_create_should_not_break_with_non_numerical_id
assert_no_difference 'IssueRelation.count' do
assert_nothing_raised do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:issue_id => 1,
:relation => {
:issue_to_id => 'foo',
:delay => ''
}
}
+ )
end
end
end
issue2 = Issue.generate!
assert_difference 'IssueRelation.count' do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:issue_id => issue2.id,
:relation => {
:issue_to_id => issue1.id,
}
},
:xhr => true
+ )
end
assert_include 'Followed issue', response.body
end
assert_nil Issue.visible(User.find(3)).find_by_id(4)
assert_no_difference 'IssueRelation.count' do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:issue_id => 1,
:relation => {
:issue_to_id => '4',
:delay => ''
}
}
+ )
end
end
def test_create_xhr_with_failure
assert_no_difference 'IssueRelation.count' do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:issue_id => 3,
:relation => {
:issue_to_id => '999',
}
},
:xhr => true
-
+ )
assert_response :success
assert_equal 'text/javascript', response.media_type
end
def test_destroy
assert_difference 'IssueRelation.count', -1 do
- delete :destroy, :params => {
- :id => '2'
- }
+ delete(:destroy, :params => {:id => '2'})
end
end
def test_destroy_invalid_relation
assert_no_difference 'IssueRelation.count' do
- delete :destroy, :params => {
- :id => '999'
- }
+ delete(:destroy, :params => {:id => '999'})
assert_response 404
end
end
end
assert_difference 'IssueRelation.count', -1 do
- delete :destroy, :params => {
- :id => '2'
- },
- :xhr => true
-
+ delete(:destroy, :params => {:id => '2'}, :xhr => true)
assert_response :success
assert_equal 'text/javascript', response.media_type
assert_include 'relation-2', response.body