added invites
This commit is contained in:
@@ -5,6 +5,7 @@ Factory.define(:user) do |f|
|
||||
f.email {Faker::Internet.email}
|
||||
f.default_image_size "medium"
|
||||
f.base_upload_limit 10
|
||||
f.level 20
|
||||
end
|
||||
|
||||
Factory.define(:banned_user, :parent => :user) do |f|
|
||||
|
||||
34
test/functional/moderator/invitations_controller_test.rb
Normal file
34
test/functional/moderator/invitations_controller_test.rb
Normal file
@@ -0,0 +1,34 @@
|
||||
require 'test_helper'
|
||||
|
||||
module Moderator
|
||||
class InvitationsControllerTest < ActionController::TestCase
|
||||
context "The invitations controller" do
|
||||
setup do
|
||||
@mod = Factory.create(:moderator_user)
|
||||
CurrentUser.user = @mod
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
MEMCACHE.flush_all
|
||||
|
||||
@user_1 = Factory.create(:user)
|
||||
@user_2 = Factory.create(:user, :inviter_id => @mod.id)
|
||||
end
|
||||
|
||||
should "render the new page" do
|
||||
get :new, {}, {:user_id => @mod.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
should "create a new invite" do
|
||||
post :create, {:invitation => {:user_id => @user_1.id, :level => User::Levels::CONTRIBUTOR}}, {:user_id => @mod.id}
|
||||
assert_redirected_to(moderator_invitations_path)
|
||||
@user_1.reload
|
||||
assert_equal(User::Levels::CONTRIBUTOR, @user_1.level)
|
||||
end
|
||||
|
||||
should "list invites" do
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -13,6 +13,24 @@ class UserTest < ActiveSupport::TestCase
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
context "that has been invited by a mod" do
|
||||
setup do
|
||||
@mod = Factory.create(:moderator_user)
|
||||
end
|
||||
|
||||
should "work" do
|
||||
@user.invite!(User::Levels::CONTRIBUTOR)
|
||||
@user.reload
|
||||
assert_equal(User::Levels::CONTRIBUTOR, @user.level)
|
||||
end
|
||||
|
||||
should "not allow invites up to janitor level or beyond" do
|
||||
@user.invite!(User::Levels::JANITOR)
|
||||
@user.reload
|
||||
assert_equal(User::Levels::MEMBER, @user.level)
|
||||
end
|
||||
end
|
||||
|
||||
should "not validate if the originating ip address is banned" do
|
||||
Factory.create(:ip_ban)
|
||||
|
||||
Reference in New Issue
Block a user