commontator 4.11.1 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -5
  3. data/app/controllers/commontator/application_controller.rb +4 -4
  4. data/app/controllers/commontator/comments_controller.rb +15 -15
  5. data/app/controllers/commontator/subscriptions_controller.rb +1 -1
  6. data/app/controllers/commontator/threads_controller.rb +5 -5
  7. data/app/mailers/commontator/subscriptions_mailer.rb +25 -37
  8. data/app/models/commontator/comment.rb +11 -11
  9. data/app/models/commontator/subscription.rb +2 -2
  10. data/app/models/commontator/thread.rb +9 -9
  11. data/app/views/commontator/comments/_actions.html.erb +8 -8
  12. data/app/views/commontator/comments/_body.html.erb +1 -1
  13. data/app/views/commontator/comments/_form.html.erb +3 -3
  14. data/app/views/commontator/comments/_list.html.erb +3 -3
  15. data/app/views/commontator/comments/_show.html.erb +8 -8
  16. data/app/views/commontator/comments/_votes.html.erb +16 -16
  17. data/app/views/commontator/comments/cancel.js.erb +5 -5
  18. data/app/views/commontator/comments/create.js.erb +9 -9
  19. data/app/views/commontator/comments/delete.js.erb +7 -7
  20. data/app/views/commontator/comments/edit.js.erb +2 -2
  21. data/app/views/commontator/comments/new.js.erb +4 -4
  22. data/app/views/commontator/comments/update.js.erb +1 -1
  23. data/app/views/commontator/comments/vote.js.erb +3 -3
  24. data/app/views/commontator/shared/_thread.html.erb +6 -6
  25. data/app/views/commontator/subscriptions/_link.html.erb +5 -5
  26. data/app/views/commontator/subscriptions/subscribe.js.erb +3 -3
  27. data/app/views/commontator/subscriptions_mailer/comment_created.html.erb +6 -6
  28. data/app/views/commontator/threads/_reply.html.erb +6 -6
  29. data/app/views/commontator/threads/_show.html.erb +33 -33
  30. data/app/views/commontator/threads/_show.js.erb +7 -7
  31. data/app/views/commontator/threads/show.js.erb +6 -6
  32. data/config/initializers/commontator.rb +43 -38
  33. data/config/locales/de.yml +100 -0
  34. data/config/locales/en.yml +26 -27
  35. data/config/locales/pt-BR.yml +78 -0
  36. data/config/locales/ru.yml +25 -26
  37. data/config/locales/zh.yml +26 -27
  38. data/config/routes.rb +4 -4
  39. data/db/migrate/0_install_commontator.rb +17 -17
  40. data/lib/commontator.rb +2 -2
  41. data/lib/commontator/acts_as_commontable.rb +14 -12
  42. data/lib/commontator/acts_as_commontator.rb +5 -5
  43. data/lib/commontator/shared_helper.rb +6 -6
  44. data/lib/commontator/version.rb +1 -1
  45. data/lib/tasks/commontator_tasks.rake +2 -2
  46. data/spec/controllers/commontator/comments_controller_spec.rb +76 -75
  47. data/spec/controllers/commontator/subscriptions_controller_spec.rb +26 -27
  48. data/spec/controllers/commontator/threads_controller_spec.rb +42 -41
  49. data/spec/dummy/app/controllers/dummy_models_controller.rb +1 -1
  50. data/spec/dummy/app/views/layouts/application.html.erb +1 -2
  51. data/spec/dummy/config/application.rb +1 -1
  52. data/spec/dummy/config/environments/development.rb +1 -2
  53. data/spec/dummy/config/environments/production.rb +1 -2
  54. data/spec/dummy/config/environments/test.rb +1 -2
  55. data/spec/dummy/config/initializers/commontator.rb +7 -7
  56. data/spec/dummy/config/routes.rb +2 -3
  57. data/spec/dummy/db/development.sqlite3 +0 -0
  58. data/spec/dummy/db/migrate/1_create_dummy_models.rb +2 -3
  59. data/spec/dummy/db/migrate/2_create_dummy_users.rb +2 -3
  60. data/spec/dummy/db/migrate/3_acts_as_votable_migration.rb +4 -10
  61. data/spec/dummy/db/schema.rb +45 -48
  62. data/spec/dummy/db/test.sqlite3 +0 -0
  63. data/spec/dummy/log/development.log +413 -0
  64. data/spec/dummy/log/test.log +33690 -0
  65. data/spec/lib/commontator/commontable_config_spec.rb +4 -5
  66. data/spec/lib/commontator/commontator_config_spec.rb +4 -5
  67. data/spec/lib/commontator_spec.rb +2 -3
  68. data/spec/mailers/commontator/subscriptions_mailer_spec.rb +2 -3
  69. data/spec/models/commontator/comment_spec.rb +10 -10
  70. data/spec/rails_helper.rb +3 -2
  71. metadata +64 -44
