commontator 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@ module Commontator
2
2
  class CommentsController < ApplicationController
3
3
  before_filter :get_thread, :only => [:new, :create]
4
4
  before_filter :get_comment_and_thread, :except => [:new, :create]
5
- before_filter :set_commontable_url, :only => :show
5
+ before_filter :set_commontable_url, :only => :create
6
6
 
7
7
  # GET /1/comments/new
8
8
  def new
@@ -21,11 +21,10 @@ module Commontator
21
21
 
22
22
  # POST /1/comments
23
23
  def create
24
- set_commontable_url
25
24
  @comment = Comment.new(params[:comment])
26
25
  @comment.thread = @thread
27
26
  @comment.creator = @user
28
-
27
+ CommentObserver.instance
29
28
  raise SecurityTransgression unless @comment.can_be_created_by?(@user)
30
29
 
31
30
  respond_to do |format|
@@ -86,4 +86,6 @@ module Commontator
86
86
  thread.can_be_read_by?(user) && user != creator
87
87
  end
88
88
  end
89
+
90
+ CommentObserver.instance
89
91
  end
@@ -78,7 +78,7 @@ module Commontator
78
78
  end
79
79
 
80
80
  def can_be_voted_on?
81
- is_votable? && !is_deleted? && thread.config.comments_can_be_voted_on
81
+ is_votable? && !is_deleted? && thread.config.can_vote_on_comments
82
82
  end
83
83
 
84
84
  def can_be_voted_on_by?(user)
@@ -11,9 +11,10 @@ Commontator.configure do |config|
11
11
  # Proc that is called after any javascript runs (e.g. to display/clear flash messages)
12
12
  # It is passed the view_context object (self from the view template), so you should be able to
13
13
  # access anything you normally could in a view template (by using, e.g. view.flash)
14
+ # However, be aware that it does not have access to the main application's helpers
14
15
  # Should return a string containing JS to be appended to all Commontator JS responses
15
- # Default: lambda { |view| '$("#error_explanation").hide();' }
16
- config.javascript_proc = lambda { |view| '$("#error_explanation").hide();' }
16
+ # Default: lambda { |view| '$("#error_explanation").remove();' }
17
+ config.javascript_proc = lambda { |view| '$("#error_explanation").remove();' }
17
18
 
18
19
 
19
20
  # User (acts_as_commontator) Configuration
@@ -11,6 +11,7 @@ Commontator.configure do |config|
11
11
  # Proc that is called after any javascript runs (e.g. to display/clear flash messages)
12
12
  # It is passed the view_context object (self from the view template), so you should be able to
13
13
  # access anything you normally could in a view template (by using, e.g. view.flash)
14
+ # However, be aware that it does not have access to the main application's helpers
14
15
  # Should return a string containing JS to be appended to all Commontator JS responses
15
16
  # Default: lambda { |view| '$("#error_explanation").remove();' }
16
17
  config.javascript_proc = lambda { |view| '$("#error_explanation").hide();' }
@@ -1,6 +1,7 @@
1
1
  module Commontator
2
2
  class Engine < ::Rails::Engine
3
3
  isolate_namespace Commontator
4
- pp main_app
4
+
5
+ config.active_record.observers = :comment_observer
5
6
  end
6
7
  end
@@ -1,3 +1,3 @@
1
1
  module Commontator
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
@@ -1,3 +1,3 @@
1
1
  module Commontator
2
- VERSION = "1.0.6"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -4,7 +4,7 @@ module Commontator
4
4
  describe CommentObserver do
5
5
  before do
6
6
  setup_model_spec
7
- @comment_observer = CommentObserver.send :new
7
+ @comment_observer = CommentObserver.instance
8
8
  @thread.subscribe(@user)
9
9
  @comment = Comment.new
10
10
  @comment.thread = @thread
@@ -20,7 +20,7 @@ module Commontator
20
20
  it 'must send mail if recipients not empty' do
21
21
  @user2 = DummyUser.create
22
22
  @thread.subscribe(@user2)
23
- pp @thread.active_subscribers
23
+ @comment.reload
24
24
  @comment_observer.after_create(@comment).must_be_instance_of Mail::Message
25
25
  end
26
26
  end
@@ -11,9 +11,10 @@ Commontator.configure do |config|
11
11
  # Proc that is called after any javascript runs (e.g. to display/clear flash messages)
12
12
  # It is passed the view_context object (self from the view template), so you should be able to
13
13
  # access anything you normally could in a view template (by using, e.g. view.flash)
14
+ # However, be aware that it does not have access to the main application's helpers
14
15
  # Should return a string containing JS to be appended to all Commontator JS responses
15
- # Default: lambda { |view| '$("#error_explanation").hide();' }
16
- config.javascript_proc = lambda { |view| '' }
16
+ # Default: lambda { |view| '$("#error_explanation").remove();' }
17
+ config.javascript_proc = lambda { |view| '$("#error_explanation").remove();' }
17
18
 
18
19
 
19
20
  # User (acts_as_commontator) Configuration
@@ -11,9 +11,10 @@ Commontator.configure do |config|
11
11
  # Proc that is called after any javascript runs (e.g. to display/clear flash messages)
12
12
  # It is passed the view_context object (self from the view template), so you should be able to
13
13
  # access anything you normally could in a view template (by using, e.g. view.flash)
14
+ # However, be aware that it does not have access to the main application's helpers
14
15
  # Should return a string containing JS to be appended to all Commontator JS responses
15
- # Default: lambda { |view| '$("#error_explanation").hide();' }
16
- config.javascript_proc = lambda { |view| 'Dummy Javascript' }
16
+ # Default: lambda { |view| '$("#error_explanation").remove();' }
17
+ config.javascript_proc = lambda { |view| '' }
17
18
 
18
19
 
19
20
  # User (acts_as_commontator) Configuration
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: commontator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: