changes
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
require 'test_helper'
|
||||
|
||||
class JobsControllerTest < ActionController::TestCase
|
||||
# Replace this with your real tests.
|
||||
test "the truth" do
|
||||
assert true
|
||||
end
|
||||
end
|
||||
@@ -1,6 +1,11 @@
|
||||
require_relative "../test_helper"
|
||||
|
||||
class ArtistTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
context "The current user" do
|
||||
should "be set only within the scope of the block" do
|
||||
user = Factory.create(:user)
|
||||
@@ -16,4 +21,29 @@ class ArtistTest < ActiveSupport::TestCase
|
||||
assert_equal("1.2.3.4", CurrentUser.ip_addr)
|
||||
end
|
||||
end
|
||||
|
||||
context "A scoped current user" do
|
||||
should "reset the current user after the block has exited" do
|
||||
user1 = Factory.create(:user)
|
||||
user2 = Factory.create(:user)
|
||||
CurrentUser.user = user1
|
||||
CurrentUser.scoped(user2, nil) do
|
||||
assert_equal(user2.id, CurrentUser.user.id)
|
||||
end
|
||||
assert_equal(user1.id, CurrentUser.user.id)
|
||||
end
|
||||
|
||||
should "reset the current user even if an exception is thrown" do
|
||||
user1 = Factory.create(:user)
|
||||
user2 = Factory.create(:user)
|
||||
CurrentUser.user = user1
|
||||
assert_raises(RuntimeError) do
|
||||
CurrentUser.scoped(user2, nil) do
|
||||
assert_equal(user2.id, CurrentUser.user.id)
|
||||
raise "ERROR"
|
||||
end
|
||||
end
|
||||
assert_equal(user1.id, CurrentUser.user.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,4 +0,0 @@
|
||||
require 'test_helper'
|
||||
|
||||
class JobsHelperTest < ActionView::TestCase
|
||||
end
|
||||
@@ -1,8 +1,23 @@
|
||||
require_relative '../test_helper'
|
||||
|
||||
class JanitorTrialTest < ActiveSupport::TestCase
|
||||
# Replace this with your real tests.
|
||||
test "the truth" do
|
||||
assert true
|
||||
setup do
|
||||
user = Factory.create(:user)
|
||||
CurrentUser.user = user
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
MEMCACHE.flush_all
|
||||
end
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
should "create a dmail when testing a new janitor" do
|
||||
admin = Factory.create(:admin_user)
|
||||
user = Factory.create(:user)
|
||||
assert_difference("Dmail.count", 2) do
|
||||
JanitorTrial.create(:user_id => user.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
require_relative '../test_helper'
|
||||
|
||||
class JobTest < ActiveSupport::TestCase
|
||||
# Replace this with your real tests.
|
||||
test "the truth" do
|
||||
assert true
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user