radiant-forum-extension 2.1.4 → 2.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.4
1
+ 2.1.6
@@ -14,16 +14,12 @@ protected
14
14
 
15
15
  def establish_context
16
16
  @reader = Reader.find(params[:reader_id]) unless params[:reader_id].blank?
17
- @topic = Topic.find(params[:topic_id]) unless params[:topic_id].blank?
18
- @forum = Forum.find(params[:forum_id]) unless params[:forum_id].blank?
19
- @page = Page.find(params[:page_id]) unless params[:page_id].blank?
17
+ @topic = Topic.visible_to(current_reader).find(params[:topic_id]) unless params[:topic_id].blank?
18
+ @forum = Forum.visible_to(current_reader).find(params[:forum_id]) unless params[:forum_id].blank?
19
+ @page = Page.visible_to(current_reader).find(params[:page_id]) unless params[:page_id].blank?
20
20
  end
21
21
 
22
22
  def redirect_to_post
23
-
24
- Rails.logger.warn "!!! redirecting to post #{@post.inspect}"
25
- Rails.logger.warn "! which will have topic #{@post.topic} and within it page #{@post.page_when_paginated}"
26
-
27
23
  if (@post.page)
28
24
  redirect_to "#{@post.page.url}?#{WillPaginate::ViewHelpers.pagination_options[:param_name]}=#{@post.page_when_paginated}##{@post.dom_id}"
29
25
  elsif @post.first?
@@ -54,9 +50,17 @@ protected
54
50
 
55
51
  def render_page_or_feed(template_name = action_name)
56
52
  respond_to do |format|
57
- format.html { render :action => template_name }
58
- format.rss { render :action => template_name, :layout => 'feed' }
59
- format.js { render :action => template_name, :layout => false }
53
+ format.html {
54
+ expires_now
55
+ render :action => template_name
56
+ }
57
+ format.rss {
58
+ expires_now
59
+ render :action => template_name, :layout => 'feed'
60
+ }
61
+ format.js {
62
+ render :action => template_name, :layout => false
63
+ }
60
64
  end
61
65
  end
62
66
 
@@ -67,6 +71,7 @@ protected
67
71
  def render_locked
68
72
  respond_to do |format|
69
73
  format.html {
74
+ expires_now
70
75
  flash[:error] = t('topic_locked')
71
76
  redirect_to_page_or_topic
72
77
  }
@@ -1,11 +1,12 @@
1
1
  class ForumsController < ForumBaseController
2
2
 
3
3
  def index
4
- @forums = Forum.all.paginate(pagination_parameters)
4
+ @forums = Forum.visible_to(current_reader).paginate(pagination_parameters)
5
+ render_page_or_feed
5
6
  end
6
7
 
7
8
  def show
8
- @forum = Forum.find(params[:id])
9
+ @forum = Forum.visible_to(current_reader).find(params[:id])
9
10
  @topics = @forum.topics.stickyfirst.paginate(pagination_parameters)
10
11
  render_page_or_feed
11
12
  end
@@ -8,9 +8,10 @@ class PostsController < ForumBaseController
8
8
 
9
9
  def index
10
10
  @term = params[:q]
11
- posts = @forum ? Post.in_forum(@forum) : Post.scoped
11
+ posts = Post.visible_to(current_reader)
12
12
  posts = posts.containing(@term) unless @term.blank?
13
13
  posts = posts.from_reader(@reader) if @reader
14
+ posts = posts.in_forum(@forum) if @forum
14
15
  posts = posts.in_topic(@topic) if @topic
15
16
  @posts = posts.paginate(pagination_parameters)
16
17
  render_page_or_feed
@@ -29,9 +30,7 @@ class PostsController < ForumBaseController
29
30
  @post.topic = @forum.topics.new
30
31
  end
31
32
  respond_to do |format|
