Remove asert_login_required

This commit is contained in:
Rei
2014-02-10 15:26:53 +08:00
parent de84efe0a4
commit 4532ef462d
3 changed files with 12 additions and 26 deletions

View File

@@ -6,9 +6,8 @@ class NotificationsControllerTest < ActionController::TestCase
create(:notification, user: user, subject: create(:comment), name: 'comment')
create(:notification, user: user, subject: create(:comment), name: 'mention')
assert_login_required(user) do
get :index
end
login_as user
get :index
assert_response :success, @response.body
end
@@ -36,10 +35,9 @@ class NotificationsControllerTest < ActionController::TestCase
test "should destroy notification" do
user = create(:user)
notification = create(:notification, user: user)
login_as user
assert_difference "user.notifications.count", -1 do
assert_login_required(user) do
xhr :delete, :destroy, id: notification
end
xhr :delete, :destroy, id: notification
end
end

View File

@@ -21,17 +21,15 @@ class TopicsControllerTest < ActionController::TestCase
end
test "should get new page" do
assert_login_required do
get :new
end
login_as create(:user)
get :new
assert_response :success, @response.body
end
test "should create topic" do
login_as create(:user)
assert_difference "Topic.count" do
assert_login_required do
post :create, topic: attributes_for(:topic)
end
post :create, topic: attributes_for(:topic)
end
topic = Topic.last
assert_equal topic.user, topic.user
@@ -40,17 +38,15 @@ class TopicsControllerTest < ActionController::TestCase
test "should edit topic" do
topic = create(:topic)
assert_login_required topic.user do
get :edit, id: topic
end
login_as topic.user
get :edit, id: topic
assert_response :success, @response.body
end
test "should update topic" do
topic = create(:topic)
assert_login_required topic.user do
patch :update, id: topic, topic: { title: 'change', body: 'change' }
end
login_as topic.user
patch :update, id: topic, topic: { title: 'change', body: 'change' }
topic.reload
assert_equal 'change', topic.title
assert_equal 'change', topic.body

View File

@@ -13,12 +13,4 @@ class ActiveSupport::TestCase
@controller.send method, *args
end
end
def assert_login_required(user = create(:user))
logout
yield
assert_redirected_to login_url
login_as user
yield
end
end