Since there is no ChangesetsSubscribers model, we can't use a factory.
Instead we create the associations explicitly when needed.
# Offense count: 62
# Configuration parameters: CountComments.
Metrics/ClassLength:
# Offense count: 62
# Configuration parameters: CountComments.
Metrics/ClassLength:
# Offense count: 69
Metrics/CyclomaticComplexity:
# Offense count: 69
Metrics/CyclomaticComplexity:
class ChangesetControllerTest < ActionController::TestCase
api_fixtures
class ChangesetControllerTest < ActionController::TestCase
api_fixtures
- fixtures :changesets_subscribers
##
# test all routes which lead to this controller
##
# test all routes which lead to this controller
end
assert_response :success
end
assert_response :success
+ changeset = changesets(:normal_user_subscribed_change)
+ changeset.subscribers.push(users(:normal_user))
+ changeset.subscribers.push(users(:public_user))
+ changeset.subscribers.push(users(:suspended_user))
+ changeset.subscribers.push(users(:deleted_user))
+
assert_difference "ChangesetComment.count", 1 do
assert_difference "ActionMailer::Base.deliveries.size", 1 do
assert_difference "ChangesetComment.count", 1 do
assert_difference "ActionMailer::Base.deliveries.size", 1 do
- post :comment, :id => changesets(:normal_user_subscribed_change).id, :text => "This is a comment"
+ post :comment, :id => changeset.id, :text => "This is a comment"
end
end
assert_response :success
end
end
assert_response :success
assert_difference "ChangesetComment.count", 1 do
assert_difference "ActionMailer::Base.deliveries.size", 2 do
assert_difference "ChangesetComment.count", 1 do
assert_difference "ActionMailer::Base.deliveries.size", 2 do
- post :comment, :id => changesets(:normal_user_subscribed_change).id, :text => "This is a comment"
+ post :comment, :id => changeset.id, :text => "This is a comment"
end
end
assert_response :success
end
end
assert_response :success
# trying to subscribe when already subscribed
changeset = changesets(:normal_user_subscribed_change)
# trying to subscribe when already subscribed
changeset = changesets(:normal_user_subscribed_change)
+ changeset.subscribers.push(users(:public_user))
assert_no_difference "changeset.subscribers.count" do
post :subscribe, :id => changeset.id
end
assert_no_difference "changeset.subscribers.count" do
post :subscribe, :id => changeset.id
end
def test_unsubscribe_success
basic_authorization(users(:public_user).email, "test")
changeset = changesets(:normal_user_subscribed_change)
def test_unsubscribe_success
basic_authorization(users(:public_user).email, "test")
changeset = changesets(:normal_user_subscribed_change)
+ changeset.subscribers.push(users(:public_user))
assert_difference "changeset.subscribers.count", -1 do
post :unsubscribe, :id => changeset.id
assert_difference "changeset.subscribers.count", -1 do
post :unsubscribe, :id => changeset.id
+++ /dev/null
-t1:
- changeset_id: 8
- subscriber_id: 2
-
-t2:
- changeset_id: 8
- subscriber_id: 1
-
-t3:
- changeset_id: 8
- subscriber_id: 10
-
-t4:
- changeset_id: 8
- subscriber_id: 11