32
- format.html {
33
- expires_now
34
- }
33
+ format.html { expires_now }
35
34
  format.js {
36
35
  if @post.page
37
36
  render :partial => 'pages/add_comment', :layout => false
@@ -82,7 +81,7 @@ class PostsController < ForumBaseController
82
81
 
83
82
  def remove
84
83
  respond_to do |format|
85
- format.html {}
84
+ format.html { expires_now }
86
85
  format.js { render :partial => 'confirm_delete' }
87
86
  end
88
87
  end
@@ -107,7 +106,7 @@ class PostsController < ForumBaseController
107
106
  protected
108
107
 
109
108
  def find_post
110
- @post ||= Post.find(params[:id])
109
+ @post ||= Post.visible_to(current_reader).find(params[:id])
111
110
  end
112
111
 
113
112
  def require_authority
@@ -1,12 +1,13 @@
1
1
  class TopicsController < ForumBaseController
2
2
 
3
3
  def index
4
- @topics = Topic.bydate.paginate(pagination_parameters)
4
+ @topics = Topic.visible_to(current_reader).bydate.paginate(pagination_parameters)
5
5
  render_page_or_feed
6
6
  end
7
7
 
8
8
  def show
9
- @topic = Topic.find(params[:id])
9
+ @topic = Topic.visible_to(current_reader).find(params[:id])
10
+ @forum = @topic.forum
10
11
  @posts = @topic.replies.paginate(pagination_parameters)
11
12
  render_page_or_feed
12
13
  end
data/app/models/forum.rb CHANGED
@@ -2,10 +2,15 @@ class Forum < ActiveRecord::Base
2
2
  has_site if respond_to? :has_site
3
3
  has_many :topics, :dependent => :destroy
4
4
 
5
- default_scope :order => 'position ASC'
5
+ default_scope :order => 'name ASC'
6
6
  named_scope :imported, :conditions => "old_id IS NOT NULL"
7
7
  validates_presence_of :name
8
8
 
9
+ # other extensions can attach chains here to limit access
10
+ def self.visible_to(reader)
11
+ self.scoped
12
+ end
13
+
9
14
  def dom_id
10
15
  "forum_#{self.id}"
11
16
  end
data/app/models/post.rb CHANGED
@@ -14,7 +14,7 @@ class Post < ActiveRecord::Base
14
14
  after_create :notify_holder_of_creation
15
15
  after_destroy :notify_holder_of_destruction
16
16
 
17
- default_scope :order => "created_at DESC"
17
+ default_scope :order => "posts.created_at DESC"
18
18
 
19
19
  named_scope :comments, :conditions => "page_id IS NOT NULL"
20
20
  named_scope :non_comments, :conditions => "page_id IS NULL"
@@ -39,6 +39,11 @@ class Post < ActiveRecord::Base
39
39
  }
40
40
  }
41
41
 
42
+ # other extensions can attach chains here to limit access
43
+ def self.visible_to(reader)
44
+ self.scoped
45
+ end
46
+
42
47
  def self.in_forum(forum)
43
48
  in_topics(forum.topics)
44
49
  end
data/app/models/topic.rb CHANGED
@@ -8,13 +8,18 @@ class Topic < ActiveRecord::Base
8
8
  validates_presence_of :name
9
9
  validates_uniqueness_of :old_id, :allow_nil => true
10
10
 
11
+ named_scope :bydate, :order => 'replied_at DESC'
11
12
  named_scope :imported, :conditions => "old_id IS NOT NULL"
12
13
  named_scope :stickyfirst, :order => "topics.sticky DESC, topics.replied_at DESC"
13
- named_scope :bydate, :order => 'replied_at DESC'
14
14
  named_scope :latest, lambda { |count|
15
15
  { :order => 'replied_at DESC', :limit => count }
16
16
  }
17
17
 
18
+ # other extensions can attach chains here to limit access
19
+ def self.visible_to(reader)
20
+ self.scoped
21
+ end
22
+
18
23
  def dom_id
19
24
  "topic_#{self.id}"
20
25
  end
@@ -30,11 +35,7 @@ class Topic < ActiveRecord::Base
30
35
  def body
31
36
  posts.first.body
32
37
  end
