Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Specify ip always when building posts and topics.

  • Loading branch information...
commit b54b7919471586556870fd26dd4fb0a9138b33a2 1 parent 4cbfe2a
Ryan Bigg authored
View
2  app/controllers/moderator/posts_controller.rb
@@ -34,7 +34,7 @@ def split
else
@topic.subject
end
- @new_topic = @topic.forum.topics.build(:subject => @subject, :user => @posts.first.user)
+ @new_topic = @topic.forum.topics.build(:subject => @subject, :user => @posts.first.user, :ip => @posts.first.ip)
@new_topic.posts = @split_posts
@new_topic.locked = @topic.locked
@new_topic.sticky = @topic.sticky
View
8 app/controllers/users_controller.rb
@@ -25,14 +25,6 @@ def update
params[:user][:crypted_password] = current_user.encrypt(params[:user][:password])
flash[:notice] = t(:password_has_been_changed)
end
- if current_user.update_attributes(params[:user])
- flash[:notice] ||= t(:profile_has_been_updated)
- redirect_to edit_user_path(current_user)
- else
- @themes = Theme.all
- render :action => "edit"
- end
- end
end
View
2  app/models/topic.rb
@@ -83,7 +83,7 @@ def move!(new_forum_id, leave_redirect=false)
old_forum.decrement!(:posts_count, posts.count)
if leave_redirect
- redirect = old_forum.topics.build(:subject => subject, :created_at => created_at, :user => user)
+ redirect = old_forum.topics.build(:subject => subject, :created_at => created_at, :user => user, :ip => ip)
redirect.moved = true
redirect.moved_to = self
redirect.save!
View
6 config/database.yml.sample
@@ -7,7 +7,5 @@ production:
database: db/production.sqlite3
test:
- username: root
- password:
- adapter: mysql
- database: rboard_test
+ adapter: sqlite3
+ database: db/test.sqlite3
View
2  config/environments/development.rb
@@ -25,4 +25,4 @@
TIME_BETWEEN_POSTS = 1.minute
## Set this to false if you don't want to use thinking sphinx.
-SEARCHING = false
+SEARCHING = true
View
BIN  db/test.sqlite3
Binary file not shown
View
1  spec/controllers/users_controller_spec.rb
@@ -10,6 +10,7 @@
end
it "should be able to see a list of users" do
+ User.expects(:paginate)
get 'index'
response.should render_template("index")
end
View
10 spec/models/post_spec.rb
@@ -1,6 +1,5 @@
require File.dirname(__FILE__) + '/../spec_helper'
describe Post, "validations" do
- fixtures :posts
before(:each) do
@post = Post.new
end
@@ -27,6 +26,7 @@
@sub_post = @sub_topic.posts.first
@registered_user = User("registered_user")
@administrator = User("administrator")
+ @ip = Ip.make(:localhost)
end
it "should be able to find its forum" do
@@ -37,7 +37,7 @@
# Because we limit users, by default, to one post per minute
two_minutes_into_the_future = Time.now + 2.minutes
Time.stub!(:now).and_return(two_minutes_into_the_future)
- @new_post = @topic.posts.build(:user => @registered_user, :text => "Woot")
+ @new_post = @topic.posts.build(:user => @registered_user, :text => "Woot", :ip => @ip)
@new_post.forum.last_post.should eql(@sub_post)
@new_post.save
@new_post.forum.last_post.should eql(@new_post)
@@ -48,7 +48,7 @@
two_minutes_into_the_future = Time.now + 2.minutes
Time.stub!(:now).and_return(two_minutes_into_the_future)
@sub_topic.forum.sub?.should be_true
- @new_post = @sub_topic.posts.build(:user => @registered_user, :text => "Woot")
+ @new_post = @sub_topic.posts.build(:user => @registered_user, :text => "Woot", :ip => @ip)
@new_post.forum.last_post.should eql(@sub_post)
@sub_topic.save.should be_true
@sub_topic.posts.should_not be_empty
@@ -78,9 +78,9 @@
it "should not be able to be flooded" do
TIME_BETWEEN_POSTS = 1.minute
- @sub_topic.posts.build(:user => @registered_user, :text => "Woot")
+ @sub_topic.posts.build(:user => @registered_user, :text => "Woot", :ip => @ip)
@sub_topic.save.should be_true
- other_post = @sub_topic.posts.build(:user => @registered_user, :text => "Woot")
+ other_post = @sub_topic.posts.build(:user => @registered_user, :text => "Woot", :ip => @ip)
other_post.save.should be_false
end
View
12 spec/models/topic_spec.rb
@@ -15,6 +15,8 @@
@administrator = User("administrator")
# Remove the call to reverse for an interesting failing test
@posts = @valid_topic.posts.reverse
+
+ @ip = Ip.make(:localhost)
end
it "should validate everything" do
@@ -90,12 +92,12 @@
it "should be able to merge two topics" do
Topic.count.should eql(2)
- topic = @everybody.topics.build(:subject => "subject", :user => @administrator)
- post = topic.posts.build(:text => "First post", :user => @administrator)
+ topic = @everybody.topics.build(:subject => "subject", :user => @administrator, :ip => @ip)
+ post = topic.posts.build(:text => "First post", :user => @administrator, :ip => @ip)
topic.save
- other_topic = @everybody.topics.build(:subject => "second subject", :user => @administrator)
- other_post = other_topic.posts.build(:text => "Second post", :user => @administrator)
- yet_another_post = topic.posts.build(:text => "Third post", :user => @administrator)
+ other_topic = @everybody.topics.build(:subject => "second subject", :user => @administrator, :ip => @ip)
+ other_post = other_topic.posts.build(:text => "Second post", :user => @administrator, :ip => @ip)
+ yet_another_post = topic.posts.build(:text => "Third post", :user => @administrator, :ip => @ip)
topic.save(false)
other_topic.save(false)
topic.posts.size.should eql(2)
Please sign in to comment.
Something went wrong with that request. Please try again.