@@ -7,96 +7,95 @@ module Commontator
7
7
  before(:each) do
8
8
  setup_controller_spec
9
9
  end
10
-
10
+
11
11
  it "won't subscribe unless authorized" do
12
- put :subscribe, :id => @thread.id
12
+ put :subscribe, params: { id: @thread.id }
13
13
  expect(response).to have_http_status(:forbidden)
14
14
  expect(@thread.subscription_for(nil)).to be_nil
15
15
  expect(@thread.subscription_for(@user)).to be_nil
16
-
16
+
17
17
  sign_in @user
18
- put :subscribe, :id => @thread.id
18
+ put :subscribe, params: { id: @thread.id }
19
19
  expect(response).to have_http_status(:forbidden)
20
20
  expect(@thread.subscription_for(@user)).to be_nil
21
-
21
+
22
22
  @thread.subscribe(@user)
23
23
  @user.can_read = true
24
- put :subscribe, :id => @thread.id
24
+ put :subscribe, params: { id: @thread.id }
25
25
  expect(response).to redirect_to(@thread)
26
26
  expect(assigns(:thread).errors).not_to be_empty
27
27
  end
28
-
28
+
29
29
  it 'must subscribe if authorized' do
30
30
  sign_in @user
31
-
31
+
32
32
  @user.can_read = true
33
- put :subscribe, :id => @thread.id
33
+ put :subscribe, params: { id: @thread.id }
34
34
  expect(response).to redirect_to(@thread)
35
35
  expect(assigns(:thread).errors).to be_empty
36
36
  expect(@thread.subscription_for(@user)).not_to be_nil
37
-
37
+
38
38
  @thread.unsubscribe(@user)
39
39
  @user.can_read = false
40
40
  @user.can_edit = true
41
- put :subscribe, :id => @thread.id
41
+ put :subscribe, params: { id: @thread.id }
42
42
  expect(response).to redirect_to(@thread)
43
43
  expect(assigns(:thread).errors).to be_empty
44
44
  expect(@thread.subscription_for(@user)).not_to be_nil
45
-
45
+
46
46
  @thread.unsubscribe(@user)
47
47
  @user.can_edit = false
48
48
  @user.is_admin = true
49
- put :subscribe, :id => @thread.id
49
+ put :subscribe, params: { id: @thread.id }
50
50
  expect(response).to redirect_to(@thread)
51
51
  expect(assigns(:thread).errors).to be_empty
52
52
  expect(@thread.subscription_for(@user)).not_to be_nil
53
53
  end
54
-
54
+
55
55
  it "won't unsubscribe unless authorized" do
56
56
  @thread.subscribe(@user)
57
- put :unsubscribe, :id => @thread.id
57
+ put :unsubscribe, params: { id: @thread.id }
58
58
  expect(response).to have_http_status(:forbidden)
59
59
  expect(@thread.subscription_for(nil)).to be_nil
60
60
  expect(@thread.subscription_for(@user)).not_to be_nil
61
-
61
+
62
62
  sign_in @user
63
- put :unsubscribe, :id => @thread.id
63
+ put :unsubscribe, params: { id: @thread.id }
64
64
  expect(response).to have_http_status(:forbidden)
65
65
  expect(@thread.subscription_for(@user)).not_to be_nil
66
-
66
+
67
67
  @thread.unsubscribe(@user)
68
68
  @user.can_read = true
69
- put :unsubscribe, :id => @thread.id
69
+ put :unsubscribe, params: { id: @thread.id }
70
70
  expect(response).to redirect_to(@thread)
71
71
  expect(assigns(:thread).errors).not_to be_empty
72
72
  end
73
-
73
+
74
74
  it 'must unsubscribe if authorized' do
75
75
  sign_in @user
76
-
76
+
77
77
  @thread.subscribe(@user)
78
78
  @user.can_read = true
79
- put :unsubscribe, :id => @thread.id
79
+ put :unsubscribe, params: { id: @thread.id }
80
80
  expect(response).to redirect_to(@thread)
81
81
  expect(assigns(:thread).errors).to be_empty
82
82
  expect(@thread.subscription_for(@user)).to be_nil