33
-
34
- def created_at
35
- posts.first.created_at if posts.first
36
- end
37
-
38
+
38
39
  def title
39
40
  name
40
41
  end
@@ -5,11 +5,12 @@
5
5
  %h2
6
6
  = link_to forum.name, forum_url(forum), :class => 'main'
7
7
  %p.context
8
- = t("topic_count", :count => forum.topics.count)
9
- - if topic = forum.topics.first
10
- = link_to topic.name, forum_topic_url(forum, topic)
11
- = time_ago_in_words(topic.replied_at || topic.created_at)
12
- = t('ago')
13
- .forum_description
14
- = truncate_and_textilize(forum.description, 40)
8
+ = forum.description
9
+ .forum_contents
10
+ - if forum.topics.any?
11
+ %ul
12
+ - forum.topics.latest(3).each do |topic|
13
+ = render :partial => 'topics/minimal', :locals => {:topic => topic}
14
+
15
+
15
16
 
@@ -0,0 +1,8 @@
1
+ xm.item do
2
+ suffix =
3
+ xm.title h("#{forum.name}")
4
+ xm.description forum.description
5
+ xm.pubDate forum.created_at.to_s(:rfc822)
6
+ xm.guid [ActionController::Base.session_options[:session_key], forum.id.to_s].join(":"), "isPermaLink" => "false"
7
+ xm.link forum_url(forum)
8
+ end
@@ -26,8 +26,9 @@
26
26
  = link_to t('navigation.topics'), topics_url
27
27
  = link_to t('navigation.forums'), forums_url
28
28
  = link_to t('navigation.search'), posts_url
29
- = link_to t('navigation.new_topic'), new_post_url
30
- = link_to t('navigation.loading'), reader_session_url, :class => "remotecontent"
29
+ - if current_reader
30
+ = link_to t('navigation.new_topic'), new_post_url
31
+ = render :partial => 'readers/controls'
31
32
  - if Radiant::Config['forum.help_url']
32
33
  = link_to t('navigation.forum_help'), Radiant::Config['forum.help_url']
33
34
 
@@ -0,0 +1,14 @@
1
+ xml.channel do
2
+ xml.atom :link, nil, {
3
+ :href => forums_url(:format => 'rss'),
4
+ :rel => 'self', :type => 'application/rss+xml'
5
+ }
6
+
7
+ xml.title "#{@site_title} : #{t('forums')}"
8
+ xml.description t('forums')
9
+ xml.link forums_url
10
+ xml.language I18n.locale.to_s
11
+ xml.ttl "60"
12
+
13
+ render :partial => "forums/forum", :collection => @forums, :locals => {:xm => xml}
14
+ end
@@ -2,17 +2,4 @@
2
2
  = t('recent_topics')
3
3
  %ul
4
4
  - Topic.latest(5).each do |topic|
5
- %li.topic
6
- = link_to_post(topic.posts.last, :class => 'title')
7
- %br
8
- %span.context
9
- - if topic.has_replies?
10
- - if topic.replied_by
11
- = t('new_reply_from')
12
- = link_to topic.replied_by.name, reader_url(topic.replied_by)
13
- = friendly_date(topic.replied_at)
14
- - else
15
- = t('started_by')
16
- = link_to topic.reader.name, reader_url(topic.reader)
17
- = friendly_date(topic.created_at)
18
-
5
+ = render :partial => 'topics/minimal', :locals => {:topic => topic}
@@ -0,0 +1,15 @@
1
+ - topic ||= @topic
2
+
3
+ %li.topic
4
+ = link_to_post(topic.posts.last, :class => 'title')
5
+ %br
6
+ %span.context
7
+ - if topic.has_replies?
8
+ - if topic.replied_by
9
+ = t('new_reply_from')
10
+ = link_to topic.replied_by.name, reader_url(topic.replied_by)
11
+ = friendly_date(topic.replied_at)
12
+ - else
13
+ = t('started_by')
14
+ = link_to topic.reader.name, reader_url(topic.reader)
15
+ = friendly_date(topic.created_at)
@@ -92,8 +92,8 @@ en:
92
92
  search: "Search"
