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.
- checksums.yaml +4 -4
- data/README.md +6 -5
- data/app/controllers/commontator/application_controller.rb +4 -4
- data/app/controllers/commontator/comments_controller.rb +15 -15
- data/app/controllers/commontator/subscriptions_controller.rb +1 -1
- data/app/controllers/commontator/threads_controller.rb +5 -5
- data/app/mailers/commontator/subscriptions_mailer.rb +25 -37
- data/app/models/commontator/comment.rb +11 -11
- data/app/models/commontator/subscription.rb +2 -2
- data/app/models/commontator/thread.rb +9 -9
- data/app/views/commontator/comments/_actions.html.erb +8 -8
- data/app/views/commontator/comments/_body.html.erb +1 -1
- data/app/views/commontator/comments/_form.html.erb +3 -3
- data/app/views/commontator/comments/_list.html.erb +3 -3
- data/app/views/commontator/comments/_show.html.erb +8 -8
- data/app/views/commontator/comments/_votes.html.erb +16 -16
- data/app/views/commontator/comments/cancel.js.erb +5 -5
- data/app/views/commontator/comments/create.js.erb +9 -9
- data/app/views/commontator/comments/delete.js.erb +7 -7
- data/app/views/commontator/comments/edit.js.erb +2 -2
- data/app/views/commontator/comments/new.js.erb +4 -4
- data/app/views/commontator/comments/update.js.erb +1 -1
- data/app/views/commontator/comments/vote.js.erb +3 -3
- data/app/views/commontator/shared/_thread.html.erb +6 -6
- data/app/views/commontator/subscriptions/_link.html.erb +5 -5
- data/app/views/commontator/subscriptions/subscribe.js.erb +3 -3
- data/app/views/commontator/subscriptions_mailer/comment_created.html.erb +6 -6
- data/app/views/commontator/threads/_reply.html.erb +6 -6
- data/app/views/commontator/threads/_show.html.erb +33 -33
- data/app/views/commontator/threads/_show.js.erb +7 -7
- data/app/views/commontator/threads/show.js.erb +6 -6
- data/config/initializers/commontator.rb +43 -38
- data/config/locales/de.yml +100 -0
- data/config/locales/en.yml +26 -27
- data/config/locales/pt-BR.yml +78 -0
- data/config/locales/ru.yml +25 -26
- data/config/locales/zh.yml +26 -27
- data/config/routes.rb +4 -4
- data/db/migrate/0_install_commontator.rb +17 -17
- data/lib/commontator.rb +2 -2
- data/lib/commontator/acts_as_commontable.rb +14 -12
- data/lib/commontator/acts_as_commontator.rb +5 -5
- data/lib/commontator/shared_helper.rb +6 -6
- data/lib/commontator/version.rb +1 -1
- data/lib/tasks/commontator_tasks.rake +2 -2
- data/spec/controllers/commontator/comments_controller_spec.rb +76 -75
- data/spec/controllers/commontator/subscriptions_controller_spec.rb +26 -27
- data/spec/controllers/commontator/threads_controller_spec.rb +42 -41
- data/spec/dummy/app/controllers/dummy_models_controller.rb +1 -1
- data/spec/dummy/app/views/layouts/application.html.erb +1 -2
- data/spec/dummy/config/application.rb +1 -1
- data/spec/dummy/config/environments/development.rb +1 -2
- data/spec/dummy/config/environments/production.rb +1 -2
- data/spec/dummy/config/environments/test.rb +1 -2
- data/spec/dummy/config/initializers/commontator.rb +7 -7
- data/spec/dummy/config/routes.rb +2 -3
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/1_create_dummy_models.rb +2 -3
- data/spec/dummy/db/migrate/2_create_dummy_users.rb +2 -3
- data/spec/dummy/db/migrate/3_acts_as_votable_migration.rb +4 -10
- data/spec/dummy/db/schema.rb +45 -48
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +413 -0
- data/spec/dummy/log/test.log +33690 -0
- data/spec/lib/commontator/commontable_config_spec.rb +4 -5
- data/spec/lib/commontator/commontator_config_spec.rb +4 -5
- data/spec/lib/commontator_spec.rb +2 -3
- data/spec/mailers/commontator/subscriptions_mailer_spec.rb +2 -3
- data/spec/models/commontator/comment_spec.rb +10 -10
- data/spec/rails_helper.rb +3 -2
- metadata +64 -44
data/config/locales/ru.yml
CHANGED
@@ -1,30 +1,30 @@
|
|
1
|
-
ru:
|
2
|
-
activerecord:
|
3
|
-
attributes:
|
4
|
-
commontator/comment:
|
1
|
+
ru:
|
2
|
+
activerecord:
|
3
|
+
attributes:
|
4
|
+
commontator/comment:
|
5
5
|
body: Комментарий
|
6
6
|
creator: Создал
|
7
7
|
editor: Редактировал
|
8
8
|
thread: Обсуждение
|
9
|
-
commontator/subscription:
|
9
|
+
commontator/subscription:
|
10
10
|
subscriber: Подписчик
|
11
11
|
thread: Обсуждение
|
12
|
-
commontator/thread:
|
12
|
+
commontator/thread:
|
13
13
|
commontable: Комментируем
|
14
|
-
models:
|
15
|
-
commontator/comment:
|
14
|
+
models:
|
15
|
+
commontator/comment:
|
16
16
|
one: комментарий
|
17
17
|
other: комментарии
|
18
|
-
commontator/subscription:
|
18
|
+
commontator/subscription:
|
19
19
|
one: подписка
|
20
20
|
other: подписки
|
21
|
-
commontator/thread:
|
21
|
+
commontator/thread:
|
22
22
|
one: обсуждение
|
23
23
|
other: обсуждения
|
24
|
-
commontator:
|
24
|
+
commontator:
|
25
25
|
anonymous: Аноним
|
26
|
-
comment:
|
27
|
-
actions:
|
26
|
+
comment:
|
27
|
+
actions:
|
28
28
|
cancel: Отменить
|
29
29
|
confirm_delete: "Вы уверены, что хотите удалить комментарий?"
|
30
30
|
create: "Оставить Комментарий"
|
@@ -33,33 +33,32 @@ ru:
|
|
33
33
|
new: "Новый Комментарий"
|
34
34
|
undelete: Восстановить
|
35
35
|
update: "Изменить Комментарий"
|
36
|
-
errors:
|
36
|
+
errors:
|
37
37
|
already_deleted: "Этот комментарий был удален."
|
38
38
|
create: "Комментарий нельзя оставить потому что"
|
39
39
|
double_posted: "этот комментарий уже есть."
|
40
40
|
not_deleted: "Этот комментарий не удален."
|
41
41
|
update: "Этот комментарий нельзя изменить потому что"
|
42
|
-
status:
|
42
|
+
status:
|
43
43
|
created_at: "Создан %{created_at}."
|
44
44
|
deleted_by: "Комментарий был удален %{deleter_name}."
|
45
45
|
updated_at: "Редактировал %{editor_name}, %{updated_at}."
|
46
|
-
email:
|
47
|
-
comment_created:
|
46
|
+
email:
|
47
|
+
comment_created:
|
48
48
|
body: "%{creator_name} комментировал %{commontable_name}:"
|
49
49
|
subject: "%{creator_name} оставил комментарий к %{commontable_name}"
|
50
50
|
thread_link_html: "<a href=\"%{comment_url}\">Нажмите здесь</a> чтобы посмотреть все комментарии к %{commontable_name}."
|
51
|
-
undisclosed_recipients: "Не указан получатель"
|
52
51
|
require_login: "Вы должны залогиниться прежде чем оставить комментарий."
|
53
|
-
subscription:
|
54
|
-
actions:
|
52
|
+
subscription:
|
53
|
+
actions:
|
55
54
|
confirm_unsubscribe: "Вы уверены, что хотите отписать от обсуждения?"
|
56
55
|
subscribe: Подписаться
|
57
56
|
unsubscribe: Отписаться
|
58
|
-
errors:
|
57
|
+
errors:
|
59
58
|
already_subscribed: "Вы уже подписаны на это обсуждение."
|
60
59
|
not_subscribed: "Вы не подписаны на это обсуждение."
|
61
|
-
thread:
|
62
|
-
actions:
|
60
|
+
thread:
|
61
|
+
actions:
|
63
62
|
show_all: "Показать все комментарии"
|
64
63
|
filter: "Фильтровать комментарии"
|
65
64
|
close: "Закрыть обсуждение"
|
@@ -70,10 +69,10 @@ ru:
|
|
70
69
|
errors:
|
71
70
|
already_closed: "Это обсуждение было закрыто."
|
72
71
|
not_closed: "Это обсуждение не закрыто."
|
73
|
-
status:
|
72
|
+
status:
|
74
73
|
cannot_post: "Новый комментарии нельзя разместить в данный момент."
|
75
74
|
closed: "Комментарии (Закрыты %{closer_name})"
|
76
75
|
open: Комментарии
|
77
|
-
time:
|
78
|
-
formats:
|
76
|
+
time:
|
77
|
+
formats:
|
79
78
|
commontator: "%b %d %Y в %I:%M%p %Z"
|
data/config/locales/zh.yml
CHANGED
@@ -1,30 +1,30 @@
|
|
1
|
-
zh:
|
2
|
-
activerecord:
|
3
|
-
attributes:
|
4
|
-
commontator/comment:
|
1
|
+
zh:
|
2
|
+
activerecord:
|
3
|
+
attributes:
|
4
|
+
commontator/comment:
|
5
5
|
body: "留言"
|
6
6
|
creator: "留言者"
|
7
7
|
editor: "編輯"
|
8
8
|
thread: "討論"
|
9
|
-
commontator/subscription:
|
9
|
+
commontator/subscription:
|
10
10
|
subscriber: "訂閱者"
|
11
11
|
thread: "討論"
|
12
|
-
commontator/thread:
|
12
|
+
commontator/thread:
|
13
13
|
commontable: "可以留言"
|
14
|
-
models:
|
15
|
-
commontator/comment:
|
14
|
+
models:
|
15
|
+
commontator/comment:
|
16
16
|
one: "留言"
|
17
17
|
other: "留言"
|
18
|
-
commontator/subscription:
|
18
|
+
commontator/subscription:
|
19
19
|
one: "訂閱"
|
20
20
|
other: "訂閱"
|
21
|
-
commontator/thread:
|
21
|
+
commontator/thread:
|
22
22
|
one: "討論"
|
23
23
|
other: "討論"
|
24
|
-
commontator:
|
24
|
+
commontator:
|
25
25
|
anonymous: "匿名"
|
26
|
-
comment:
|
27
|
-
actions:
|
26
|
+
comment:
|
27
|
+
actions:
|
28
28
|
cancel: "取消"
|
29
29
|
confirm_delete: "確定要刪除這筆留言嗎?"
|
30
30
|
create: "發佈"
|
@@ -33,33 +33,32 @@ zh:
|
|
33
33
|
new: "新留言"
|
34
34
|
undelete: "未刪除"
|
35
35
|
update: "修改留言"
|
36
|
-
errors:
|
36
|
+
errors:
|
37
37
|
already_deleted: "此留言已經被刪除了"
|
38
38
|
create: "此留言無法發佈因為:"
|
39
39
|
double_posted: "已經有一筆相同的留言。"
|
40
40
|
not_deleted: "此留言未被刪除"
|
41
41
|
update: "此留言無法被修改因為:"
|
42
|
-
status:
|
42
|
+
status:
|
43
43
|
created_at: "於%{created_at}發佈"
|
44
44
|
deleted_by: "被%{deleter_name}刪除"
|
45
45
|
updated_at: "最在於%{updated_at}被%{editor_name}修改"
|
46
|
-
email:
|
47
|
-
comment_created:
|
46
|
+
email:
|
47
|
+
comment_created:
|
48
48
|
body: "%{creator_name}留言於%{commontable_name}"
|
49
49
|
subject: "%{creator_name}於%{commontable_name}發佈了一則留言"
|
50
50
|
thread_link_html: "<a href=\"%{comment_url}\">點此處</a>看%{commontable_name}的所有留言"
|
51
|
-
undisclosed_recipients: "收件者"
|
52
51
|
require_login: "你需要先登入"
|
53
|
-
subscription:
|
54
|
-
actions:
|
52
|
+
subscription:
|
53
|
+
actions:
|
55
54
|
confirm_unsubscribe: "你確定要去取消訂閱此則討論嗎?"
|
56
55
|
subscribe: "訂閱"
|
57
56
|
unsubscribe: "取消訂閱"
|
58
|
-
errors:
|
57
|
+
errors:
|
59
58
|
already_subscribed: "你已經訂閱過了"
|
60
59
|
not_subscribed: "你沒有訂閱過"
|
61
|
-
thread:
|
62
|
-
actions:
|
60
|
+
thread:
|
61
|
+
actions:
|
63
62
|
show_all: "列出所有留言"
|
64
63
|
filter: "過濾留言"
|
65
64
|
close: "關閉討論"
|
@@ -67,13 +66,13 @@ zh:
|
|
67
66
|
reopen: "回復討論"
|
68
67
|
show: "打開留言"
|
69
68
|
hide: "关闭留言"
|
70
|
-
errors:
|
69
|
+
errors:
|
71
70
|
already_closed: "此討論已經被關閉"
|
72
71
|
not_closed: "此討論尚未被關閉"
|
73
|
-
status:
|
72
|
+
status:
|
74
73
|
cannot_post: "現在還不能發佈"
|
75
74
|
closed: "留言已經被%{closer_name}關閉"
|
76
75
|
open: 留言
|
77
|
-
time:
|
78
|
-
formats:
|
76
|
+
time:
|
77
|
+
formats:
|
79
78
|
commontator: "%b %d %Y 於 %I:%M%p %Z"
|
data/config/routes.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Commontator::Engine.routes.draw do
|
2
|
-
resources :threads, :
|
3
|
-
resources :comments, :
|
2
|
+
resources :threads, only: [:show] do
|
3
|
+
resources :comments, except: [:index, :destroy], shallow: true do
|
4
4
|
member do
|
5
5
|
put 'delete'
|
6
6
|
put 'undelete'
|
@@ -17,8 +17,8 @@ Commontator::Engine.routes.draw do
|
|
17
17
|
put 'close'
|
18
18
|
put 'reopen'
|
19
19
|
|
20
|
-
put 'subscribe', :
|
21
|
-
put 'unsubscribe', :
|
20
|
+
put 'subscribe', to: 'subscriptions#subscribe'
|
21
|
+
put 'unsubscribe', to: 'subscriptions#unsubscribe'
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -1,38 +1,38 @@
|
|
1
|
-
class InstallCommontator < ActiveRecord::Migration
|
1
|
+
class InstallCommontator < ActiveRecord::Migration[5.0]
|
2
2
|
def change
|
3
3
|
create_table :commontator_comments do |t|
|
4
4
|
t.string :creator_type
|
5
5
|
t.integer :creator_id
|
6
6
|
t.string :editor_type
|
7
7
|
t.integer :editor_id
|
8
|
-
t.integer :thread_id, :
|
9
|
-
t.text :body, :
|
8
|
+
t.integer :thread_id, null: false
|
9
|
+
t.text :body, null: false
|
10
10
|
t.datetime :deleted_at
|
11
11
|
|
12
|
-
t.integer :cached_votes_up, :
|
13
|
-
t.integer :cached_votes_down, :
|
12
|
+
t.integer :cached_votes_up, default: 0
|
13
|
+
t.integer :cached_votes_down, default: 0
|
14
14
|
|
15
|
-
t.timestamps
|
15
|
+
t.timestamps null: false
|
16
16
|
end
|
17
17
|
|
18
18
|
add_index :commontator_comments, [:creator_id, :creator_type, :thread_id],
|
19
|
-
:
|
19
|
+
name: 'index_commontator_comments_on_c_id_and_c_type_and_t_id'
|
20
20
|
add_index :commontator_comments, [:thread_id, :created_at]
|
21
21
|
|
22
22
|
add_index :commontator_comments, :cached_votes_up
|
23
23
|
add_index :commontator_comments, :cached_votes_down
|
24
|
-
|
24
|
+
|
25
25
|
create_table :commontator_subscriptions do |t|
|
26
|
-
t.string :subscriber_type, :
|
27
|
-
t.integer :subscriber_id, :
|
28
|
-
t.integer :thread_id, :
|
26
|
+
t.string :subscriber_type, null: false
|
27
|
+
t.integer :subscriber_id, null: false
|
28
|
+
t.integer :thread_id, null: false
|
29
29
|
|
30
|
-
t.timestamps
|
30
|
+
t.timestamps null: false
|
31
31
|
end
|
32
32
|
|
33
33
|
add_index :commontator_subscriptions, [:subscriber_id, :subscriber_type, :thread_id],
|
34
|
-
:
|
35
|
-
:
|
34
|
+
unique: true,
|
35
|
+
name: 'index_commontator_subscriptions_on_s_id_and_s_type_and_t_id'
|
36
36
|
add_index :commontator_subscriptions, :thread_id
|
37
37
|
|
38
38
|
create_table :commontator_threads do |t|
|
@@ -42,11 +42,11 @@ class InstallCommontator < ActiveRecord::Migration
|
|
42
42
|
t.string :closer_type
|
43
43
|
t.integer :closer_id
|
44
44
|
|
45
|
-
t.timestamps
|
45
|
+
t.timestamps null: false
|
46
46
|
end
|
47
47
|
|
48
48
|
add_index :commontator_threads, [:commontable_id, :commontable_type],
|
49
|
-
:
|
50
|
-
:
|
49
|
+
unique: true,
|
50
|
+
name: 'index_commontator_threads_on_c_id_and_c_type'
|
51
51
|
end
|
52
52
|
end
|
data/lib/commontator.rb
CHANGED
@@ -128,8 +128,8 @@ module Commontator
|
|
128
128
|
commontator_config(user).user_avatar_proc.call(user, view)
|
129
129
|
end
|
130
130
|
|
131
|
-
def self.commontator_mentions(user, search_phrase)
|
132
|
-
commontator_config(user).user_mentions_proc.call(user, search_phrase)
|
131
|
+
def self.commontator_mentions(user, thread, search_phrase)
|
132
|
+
commontator_config(user).user_mentions_proc.call(user, thread, search_phrase)
|
133
133
|
end
|
134
134
|
|
135
135
|
def self.commontable_name(commontable)
|
@@ -7,7 +7,7 @@ module Commontator
|
|
7
7
|
base.is_commontable = false
|
8
8
|
base.extend(ClassMethods)
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
module ClassMethods
|
12
12
|
def acts_as_commontable(options = {})
|
13
13
|
class_eval do
|
@@ -15,24 +15,26 @@ module Commontator
|
|
15
15
|
self.commontable_config = Commontator::CommontableConfig.new(options)
|
16
16
|
self.is_commontable = true
|
17
17
|
|
18
|
-
has_one :thread, :
|
19
|
-
:
|
18
|
+
has_one :thread, as: :commontable,
|
19
|
+
class_name: 'Commontator::Thread'
|
20
20
|
|
21
21
|
validates_presence_of :thread
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
prepend ThreadWithCommontator
|
24
|
+
end
|
25
|
+
end
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
module ThreadWithCommontator
|
28
|
+
def thread
|
29
|
+
@thread ||= super
|
30
|
+
return @thread unless @thread.nil?
|
31
31
|
|
32
|
-
|
32
|
+
@thread = build_thread
|
33
|
+
@thread.save if persisted?
|
34
|
+
@thread
|
33
35
|
end
|
34
36
|
end
|
35
|
-
|
37
|
+
|
36
38
|
alias_method :acts_as_commentable, :acts_as_commontable
|
37
39
|
end
|
38
40
|
end
|
@@ -15,11 +15,11 @@ module Commontator
|
|
15
15
|
self.commontator_config = Commontator::CommontatorConfig.new(options)
|
16
16
|
self.is_commontator = true
|
17
17
|
|
18
|
-
has_many :comments, :
|
19
|
-
:
|
20
|
-
has_many :subscriptions, :
|
21
|
-
:
|
22
|
-
:
|
18
|
+
has_many :comments, as: :creator,
|
19
|
+
class_name: 'Commontator::Comment'
|
20
|
+
has_many :subscriptions, as: :subscriber,
|
21
|
+
class_name: 'Commontator::Subscription',
|
22
|
+
dependent: :destroy
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -4,9 +4,9 @@ module Commontator
|
|
4
4
|
user = Commontator.current_user_proc.call(self)
|
5
5
|
thread = commontable.thread
|
6
6
|
|
7
|
-
render(:
|
8
|
-
:
|
9
|
-
:
|
7
|
+
render(partial: 'commontator/shared/thread',
|
8
|
+
locals: { thread: thread,
|
9
|
+
user: user }).html_safe
|
10
10
|
end
|
11
11
|
|
12
12
|
def commontator_gravatar_image_tag(user, border = 1, options = {})
|
@@ -17,9 +17,9 @@ module Commontator
|
|
17
17
|
hash = Digest::MD5.hexdigest(email)
|
18
18
|
url = "http#{base}.gravatar.com/avatar/#{hash}?#{options.to_query}"
|
19
19
|
|
20
|
-
image_tag(url, { :
|
21
|
-
:
|
22
|
-
:
|
20
|
+
image_tag(url, { alt: name,
|
21
|
+
title: name,
|
22
|
+
border: border })
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
data/lib/commontator/version.rb
CHANGED
@@ -10,7 +10,7 @@ namespace :commontator do
|
|
10
10
|
if File.exists?(File.expand_path(File.basename(file), 'config/initializers'))
|
11
11
|
print "NOTE: Initializer #{File.basename(file)} from commontator has been skipped. Initializer with the same name already exists.\n"
|
12
12
|
else
|
13
|
-
cp file, 'config/initializers', :
|
13
|
+
cp file, 'config/initializers', verbose: false
|
14
14
|
print "Copied initializer #{File.basename(file)} from commontator\n"
|
15
15
|
end
|
16
16
|
end
|
@@ -23,7 +23,7 @@ namespace :commontator do
|
|
23
23
|
desc "Copy #{name} from commontator to application"
|
24
24
|
task name.to_sym do
|
25
25
|
namespace = path.start_with?('app') ? '/commontator' : ''
|
26
|
-
cp_r File.expand_path("../../../#{path}#{namespace}", __FILE__), path, :
|
26
|
+
cp_r File.expand_path("../../../#{path}#{namespace}", __FILE__), path, verbose: false
|
27
27
|
print "Copied #{name} from commontator\n"
|
28
28
|
end
|
29
29
|
end
|
@@ -16,11 +16,11 @@ module Commontator
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it "won't get new unless authorized" do
|
19
|
-
get :new, :thread_id
|
19
|
+
get :new, params: { thread_id: @thread.id }
|
20
20
|
expect(response).to have_http_status(:forbidden)
|
21
21
|
|
22
22
|
sign_in @user
|
23
|
-
get :new, :thread_id
|
23
|
+
get :new, params: { thread_id: @thread.id }
|
24
24
|
expect(response).to have_http_status(:forbidden)
|
25
25
|
end
|
26
26
|
|
@@ -28,19 +28,19 @@ module Commontator
|
|
28
28
|
sign_in @user
|
29
29
|
|
30
30
|
@user.can_read = true
|
31
|
-
get :new, :thread_id
|
31
|
+
get :new, params: { thread_id: @thread.id }
|
32
32
|
expect(response).to redirect_to @thread
|
33
33
|
expect(assigns(:comment).errors).to be_empty
|
34
34
|
|
35
35
|
@user.can_read = false
|
36
36
|
@user.can_edit = true
|
37
|
-
get :new, :thread_id
|
37
|
+
get :new, params: { thread_id: @thread.id }
|
38
38
|
expect(response).to redirect_to @thread
|
39
39
|
expect(assigns(:comment).errors).to be_empty
|
40
40
|
|
41
41
|
@user.can_edit = false
|
42
42
|
@user.is_admin = true
|
43
|
-
get :new, :thread_id
|
43
|
+
get :new, params: { thread_id: @thread.id }
|
44
44
|
expect(response).to redirect_to @thread
|
45
45
|
expect(assigns(:comment).errors).to be_empty
|
46
46
|
end
|
@@ -49,18 +49,18 @@ module Commontator
|
|
49
49
|
attributes = Hash.new
|
50
50
|
attributes[:body] = 'Something else'
|
51
51
|
|
52
|
-
post :create, :thread_id
|
52
|
+
post :create, params: { thread_id: @thread.id, comment: attributes }
|
53
53
|
expect(response).to have_http_status(:forbidden)
|
54
54
|
|
55
55
|
sign_in @user
|
56
|
-
post :create, :thread_id
|
56
|
+
post :create, params: { thread_id: @thread.id, comment: attributes }
|
57
57
|
expect(response).to have_http_status(:forbidden)
|
58
58
|
|
59
59
|
@user.can_read = true
|
60
60
|
@user.can_edit = true
|
61
61
|
@user.is_admin = true
|
62
62
|
expect(@thread.close).to eq true
|
63
|
-
post :create, :thread_id
|
63
|
+
post :create, params: { thread_id: @thread.id, comment: attributes }
|
64
64
|
expect(response).to have_http_status(:forbidden)
|
65
65
|
end
|
66
66
|
|
@@ -70,7 +70,7 @@ module Commontator
|
|
70
70
|
|
71
71
|
attributes[:body] = 'Something else'
|
72
72
|
@user.can_read = true
|
73
|
-
post :create, :thread_id
|
73
|
+
post :create, params: { thread_id: @thread.id, comment: attributes }
|
74
74
|
expect(response).to redirect_to @thread
|
75
75
|
expect(assigns(:comment).errors).to be_empty
|
76
76
|
expect(assigns(:comment).body).to eq 'Something else'
|
@@ -81,7 +81,7 @@ module Commontator
|
|
81
81
|
attributes[:body] = 'Another thing'
|
82
82
|
@user.can_read = false
|
83
83
|
@user.can_edit = true
|
84
|
-
post :create, :thread_id
|
84
|
+
post :create, params: { thread_id: @thread.id, comment: attributes }
|
85
85
|
expect(response).to redirect_to @thread
|
86
86
|
expect(assigns(:comment).errors).to be_empty
|
87
87
|
expect(assigns(:comment).body).to eq 'Another thing'
|
@@ -92,7 +92,7 @@ module Commontator
|
|
92
92
|
attributes[:body] = 'And this too'
|
93
93
|
@user.can_edit = false
|
94
94
|
@user.is_admin = true
|
95
|
-
post :create, :thread_id
|
95
|
+
post :create, params: { thread_id: @thread.id, comment: attributes }
|
96
96
|
expect(response).to redirect_to @thread
|
97
97
|
expect(assigns(:comment).errors).to be_empty
|
98
98
|
expect(assigns(:comment).body).to eq 'And this too'
|
@@ -107,12 +107,12 @@ module Commontator
|
|
107
107
|
attributes = Hash.new
|
108
108
|
|
109
109
|
attributes[:body] = 'Something'
|
110
|
-
post :create, :thread_id
|
110
|
+
post :create, params: { thread_id: @thread.id, comment: attributes }
|
111
111
|
assert_redirected_to @thread
|
112
112
|
expect(assigns(:comment).errors).not_to be_empty
|
113
113
|
|
114
114
|
attributes[:body] = 'Something else'
|
115
|
-
post :create, :thread_id
|
115
|
+
post :create, params: { thread_id: @thread.id, comment: attributes }
|
116
116
|
expect(response).to redirect_to @thread
|
117
117
|
expect(assigns(:comment).errors).to be_empty
|
118
118
|
expect(assigns(:comment).body).to eq 'Something else'
|
@@ -121,17 +121,17 @@ module Commontator
|
|
121
121
|
expect(assigns(:comment).thread).to eq @thread
|
122
122
|
|
123
123
|
attributes[:body] = 'Something else'
|
124
|
-
post :create, :thread_id
|
124
|
+
post :create, params: { thread_id: @thread.id, comment: attributes }
|
125
125
|
expect(response).to redirect_to @thread
|
126
126
|
expect(assigns(:comment).errors).not_to be_empty
|
127
127
|
end
|
128
128
|
|
129
129
|
it "won't edit unless authorized" do
|
130
|
-
get :edit, :id
|
130
|
+
get :edit, params: { id: @comment.id }
|
131
131
|
expect(response).to have_http_status(:forbidden)
|
132
132
|
|
133
133
|
sign_in @user
|
134
|
-
get :edit, :id
|
134
|
+
get :edit, params: { id: @comment.id }
|
135
135
|
expect(response).to have_http_status(:forbidden)
|
136
136
|
|
137
137
|
user2 = DummyUser.create
|
@@ -139,7 +139,7 @@ module Commontator
|
|
139
139
|
user2.can_edit = true
|
140
140
|
user2.is_admin = true
|
141
141
|
sign_in user2
|
142
|
-
get :edit, :id
|
142
|
+
get :edit, params: { id: @comment.id }
|
143
143
|
expect(response).to have_http_status(:forbidden)
|
144
144
|
|
145
145
|
@user.can_read = true
|
@@ -151,7 +151,7 @@ module Commontator
|
|
151
151
|
comment2.creator = @user
|
152
152
|
comment2.body = 'Something else'
|
153
153
|
comment2.save!
|
154
|
-
get :edit, :id
|
154
|
+
get :edit, params: { id: @comment.id }
|
155
155
|
expect(response).to have_http_status(:forbidden)
|
156
156
|
end
|
157
157
|
|
@@ -159,19 +159,19 @@ module Commontator
|
|
159
159
|
sign_in @user
|
160
160
|
|
161
161
|
@user.can_read = true
|
162
|
-
get :edit, :id
|
162
|
+
get :edit, params: { id: @comment.id }
|
163
163
|
expect(response).to redirect_to @thread
|
164
164
|
expect(assigns(:comment).errors).to be_empty
|
165
165
|
|
166
166
|
@user.can_read = false
|
167
167
|
@user.can_edit = true
|
168
|
-
get :edit, :id
|
168
|
+
get :edit, params: { id: @comment.id }
|
169
169
|
expect(response).to redirect_to @thread
|
170
170
|
expect(assigns(:comment).errors).to be_empty
|
171
171
|
|
172
172
|
@user.can_edit = false
|
173
173
|
@user.is_admin = true
|
174
|
-
get :edit, :id
|
174
|
+
get :edit, params: { id: @comment.id }
|
175
175
|
expect(response).to redirect_to @thread
|
176
176
|
expect(assigns(:comment).errors).to be_empty
|
177
177
|
end
|
@@ -180,14 +180,14 @@ module Commontator
|
|
180
180
|
attributes = Hash.new
|
181
181
|
attributes[:body] = 'Something else'
|
182
182
|
|
183
|
-
put :update, :id
|
183
|
+
put :update, params: { id: @comment.id, comment: attributes }
|
184
184
|
expect(response).to have_http_status(:forbidden)
|
185
185
|
@comment.reload
|
186
186
|
expect(@comment.body).to eq 'Something'
|
187
187
|
expect(@comment.editor).to be_nil
|
188
188
|
|
189
189
|
sign_in @user
|
190
|
-
put :update, :id
|
190
|
+
put :update, params: { id: @comment.id, comment: attributes }
|
191
191
|
expect(response).to have_http_status(:forbidden)
|
192
192
|
@comment.reload
|
193
193
|
expect(@comment.body).to eq 'Something'
|
@@ -198,7 +198,7 @@ module Commontator
|
|
198
198
|
user2.can_edit = true
|
199
199
|
user2.is_admin = true
|
200
200
|
sign_in user2
|
201
|
-
put :update, :id
|
201
|
+
put :update, params: { id: @comment.id, comment: attributes }
|
202
202
|
expect(response).to have_http_status(:forbidden)
|
203
203
|
@comment.reload
|
204
204
|
expect(@comment.body).to eq 'Something'
|
@@ -213,7 +213,7 @@ module Commontator
|
|
213
213
|
comment2.creator = @user
|
214
214
|
comment2.body = 'Something else'
|
215
215
|
comment2.save!
|
216
|
-
put :update, :id
|
216
|
+
put :update, params: { id: @comment.id, comment: attributes }
|
217
217
|
expect(response).to have_http_status(:forbidden)
|
218
218
|
@comment.reload
|
219
219
|
expect(@comment.body).to eq 'Something'
|
@@ -226,42 +226,42 @@ module Commontator
|
|
226
226
|
attributes[:body] = 'Something else'
|
227
227
|
|
228
228
|
@user.can_read = true
|
229
|
-
put :update, :id
|
229
|
+
put :update, params: { id: @comment.id, comment: attributes }
|
230
230
|
expect(response).to redirect_to @thread
|
231
231
|
expect(assigns(:comment).errors).to be_empty
|
232
232
|
expect(assigns(:comment).editor).to eq @user
|
233
233
|
|
234
234
|
@user.can_read = false
|
235
235
|
@user.can_edit = true
|
236
|
-
put :update, :id
|
236
|
+
put :update, params: { id: @comment.id, comment: attributes }
|
237
237
|
expect(response).to redirect_to @thread
|
238
238
|
expect(assigns(:comment).errors).to be_empty
|
239
239
|
expect(assigns(:comment).editor).to eq @user
|
240
240
|
|
241
241
|
@user.can_edit = false
|
242
242
|
@user.is_admin = true
|
243
|
-
put :update, :id
|
243
|
+
put :update, params: { id: @comment.id, comment: attributes }
|
244
244
|
expect(response).to redirect_to @thread
|
245
245
|
expect(assigns(:comment).errors).to be_empty
|
246
246
|
expect(assigns(:comment).editor).to eq @user
|
247
247
|
end
|
248
248
|
|
249
249
|
it "won't delete unless authorized and not deleted" do
|
250
|
-
put :delete, :id
|
250
|
+
put :delete, params: { id: @comment.id }
|
251
251
|
expect(response).to have_http_status(:forbidden)
|
252
252
|
@comment.reload
|
253
253
|
expect(@comment.is_deleted?).to eq false
|
254
254
|
|
255
255
|
sign_in @user
|
256
256
|
|
257
|
-
put :delete, :id
|
257
|
+
put :delete, params: { id: @comment.id }
|
258
258
|
expect(response).to have_http_status(:forbidden)
|
259
259
|
@comment.reload
|
260
260
|
expect(@comment.is_deleted?).to eq false
|
261
261
|
|
262
262
|
@user.can_read = true
|
263
263
|
expect(@comment.delete_by(@user)).to eq true
|
264
|
-
put :delete, :id
|
264
|
+
put :delete, params: { id: @comment.id }
|
265
265
|
expect(response).to redirect_to @thread
|
266
266
|
expect(assigns(:comment).errors).not_to be_empty
|
267
267
|
|
@@ -271,7 +271,7 @@ module Commontator
|
|
271
271
|
comment2.body = 'Something else'
|
272
272
|
comment2.save!
|
273
273
|
expect(@comment.undelete_by(@user)).to eq true
|
274
|
-
put :delete, :id
|
274
|
+
put :delete, params: { id: @comment.id }
|
275
275
|
expect(response).to have_http_status(:forbidden)
|
276
276
|
@comment.reload
|
277
277
|
expect(@comment.is_deleted?).to eq false
|
@@ -281,7 +281,7 @@ module Commontator
|
|
281
281
|
sign_in @user
|
282
282
|
|
283
283
|
@user.can_read = true
|
284
|
-
put :delete, :id
|
284
|
+
put :delete, params: { id: @comment.id }
|
285
285
|
expect(response).to redirect_to @thread
|
286
286
|
expect(assigns(:comment).errors).to be_empty
|
287
287
|
expect(assigns(:comment).is_deleted?).to eq true
|
@@ -297,7 +297,7 @@ module Commontator
|
|
297
297
|
|
298
298
|
expect(assigns(:comment).undelete_by(@user)).to eq true
|
299
299
|
user2.can_edit = true
|
300
|
-
put :delete, :id
|
300
|
+
put :delete, params: { id: @comment.id }
|
301
301
|
expect(response).to redirect_to @thread
|
302
302
|
expect(assigns(:comment).errors).to be_empty
|
303
303
|
expect(assigns(:comment).is_deleted?).to eq true
|
@@ -306,7 +306,7 @@ module Commontator
|
|
306
306
|
expect(assigns(:comment).undelete_by(@user)).to eq true
|
307
307
|
user2.can_edit = false
|
308
308
|
user2.is_admin = true
|
309
|
-
put :delete, :id
|
309
|
+
put :delete, params: { id: @comment.id }
|
310
310
|
expect(response).to redirect_to @thread
|
311
311
|
expect(assigns(:comment).errors).to be_empty
|
312
312
|
expect(assigns(:comment).is_deleted?).to eq true
|
@@ -315,21 +315,21 @@ module Commontator
|
|
315
315
|
|
316
316
|
it "won't undelete unless authorized and deleted" do
|
317
317
|
expect(@comment.delete_by(@user)).to eq true
|
318
|
-
put :undelete, :id
|
318
|
+
put :undelete, params: { id: @comment.id }
|
319
319
|
expect(response).to have_http_status(:forbidden)
|
320
320
|
@comment.reload
|
321
321
|
expect(@comment.is_deleted?).to eq true
|
322
322
|
|
323
323
|
sign_in @user
|
324
324
|
|
325
|
-
put :undelete, :id
|
325
|
+
put :undelete, params: { id: @comment.id }
|
326
326
|
expect(response).to have_http_status(:forbidden)
|
327
327
|
@comment.reload
|
328
328
|
expect(@comment.is_deleted?).to eq true
|
329
329
|
|
330
330
|
@user.can_read = true
|
331
331
|
expect(@comment.undelete_by(@user)).to eq true
|
332
|
-
put :undelete, :id
|
332
|
+
put :undelete, params: { id: @comment.id }
|
333
333
|
expect(response).to redirect_to @thread
|
334
334
|
expect(assigns(:comment).errors).not_to be_empty
|
335
335
|
|
@@ -338,7 +338,7 @@ module Commontator
|
|
338
338
|
user2.can_edit = true
|
339
339
|
user2.is_admin = true
|
340
340
|
expect(@comment.delete_by(user2)).to eq true
|
341
|
-
put :undelete, :id
|
341
|
+
put :undelete, params: { id: @comment.id }
|
342
342
|
expect(response).to have_http_status(:forbidden)
|
343
343
|
@comment.reload
|
344
344
|
expect(@comment.is_deleted?).to eq true
|
@@ -350,7 +350,7 @@ module Commontator
|
|
350
350
|
comment2.save!
|
351
351
|
expect(@comment.undelete_by(@user)).to eq true
|
352
352
|
expect(@comment.delete_by(@user)).to eq true
|
353
|
-
put :undelete, :id
|
353
|
+
put :undelete, params: { id: @comment.id }
|
354
354
|
expect(response).to have_http_status(:forbidden)
|
355
355
|
@comment.reload
|
356
356
|
expect(@comment.is_deleted?).to eq true
|
@@ -361,7 +361,7 @@ module Commontator
|
|
361
361
|
|
362
362
|
expect(@comment.delete_by(@user)).to eq true
|
363
363
|
@user.can_read = true
|
364
|
-
put :undelete, :id
|
364
|
+
put :undelete, params: { id: @comment.id }
|
365
365
|
expect(response).to redirect_to @thread
|
366
366
|
expect(assigns(:comment).errors).to be_empty
|
367
367
|
expect(assigns(:comment).is_deleted?).to eq false
|
@@ -376,7 +376,7 @@ module Commontator
|
|
376
376
|
|
377
377
|
expect(assigns(:comment).delete_by(@user)).to eq true
|
378
378
|
user2.can_edit = true
|
379
|
-
put :undelete, :id
|
379
|
+
put :undelete, params: { id: @comment.id }
|
380
380
|
expect(response).to redirect_to @thread
|
381
381
|
expect(assigns(:comment).errors).to be_empty
|
382
382
|
expect(assigns(:comment).is_deleted?).to eq false
|
@@ -384,14 +384,14 @@ module Commontator
|
|
384
384
|
expect(assigns(:comment).delete_by(@user)).to eq true
|
385
385
|
user2.can_edit = false
|
386
386
|
user2.is_admin = true
|
387
|
-
put :undelete, :id
|
387
|
+
put :undelete, params: { id: @comment.id }
|
388
388
|
expect(response).to redirect_to @thread
|
389
389
|
expect(assigns(:comment).errors).to be_empty
|
390
390
|
expect(assigns(:comment).is_deleted?).to eq false
|
391
391
|
end
|
392
392
|
|
393
393
|
it "won't upvote unless authorized" do
|
394
|
-
put :upvote, :id
|
394
|
+
put :upvote, params: { id: @comment.id }
|
395
395
|
expect(response).to have_http_status(:forbidden)
|
396
396
|
@comment.reload
|
397
397
|
expect(@comment.get_upvotes).to be_empty
|
@@ -399,7 +399,7 @@ module Commontator
|
|
399
399
|
|
400
400
|
sign_in @user
|
401
401
|
@user.can_read = true
|
402
|
-
put :upvote, :id
|
402
|
+
put :upvote, params: { id: @comment.id }
|
403
403
|
expect(response).to have_http_status(:forbidden)
|
404
404
|
@comment.reload
|
405
405
|
expect(@comment.get_upvotes).to be_empty
|
@@ -407,7 +407,7 @@ module Commontator
|
|
407
407
|
|
408
408
|
user2 = DummyUser.create
|
409
409
|
sign_in user2
|
410
|
-
put :upvote, :id
|
410
|
+
put :upvote, params: { id: @comment.id }
|
411
411
|
expect(response).to have_http_status(:forbidden)
|
412
412
|
@comment.reload
|
413
413
|
expect(@comment.get_upvotes).to be_empty
|
@@ -419,26 +419,26 @@ module Commontator
|
|
419
419
|
user2.can_read = true
|
420
420
|
sign_in user2
|
421
421
|
|
422
|
-
put :upvote, :id
|
422
|
+
put :upvote, params: { id: @comment.id }
|
423
423
|
expect(response).to redirect_to @thread
|
424
424
|
expect(assigns(:comment).get_upvotes.count).to eq 1
|
425
425
|
expect(assigns(:comment).get_downvotes).to be_empty
|
426
426
|
|
427
|
-
put :upvote, :id
|
427
|
+
put :upvote, params: { id: @comment.id }
|
428
428
|
expect(response).to redirect_to @thread
|
429
429
|
expect(assigns(:comment).get_upvotes.count).to eq 1
|
430
430
|
expect(assigns(:comment).get_downvotes).to be_empty
|
431
431
|
|
432
432
|
expect(@comment.downvote_from(user2)).to eq true
|
433
433
|
|
434
|
-
put :upvote, :id
|
434
|
+
put :upvote, params: { id: @comment.id }
|
435
435
|
expect(response).to redirect_to @thread
|
436
436
|
expect(assigns(:comment).get_upvotes.count).to eq 1
|
437
437
|
expect(assigns(:comment).get_downvotes).to be_empty
|
438
438
|
end
|
439
439
|
|
440
440
|
it "won't downvote unless authorized" do
|
441
|
-
put :downvote, :id
|
441
|
+
put :downvote, params: { id: @comment.id }
|
442
442
|
expect(response).to have_http_status(:forbidden)
|
443
443
|
@comment.reload
|
444
444
|
expect(@comment.get_upvotes).to be_empty
|
@@ -446,7 +446,7 @@ module Commontator
|
|
446
446
|
|
447
447
|
sign_in @user
|
448
448
|
@user.can_read = true
|
449
|
-
put :downvote, :id
|
449
|
+
put :downvote, params: { id: @comment.id }
|
450
450
|
expect(response).to have_http_status(:forbidden)
|
451
451
|
@comment.reload
|
452
452
|
expect(@comment.get_upvotes).to be_empty
|
@@ -454,7 +454,7 @@ module Commontator
|
|
454
454
|
|
455
455
|
user2 = DummyUser.create
|
456
456
|
sign_in user2
|
457
|
-
put :downvote, :id
|
457
|
+
put :downvote, params: { id: @comment.id }
|
458
458
|
expect(response).to have_http_status(:forbidden)
|
459
459
|
@comment.reload
|
460
460
|
expect(@comment.get_upvotes).to be_empty
|
@@ -466,19 +466,19 @@ module Commontator
|
|
466
466
|
user2.can_read = true
|
467
467
|
sign_in user2
|
468
468
|
|
469
|
-
put :downvote, :id
|
469
|
+
put :downvote, params: { id: @comment.id }
|
470
470
|
expect(response).to redirect_to @thread
|
471
471
|
expect(@comment.get_upvotes).to be_empty
|
472
472
|
expect(@comment.get_downvotes.count).to eq 1
|
473
473
|
|
474
|
-
put :downvote, :id
|
474
|
+
put :downvote, params: { id: @comment.id }
|
475
475
|
expect(response).to redirect_to @thread
|
476
476
|
expect(@comment.get_upvotes).to be_empty
|
477
477
|
expect(@comment.get_downvotes.count).to eq 1
|
478
478
|
|
479
479
|
expect(@comment.upvote_from(user2)).to eq true
|
480
480
|
|
481
|
-
put :downvote, :id
|
481
|
+
put :downvote, params: { id: @comment.id }
|
482
482
|
expect(response).to redirect_to @thread
|
483
483
|
expect(@comment.get_upvotes).to be_empty
|
484
484
|
expect(@comment.get_downvotes.count).to eq 1
|
@@ -487,7 +487,7 @@ module Commontator
|
|
487
487
|
it "won't unvote unless authorized" do
|
488
488
|
expect(@comment.upvote_from(@user)).to eq true
|
489
489
|
|
490
|
-
put :unvote, :id
|
490
|
+
put :unvote, params: { id: @comment.id }
|
491
491
|
expect(response).to have_http_status(:forbidden)
|
492
492
|
@comment.reload
|
493
493
|
expect(@comment.get_upvotes.count).to eq 1
|
@@ -495,7 +495,7 @@ module Commontator
|
|
495
495
|
|
496
496
|
sign_in @user
|
497
497
|
@user.can_read = true
|
498
|
-
put :unvote, :id
|
498
|
+
put :unvote, params: { id: @comment.id }
|
499
499
|
expect(response).to have_http_status(:forbidden)
|
500
500
|
@comment.reload
|
501
501
|
expect(@comment.get_upvotes.count).to eq 1
|
@@ -503,7 +503,7 @@ module Commontator
|
|
503
503
|
|
504
504
|
user2 = DummyUser.create
|
505
505
|
sign_in user2
|
506
|
-
put :unvote, :id
|
506
|
+
put :unvote, params: { id: @comment.id }
|
507
507
|
expect(response).to have_http_status(:forbidden)
|
508
508
|
@comment.reload
|
509
509
|
expect(@comment.get_upvotes.count).to eq 1
|
@@ -516,18 +516,18 @@ module Commontator
|
|
516
516
|
sign_in user2
|
517
517
|
|
518
518
|
expect(@comment.upvote_from(user2)).to eq true
|
519
|
-
put :unvote, :id
|
519
|
+
put :unvote, params: { id: @comment.id }
|
520
520
|
expect(response).to redirect_to @thread
|
521
521
|
expect(assigns(:comment).get_upvotes).to be_empty
|
522
522
|
expect(assigns(:comment).get_downvotes).to be_empty
|
523
523
|
|
524
|
-
put :unvote, :id
|
524
|
+
put :unvote, params: { id: @comment.id }
|
525
525
|
expect(response).to redirect_to @thread
|
526
526
|
expect(assigns(:comment).get_upvotes).to be_empty
|
527
527
|
expect(assigns(:comment).get_downvotes).to be_empty
|
528
528
|
|
529
529
|
expect(@comment.downvote_from(user2)).to eq true
|
530
|
-
put :unvote, :id
|
530
|
+
put :unvote, params: { id: @comment.id }
|
531
531
|
expect(response).to redirect_to @thread
|
532
532
|
expect(assigns(:comment).get_upvotes).to be_empty
|
533
533
|
expect(assigns(:comment).get_downvotes).to be_empty
|
@@ -540,10 +540,9 @@ module Commontator
|
|
540
540
|
@user.can_read = true
|
541
541
|
sign_in @user
|
542
542
|
|
543
|
-
attributes = { :
|
544
|
-
|
545
|
-
|
546
|
-
}.not_to change{ ActionMailer::Base.deliveries.count }
|
543
|
+
attributes = { body: 'Something else' }
|
544
|
+
expect_any_instance_of(ActionMailer::MessageDelivery).not_to receive(:deliver_later)
|
545
|
+
post :create, params: { thread_id: @thread.id, comment: attributes }
|
547
546
|
expect(assigns(:comment).errors).to be_empty
|
548
547
|
end
|
549
548
|
|
@@ -555,10 +554,9 @@ module Commontator
|
|
555
554
|
@user.can_read = true
|
556
555
|
sign_in @user
|
557
556
|
|
558
|
-
attributes = { :
|
559
|
-
|
560
|
-
|
561
|
-
}.to change{ ActionMailer::Base.deliveries.count }.by(1)
|
557
|
+
attributes = { body: 'Something else' }
|
558
|
+
expect_any_instance_of(ActionMailer::MessageDelivery).to receive(:deliver_later)
|
559
|
+
post :create, params: { thread_id: @thread.id, comment: attributes }
|
562
560
|
expect(assigns(:comment).errors).to be_empty
|
563
561
|
end
|
564
562
|
|
@@ -567,9 +565,11 @@ module Commontator
|
|
567
565
|
let!(:other_user) { DummyUser.create }
|
568
566
|
|
569
567
|
let(:attributes) { { body: 'some comment' } }
|
570
|
-
let(:call_request)
|
571
|
-
|
572
|
-
|
568
|
+
let(:call_request) do
|
569
|
+
post :create, params: { thread_id: @thread.id,
|
570
|
+
comment: attributes,
|
571
|
+
mentioned_ids: [user_to_subscribe.id] }
|
572
|
+
end
|
573
573
|
|
574
574
|
before do
|
575
575
|
@user.can_read = true
|
@@ -587,7 +587,8 @@ module Commontator
|
|
587
587
|
end
|
588
588
|
|
589
589
|
it 'does not send subscription emails' do
|
590
|
-
|
590
|
+
expect_any_instance_of(ActionMailer::MessageDelivery).not_to receive(:deliver_later)
|
591
|
+
call_request
|
591
592
|
end
|
592
593
|
end
|
593
594
|
|
@@ -603,10 +604,10 @@ module Commontator
|
|
603
604
|
end
|
604
605
|
|
605
606
|
it 'sends a subscription email' do
|
606
|
-
|
607
|
+
expect_any_instance_of(ActionMailer::MessageDelivery).to receive(:deliver_later)
|
608
|
+
call_request
|
607
609
|
end
|
608
610
|
end
|
609
611
|
end
|
610
612
|
end
|
611
613
|
end
|
612
|
-
|