83
-
83
+
84
84
  @thread.subscribe(@user)
85
85
  @user.can_read = false
86
86
  @user.can_edit = true
87
- put :unsubscribe, :id => @thread.id
87
+ put :unsubscribe, params: { id: @thread.id }
88
88
  expect(response).to redirect_to(@thread)
89
89
  expect(assigns(:thread).errors).to be_empty
90
90
  expect(@thread.subscription_for(@user)).to be_nil
91
-
91
+
92
92
  @thread.subscribe(@user)
93
93
  @user.can_edit = false
94
94
  @user.is_admin = true
95
- put :unsubscribe, :id => @thread.id
95
+ put :unsubscribe, params: { id: @thread.id }
96
96
  expect(response).to redirect_to(@thread)
97
97
  expect(assigns(:thread).errors).to be_empty
98
98
  expect(@thread.subscription_for(@user)).to be_nil
99
99
  end
100
100
  end
101
101
  end
102
-
@@ -7,128 +7,130 @@ module Commontator
7
7
  before(:each) do
8
8
  setup_controller_spec
9
9
  end
10
-
10
+
11
11
  it "won't show unless authorized" do
12
- get :show, :id => @thread.id
12
+ get :show, params: { id: @thread.id }
13
13
  expect(response).to have_http_status(:forbidden)
14
-
14
+
15
15
  sign_in @user
16
- get :show, :id => @thread.id
16
+ get :show, params: { id: @thread.id }
17
17
  expect(response).to have_http_status(:forbidden)
18
18
  end
19
-
19
+
20
20
  it 'must show if authorized' do
21
21
  commontable_path = Rails.application.routes.url_helpers.dummy_model_path(@commontable)
22
22
  sign_in @user
23
-
23
+
24
24
  @user.can_read = true
25
- get :show, :id => @thread.id
25
+ get :show, params: { id: @thread.id }
26
26
  expect(response).to redirect_to(commontable_path)
27
-
27
+
28
28
  @user.can_read = false
29
29
  @user.can_edit = true
30
- get :show, :id => @thread.id
30
+ get :show, params: { id: @thread.id }
31
31
  expect(response).to redirect_to(commontable_path)
32
-
32
+
33
33
  @user.can_edit = false
34
34
  @user.is_admin = true
35
- get :show, :id => @thread.id
35
+ get :show, params: { id: @thread.id }
36
36
  expect(response).to redirect_to(commontable_path)
37
37
  end
38
-
38
+
39
39
  it "won't close unless authorized and open" do
40
- put :close, :id => @thread.id
40
+ put :close, params: { id: @thread.id }
41
41
  expect(response).to have_http_status(:forbidden)
42
42
  @thread.reload
43
43
  expect(@thread.is_closed?).to eq false
44
-
44
+
45
45
  sign_in @user
46
- put :close, :id => @thread.id
46
+ put :close, params: { id: @thread.id }
47
47
  expect(response).to have_http_status(:forbidden)
48
48
  @thread.reload
49
49
  expect(@thread.is_closed?).to eq false
50
-
50
+
51
51
  @user.can_read = true
52
- put :close, :id => @thread.id
52
+ put :close, params: { id: @thread.id }
53
53
  expect(response).to have_http_status(:forbidden)
54
54
  @thread.reload
55
55
  expect(@thread.is_closed?).to eq false
56
-
56
+
57
57
  @user.can_edit = true
58
58
  expect(@thread.close).to eq true
59
- put :close, :id => @thread.id
59
+ put :close, params: { id: @thread.id }
60
60
  expect(response).to redirect_to(@thread)
61
61
  expect(assigns(:thread).errors).not_to be_empty
62
62
  end
63
-
63
+
64
64
  it 'must close if authorized and open' do
65
65
  sign_in @user
66
-
66
+
67
67
  @user.can_edit = true
68
- put :close, :id => @thread.id
68
+ put :close, params: { id: @thread.id }
69
69
  expect(response).to redirect_to(@thread)
70
70
  expect(assigns(:thread).errors).to be_empty
71
71
  expect(assigns(:thread).is_closed?).to eq true
72
72
  expect(assigns(:thread).closer).to eq @user
73
-
73
+
74
74
  expect(assigns(:thread).reopen).to eq true
75
75
  @user.can_edit = false
76
76
  @user.is_admin = true
77
- put :close, :id => @thread.id
77
+ put :close, params: { id: @thread.id }
78
78
  expect(response).to redirect_to(@thread)
79
79
  expect(assigns(:thread).errors).to be_empty