93
93
  topics: "Latest"
94
94
  new_forum: "New forum"
95
- new_reply_to: "new reply to"
96
- new_reply_from: "new reply from"
95
+ new_reply_to: "New reply to"
96
+ new_reply_from: "New reply from"
97
97
  new_topic: "Start a new discussion"
98
98
  new_topic_button: "Submit topic"
99
99
  new_topic_heading: "Start a new topic"
@@ -6,8 +6,6 @@ class TopicMerelyAssociative < ActiveRecord::Migration
6
6
  remove_column :topics, :posts_count
7
7
  remove_column :topics, :updated_by_id
8
8
  remove_column :topics, :created_by_id
9
- remove_column :topics, :updated_at
10
- remove_column :topics, :created_at
11
9
  end
12
10
 
13
11
  def self.down
@@ -15,8 +13,6 @@ class TopicMerelyAssociative < ActiveRecord::Migration
15
13
  add_column :topics, :first_post_id, :integer
16
14
  add_column :topics, :last_post_id, :integer
17
15
  add_column :topics, :posts_count, :integer
18
- add_column :topics, :updated_at, :datetime
19
- add_column :topics, :created_at, :datetime
20
16
  add_column :topics, :updated_by_id, :integer
21
17
  add_column :topics, :created_by_id, :integer
22
18
  end
data/forum_extension.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require_dependency 'application_controller'
2
2
 
3
3
  class ForumExtension < Radiant::Extension
4
- version "2.1.4"
4
+ version "2.1.6"
5
5
  description "Nice clean forums and page comments for inclusion in your radiant site. Requires the reader extension and share_layouts."
6
6
  url "http://spanner.org/radiant/forum"
7
7
 
@@ -0,0 +1,5 @@
1
+ td
2
+ padding: 3px
3
+ td.actions
4
+ white-space: nowrap
5
+ min-width: 75px
@@ -3,14 +3,12 @@
3
3
  @import gallery.sass
4
4
 
5
5
  div#forum
6
+ h2
7
+ line-height: 1
8
+ margin: 0
6
9
  div.forum
7
10
  div.forum_wrapper
8
11
  margin: 2em 0
9
- div.forum_header
10
- h2
11
- +strong
12
- line-height: 1
13
- margin: 0
14
12
  div.forum_description
15
13
  p
16
14
  margin: 0
@@ -21,24 +19,17 @@ div#forum
21
19
  &.deleted
22
20
  text-decoration: line-through
23
21
  color: $mid
24
- div.post_wrapper
22
+ div.wrapper
25
23
  margin: 1em 0 2em 0
26
24
  div.post_header
27
- h2
28
- line-height: 1
29
- margin: 0
30
- &.reply
31
- a
32
- color: $mid
33
- &:hover
34
- color: $accent
25
+ h2.reply
26
+ a
27
+ color: $mid
28
+ &:hover
29
+ color: $accent
35
30
  a
36
31
  &:hover
37
32
  color: $accent
38
- &.waiting
39
- color: $mid
40
- padding-left: 18px
41
- background: transparent url(/images/furniture/wait_16_grey.gif) no-repeat left top
42
33
  &.edit_post, &.delete_post
43
34
  color: white
44
35
  padding: 1px 3px
@@ -75,12 +66,12 @@ div#forum
75
66
  a
76
67
  color: $pale
77
68
  &.first
78
- div.post_wrapper
69
+ div.wrapper
79
70
  margin-top: 0
80
71
  padding-bottom: 1em
81
72
  border-bottom: 3px dotted $mid
82
73
 
83
- div.post_form
74
+ div.remote_form
84
75
  margin: 0
85
76
  p
86
77
  margin: 0
@@ -104,8 +95,6 @@ div#forum
104
95
  div#search
105
96
  overflow: hidden
106
97
  margin: 0 0 2em 0
107
- h2
108
- margin: 0
109
98
  p
110
99
  width: 24%
111
100
  margin-right: 1%
