Changesets can be listed by changeset number.
The Git repository is here.
Changeset 10
Checking in HEAD from RForum's SVN of 22-Jul-2006, 8pm (revision 906).
- Comitted by: adh
- Date: Saturday July 22 20:02:44 2006 (over 18 years ago)
Affected files:
- rool/rails/rforum/trunk/attachments/
- rool/rails/rforum/trunk/public/skins/default/
- rool/rails/rforum/trunk/public/skins/ice/
- rool/rails/rforum/trunk/public/skins/mikrocontroller.net/
- rool/rails/rforum/trunk/vendor/
- rool/rails/rforum/trunk/vendor/plugins/
- rool/rails/rforum/trunk/vendor/plugins/acts_as_ferret/
- rool/rails/rforum/trunk/vendor/plugins/acts_as_ferret/lib/
- rool/rails/rforum/trunk/app/controllers/attachment_controller.rb
- rool/rails/rforum/trunk/app/models/site.rb
- rool/rails/rforum/trunk/app/views/sidebar.rhtml
- rool/rails/rforum/trunk/db/migrate/005_add_site_table.rb
- rool/rails/rforum/trunk/db/migrate/006_add_readonly_field_to_forum.rb
- rool/rails/rforum/trunk/db/migrate/007_add_ml_from_address_to_forum.rb
- rool/rails/rforum/trunk/db/migrate/009_add_user_activated.rb
- rool/rails/rforum/trunk/db/migrate/010_add_created_at_to_session_table.rb
- rool/rails/rforum/trunk/db/migrate/011_capitalize_user_realnames.rb
- rool/rails/rforum/trunk/lang/cn.yaml
- rool/rails/rforum/trunk/lang/ro.yaml
- rool/rails/rforum/trunk/lib/mysql_session.rb
- rool/rails/rforum/trunk/lib/postgresql_session.rb
- rool/rails/rforum/trunk/lib/sql_session_store.rb
- rool/rails/rforum/trunk/public/images/comment_add.png
- rool/rails/rforum/trunk/public/images/email.png
- rool/rails/rforum/trunk/public/skins/default/style.css
- rool/rails/rforum/trunk/public/skins/ice/style.css
- rool/rails/rforum/trunk/public/skins/mikrocontroller.net/style.css
- rool/rails/rforum/trunk/script/update_index
- rool/rails/rforum/trunk/test/functional/attachment_controller_test.rb
- rool/rails/rforum/trunk/vendor/plugins/acts_as_ferret/LICENSE
- rool/rails/rforum/trunk/vendor/plugins/acts_as_ferret/README
- rool/rails/rforum/trunk/vendor/plugins/acts_as_ferret/init.rb
- rool/rails/rforum/trunk/vendor/plugins/acts_as_ferret/lib/acts_as_ferret.rb
- rool/rails/rforum/trunk/vendor/plugins/acts_as_ferret/lib/multi_index.rb
- rool/rails/rforum/trunk/vendor/plugins/acts_as_ferret/rakefile
- rool/rails/rforum/trunk/vendor/plugins/acts_as_ferret/true
- rool/rails/rforum/trunk/app/controllers/admin_controller.rb (diff)
- rool/rails/rforum/trunk/app/controllers/application.rb (diff)
- rool/rails/rforum/trunk/app/controllers/feed_controller.rb (diff)
- rool/rails/rforum/trunk/app/controllers/forum_controller.rb (diff)
- rool/rails/rforum/trunk/app/controllers/mailer.rb (diff)
- rool/rails/rforum/trunk/app/controllers/security_controller.rb (diff)
- rool/rails/rforum/trunk/app/controllers/topic_controller.rb (diff)
- rool/rails/rforum/trunk/app/controllers/user_controller.rb (diff)
- rool/rails/rforum/trunk/app/models/attachment.rb (diff)
- rool/rails/rforum/trunk/app/models/forum.rb (diff)
- rool/rails/rforum/trunk/app/models/post.rb (diff)
- rool/rails/rforum/trunk/app/models/tag.rb (diff)
- rool/rails/rforum/trunk/app/models/user.rb (diff)
- rool/rails/rforum/trunk/app/views/forum/forum.rhtml (diff)
- rool/rails/rforum/trunk/app/views/forum/list.rhtml (diff)
- rool/rails/rforum/trunk/app/views/forum/search.rhtml (diff)
- rool/rails/rforum/trunk/app/views/layouts/default.rhtml (diff)
- rool/rails/rforum/trunk/app/views/topic/_post.rhtml (diff)
- rool/rails/rforum/trunk/app/views/topic/_postform.rhtml (diff)
- rool/rails/rforum/trunk/app/views/user/list.rhtml (diff)
- rool/rails/rforum/trunk/app/views/user/registration_complete.rhtml (diff)
- rool/rails/rforum/trunk/config/app.rb (diff)
- rool/rails/rforum/trunk/config/database.yml (diff)
- rool/rails/rforum/trunk/config/default_site.rb (diff)
- rool/rails/rforum/trunk/config/routes.rb (diff)
- rool/rails/rforum/trunk/lang/de.yaml (diff)
- rool/rails/rforum/trunk/lang/en.yaml (diff)
- rool/rails/rforum/trunk/lib/received_mail.rb (diff)
- rool/rails/rforum/trunk/public/skins/ruby-forum.com/style.css (diff)
- rool/rails/rforum/trunk/public/stylesheets/main.css (diff)
- rool/rails/rforum/trunk/public/stylesheets/print.css (diff)
- rool/rails/rforum/trunk/script/process_mails (diff)
- rool/rails/rforum/trunk/test/functional/topic_controller_test.rb (diff)
- rool/rails/rforum/trunk/test/functional/user_controller_test.rb (diff)
- rool/rails/rforum/trunk/test/test_helper.rb (diff)
- rool/rails/rforum/trunk/test/unit/attachment_test.rb (diff)
- rool/rails/rforum/trunk/test/unit/forum_test.rb (diff)
- rool/rails/rforum/trunk/test/unit/localization_test.rb (diff)
- rool/rails/rforum/trunk/test/unit/post_test.rb (diff)
- rool/rails/rforum/trunk/test/unit/search_ferret_test.rb (diff)
- rool/rails/rforum/trunk/test/unit/user_test.rb (diff)
rool/rails/rforum/trunk/app/controllers/admin_controller.rb:
prev. | current | |
1 | ||
2 | ||
class AdminController < ApplicationController | ||
def block_ip |
rool/rails/rforum/trunk/app/controllers/application.rb:
prev. | current | |
require 'navbar' | ||
require 'post_menu' | ||
require 'url_generator' | ||
4 | ||
# The filters added to this controller will be run for all controllers in the application. | ||
# Likewise will all the methods added be available for all controllers. | ||
... | ... | |
include RForum::Localization | ||
layout 'default' | ||
17 | | |
16 | before_filter :check_block, :setup_user, :setup_url_generator, :setup_local, \ | |
17 | :setup_skin | |
18 | ||
19 | before_filter :detect_site if RForum::CONFIG[:use_sites] | |
20 | ||
21 | before_filter :get_forums | |
22 | ||
after_filter :finish_user, :remember_location | ||
# Default index action: redirect to start page | ||
... | ... | |
@headers["Content-Type"] = "text/html; charset=#{RForum::CONFIG[:web_charset]}" | ||
end | ||
105 | def setup_skin | |
106 | if @params['set_skin'] | |
107 | @session[:skin] = @params['set_skin'] | |
108 | end | |
109 | ||
110 | @skin = @session[:skin] || RForum::CONFIG[:skin] | |
111 | end | |
112 | ||
113 | def detect_site | |
114 | @site = Site.find(:first, :conditions => ["host = ?", request.host]) | |
115 | if @site | |
116 | self.class.layout @site.layout || 'default' | |
117 | @skin = @session[:skin] || @site.skin || 'default' | |
118 | end | |
119 | end | |
120 | ||
121 | def get_forums | |
122 | if @site | |
123 | @forums = @site.forums.find(:all, :order => 'position') | |
124 | else | |
125 | @forums = Forum.find(:all, :order => 'site_id, position') | |
126 | end | |
127 | end | |
128 | ||
129 | def redirect_if_site_doesnt_match | |
130 | if @site && @forum && @forum.site && (@site != @forum.site) | |
131 | headers["Status"] = "301 Moved Permanently" | |
132 | redirect_to_url 'http://' + @forum.site.host + request.path | |
133 | return true | |
134 | end | |
135 | return false | |
136 | end | |
end | ||
module RForum |
rool/rails/rforum/trunk/app/controllers/feed_controller.rb:
prev. | current | |
1 | ||
2 | ||
class FeedController < ApplicationController | ||
layout nil | ||
rool/rails/rforum/trunk/app/controllers/forum_controller.rb:
prev. | current | |
1 | ||
2 | ||
class ForumController < ApplicationController | ||
helper :forum | ||
#caches_page :index, :forum | ||
... | ... | |
def forum | ||
begin | ||
@forum = Forum.find(@params['id']) | ||
10 | return if redirect_if_site_doesnt_match | |
rescue ActiveRecord::RecordNotFound | ||
render_text "Forum not found", 404 | ||
return | ||
... | ... | |
# List all forums. | ||
def list | ||
@title = l(:forum_list_title) | ||
45 | | |
46 | | |
44 | ||
@forums.each{|f| f['last_post'] = f.get_last_post} | ||
end | ||
... | ... | |
redirect_to :controller => 'forum', :action => 'list' | ||
end | ||
54 | | |
def search | ||
@title = l(:search_title) | ||
57 | | |
59 | | |
60 | | |
61 | | |
62 | | |
63 | | |
64 | | |
65 | | |
66 | | |
if @params['forums'] | ||
@selected_forums = @params['forums'].collect {|id| id.to_i} | ||
else | ||
@selected_forums = (@forums.collect {|f| f.id}) | ||
end | ||
72 | | |
60 | ||
if @params['query'] | ||
@query = @params['query'] | ||
@page_params = {'query' => @query} | ||
... | ... | |
redirect_to :action => 'list' | ||
end | ||
132 | ||
end |
rool/rails/rforum/trunk/app/controllers/mailer.rb:
prev. | current | |
1 | ||
require 'url_generator' | ||
require 'digest/md5' | ||
require 'received_mail' | ||
... | ... | |
footer = "\n\n-- \nPosted via http://www.ruby-forum.com/." | ||
@body = post.text + footer | ||
55 | ||
if post.author.guest? | ||
57 | | |
58 | | |
57 | name = (post.author.guest_name || 'Guest').dup | |
58 | email = post.author.guest_email | |
else | ||
60 | | |
60 | name = "#{post.author.firstname} #{post.author.surname}" | |
61 | email = post.author.email | |
end | ||
64 | if post.topic.forum.ml_from_address | |
65 | email = post.topic.forum.ml_from_address | |
66 | end | |
67 | ||
68 | @from = "#{name} <#{email}>" | |
69 | ||
@subject = post.subject | ||
@recipients = post.topic.forum.list_address | ||
@sent_on = post.created_at |
rool/rails/rforum/trunk/app/controllers/security_controller.rb:
prev. | current | |
1 | ||
2 | ||
class SecurityController < ApplicationController | ||
def access_denied | ||
# TODO log, or notify admin, or something like that |
rool/rails/rforum/trunk/app/controllers/topic_controller.rb:
prev. | current | |
1 | ||
2 | ||
class TopicController < ApplicationController | ||
helper :forum | ||
... | ... | |
@title = @topic.subject | ||
@forum = @topic.forum | ||
15 | ||
16 | return if redirect_if_site_doesnt_match | |
raise RForum::SecurityError if @topic.hidden? && !@user.can_view_deleted_posts?(@topic) | ||
... | ... | |
else | ||
# Create reply | ||
post = prepare_post_from_params(@params['post']) | ||
36 | ||
post.parent_id = @params['post']['parent_id'] | ||
37 | | |
38 | parent = Post.find(@params['post']['parent_id']) | |
39 | ||
40 | if parent.topic.forum.readonly == 1 | |
41 | render_text 'This forum does not allow posts.' | |
42 | end | |
43 | ||
44 | parent.add_reply(post) | |
end | ||
display_post(post) | ||
... | ... | |
end | ||
# if reply_to parameter specified, prepare template inputs for a post editing form | ||
elsif @params['reply_to'] | ||
54 | ||
55 | if @forum.readonly == 1 | |
56 | render_text 'This forum does not allow posts.' | |
57 | end | |
58 | ||
@no_robots = true | ||
@post = prepare_reply_for_form(@params['reply_to']) | ||
elsif @params['edit'] | ||
... | ... | |
@forum = Forum.find(@params['forum_id']) rescue Forum.find_first | ||
@title = "New post in forum '#{@forum.name}'" | ||
78 | if @forum.readonly == 1 | |
79 | render_text 'This forum does not allow posts.' | |
80 | return | |
81 | end | |
82 | ||
if @params['post'] | ||
# Form submitted | ||
new_post = prepare_post_from_params(@params['post']) | ||
... | ... | |
@post = e.entity | ||
end | ||
else | ||
95 | return if redirect_if_site_doesnt_match | |
@post = Post.new | ||
@post.author = @user | ||
end | ||
... | ... | |
redirect_to :action => 'show', :id => topic.id | ||
else | ||
@topic = topic | ||
96 | | |
end | ||
end | ||
... | ... | |
# prepare a Post object from a form, update @user with guest_name and guest_email | ||
def prepare_post_from_params(form_attributes) | ||
new_post = Post.new | ||
198 | ||
199 | if form_attributes['new_attachment'] && form_attributes['new_attachment'].size > 0 | |
200 | new_post.new_attachment = form_attributes['new_attachment'] | |
201 | end | |
202 | ||
new_post.subject = form_attributes['subject'] | ||
new_post.text = form_attributes['text'] | ||
rool/rails/rforum/trunk/app/controllers/user_controller.rb:
prev. | current | |
1 | ||
2 | ||
class UserController < ApplicationController | ||
def login | ||
... | ... | |
if user | ||
# login successful | ||
@user = user | ||
11 | user.activated = 1 | |
12 | user.save | |
return_to_last_remembered | ||
else | ||
# login failed |
rool/rails/rforum/trunk/app/models/attachment.rb:
prev. | current | |
def before_save | ||
self.filename.gsub!(/[^a-z_\.\-0-9]/i, '_') | ||
10 | self.filename.gsub!(/^\.+/, '_') | |
end | ||
def after_save | ||
... | ... | |
File.open(self.file_path, 'w') do |f| | ||
f.write(@data) | ||
end | ||
23 | @data = nil | |
end | ||
def after_destroy | ||
... | ... | |
end | ||
def get_file_content | ||
43 | self.reload | |
File.read self.file_path | ||
end | ||
43 | | |
47 | def url | |
48 | "/attachment/#{self.id}/#{self.filename}" | |
49 | end | |
50 | ||
end |
rool/rails/rforum/trunk/app/models/forum.rb:
prev. | current | |
class Forum < ActiveRecord::Base | ||
has_many :topics, :dependent => true | ||
3 | | |
3 | belongs_to :site | |
4 | ||
5 | acts_as_list :scope => :site_id | |
include ErrorRaising | ||
... | ... | |
# Transaction is necessary here because more than one entity is being | ||
# created if saving of post raises an error (e.g., | ||
# RForum::ValidationError), complete trx must be rolled back | ||
56 | | |
58 | # Transaction::Simple is not necessary here, because post won't be | |
59 | # used anymore | |
60 | transaction do | |
topic = Topic.create('forum_id' => self.id, 'subject' => post.subject) | ||
topic.created_at = topic.updated_at = post.created_at = post.updated_at = (post.created_at or Time.now) | ||
post.topic = topic | ||
... | ... | |
end | ||
def get_last_post | ||
113 | | |
114 | | |
115 | | |
116 | | |
117 | | |
118 | | |
119 | | |
120 | | |
121 | | |
122 | | |
117 | topic = topics.find( | |
118 | :first, | |
119 | :conditions => 'deleted = 0', | |
120 | :order => 'last_post_created_at DESC' | |
121 | ) | |
122 | ||
123 | return nil if topic.nil? | |
124 | ||
125 | topic.posts.find( | |
126 | :first, | |
127 | :conditions => 'deleted = 0', | |
128 | :order => 'created_at DESC' | |
129 | ) | |
end | ||
end |
rool/rails/rforum/trunk/app/models/post.rb:
prev. | current | |
belongs_to :parent, :class_name => 'Post', :foreign_key => 'parent_id' | ||
has_many :children, :class_name => 'Post', :foreign_key => 'parent_id' | ||
has_many :post_votes, :dependent => true | ||
20 | | |
has_many :attachments, :dependent => true | ||
composed_of :guest, :mapping => [ %w(guest_name guest_name), %w(guest_email guest_email) ] | ||
24 | | |
23 | # TODO: don't tokenize the id fields | |
24 | acts_as_ferret :fields => [:subject, :text, :user_id, :forum_id, :deleted], :auto_index_update => false | |
25 | ||
26 | attr_accessor :new_attachment | |
27 | ||
28 | validates_length_of :text, :within => 2..50000, | |
:too_short => 'formerror_text_short', :too_long => 'formerror_text_long' | ||
validates_length_of :subject, :within => 3..60, | ||
:too_short => 'formerror_subject_short', :too_long => 'formerror_subject_long' | ||
validates_uniqueness_of :messageid | ||
31 | | |
32 | | |
33 | | |
34 | | |
35 | ||
include ErrorRaising | ||
... | ... | |
EOL | ||
end | ||
52 | | |
53 | | |
54 | | |
51 | # Find the <tt>number</tt> latest posts. | |
52 | def self.find_latest(number) | |
53 | Post.find_all "deleted = 0", 'created_at DESC, id DESC', number | |
end | ||
# Finds post with specified id, and adds data from corresponding USERS row | ||
... | ... | |
end | ||
# Return an Array of posts matching the query string | ||
124 | | |
125 | | |
123 | def self.search(query, forums=[], number=1, offset=0) | |
124 | if forums.size > 0 | |
125 | forum_query = " +forum_id:(#{forums.join('|')}" | |
126 | else | |
127 | forum_query = "" | |
128 | end | |
129 | ||
130 | self.find_by_contents(query + forum_query + ' +deleted:0', :first_doc => offset, :num_docs => number) | |
end | ||
128 | | |
129 | | |
130 | | |
131 | ||
# CALLBACKS | ||
def before_validation | ||
# Guest post | ||
... | ... | |
end | ||
def validate | ||
155 | | |
156 | # spam filter (only for forum posts) | |
157 | if self.post_method != 'mail' | |
158 | matches = RForum::CONFIG[:spam_filter_regex].match(self.subject.to_s + self.text.to_s) | |
159 | if matches | |
160 | errors.add('text', "Your post seems to contain Spam: \"#{matches[0]}\".") | |
161 | end | |
162 | end | |
163 | ||
check_mandatory_atributes(:topic_id) | ||
if self.parent_id and self.parent.topic_id != self.topic_id | ||
raise ArgumentError.new("Post ##{self.parent_id} does not belong to topic #{self.topic_id}") | ||
end | ||
169 | if @new_attachment && @new_attachment.size > RForum::CONFIG[:max_attachment_size] | |
170 | errors.add('new_attachment', :attachment_too_large) | |
171 | end | |
172 | ||
errors.add('text', :formerror_text_short) if text.nil? | ||
errors.add('subject', :formerror_subject_short) if subject.nil? | ||
... | ... | |
end | ||
def after_create | ||
201 | # send list mails | |
202 | if RForum::CONFIG[:deliver_mail] and self.topic.forum.list_address and self.post_method != 'mail' | |
203 | Mailer.deliver_ml_post(self) | |
204 | end | |
205 | ||
# notify users | ||
self.topic.topic_subscriptions.each do |subscription| | ||
subscription.do_notify(self) | ||
end | ||
193 | ||
194 | | |
195 | | |
196 | | |
197 | | |
198 | | |
end | ||
def before_destroy | ||
... | ... | |
self.topic.update_post_counter | ||
self.topic.subject = self.subject if self.root? | ||
self.topic.save | ||
224 | | |
235 | ||
236 | if @new_attachment | |
237 | self.attach_file(@new_attachment.original_filename, @new_attachment.read) | |
238 | end | |
end | ||
# OTHER METHODS | ||
243 | # pseudo attribute for ferret indexer | |
244 | def forum_id | |
245 | self.topic.forum_id | |
246 | end | |
247 | ||
# Add a reply to the current post, and return the saved reply | ||
def add_reply(post) | ||
231 | | |
250 | # Transaction::Simple is not necessary here, because post won't be | |
251 | # used anymore | |
252 | transaction do | |
post.parent = self | ||
post.topic = self.topic | ||
post.save | ||
... | ... | |
a = Attachment.new | ||
a.filename = filename | ||
a.data = data | ||
264 | a.post = self | |
a.save | ||
244 | | |
a | ||
end | ||
... | ... | |
if recursive | ||
self.children.each { |child| child.hide(:recursive) } | ||
end | ||
277 | | |
end | ||
def unhide(recursive=false) | ||
... | ... | |
if recursive | ||
self.children.each { |child| child.unhide(:recursive) } | ||
end | ||
286 | ||
287 | | |
end | ||
def hidden? |
rool/rails/rforum/trunk/app/models/tag.rb:
prev. | current | |
class Tag < ActiveRecord::Base | ||
has_and_belongs_to_many :topics, :join_table => 'topics_tags' | ||
3 | ||
4 | include ErrorRaising | |
end |
rool/rails/rforum/trunk/app/models/user.rb:
prev. | current | |
self[attr] = self[attr].to_s.strip.squeeze(' ').chomp | ||
end | ||
50 | self.surname.capitalize! | |
51 | self.firstname.capitalize! | |
self.name.downcase! | ||
self.email.downcase! | ||
self.role = 'User' |
rool/rails/rforum/trunk/app/views/forum/forum.rhtml:
prev. | current | |
<div class="forum"> | ||
<div class="forum"> | ||
3 | | |
5 | | |
6 | | |
7 | | |
4 | <% if @topics.empty? %> | |
5 | <%=l :forum_is_empty %> | |
6 | <% else %> | |
9 | | |
8 | <table class="topics list"> | |
<tr> | ||
<th class="subject">Subject</th> | ||
<th class="replies">Replies</th> | ||
<th class="last-post"><%= l(:last_post) %></th> | ||
</tr> | ||
16 | | |
17 | | |
15 | <% @topics.each_with_index do |topic, i| %> | |
16 | <tr class="<%= i.even? ? 'even' : 'odd' %> <%= 'new-posts' if (@user.is_a? User and (topic['last_read_time'] == nil or topic['last_read_time'] < topic.last_post_created_at)) %> <%= 'deleted-topic' if (topic.hidden?) %>"> | |
<td class="subject"> | ||
<a href="<%=h url_for(:controller => 'topic', :action => 'show', :id => topic.id, :anchor => 'new') %>"><%=h topic.subject %></a><%= ' (' + l(:deleted_topic) + ')' if topic.hidden? %> | ||
</td> | ||
... | ... | |
</tr> | ||
<% end %> | ||
</table> | ||
29 | | |
28 | ||
29 | <% end %> | |
30 | ||
</div> | ||
</div> |
rool/rails/rforum/trunk/app/views/forum/list.rhtml:
prev. | current | |
<div class="forum"> | ||
<div class="list"> | ||
11 | | |
<% if @forums.empty? %> | ||
<%=l :no_forums_available %> | ||
<% else %> | ||
16 | | |
15 | ||
16 | <table class="list"> | |
17 | <tr> | |
18 | <th class="name-description">Forum</th> | |
19 | <th class="lastpost"><%= l(:last_post) %></th> | |
20 | <th class="topics_num"><%= l(:number_of_topics) %></th> | |
21 | <th class="posts_num"><%= l(:number_of_posts) %></th> | |
22 | </tr> | |
23 | ||
<% @forums.each do |forum| %> | ||
<tr> | ||
<td class="name-description"> | ||
<a href="<%=h url_for(:controller => 'forum', :action => 'forum', :id => forum.id) %>"><%=h forum.name %></a> | ||
29 | ||
30 | <% if forum.readonly == 1 %> | |
31 | (read only) | |
32 | <% end %> | |
<span class="name"> | ||
<% if @user.admin? %> | ||
... | ... | |
</td> | ||
<td class="lastpost"> | ||
<% if forum.last_post %> | ||
37 | | |
38 | | |
48 | <a href="<%=h url_for(:controller => 'topic', :action => 'show', :id => forum.last_post.topic_id, :anchor => forum.last_post.id) %>"><%=h format_relative_time(forum.last_post.created_at) %></a><br /> | |
49 | <%=l :by %> <%=h forum.last_post.author.get_display_name %> | |
<% end %> | ||
</td> | ||
<td class="topics_num"> | ||
42 | | |
53 | <%=h forum.get_topics_num %> | |
</td> | ||
<td class="posts_num"> | ||
45 | | |
56 | <%=h forum.get_posts_num %> | |
</td> | ||
</tr> | ||
<% end %> | ||
... | ... | |
<% end %> | ||
53 | | |
</div> | ||
</div> |
rool/rails/rforum/trunk/app/views/forum/search.rhtml:
prev. | current | |
<form action="<%= url_for() %>"> | ||
<input type="text" name="query" value="<%=h @query %>" /> | ||
11 | | |
12 | | |
13 | | |
14 | | |
15 | | |
16 | | |
17 | | |
18 | | |
19 | ||
<br /> | ||
12 | <label><%=h l(:search_in_forums) %></label> | |
13 | <br /> | |
14 | <select name="forums[]" size="<%= [5, @forums.size].min %>" multiple="multiple"> | |
15 | <%= options_from_collection_for_select(@forums, :id, :name, @selected_forums) %> | |
16 | </select> | |
17 | ||
18 | <br /> | |
<input type="submit" value="Search" /> | ||
</form> | ||
<% end %> | ||
... | ... | |
<table class="searchresults"> | ||
<% @results.each do |result| %> | ||
<tr> | ||
36 | | |
34 | <td class="subject"><%= link_to h(result.subject), :controller => 'topic', :action => 'show', :id => result.topic_id, :anchor => result.id %></td> | |
<td class="text"> | ||
<%= searchresult_text_excerpt(result.text, @query) %> | ||
</td> |
rool/rails/rforum/trunk/app/views/layouts/default.rhtml:
prev. | current | |
<link type="text/css" rel="stylesheet" href="/stylesheets/syntax.css" /> | ||
<link type="text/css" rel="stylesheet" media="print" href="/stylesheets/print.css" /> | ||
13 | | |
14 | | |
13 | <% if @skin %> | |
14 | <link type="text/css" rel="stylesheet" href="/skins/<%= h @skin %>/style.css" /> | |
<% end %> | ||
<link rel="alternate" type="application/atom+xml" title="<%= l(:feed_description_global) %>" href="/feed/global" /> | ||
... | ... | |
</div>--> | ||
</div> | ||
47 | <div id="sidebar"><%= render 'sidebar' %></div> | |
48 | ||
</body> | ||
</html> |
rool/rails/rforum/trunk/app/views/topic/_post.rhtml:
prev. | current | |
1 | ||
2 | ||
3 | ||
1 | <% if @last_read_at and post.created_at > @last_read_at and !@have_newpost_anchor %> | |
<a name="new"></a> | ||
3 | <% @have_newpost_anchor = true %> | |
<% end %> | ||
<!-- The class "new" is added if this is an unread post. --> | ||
<div class="post box <%= "new-post" if @last_read_at and post.created_at > @last_read_at %> <%= "deleted-post" if post.hidden? %>"> | ||
<div class="subject"> | ||
11 | | |
10 | <strong><a name="<%=h post.id %>" href="#<%=h post.id %>"><%=h post.subject %><%= ' (' + l(:deleted_post) + ')' if post.hidden? %></a></strong> | |
</div> | ||
<div class="info"> | ||
<div class="author"> | ||
16 | | |
15 | <%=l :posted_by %> | |
<span class="name"> | ||
<% if post.user_id == nil %> | ||
<%= h post.get_display_name %> (Guest) | ||
... | ... | |
on <%=h format_datetime(post.created_at) %> | ||
</div> | ||
41 | <% for attachment in post.attachments %> | |
42 | <div class="attachment"> | |
43 | <%=l :attachment %>: | |
44 | <a href="<%=h attachment.url %>"><%=h attachment.filename %></a> | |
45 | </div> | |
46 | <% end %> | |
47 | ||
<% if post.post_method == 'mail' %> | ||
43 | | |
49 | <img src="/images/email.png" alt="(<%= l(:received_by_mail) %>)" title="<%= l(:received_by_mail) %>" /> | |
<% end %> | ||
</div> | ||
rool/rails/rforum/trunk/app/views/topic/_postform.rhtml:
prev. | current | |
<div class="postform box"> | ||
<a name="postform"></a> | ||
3 | | |
3 | <form action="<%= url_for(:action => @params['action'], :id => @params['id'], :anchor => 'postform') %>" method="post" enctype="multipart/form-data"> | |
<input type="hidden" name="dummy" value="ie-workaround" /> | ||
<table> | ||
... | ... | |
<% end %> | ||
<%= form_input(:text_field, 'post', 'subject', 'Subject', 'size' => '60', 'maxlength' => '60') %> | ||
26 | <%= form_input(:file_field, 'post', 'new_attachment', 'Attachment') %> | |
<%= form_input(:text_area, 'post', 'text', 'Text', 'cols' => 80, 'rows' => 24, 'wrap' => 'virtual') %> | ||
28 | ||
<%= form_input(:submit_button, 'post', 'submit', 'Submit') %> | ||
</table> | ||
</form> |
rool/rails/rforum/trunk/app/views/user/list.rhtml:
prev. | current | |
1 | ||
2 | | |
1 | <div class="user"><div class="list"> | |
2 | <% if @users.empty? %> | |
<%=l :no_users_registered %> | ||
<% else %> | ||
6 | | |
6 | <table class="list"> | |
<tr> | ||
<th class="id">#</th> | ||
<th class="name"><%=l :user_name %></th> | ||
... | ... | |
</table> | ||
<% end %> | ||
31 | ||
32 | </div></div> |
rool/rails/rforum/trunk/app/views/user/registration_complete.rhtml:
prev. | current | |
<div class="register"> | ||
2 | | |
3 | | |
2 | <div class="box"> | |
3 | <p><%=h l(:registration_complete_text) %></p> | |
4 | <p><%=h l(:registration_email_sent, @new_user.email) %></p> | |
5 | </div> | |
</div> |
rool/rails/rforum/trunk/config/app.rb:
prev. | current | |
# Load site specific parameters | ||
2 | ||
3 | | |
4 | ||
5 | | |
2 | if RAILS_ENV == 'test' | |
require File.join(RAILS_ROOT, 'config/default_site') | ||
4 | else | |
5 | begin | |
6 | require File.join(RAILS_ROOT, 'config/site') | |
7 | rescue LoadError | |
8 | STDERR.puts 'WARNING: config/site.rb not found, using default settings from config/default_site.rb' | |
9 | require File.join(RAILS_ROOT, 'config/default_site') | |
10 | end | |
end | ||
if RForum::CONFIG[:web_charset] == 'utf-8' |
rool/rails/rforum/trunk/config/database.yml:
prev. | current | |
# SQLite is enabled by default. Remember to change the dbfile path. | ||
production: | ||
3 | | |
3 | adapter: sqlite3 | |
dbfile: /tmp/rforum_prod.db | ||
# Uncomment this section for MySQL: | ||
... | ... | |
# The following settings are only used for testing and development. | ||
development: | ||
24 | | |
24 | adapter: sqlite3 | |
dbfile: /tmp/rforum_dev.db | ||
test: | ||
28 | | |
29 | | |
28 | adapter: sqlite3 | |
29 | dbfile: /Volumes/RamDisk/rforum_test.db |
rool/rails/rforum/trunk/config/default_site.rb:
prev. | current | |
:db_charset => 'utf-8', | ||
:mail_charset => 'utf-8', | ||
33 | | |
34 | | |
35 | | |
36 | | |
37 | | |
38 | | |
:search_results_per_page => 40, | ||
:topics_per_page => 40, | ||
... | ... | |
:accept_mail_from_guests => true, | ||
57 | | |
58 | | |
51 | # Path relative to root directory. | |
52 | :attachment_path => '/attachments', | |
53 | ||
54 | :max_attachment_size => 100.kilobytes, | |
# Formatting of posts with quoting. | ||
# :simple is fixed with and with colored quoting levels | ||
... | ... | |
# added to the URL and sent to the user by email. Such token allows the user to perform certain | ||
# security-sensitive activities without providing a password. This token will expire | ||
# after the number of hours specified by the parameter below. | ||
69 | | |
65 | :security_token_life_hours => 24, | |
66 | ||
67 | :spam_filter_regex => /(cialis|viagra|xenical|valium|xanax|phentermine|hydrocodone|casino|tramadol|ambien|impressive|congratulations|alprazolam|carisoprodol|rivotril|narod\.ru|href=|cymbalta|great design|adult|online store|gambling|world of warcraft|porn|\[url|<\/a>|e-cigarette|ezigaretten\.com|billige zigaretten)/i, | |
68 | ||
69 | :use_sites => false | |
} | ||
# Mailer configuration |
rool/rails/rforum/trunk/config/routes.rb:
prev. | current | |
:requirements => {:id => /^[0-9]+$/} | ||
map.connect 'forum/:id', :controller => 'forum', :action => 'forum', | ||
:requirements => {:id => /^[0-9]+$/} | ||
7 | map.connect 'search', :controller => 'forum', :action => 'search' | |
8 | map.connect 'attachment/:id/:filename', :controller => 'attachment', | |
9 | :action => 'fetch', :requirements => {:id => /^[0-9]+$/} | |
map.connect ':controller/:action/:id' | ||
map.connect ':controller/:action' | ||
end |
rool/rails/rforum/trunk/lang/de.yaml:
prev. | current | |
nav_register: Account erstellen | ||
nav_user_list: Benutzerliste | ||
21 | posted_by: Geschrieben von | |
22 | posted_on: am | |
23 | ||
24 | attachment: Dateianhang | |
25 | attachment_too_large: Die angehängte Datei ist zu groß. | |
26 | ||
postmenu_reply_to: Antwort mit Zitat | ||
postmenu_move_topic: Thread verschieben | ||
postmenu_delete_post: Löschen | ||
... | ... | |
no_users_registered: Keine Benutzer registriert. | ||
no_forums_to_search: Es sind keine Foren zum Durchsuchen vorhanden. | ||
114 | ||
120 | search_in_forums: "Suchen in: (Strg oder Command-Taste drücken um mehrere Foren auszuwählen)" | |
search_no_result: Keine passenden Beiträge gefunden. | ||
create_forum_title: Forum erstellen |
rool/rails/rforum/trunk/lang/en.yaml:
prev. | current | |
nav_register: Register | ||
nav_user_list: User List | ||
19 | posted_by: Posted by | |
20 | posted_on: "on" | |
21 | ||
22 | attachment: Attachment | |
23 | attachment_too_large: The attached file is too large. | |
24 | ||
postmenu_reply_to: Reply with quote | ||
postmenu_move_topic: Move | ||
postmenu_delete_post: Delete |
rool/rails/rforum/trunk/lib/received_mail.rb:
prev. | current | |
return user | ||
else | ||
name = TMail::Address.parse(self['from'].to_s).phrase | ||
15 | name = TMail::Unquoter.unquote_and_convert_to(name, 'utf-8') | |
if name.nil? || name.size < 2 | ||
name = 'unknown' | ||
end |
rool/rails/rforum/trunk/public/skins/ruby-forum.com/style.css:
prev. | current | |
.box { | ||
background-repeat: repeat-x; | ||
background-image: url(/skins/ruby-forum.com/images/post-background.png); | ||
12 | | |
13 | | |
} | ||
.forum .post .text { | ||
... | ... | |
.adfooter { | ||
margin-top: 5ex; | ||
24 | text-align: center; | |
} | ||
.stats .box { |
rool/rails/rforum/trunk/public/stylesheets/main.css:
prev. | current | |
body | ||
{ | ||
font-family: "Lucida Grande", verdana, arial, helvetica, sans-serif; | ||
6 | | |
6 | font-size: 0.81em; | |
padding: 0 3ex 0 3ex; | ||
margin: 0; | ||
text-align: center; | ||
... | ... | |
a, a:link, a:visited { color: #a00000; text-decoration: none; } | ||
a:hover { text-decoration: underline; } | ||
15 | .currentlink { text-decoration: underline ! important; } | |
16 | ||
17 | a img { border-width: 0; } | |
18 | ||
h1#pageName { | ||
margin: 5px 0 0; | ||
padding: 0; | ||
... | ... | |
h2 { font-size: 18px } | ||
h3 { font-size: 16px } | ||
38 | /* <Sidebar> */ | |
39 | ||
40 | #sidebar { | |
41 | text-align: left; | |
42 | width: 15ex; | |
43 | float: left; | |
44 | } | |
45 | ||
46 | #sidebar ul { | |
47 | list-style-type: none; | |
48 | padding-left: 0; | |
49 | margin-left: 0; | |
50 | } | |
51 | ||
52 | #sidebar li { | |
53 | margin-left: 0; | |
54 | } | |
55 | ||
56 | /* </Sidebar> */ | |
57 | ||
#container { | ||
35 | | |
59 | width: 80%; | |
60 | float: right; | |
text-align: left; | ||
margin: 0 auto 0 auto; | ||
} | ||
... | ... | |
padding-left: 5px; | ||
} | ||
79 | ||
104 | table.list { | |
105 | width: 100%; | |
106 | border-collapse: collapse; | |
107 | } | |
108 | ||
109 | .user div.show .user_message textarea { | |
width: 80ex; | ||
height: 15em; | ||
} | ||
84 | ||
85 | | |
86 | | |
87 | ||
88 | ||
89 | ||
90 | | |
91 | ||
92 | | |
93 | ||
114 | /* Forum list view */ | |
115 | .forum div.list .name { | |
font-weight: bold; | ||
} | ||
97 | ||
119 | .forum div.list .description { | |
font-size: 0.8em; | ||
} | ||
101 | ||
123 | .forum div.list .edit { | |
font-size: smaller; | ||
font-weight: normal; | ||
} | ||
/* Forum view */ | ||
107 | ||
108 | | |
109 | | |
110 | ||
111 | ||
112 | ||
129 | .forum div.forum td.subject { | |
width: 50%; | ||
} | ||
116 | ||
133 | table.list th,td { | |
134 | padding: 2px; | |
135 | margin: 0; | |
136 | } | |
137 | ||
138 | /* <borders> */ | |
139 | table.list { | |
140 | border: 1px solid #EEE; | |
141 | } | |
142 | ||
143 | table.list th { | |
144 | border-bottom: 1px solid #EEE; | |
145 | } | |
146 | ||
147 | table.list td { | |
148 | border-bottom: 1px solid #EEE; | |
149 | } | |
150 | ||
151 | .forum .forum table.topics td.subject { | |
152 | border-left: 1px solid #EEE; | |
153 | } | |
154 | ||
155 | .forum .forum table.topics td.last-post { | |
156 | border-right: 1px solid #EEE; | |
157 | } | |
158 | /* </borders> */ | |
159 | ||
160 | ||
161 | .forum .forum table.topics .last-post { | |
padding-left: 15px; | ||
} | ||
120 | ||
165 | .forum .forum table.topics td.replies { | |
text-align: center; | ||
} | ||
124 | ||
169 | .forum .forum table.topics .new-posts .subject { | |
font-weight: bold; | ||
} | ||
128 | ||
173 | .forum .forum table.topics .deleted-topic * { | |
color: #D0D0D0 ! important; | ||
} | ||
... | ... | |
font-size: 1.1em; | ||
} | ||
198 | .forum .post .subject a { | |
199 | color: inherit ! important; | |
200 | } | |
201 | ||
.forum .post .info { | ||
font-size: 0.7em; | ||
} | ||
... | ... | |
display: inline; | ||
} | ||
210 | .forum .post .info div.attachment { | |
211 | display: block; | |
212 | } | |
213 | ||
.forum .post .text { | ||
font-size: 1.0em; | ||
} |
rool/rails/rforum/trunk/public/stylesheets/print.css:
prev. | current | |
body { | ||
font-family: serif; | ||
3 | | |
4 | | |
5 | | |
} | ||
a { | ||
text-decoration: underline; | ||
} | ||
9 | * { | |
10 | background-color: white ! important; | |
11 | color: black; | |
12 | } | |
13 | ||
14 | #sidebar { | |
15 | display: none; | |
16 | } | |
17 | ||
18 | #container { | |
19 | width: 100% | |
20 | } | |
21 | ||
.navbar { | ||
display: none; | ||
} |
rool/rails/rforum/trunk/script/process_mails:
prev. | current | |
require 'fileutils' | ||
require 'breakpoint' | ||
15 | def do_update | |
16 | puts "Reading last update time from last_update.yaml... " | |
17 | begin | |
18 | from = YAML.load(File.read(RAILS_ROOT + '/last_update.yaml')) | |
19 | puts "done." | |
20 | rescue | |
21 | puts "could not load file. Using default (1 day ago)." | |
22 | from = 1.day.ago | |
23 | end | |
24 | ||
25 | puts "Updating index starting from #{from.to_s}..." | |
26 | last_update = Time.now | |
27 | number = Post.search_handler.rebuild_index(from).size | |
28 | puts "done (#{number} posts)." | |
29 | ||
30 | puts "Saving last update time to last_update.yaml... " | |
31 | File.open(RAILS_ROOT + '/last_update.yaml', 'w') do |file| | |
32 | file.write(last_update.to_yaml) | |
33 | end | |
34 | puts "done." | |
35 | end | |
36 | ||
def do_import(maildir) | ||
puts "Checking for new mails" | ||
Dir[File.join(maildir, '*')].each do |file| | ||
... | ... | |
puts "Skipped file #{file} (invalid encoding)" | ||
FileUtils.move(file, RAILS_ROOT + '/mails/rejected/invalid_encoding/') rescue ArgumentError | ||
elsif e.message['messageid : has already been taken'] | ||
30 | | |
31 | | |
52 | puts "Skipped & deleted file #{file} (messageid already in database)" | |
53 | File.delete(file) rescue ArgumentError | |
elsif e.is_a? RForum::ValidationError | ||
puts "Skipped file #{file} (ValidationError): #{e.inspect}" | ||
FileUtils.move(file, RAILS_ROOT + '/mails/rejected/validation_error/') rescue ArgumentError | ||
... | ... | |
loop do | ||
do_import(maildir) | ||
GC.start | ||
74 | do_update() | |
75 | GC.start | |
puts "sleeping for #{sleeptime} minutes..." | ||
sleep sleeptime * 60 | ||
end |
rool/rails/rforum/trunk/test/functional/topic_controller_test.rb:
prev. | current | |
GUEST_EMAIL_ANON = /<input name='post\[guest_email\]' .*/ | ||
GUEST_EMAIL_ALEX = /<input name='post\[guest_email\]' .*value='alex@someplace.org'/ | ||
SUBMIT_BUTTON = /<input name='submit'/ | ||
66 | NEW_ATTACHMENT = /<input name='post\[new_attachment\]'/ | |
def test_show_reply_form | ||
r = process('show', {'id' => '2', 'reply_to' => '102'}, {:user_id => 1}) | ||
check_post_in_form(r) | ||
70 | | |
71 | assert_matches_all [MS_BUG_WORKAROUND, SELF_ID, NEW_ATTACHMENT, PARENT_ID, SUBJECT, TOPIC_ID, SUBMIT_BUTTON], | |
form_inputs(r) | ||
end | ||
def test_show_reply_form_for_anonymous | ||
r = process('show', {'id' => '2', 'reply_to' => '102'}, {:user_id => nil}) | ||
77 | | |
78 | assert_matches_all [MS_BUG_WORKAROUND, GUEST_EMAIL_ANON, GUEST_NAME_ANON, SELF_ID, NEW_ATTACHMENT, PARENT_ID, | |
SUBJECT, TOPIC_ID, SUBMIT_BUTTON], form_inputs(r) | ||
end | ||
... | ... | |
r = process('show', {'id' => '2', 'reply_to' => '102'}, | ||
{:user_id => nil, :guest_name => 'Alex'}) | ||
85 | | |
86 | | |
86 | assert_matches_all [MS_BUG_WORKAROUND, GUEST_EMAIL_ANON, GUEST_NAME_ALEX, | |
87 | SELF_ID, NEW_ATTACHMENT, PARENT_ID, SUBJECT, TOPIC_ID, SUBMIT_BUTTON], | |
88 | form_inputs(r) | |
end | ||
def test_show_reply_form_for_known_guest_email | ||
r = process('show', {'id' => '2', 'reply_to' => '102'}, | ||
{:user_id => nil, :guest_email => 'alex@someplace.org'}) | ||
93 | | |
95 | assert_matches_all [MS_BUG_WORKAROUND, GUEST_EMAIL_ALEX, GUEST_NAME_ANON, SELF_ID, NEW_ATTACHMENT, PARENT_ID, | |
SUBJECT, TOPIC_ID, SUBMIT_BUTTON], form_inputs(r) | ||
end | ||
... | ... | |
def form_inputs(response) | ||
xml = REXML::Document.new(response.body) | ||
375 | | |
376 | | |
377 | | |
377 | REXML::XPath.match(xml, '//form[@action="/topic/2#postform"]//input').collect {|i| i.to_s}.sort | |
end | ||
def check_post_in_form(response) |
rool/rails/rforum/trunk/test/functional/user_controller_test.rb:
prev. | current | |
end | ||
def test_login | ||
18 | assert_equal 0, User.find_by_login('a', 'a').activated | |
r = process('login', {'name' => 'a', 'password' => 'a', 'submit' => 'Login'}, | ||
{:return_to => '/forum/forum/1'}) | ||
assert_redirect_url_match '/forum/forum/1' | ||
assert_equal User.find_by_login('a', 'a').id, r.session[:user_id] | ||
23 | assert_equal 1, User.find_by_login('a', 'a').activated | |
end | ||
def test_login_wrong_password |
rool/rails/rforum/trunk/test/test_helper.rb:
prev. | current | |
} | ||
FtaPrototypes::set_prototype :User, { | ||
56 | | |
56 | 'name' => 'ryan', 'firstname' => 'ryan', 'surname' => 'platte', | |
'email' => 'ryan.platte@example.com' | ||
} | ||
rool/rails/rforum/trunk/test/unit/attachment_test.rb:
prev. | current | |
end | ||
end | ||
18 | | |
18 | def create_attachment | |
a = Attachment.new | ||
a.data = 'some data' | ||
a.filename = '../../data.txt' | ||
a.save | ||
23 | a | |
24 | end | |
24 | | |
26 | def test_create | |
27 | a = create_attachment | |
28 | ||
29 | assert_equal '__.._data.txt', a.filename | |
assert_equal 'some data', File.read(a.file_path) | ||
31 | end | |
33 | def test_destroy | |
34 | a = create_attachment | |
p = Post.find(1) | ||
p.attachments << a | ||
... | ... | |
assert_raises(Errno::ENOENT) { File.stat(a.dir_path) } | ||
end | ||
42 | def test_post_destroy | |
43 | a = create_attachment | |
44 | p = Post.find(1) | |
45 | p.attachments << a | |
46 | ||
47 | p.destroy | |
48 | assert_raises(Errno::ENOENT) { File.stat(a.dir_path) } | |
49 | end | |
50 | ||
end |
rool/rails/rforum/trunk/test/unit/forum_test.rb:
prev. | current | |
end | ||
def test_get_last_post | ||
103 | Topic.find_all.each { |t| t.update_last_post_data; t.save } | |
f = Forum.find(1) | ||
p = f.get_last_post | ||
assert_equal 11, p.id |
rool/rails/rforum/trunk/test/unit/localization_test.rb:
prev. | current | |
# TODO: shouldn't use production data for tests | ||
# require File.dirname(__FILE__) + '/../test_helper' | ||
11 | | |
11 | TRANSLATION_TABLE = LOCALIZED_STRINGS['en'] | |
def test_normal_translation | ||
assert_equal TRANSLATION_TABLE[:available_forums], l(:available_forums) |
rool/rails/rforum/trunk/test/unit/post_test.rb:
prev. | current | |
require File.dirname(__FILE__) + '/../test_helper' | ||
class PostTest < Test::Unit::TestCase | ||
6 | | |
6 | fixtures 'users', 'forums', 'topics', 'posts', 'attachments' | |
def teardown | ||
... | ... | |
assert_equal 0, p.deleted | ||
end | ||
37 | def test_create_spam_from_web | |
38 | assert_raise(RForum::ValidationError, "Spam is accepted") { | |
39 | Post.create(prototype_params(Post, 'text' => 'xanax')) | |
40 | } | |
41 | end | |
42 | ||
43 | def test_create_spam_from_mail | |
44 | # incoming mails are not affected by the spam filter | |
45 | assert Post.create(prototype_params(Post, 'post_method'=> 'mail', 'text' => 'xanax')) | |
46 | end | |
47 | ||
def test_create_with_empty_messageid | ||
p = Post.create(prototype_params(Post, 'messageid' => nil)) | ||
... | ... | |
end | ||
def test_validate_empty_text | ||
63 | | |
74 | [nil, '', '1', "1 "].each { |empty_text_value| | |
assert_raise(RForum::ValidationError, "Text #{empty_text_value.inspect} is accepted") { | ||
Post.create(prototype_params(Post, 'text' => empty_text_value)) | ||
} | ||
... | ... | |
end | ||
def test_validate_empty_subject | ||
71 | | |
82 | [nil, '', '1'].each { |empty_subject_value| | |
assert_raise(RForum::ValidationError, "Subject #{empty_subject_value.inspect} is accepted") { | ||
Post.create(prototype_params(Post, 'subject' => empty_subject_value)) | ||
} | ||
... | ... | |
p = Post.create(prototype_params(Post)) | ||
a = p.attach_file('test.txt', 'testdata') | ||
assert_equal 'testdata', File.read(a.file_path) | ||
352 | assert_equal 'testdata', a.get_file_content | |
end | ||
355 | def test_attach_file_directly | |
356 | RForum::CONFIG[:max_attachment_size] = 100 | |
357 | p = Post.new(prototype_params(Post)) | |
358 | upload = Struct.new(:read, :original_filename, :size).new | |
359 | upload.read = 'testdata' | |
360 | upload.size = 8 | |
361 | upload.original_filename = 'test.txt' | |
362 | p.new_attachment = upload | |
363 | p.save | |
364 | p.reload | |
365 | assert_equal 'testdata', p.attachments[0].get_file_content | |
366 | assert_equal 'test.txt', p.attachments[0].filename | |
367 | end | |
368 | ||
369 | def test_attach_large_file_directly | |
370 | RForum::CONFIG[:max_attachment_size] = 5 | |
371 | p = Post.new(prototype_params(Post)) | |
372 | upload = Struct.new(:read, :original_filename, :size).new | |
373 | upload.read = 'testdata' | |
374 | upload.size = 8 | |
375 | upload.original_filename = 'test.txt' | |
376 | p.new_attachment = upload | |
377 | assert_raise(RForum::ValidationError) { p.save } | |
378 | end | |
379 | ||
def test_author_is_guest_without_name | ||
p = Post.create( :guest_name => '', :subject => 'subject foo', :topic_id => '1', :text => 'content' ) | ||
assert p.author.is_a?(Guest) |
rool/rails/rforum/trunk/test/unit/search_ferret_test.rb:
prev. | current | |
fixtures 'posts', 'topics', 'forums', 'users' | ||
def setup | ||
9 | | |
10 | | |
11 | | |
12 | | |
13 | | |
9 | Post.rebuild_index | |
end | ||
def teardown | ||
... | ... | |
end | ||
def test_rebuild_index | ||
21 | | |
22 | | |
23 | | |
17 | assert_equal Post.count, Post.ferret_index.size | |
18 | Post.rebuild_index | |
19 | assert_equal Post.count, Post.ferret_index.size | |
end | ||
def test_search | ||
27 | | |
23 | assert_equal Post.count("deleted = 0 AND text LIKE '%xyz%'"), Post.search('xyz', [], 999, 0).size | |
end | ||
def test_search_by_forum | ||
topics = Forum.find(2).topics.find(:all, :conditions => 'deleted=0') | ||
sum = topics.inject(0) { |n, t| n + t.post_counter } | ||
33 | | |
29 | assert_equal sum, Post.search('', [2], 999, 0).size | |
end | ||
36 | | |
32 | def test_update | |
Post.find(21).hide | ||
38 | | |
34 | assert_equal Post.count('deleted=0') + 1, Post.search('', [], 999, 0).size | |
35 | Post.manual_index_update | |
36 | assert_equal Post.count('deleted=0'), Post.search('', [], 999, 0).size | |
end | ||
end |
rool/rails/rforum/trunk/test/unit/user_test.rb:
prev. | current | |
User.create(prototype_params(User)) | ||
user = User.find_all[0] | ||
assert user | ||
29 | | |
29 | assert_equal prototype_params(User)['firstname'].capitalize, user.firstname | |
30 | assert_equal prototype_params(User)['surname'].capitalize, user.surname | |
31 | ||
32 | prototype_params(User).each_pair { |k, v| | |
33 | next if ['firstname', 'surname'].include? k | |
assert_equal v, user[k], "Value of #{k} not as expected" unless k == 'id' | ||
} | ||
end |