80
80
  expect(assigns(:thread).is_closed?).to eq true
81
81
  expect(assigns(:thread).closer).to eq @user
82
82
  end
83
-
83
+
84
84
  it "won't reopen unless authorized and closed" do
85
85
  expect(@thread.close).to eq true
86
- put :reopen, :id => @thread.id
86
+ put :reopen, params: { id: @thread.id }
87
87
  expect(response).to have_http_status(:forbidden)
88
88
  @thread.reload
89
89
  expect(@thread.is_closed?).to eq true
90
-
90
+
91
91
  sign_in @user
92
- put :reopen, :id => @thread.id
92
+ put :reopen, params: { id: @thread.id }
93
93
  expect(response).to have_http_status(:forbidden)
94
94
  @thread.reload
95
95
  expect(@thread.is_closed?).to eq true
96
-
96
+
97
97
  @user.can_read = true
98
- put :reopen, :id => @thread.id
98
+ put :reopen, params: { id: @thread.id }
99
99
  expect(response).to have_http_status(:forbidden)
100
100
  @thread.reload
101
101
  expect(@thread.is_closed?).to eq true
102
-
102
+
103
103
  expect(@thread.reopen).to eq true
104
104
  @user.can_edit = true
105
- put :reopen, :id => @thread.id
105
+ put :reopen, params: { id: @thread.id }
106
106
  expect(response).to redirect_to(@thread)
107
107
  expect(assigns(:thread).errors).not_to be_empty
108
108
  end
109
-
109
+
110
110
  it 'must reopen if authorized and closed' do
111
111
  sign_in @user
112
-
112
+
113
113
  expect(@thread.close).to eq true
114
114
  @user.can_edit = true
115
- put :reopen, :id => @thread.id
115
+ put :reopen, params: { id: @thread.id }
116
116
  expect(response).to redirect_to(@thread)
117
117
  expect(assigns(:thread).errors).to be_empty
118
118
  expect(assigns(:thread).is_closed?).to eq false
119
-
119
+
120
120
  expect(assigns(:thread).close).to eq true
121
121
  @user.can_edit = false
122
122
  @user.is_admin = true
123
- put :reopen, :id => @thread.id
123
+ put :reopen, params: { id: @thread.id }
124
124
  expect(response).to redirect_to(@thread)
125
125
  expect(assigns(:thread).errors).to be_empty
126
126
  expect(assigns(:thread).is_closed?).to eq false
127
127
  end
128
-
128
+
129
129
  context '#mentions' do
130
130
  let(:search_phrase) { nil }
131
- let(:call_request) { get :mentions, id: @thread.id, format: :json, q: search_phrase }
131
+ let(:call_request) do
132
+ get :mentions, params: { id: @thread.id, format: :json, q: search_phrase }
133
+ end
132
134
 
133
135
  let!(:other_user) { DummyUser.create }
134
136
 
@@ -199,7 +201,7 @@ module Commontator
199
201
 
200
202
  it 'calls the user_mentions_proc and returns the result' do
201
203
  expect(Commontator.user_mentions_proc).to(
202
- receive(:call).with(@user, search_phrase).and_return(valid_result)
204
+ receive(:call).with(@user, @thread, search_phrase).and_return(valid_result)
203
205
  )
204
206
 
205
207
  call_request
@@ -215,4 +217,3 @@ module Commontator
215
217
  end
216
218
  end
217
219
  end
218
-
@@ -1,5 +1,5 @@
1
1
  class DummyModelsController < ApplicationController
2
- before_filter :get_dummy
2
+ before_action :get_dummy
3
3
 
4
4
  def show
5
5
  commontator_thread_show(@dummy_model)
@@ -2,7 +2,7 @@
2
2
  <html>
3
3
  <head>
4
4
  <title>Dummy</title>
5
- <%= stylesheet_link_tag "application", :media => "all" %>
5
+ <%= stylesheet_link_tag "application", media: "all" %>
6
6
  <%= javascript_include_tag "application" %>
7
7
  <%= csrf_meta_tags %>
8
8
  </head>
@@ -12,4 +12,3 @@
12
12
 
13
13
  </body>
14
14
  </html>
15
-
@@ -20,7 +20,7 @@ module Dummy
20
20
  # config.i18n.default_locale = :de
21
21
 
22
22
  config.generators do |g|
23
- g.test_framework :mini_test, :spec => true, :fixture => false
23
+ g.test_framework :mini_test, spec: true, fixture: false
24
24
  end
25
25
  end
26
26
  end