@@ -192,7 +181,7 @@ a.rssfeed
192
181
  +functional
193
182
  color: $pale
194
183
 
195
- p.waiting, span.waiting
184
+ p.waiting, span.waiting, a.waiting
196
185
  color: $mid
197
186
  padding-left: 18px
198
187
  background: transparent url(/images/furniture/wait_16_grey.gif) no-repeat left top
@@ -207,6 +196,9 @@ div.speaker
207
196
  width: 50px
208
197
  height: 50px
209
198
  margin-right: 8px
199
+
200
+ p.add_comment, p.add_reply
201
+ font-size: 200%
210
202
 
211
203
  // emoticons in message display are interpolated by our redcloth extension as <img class="emoticon something" />
212
204
 
@@ -243,3 +235,5 @@ img.emoticon
243
235
  &.cool
244
236
  background-position: -176px 0
245
237
 
238
+ .punymce_emoticons
239
+ z-index: 2000
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{radiant-forum-extension}
8
- s.version = "2.1.4"
8
+ s.version = "2.1.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["spanner"]
12
- s.date = %q{2011-02-15}
12
+ s.date = %q{2011-02-16}
13
13
  s.description = %q{Nice clean forums and page comments for inclusion in your radiant site. Derived long ago from beast. Requires the reader extension and share_layouts.}
14
14
  s.email = %q{will@spanner.org}
