Merge branch 'master' into group-admin-incremental

This commit is contained in:
Jason W. May
2014-11-21 10:04:05 -08:00
58 changed files with 792 additions and 437 deletions

View File

@@ -22,13 +22,26 @@ describe SpamHandler do
-> { Fabricate(:user, ip_address: "42.42.42.42", trust_level: TrustLevel[0]) }.should raise_error(ActiveRecord::RecordInvalid)
end
it "only limit new registrations from an IP if *all* the users from that IP are TL1 or TL0" do
it "doesn't limit registrations since there is a TL2+ user with that IP" do
# setup
SiteSetting.stubs(:max_new_accounts_per_registration_ip).returns(0)
Fabricate(:user, ip_address: "42.42.42.42", trust_level: TrustLevel[0])
Fabricate(:user, ip_address: "42.42.42.42", trust_level: TrustLevel[2])
# should not limit registrations since there is a TL2 user with that IP
# should not limit registration
SiteSetting.stubs(:max_new_accounts_per_registration_ip).returns(1)
Fabricate(:user, ip_address: "42.42.42.42", trust_level: TrustLevel[0])
end
it "doesn't limit registrations since there is a staff member with that IP" do
# setup
SiteSetting.stubs(:max_new_accounts_per_registration_ip).returns(0)
Fabricate(:user, ip_address: "42.42.42.42", trust_level: TrustLevel[0])
Fabricate(:moderator, ip_address: "42.42.42.42", trust_level: TrustLevel[0])
Group.refresh_automatic_groups!(:staff)
# should not limit registration
SiteSetting.stubs(:max_new_accounts_per_registration_ip).returns(1)
Fabricate(:user, ip_address: "42.42.42.42", trust_level: TrustLevel[0])
end

View File

@@ -414,6 +414,19 @@ describe Admin::UsersController do
end
context "delete_other_accounts_with_same_ip" do
it "works" do
Fabricate(:user, ip_address: "42.42.42.42")
Fabricate(:user, ip_address: "42.42.42.42")
UserDestroyer.any_instance.expects(:destroy).twice
xhr :delete, :delete_other_accounts_with_same_ip, ip: "42.42.42.42", exclude: -1, order: "trust_level DESC"
end
end
end
it 'can sync up sso' do

View File

@@ -8,7 +8,7 @@ describe ApiKey do
it { should validate_presence_of :key }
it 'validates uniqueness of user_id' do
pending 'validates uniqueness of user_id' do
Fabricate(:api_key)
should validate_uniqueness_of(:user_id)
end

View File

@@ -79,6 +79,27 @@ describe TopicLinkClick do
end
end
context "relative urls" do
let(:host) { URI.parse(Discourse.base_url).host }
it 'returns the url' do
url = TopicLinkClick.create_from(url: '/relative-url', post_id: @post.id, ip: '127.0.0.1')
url.should == "/relative-url"
end
it 'finds a protocol relative urls with a host' do
url = "//#{host}/relative-url"
redirect = TopicLinkClick.create_from(url: url)
redirect.should == url
end
it "returns the url if it's on our host" do
url = "http://#{host}/relative-url"
redirect = TopicLinkClick.create_from(url: url)
redirect.should == url
end
end
context 'with a HTTPS version of the same URL' do
before do
@url = TopicLinkClick.create_from(url: 'https://twitter.com', topic_id: @topic.id, ip: '127.0.0.3')