@@ -16,7 +16,7 @@ Dummy::Application.configure do
16
16
  # Don't care if the mailer can't send.
17
17
  config.action_mailer.raise_delivery_errors = false
18
18
 
19
- config.action_mailer.default_url_options = { :host => "dev.example.com" }
19
+ config.action_mailer.default_url_options = { host: "dev.example.com" }
20
20
 
21
21
  # Print deprecation notices to the Rails logger.
22
22
  config.active_support.deprecation = :log
@@ -29,4 +29,3 @@ Dummy::Application.configure do
29
29
  # number of complex assets.
30
30
  config.assets.debug = true
31
31
  end
32
-
@@ -69,7 +69,7 @@ Dummy::Application.configure do
69
69
  # the I18n.default_locale when a translation can not be found).
70
70
  config.i18n.fallbacks = true
71
71
 
72
- config.action_mailer.default_url_options = { :host => "www.example.com" }
72
+ config.action_mailer.default_url_options = { host: "www.example.com" }
73
73
 
74
74
  # Send deprecation notices to registered listeners.
75
75
  config.active_support.deprecation = :notify
@@ -80,4 +80,3 @@ Dummy::Application.configure do
80
80
  # Use default logging formatter so that PID and timestamp are not suppressed.
81
81
  config.log_formatter = ::Logger::Formatter.new
82
82
  end
83
-
@@ -31,11 +31,10 @@ Dummy::Application.configure do
31
31
  # ActionMailer::Base.deliveries array.
32
32
  config.action_mailer.delivery_method = :test
33
33
 
34
- config.action_mailer.default_url_options = { :host => "test.example.com" }
34
+ config.action_mailer.default_url_options = { host: "test.example.com" }
35
35
 
36
36
  # Print deprecation notices to the stderr.
37
37
  config.active_support.deprecation = :stderr
38
38
 
39
39
  config.active_support.test_order = :sorted
40
40
  end
41
-
@@ -1,12 +1,12 @@
1
1
  # Dummy application configuration file
2
2
  Commontator.configure do |config|
3
- config.javascript_proc = lambda { |view| '// Some javascript' }
3
+ config.javascript_proc = ->(view) { '// Some javascript' }
4
4
 
5
- config.user_name_proc = lambda { |user| user.try(:name) || 'Anonymous' }
5
+ config.user_name_proc = ->(user) { user.try(:name) || 'Anonymous' }
6
6
 
7
- config.thread_read_proc = lambda { |thread, user| user && user.can_read }
7
+ config.thread_read_proc = ->(thread, user) { user && user.can_read }
8
8
 
9
- config.thread_moderator_proc = lambda { |thread, user| user.is_admin || user.can_edit }
9
+ config.thread_moderator_proc = ->(thread, user) { user.is_admin || user.can_edit }
10
10
 
11
11
  config.comment_voting = :ld
12
12
 
@@ -14,7 +14,7 @@ Commontator.configure do |config|
14
14
 
15
15
  config.mentions_enabled = true
16
16
 
17
- config.user_mentions_proc = lambda { |current_user, query|
18
- 'DummyUser'.include?(query) ? DummyUser.all : DummyUser.none }
17
+ config.user_mentions_proc = ->(current_user, thread, query) {
18
+ 'DummyUser'.include?(query) ? DummyUser.all : DummyUser.none
19
+ }
19
20
  end
20
-
@@ -1,10 +1,9 @@
1
1
  Rails.application.routes.draw do
2
- root to: "dummy_models#show", id: 1
2
+ root to: 'dummy_models#show', id: 1
3
3
 
4
4
  resources :dummy_models, only: :show do
5
5
  get :hide, on: :member
6
6
  end
7
7
 
8
- mount Commontator::Engine => "/commontator"
8
+ mount Commontator::Engine => '/commontator'
9
9
  end
10
-
Binary file
@@ -1,8 +1,7 @@
1
- class CreateDummyModels < ActiveRecord::Migration
1
+ class CreateDummyModels < ActiveRecord::Migration[5.0]
2
2
  def change
3
3
  create_table "dummy_models" do |t|
4
- t.timestamps
4
+ t.timestamps null: false
5
5
  end
6
6
  end
7
7
  end
8
-
@@ -1,8 +1,7 @@
1
- class CreateDummyUsers < ActiveRecord::Migration
1
+ class CreateDummyUsers < ActiveRecord::Migration[5.0]
2
2
  def change
3
3
  create_table "dummy_users" do |t|
4
- t.timestamps
4
+ t.timestamps null: false
5
5
  end
6
6
  end
7
7
  end
8
-