15
15
  s.extra_rdoc_files = [
@@ -50,10 +50,12 @@ Gem::Specification.new do |s|
50
50
  "app/views/admin/topics/edit.html.haml",
51
51
  "app/views/admin/topics/index.html.haml",
52
52
  "app/views/forums/_forum.html.haml",
53
+ "app/views/forums/_forum.rss.builder",
53
54
  "app/views/forums/_latest.html.haml",
54
55
  "app/views/forums/_standard_parts.html.haml",
55
56
  "app/views/forums/_statistics.html.haml",
56
57
  "app/views/forums/index.html.haml",
58
+ "app/views/forums/index.rss.builder",
57
59
  "app/views/forums/show.html.haml",
58
60
  "app/views/forums/show.rss.builder",
59
61
  "app/views/layouts/feed.rss.builder",
@@ -84,6 +86,7 @@ Gem::Specification.new do |s|
84
86
  "app/views/topics/_context.html.haml",
85
87
  "app/views/topics/_latest.html.haml",
86
88
  "app/views/topics/_locked.html.haml",
89
+ "app/views/topics/_minimal.html.haml",
87
90
  "app/views/topics/_replies.html.haml",
88
91
  "app/views/topics/_reply.html.haml",
89
92
  "app/views/topics/_topic.html.haml",
@@ -206,6 +209,7 @@ Gem::Specification.new do |s|
206
209
  "public/punymce/puny_mce.js",
207
210
  "public/punymce/puny_mce_full.js",
208
211
  "public/punymce/puny_mce_src.js",
212
+ "public/stylesheets/sass/admin/forum.sass",
209
213
  "public/stylesheets/sass/forum.sass",
210
214
  "public/stylesheets/sass/gallery.sass",
211
215
  "radiant-forum-extension.gemspec",
@@ -6,17 +6,13 @@ describe PostsController do
6
6
  before do
7
7
  Page.current_site = sites(:test) if defined? Site
8
8
  controller.stub!(:request).and_return(request)
9
- @forum = forums(:public)
10
- @topic = topics(:older)
11
- @post = posts(:first)
12
- @comment = posts(:comment)
13
9
  end
14
10
 
15
11
  describe "on get to index" do
16
12
  before do
17
13
  get :index
18
14
  end
19
-
15
+
20
16
  it "should render the index page" do
21
17
  response.should be_success
22
18
  response.should render_template("index")
@@ -24,17 +20,14 @@ describe PostsController do
24
20
  end
25
21
 
26
22
  describe "on get to show" do
27
-
28
23
  describe "for a page comment" do
29
24
  before do
30
25
  Radiant::Config['forum.public?'] = true
31
- @comment = posts(:comment)
32
- @page = pages(:commentable)
33
- get :show, :id => post_id(:comment)
34
26
  end
35
27
  it "should redirect to the page address and post anchor" do
28
+ get :show, :id => post_id(:comment)
36
29
  response.should be_redirect
37
- response.should redirect_to(@page.url + "?page=1##{@comment.dom_id}")
30
+ response.should redirect_to(pages(:commentable).url + "?page=1##{posts(:comment).dom_id}")
38
31
  end
39
32
  end
40
33
 
@@ -45,7 +38,8 @@ describe PostsController do
45
38
  end
46
39
  it "should redirect to the topic" do
47
40
  response.should be_redirect
48
- response.should redirect_to(forum_topic_url(@topic.forum, @topic))
41
+ topic = topics(:older)
42
+ response.should redirect_to(forum_topic_url(topic.forum, topic))
49
43
  end
50
44
  end
51
45
 
@@ -56,11 +50,10 @@ describe PostsController do
56
50
  end
57
51
  it "should redirect to the topic with the page and anchor of the post" do
58
52
  response.should be_redirect
59
- response.should redirect_to(forum_topic_url(@topic.forum, @topic, {:page => posts(:second).page_when_paginated, :anchor => "post_#{posts(:second).id}"}))
53
+ topic = topics(:older)
54
+ response.should redirect_to(forum_topic_url(topic.forum, topic, {:page => posts(:second).page_when_paginated, :anchor => "post_#{posts(:second).id}"}))
60
55
  end
61
56
  end
62
-
63
-
64
57
  end
65
58
 
66
59
  describe "on get to new" do
@@ -104,14 +97,13 @@ describe PostsController do
104
97
 
105
98
  describe "but to a locked topic" do
106
99
  before do
107
- @topic.locked = true
108
- @topic.save!
109
- get :new, :topic_id => @topic.id, :forum_id => forum_id(:public)
100
+ get :new, :topic_id => topic_id(:locked), :forum_id => forum_id(:public)
110
101
  end
111
102
 
112
103
  it "should redirect to the topic page" do
113
104
  response.should be_redirect
114
- response.should redirect_to(forum_topic_url(@topic.forum, @topic))
105
+ topic = topics(:locked)
106
+ response.should redirect_to(forum_topic_url(topic.forum, topic))
115
107
  end
116
108
 
117
109
  it "should flash an appropriate message" do
@@ -122,7 +114,7 @@ describe PostsController do
122
114
 
123
115
  describe "over normal http" do
124
116
  before do
125
- get :new, :topic_id => @topic.id, :forum_id => forum_id(:public)
117
+ get :new, :topic_id => topic_id(:older), :forum_id => forum_id(:public)
126
118
  end
127
119
 
128
120
  it "should render the new post form in the normal way" do
@@ -134,7 +126,7 @@ describe PostsController do
134
126
 
135
127
  describe "over xmlhttp" do
136
128
  before do
137
- xhr :get, :new, :topic_id => @topic.id, :forum_id => forum_id(:public)
129
+ xhr :get, :new, :topic_id => topic_id(:older), :forum_id => forum_id(:public)
138
130
  end
139
131
 
140
132
  it "should render a bare reply form" do
@@ -150,7 +142,7 @@ describe PostsController do
150
142
  describe "without a logged-in reader" do
151
143
  before do
152
144
  logout_reader
153
- post :create, :post => {:body => 'otherwise complete'}, :topic_id => @topic.id, :forum_id => forum_id(:public)
145
+ post :create, :post => {:body => 'otherwise complete'}, :topic_id => topic_id(:older), :forum_id => forum_id(:public)
154
146
  end
155
147
 
156
148
  it "should redirect to login" do
@@ -165,18 +157,14 @@ describe PostsController do
165
157
  end
166
158
 
167
159
  describe "but to a locked topic" do
168
- before do
169
- @topic.locked = true
170
- @topic.save!
171
- end
172
-
173
160
  describe "over normal http" do
174
161
  before do
175
- post :create, :post => {:body => ''}, :topic_id => @topic.id, :forum_id => forum_id(:public)
162
+ post :create, :post => {:body => ''}, :topic_id => topic_id(:locked)
176
163
  end
177
164
  it "should redirect to the topic page" do
178
165
  response.should be_redirect
179
- response.should redirect_to(forum_topic_url(@topic.forum, @topic))
166
+ topic = topics(:locked)
167
+ response.should redirect_to(forum_topic_url(topic.forum, topic))
180
168
  end
181
169
 
182
170
  it "should flash an appropriate error" do
@@ -186,7 +174,7 @@ describe PostsController do
186
174
  end
187
175
  describe "over xmlhttp" do
188
176
  before do
189
- xhr :post, :create, :post => {:body => 'otherwise complete'}, :topic_id => @topic.id, :forum_id => forum_id(:public)
177
+ xhr :post, :create, :post => {:body => 'otherwise complete'}, :topic_id => topic_id(:locked), :forum_id => forum_id(:public)
190
178
  end
191
179
 
192
180
  it "should render a bare 'locked' template" do
@@ -200,7 +188,7 @@ describe PostsController do
200
188
  describe "with an invalid message" do
201
189
  describe "over normal http" do
202
190
  before do
203
- post :create, :post => {:body => ''}, :topic_id => @topic.id, :forum_id => forum_id(:public)
191
+ post :create, :post => {:body => ''}, :topic_id => topic_id(:older), :forum_id => forum_id(:public)
204
192
  end
205
193
 
206
194
  it "should re-render the post form with layout" do
@@ -216,7 +204,7 @@ describe PostsController do
216
204
 
217
205
  describe "over xmlhttp" do
218
206
  before do
219
- xhr :post, :create, :post => {:body => ''}, :topic_id => @topic.id, :forum_id => forum_id(:public)
207
+ xhr :post, :create, :post => {:body => ''}, :topic_id => topic_id(:older), :forum_id => forum_id(:public)
220
208
  end
221
209
 
222
210
  it "should re-render the bare post form" do
@@ -238,7 +226,7 @@ describe PostsController do
238
226
  before do
239
227
  alphabet = ("a".."z").to_a
240
228
  @body = Array.new(64, '').collect{alphabet[rand(alphabet.size)]}.join
241
- post :create, :post => {:body => @body}, :topic_id => @topic.id, :forum_id => forum_id(:public)
229
+ post :create, :post => {:body => @body}, :topic_id => topic_id(:older), :forum_id => forum_id(:public)
242
230
  @post = Post.find_by_body(@body)
243
231
  end
244
232
 
@@ -247,18 +235,19 @@ describe PostsController do
247
235
  end
248
236
 
249
237
  it "should associate the post with its topic" do
250
- @post.topic.should == @topic
238
+ @post.topic.should == topics(:older)
251
239
  end
252
240
 
253
241
  it "should redirect to the right topic and page" do
254
242
  response.should be_redirect
255
- response.should redirect_to(forum_topic_url(@forum, @topic, {:page => @post.page_when_paginated, :anchor => "post_#{@post.id}"}))
243
+ topic = topics(:older)
244
+ response.should redirect_to(forum_topic_url(topic.forum, topic, {:page => @post.page_when_paginated, :anchor => "post_#{@post.id}"}))
256
245
  end
257
246
  end
258
247
 
259
248
  describe "over xmlhttp" do
260
249
  before do
261
- xhr :post, :create, :post => {:body => 'test post body'}, :topic_id => @topic.id, :forum_id => forum_id(:public)
250
+ xhr :post, :create, :post => {:body => 'test post body'}, :topic_id => topics(:older), :forum_id => forum_id(:public)
262
251
  end
263
252
 
264
253
  it "should return the formatted message for inclusion in the page" do
@@ -290,7 +279,6 @@ describe PostsController do
290
279
  it "should clear the cache" do
291
280
  Radiant::Cache.should_receive(:clear)
292
281
  post :create, :post => {:body => 'marmalade'}, :page_id => page_id(:commentable)
293
- Post.find_by_body('marmalade').should_not be_nil
294
282
  end
295
283
  end
296
284
 
@@ -7,25 +7,40 @@ describe 'Forum-extended page' do
7
7
  login_as_reader(:normal)
8
8
  end
9
9
 
10
- it "should normally be commentable" do
11
- pages(:uncommented).locked?.should be_false
12
- end
10
+ describe "when pages are commentable" do
11
+ before do
12
+ Radiant::Config['forum.allow_page_comments?'] = true
13
+ end
14
+
15
+ it "should normally be commentable" do
16
+ pages(:uncommented).locked?.should be_false
17
+ end
13
18
 
14
- it "should be locked if marked not commentable" do
15
- pages(:uncommentable).locked?.should be_true
16
- end
19
+ it "should be locked if marked not commentable" do
20
+ pages(:uncommentable).locked?.should be_true
21
+ end
17
22
 
18
- it "should be locked if marked comments_closed" do
19
- pages(:comments_closed).locked?.should be_true
20
- end
23
+ it "should be locked if marked comments_closed" do
24
+ pages(:comments_closed).locked?.should be_true
25
+ end
21
26
 
22
- it "should be locked if there is a commentable period and it has expired" do
23
- Radiant::Config['forum.commentable_period'] = 28
24
- page = pages(:commentable)
25
- page.commentable_period.should == 28.days
26
- page.locked?.should be_false
27
- page.created_at = Time.now - 30.days
28
- page.locked?.should be_true
27
+ it "should be locked if there is a commentable period and it has expired" do
28
+ Radiant::Config['forum.commentable_period'] = 28
29
+ page = pages(:commentable)
30
+ page.send(:commentable_period).should == 28.days
31
+ page.locked?.should be_false
32
+ page.created_at = Time.now - 30.days
33
+ page.locked?.should be_true
34
+ end
29
35
  end
36
+
37
+ describe "when pages are not commentable" do
38
+ before do
39
+ Radiant::Config['forum.allow_page_comments?'] = false
40
+ end
30
41
 
42
+ it "should not be commentable" do
43
+ pages(:uncommented).locked?.should be_true
44
+ end
45
+ end
31
46
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radiant-forum-extension
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 7
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
8
  - 1
9
- - 4
10
- version: 2.1.4
9
+ - 6
10
+ version: 2.1.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - spanner
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-15 00:00:00 +00:00
18
+ date: 2011-02-16 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -93,10 +93,12 @@ files:
93
93
  - app/views/admin/topics/edit.html.haml
94
94
  - app/views/admin/topics/index.html.haml
95
95
  - app/views/forums/_forum.html.haml
96
+ - app/views/forums/_forum.rss.builder
96
97
  - app/views/forums/_latest.html.haml
97
98
  - app/views/forums/_standard_parts.html.haml
98
99
  - app/views/forums/_statistics.html.haml
99
100
  - app/views/forums/index.html.haml
101
+ - app/views/forums/index.rss.builder
100
102
  - app/views/forums/show.html.haml
101
103
  - app/views/forums/show.rss.builder
102
104
  - app/views/layouts/feed.rss.builder
@@ -127,6 +129,7 @@ files:
127
129
  - app/views/topics/_context.html.haml
128
130
  - app/views/topics/_latest.html.haml
129
131
  - app/views/topics/_locked.html.haml
132
+ - app/views/topics/_minimal.html.haml
130
133
  - app/views/topics/_replies.html.haml
131
134
  - app/views/topics/_reply.html.haml
132
135
  - app/views/topics/_topic.html.haml
@@ -249,6 +252,7 @@ files:
249
252
  - public/punymce/puny_mce.js
250
253
  - public/punymce/puny_mce_full.js
251
254
  - public/punymce/puny_mce_src.js
255
+ - public/stylesheets/sass/admin/forum.sass
252
256
  - public/stylesheets/sass/forum.sass
253
257
  - public/stylesheets/sass/gallery.sass
254
258
  - radiant-forum-extension.gemspec