commontator 4.10.4 → 4.10.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -3
- data/config/locales/ru.yml +78 -0
- data/lib/commontator/version.rb +1 -1
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +119 -33
- data/spec/dummy/log/test.log +33201 -33045
- data/spec/dummy/tmp/cache/assets/test/sprockets/{02d4b791eb831cf2057bf4703a1218d1 → 72b63dddbc5c995f79af8e3c94904fd9} +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/{c69ee3cc5796188d873574179290a6ef → a473b3873e554893372a53d71f5e9879} +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/{e85565206c3e5fdf9dfeb367c85557b1 → a77b1a9223d168112e1705c29220116f} +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/{a3fb9025f90ff05a6fd4afc7ded2692c → afa63eb365bdf4f42584b17ac9176b9d} +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/{0f196a1a50363b0a076ec6e1ee5417f6 → d2244ccef8e05bb993f75715af0344cc} +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/decb63cac838a5314aa0c22a979f5ac9 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/{e1f674c11941d62aac1764ef3a7134e4 → f721383d531f067d82b071e14aed7a92} +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/2MuTpyqaQLj1O4wgROKGqNe4lXIGrVZDYXCWWWMRmrA.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/4CjNCL1K4fowKckGvL9F3HkCEtCH42rfsn2geU5A1xs.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/CT_fvD-uYyN5f1Kis6kQ7DNUnwtnSVT1sdDKxW1e4hw.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/CjR916jO_S7Mo8eTI1vKieKJoKQ0t-bk4sxhcYYQ5Bw.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/DtzP3rNdkPulzFug4nVQunOws8OXjvPJwB2nNhp9Scs.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/E6KZN1luOC7jAKXFS_xo-XOd5H41vK-eeCsj8MITJHA.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/FmvRMZstlcKHCKy5g4mmAu4vjz-YPScTigFnnvs1v-E.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/HXtFVXhiLFEohXrf9PBX2u9xkPew5yU2IOyxmFCa7fo.cache +2 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/Kg9VuIGtHRNvM4_TXG3EmqpEWzfEY1kQUI1Mx8AHklY.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/Kqg37VotFbWELQyr3-R20M2yWWoiloqBWDWRG-i3m5E.cache +2 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/PeZjQ1KGvso4tt6qvVQZniMzlTlVTWeH-tjln1fERkw.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/SN7TWtuyq1ZblzWxqqcr26s_vanAr5PyZ8q_w8IxIPE.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/VH5BWA_SC2XnIxStJ5vtjX3pNqdbo7uMo9Tg9GVFUGU.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/lzmR_-kjjgHYgaJd_fvBlAimt7_xADtnhEPo_CIBiPM.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/q3giWdNvlLQ39xIHQWPY8vzbfjW9zXkSqwibRQBKcvM.cache +2 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/zpCVMbdGU9JtJWkk95WWomNsxP3Q7jqZmWKJXnsGH0g.cache +2 -0
- data/spec/spec_helper.rb +10 -3
- metadata +100 -171
- data/app/models/commontator/subscription.rb~ +0 -23
- data/lib/commontator/version.rb~ +0 -3
- data/spec/controllers/commontator/comments_controller_spec.rb~ +0 -565
- data/spec/controllers/commontator/subscriptions_controller_spec.rb~ +0 -101
- data/spec/controllers/commontator/threads_controller_spec.rb~ +0 -130
- data/spec/dummy/README.md~ +0 -3
- data/spec/dummy/Rakefile~ +0 -6
- data/spec/dummy/app/assets/javascripts/application.js~ +0 -15
- data/spec/dummy/app/assets/stylesheets/application.css~ +0 -13
- data/spec/dummy/app/controllers/application_controller.rb~ +0 -3
- data/spec/dummy/app/controllers/dummy_models_controller.rb~ +0 -34
- data/spec/dummy/app/helpers/application_helper.rb~ +0 -15
- data/spec/dummy/app/models/dummy_model.rb~ +0 -3
- data/spec/dummy/app/models/dummy_user.rb~ +0 -13
- data/spec/dummy/app/views/dummy_model/show.html.erb~ +0 -1
- data/spec/dummy/app/views/layouts/application.html.erb~ +0 -14
- data/spec/dummy/config.ru~ +0 -4
- data/spec/dummy/config/application.rb~ +0 -26
- data/spec/dummy/config/boot.rb~ +0 -5
- data/spec/dummy/config/database.yml~ +0 -25
- data/spec/dummy/config/environment.rb~ +0 -5
- data/spec/dummy/config/environments/development.rb~ +0 -31
- data/spec/dummy/config/environments/production.rb~ +0 -82
- data/spec/dummy/config/environments/test.rb~ +0 -40
- data/spec/dummy/config/initializers/backtrace_silencers.rb~ +0 -7
- data/spec/dummy/config/initializers/commontator.rb~ +0 -14
- data/spec/dummy/config/initializers/filter_parameter_logging.rb~ +0 -4
- data/spec/dummy/config/initializers/inflections.rb~ +0 -16
- data/spec/dummy/config/initializers/mime_types.rb~ +0 -5
- data/spec/dummy/config/initializers/secret_token.rb~ +0 -12
- data/spec/dummy/config/initializers/session_store.rb~ +0 -3
- data/spec/dummy/config/initializers/wrap_parameters.rb~ +0 -14
- data/spec/dummy/config/routes.rb~ +0 -7
- data/spec/dummy/db/migrate/1_create_dummy_models.rb~ +0 -7
- data/spec/dummy/db/migrate/2_create_dummy_users.rb~ +0 -7
- data/spec/dummy/db/migrate/3_acts_as_votable_migration.rb~ +0 -27
- data/spec/dummy/public/404.html~ +0 -26
- data/spec/dummy/public/422.html~ +0 -26
- data/spec/dummy/public/500.html~ +0 -25
- data/spec/dummy/script/rails~ +0 -6
- data/spec/dummy/tmp/cache/assets/test/sprockets/a41c8be5379abec3c0d0d98e2f0d5609 +0 -0
- data/spec/helpers/commontator/application_helper_spec.rb~ +0 -9
- data/spec/lib/commontator/acts_as_commontable_spec.rb~ +0 -25
- data/spec/lib/commontator/acts_as_commontator_spec.rb~ +0 -52
- data/spec/lib/commontator/commontable_config_spec.rb~ +0 -29
- data/spec/lib/commontator/commontator_config_spec.rb~ +0 -29
- data/spec/lib/commontator/controller_includes_spec.rb~ +0 -18
- data/spec/lib/commontator/shared_helper_spec.rb~ +0 -22
- data/spec/lib/commontator_spec.rb~ +0 -26
- data/spec/mailers/commontator/subscriptions_mailer_spec.rb~ +0 -30
- data/spec/models/commontator/comment_spec.rb~ +0 -82
- data/spec/models/commontator/subscription_spec.rb~ +0 -38
- data/spec/models/commontator/thread_spec.rb~ +0 -122
- data/spec/rails_helper.rb~ +0 -74
- data/spec/spec_helper.rb~ +0 -86
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
module Commontator
|
4
|
-
RSpec.describe CommontableConfig, type: :lib do
|
5
|
-
it 'must respond to commontable attributes' do
|
6
|
-
config = CommontableConfig.new
|
7
|
-
COMMONTABLE_ATTRIBUTES.each do |attribute|
|
8
|
-
expect(config).to respond_to(attribute)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
it "won't respond to engine or commontator attributes" do
|
13
|
-
config = CommontableConfig.new
|
14
|
-
(ENGINE_ATTRIBUTES + COMMONTATOR_ATTRIBUTES).each do |attribute|
|
15
|
-
expect(config).not_to respond_to(attribute)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'must be configurable' do
|
20
|
-
proc = lambda { |thread| 'Some name' }
|
21
|
-
proc2 = lambda { |thread| 'Another name' }
|
22
|
-
config = CommontableConfig.new(:commontable_name_proc => proc)
|
23
|
-
expect(config.commontable_name_proc).to eq proc
|
24
|
-
config = CommontableConfig.new(:commontable_name_proc => proc2)
|
25
|
-
(config.commontable_name_proc == proc2).must_equal true
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
module Commontator
|
4
|
-
RSpec.describe CommontatorConfig, type: :lib do
|
5
|
-
it 'must respond to commontator attributes' do
|
6
|
-
config = CommontatorConfig.new
|
7
|
-
COMMONTATOR_ATTRIBUTES.each do |attribute|
|
8
|
-
config.must_respond_to attribute
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
it "won't respond to engine or commontable attributes" do
|
13
|
-
config = CommontatorConfig.new
|
14
|
-
(ENGINE_ATTRIBUTES + COMMONTABLE_ATTRIBUTES).each do |attribute|
|
15
|
-
expect(config).not_to respond_to(attribute)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'must be configurable' do
|
20
|
-
proc = lambda { |user| 'Some name' }
|
21
|
-
proc2 = lambda { |user| 'Another name' }
|
22
|
-
config = CommontatorConfig.new(:user_name_proc => proc)
|
23
|
-
expect(config.user_name_proc).to eq proc
|
24
|
-
config = CommontatorConfig.new(:user_name_proc => proc2)
|
25
|
-
expect(config.user_name_proc).to eq proc2
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
module Commontator
|
4
|
-
RSpec.describe ControllerIncludes, type: :lib do
|
5
|
-
it 'must add commontator_thread_show to ActionController instances' do
|
6
|
-
expect(ActionController::Base.new.respond_to?(:commontator_thread_show,
|
7
|
-
true)).to eq true
|
8
|
-
expect(DummyModelsController.new.respond_to?(:commontator_thread_show,
|
9
|
-
true)).to eq true
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'must add shared helper to ActionController and subclasses' do
|
13
|
-
expect(ActionController::Base.helpers).to respond_to(:commontator_thread)
|
14
|
-
DummyModelsController.helpers.must_respond_to :commontator_thread
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
module Commontator
|
4
|
-
RSpec.describe SharedHelper, type: :lib do
|
5
|
-
before(:each) do
|
6
|
-
setup_controller_spec
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'must show commontator thread' do
|
10
|
-
@user.can_read = true
|
11
|
-
sign_in @user
|
12
|
-
|
13
|
-
controller = DummyModelsController.new
|
14
|
-
|
15
|
-
thread_link = controller.view_context
|
16
|
-
.commontator_thread(DummyModel.create)
|
17
|
-
expect(thread_link).not_to be_blank
|
18
|
-
puts thread_link
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
module Commontator
|
4
|
-
RSpec.describe Commontator, type: :lib do
|
5
|
-
it 'must respond to all attributes' do
|
6
|
-
(ENGINE_ATTRIBUTES + COMMONTATOR_ATTRIBUTES + \
|
7
|
-
COMMONTABLE_ATTRIBUTES).each do |attribute|
|
8
|
-
expect(Commontator).to respond_to(attribute)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'must be configurable' do
|
13
|
-
l1 = lambda { |controller| controller.current_user }
|
14
|
-
l2 = lambda { |controller| controller.current_user }
|
15
|
-
Commontator.configure do |config|
|
16
|
-
config.current_user_proc = l1
|
17
|
-
end
|
18
|
-
expect(Commontator.current_user_proc).to eq l1
|
19
|
-
Commontator.configure do |config|
|
20
|
-
config.current_user_proc = l2
|
21
|
-
end
|
22
|
-
assert_equal(Commontator.current_user_proc, l2)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
module Commontator
|
4
|
-
RSpec.describe SubscriptionsMailer, type: :mailer do
|
5
|
-
before(:each) do
|
6
|
-
setup_mailer_spec
|
7
|
-
@user2 = DummyUser.create
|
8
|
-
@thread.subscribe(@user)
|
9
|
-
@thread.subscribe(@user2)
|
10
|
-
@comment = Comment.new
|
11
|
-
@comment.thread = @thread
|
12
|
-
@comment.creator = @user
|
13
|
-
@comment.body = 'Something'
|
14
|
-
@comment.save!
|
15
|
-
@recipients = @thread.subscribers.reject{|s| s == @user}
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'must create deliverable mail' do
|
19
|
-
mail = SubscriptionsMailer.comment_created(@comment, @recipients)
|
20
|
-
expect(mail.to).to eq I18n.t('commontator.email.undisclosed_recipients')
|
21
|
-
expect(mail.cc).to be_nil
|
22
|
-
expect(mail.bcc.size).to eq 1
|
23
|
-
expect(mail.bcc).to include(@user2.email)
|
24
|
-
expect(mail.subject).not_to be_empty
|
25
|
-
expect(mail.body).not_to be_empty
|
26
|
-
expect(mail.deliver).to eq mail
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
@@ -1,82 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
require 'acts_as_votable'
|
3
|
-
|
4
|
-
module Commontator
|
5
|
-
RSpec.describe Comment, type: :model do
|
6
|
-
before(:each) do
|
7
|
-
setup_model_spec
|
8
|
-
@comment = Comment.new
|
9
|
-
@comment.thread = @thread
|
10
|
-
@comment.creator = @user
|
11
|
-
@comment.body = 'Something'
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'must be votable if acts_as_votable is installed' do
|
15
|
-
Comment.must_respond_to(:acts_as_votable)
|
16
|
-
expect(@comment.is_votable?).to eq true
|
17
|
-
expect(@comment.acts_as_votable_initialized).to eq true
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'must know if it has been modified' do
|
21
|
-
@comment.save!
|
22
|
-
|
23
|
-
expect(@comment.is_modified?).to eq false
|
24
|
-
|
25
|
-
@comment.body = 'Something else'
|
26
|
-
@comment.editor = @user
|
27
|
-
@comment.save!
|
28
|
-
|
29
|
-
expect(@comment.is_modified?).to eq true
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'must know if it has been deleted' do
|
33
|
-
user = DummyUser.new
|
34
|
-
|
35
|
-
expect(@comment.is_deleted?).to eq false
|
36
|
-
expect(@comment.editor).to be_nil
|
37
|
-
|
38
|
-
@comment.delete_by(user)
|
39
|
-
|
40
|
-
expect(@comment.is_deleted?).to eq true
|
41
|
-
expect(@comment.editor).to eq user
|
42
|
-
|
43
|
-
@comment.undelete_by(user)
|
44
|
-
|
45
|
-
expect(@comment.is_deleted?).to eq false
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'must make proper timestamps' do
|
49
|
-
@comment.save!
|
50
|
-
|
51
|
-
expect(@comment.created_timestamp).to eq(
|
52
|
-
I18n.t('commontator.comment.status.created_at',
|
53
|
-
:created_at => I18n.l(@comment.created_at,
|
54
|
-
:format => :commontator))
|
55
|
-
)
|
56
|
-
expect(@comment.updated_timestamp).to eq(
|
57
|
-
I18n.t('commontator.comment.status.updated_at',
|
58
|
-
:editor_name => @user.name,
|
59
|
-
:updated_at => I18n.l(@comment.updated_at,
|
60
|
-
:format => :commontator))
|
61
|
-
)
|
62
|
-
|
63
|
-
user2 = DummyUser.create
|
64
|
-
@comment.body = 'Something else'
|
65
|
-
@comment.editor = user2
|
66
|
-
@comment.save!
|
67
|
-
|
68
|
-
expect(@comment.created_timestamp).to eq(
|
69
|
-
I18n.t('commontator.comment.status.created_at',
|
70
|
-
:created_at => I18n.l(@comment.created_at,
|
71
|
-
:format => :commontator))
|
72
|
-
)
|
73
|
-
expect(@comment.updated_timestamp).to eq(
|
74
|
-
I18n.t('commontator.comment.status.updated_at',
|
75
|
-
:editor_name => user2.name,
|
76
|
-
:updated_at => I18n.l(@comment.updated_at,
|
77
|
-
:format => :commontator))
|
78
|
-
)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
module Commontator
|
4
|
-
RSpec.describe Subscription, type: :model do
|
5
|
-
before(:each) do
|
6
|
-
setup_model_spec
|
7
|
-
@subscription = Subscription.new
|
8
|
-
@subscription.thread = @thread
|
9
|
-
@subscription.subscriber = @user
|
10
|
-
@subscription.save!
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'must count unread comments' do
|
14
|
-
expect(@subscription.unread_comments.count).to eq 0
|
15
|
-
|
16
|
-
comment = Comment.new
|
17
|
-
comment.thread = @thread
|
18
|
-
comment.creator = @user
|
19
|
-
comment.body = 'Something'
|
20
|
-
comment.save!
|
21
|
-
|
22
|
-
expect(@subscription.reload.unread_comments.count).to eq 1
|
23
|
-
|
24
|
-
comment = Comment.new
|
25
|
-
comment.thread = @thread
|
26
|
-
comment.creator = @user
|
27
|
-
comment.body = 'Something else'
|
28
|
-
comment.save!
|
29
|
-
|
30
|
-
expect(@subscription.reload.unread_comments.count).to eq 2
|
31
|
-
|
32
|
-
@subscription.touch
|
33
|
-
|
34
|
-
expect(@subscription.reload.unread_comments.count).to eq 0
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
@@ -1,122 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
module Commontator
|
4
|
-
RSpec.describe Thread, type: :model do
|
5
|
-
before(:each) do
|
6
|
-
setup_model_spec
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'must have a config' do
|
10
|
-
expect(@thread.config).to be_a(CommontableConfig)
|
11
|
-
@thread.update_attribute(:commontable_id, nil)
|
12
|
-
expect(Thread.find(@thread.id).config).to eq Commontator
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'must order all comments' do
|
16
|
-
comment = Comment.new
|
17
|
-
comment.thread = @thread
|
18
|
-
comment.creator = @user
|
19
|
-
comment.body = 'Something'
|
20
|
-
comment.save!
|
21
|
-
comment2 = Comment.new
|
22
|
-
comment2.thread = @thread
|
23
|
-
comment2.creator = @user
|
24
|
-
comment2.body = 'Something else'
|
25
|
-
comment2.save!
|
26
|
-
|
27
|
-
comments = @thread.comments
|
28
|
-
ordered_comments = @thread.ordered_comments
|
29
|
-
|
30
|
-
comments.each { |c| expect(ordered_comments).to include(c) }
|
31
|
-
ordered_comments.each { |oc| expect(comments).to include(oc) }
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'must list all subscribers' do
|
35
|
-
@thread.subscribe(@user)
|
36
|
-
@thread.subscribe(DummyUser.create)
|
37
|
-
|
38
|
-
@thread.subscriptions.each do |sp|
|
39
|
-
expect(@thread.subscribers).to include(sp.subscriber)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'must find the subscription for each user' do
|
44
|
-
@thread.subscribe(@user)
|
45
|
-
user2 = DummyUser.create
|
46
|
-
@thread.subscribe(user2)
|
47
|
-
|
48
|
-
subscription = @thread.subscription_for(@user)
|
49
|
-
expect(subscription.thread).to eq @thread
|
50
|
-
expect(subscription.subscriber).to eq @user
|
51
|
-
subscription = @thread.subscription_for(user2)
|
52
|
-
expect(subscription.thread).to eq @thread
|
53
|
-
expect(subscription.subscriber).to eq user2
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'must know if it is closed' do
|
57
|
-
expect(@thread.is_closed?).to eq false
|
58
|
-
|
59
|
-
@thread.close(@user)
|
60
|
-
|
61
|
-
expect(@thread.is_closed?).to eq true
|
62
|
-
expect(@thread.closer).to eq @user
|
63
|
-
|
64
|
-
@thread.reopen
|
65
|
-
|
66
|
-
expect(@thread.is_closed?).to eq false
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'must mark comments as read' do
|
70
|
-
@thread.subscribe(@user)
|
71
|
-
|
72
|
-
subscription = @thread.subscription_for(@user)
|
73
|
-
expect(subscription.unread_comments.count).to eq 0
|
74
|
-
|
75
|
-
comment = Comment.new
|
76
|
-
comment.thread = @thread
|
77
|
-
comment.creator = @user
|
78
|
-
comment.body = 'Something'
|
79
|
-
comment.save!
|
80
|
-
|
81
|
-
expect(subscription.reload.unread_comments.count).to eq 1
|
82
|
-
|
83
|
-
@thread.mark_as_read_for(@user)
|
84
|
-
|
85
|
-
expect(subscription.reload.unread_comments.count).to eq 0
|
86
|
-
end
|
87
|
-
|
88
|
-
it 'must be able to clear comments' do
|
89
|
-
comment = Comment.new
|
90
|
-
comment.thread = @thread
|
91
|
-
comment.creator = @user
|
92
|
-
comment.body = 'Something'
|
93
|
-
comment.save!
|
94
|
-
|
95
|
-
@thread.close(@user)
|
96
|
-
|
97
|
-
expect(@thread.commontable).to eq @commontable
|
98
|
-
expect(@thread.comments).to include(comment)
|
99
|
-
expect(@thread.is_closed?).to eq true
|
100
|
-
expect(@thread.closer).to eq @user
|
101
|
-
|
102
|
-
@commontable = DummyModel.find(@commontable.id)
|
103
|
-
expect(@commontable.thread).to eq @thread
|
104
|
-
|
105
|
-
@thread.clear
|
106
|
-
|
107
|
-
expect(@thread.commontable).to be_nil
|
108
|
-
expect(@thread.comments).to include(comment)
|
109
|
-
|
110
|
-
@commontable = DummyModel.find(@commontable.id)
|
111
|
-
expect(@commontable.thread).to be_nil
|
112
|
-
expect(@commontable.thread).not_to eq @thread
|
113
|
-
expect(@commontable.thread.comments).not_to include(comment)
|
114
|
-
end
|
115
|
-
|
116
|
-
it 'must return nil subscription for nil or false subscriber' do
|
117
|
-
expect(@thread.subscription_for(nil)).to eq nil
|
118
|
-
expect(@thread.subscription_for(false)).to eq nil
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
data/spec/rails_helper.rb~
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
-
ENV["RAILS_ENV"] ||= 'test'
|
3
|
-
require 'spec_helper'
|
4
|
-
require File.expand_path("../dummy/config/environment", __FILE__)
|
5
|
-
require 'rspec/rails'
|
6
|
-
# Add additional requires below this line. Rails is not loaded until this point!
|
7
|
-
|
8
|
-
# Requires supporting ruby files with custom matchers and macros, etc, in
|
9
|
-
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
10
|
-
# run as spec files by default. This means that files in spec/support that end
|
11
|
-
# in _spec.rb will both be required and run as specs, causing the specs to be
|
12
|
-
# run twice. It is recommended that you do not name files matching this glob to
|
13
|
-
# end with _spec.rb. You can configure this pattern with the --pattern
|
14
|
-
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
|
15
|
-
#
|
16
|
-
# The following line is provided for convenience purposes. It has the downside
|
17
|
-
# of increasing the boot-up time by auto-requiring all files in the support
|
18
|
-
# directory. Alternatively, in the individual `*_spec.rb` files, manually
|
19
|
-
# require only the support files necessary.
|
20
|
-
#
|
21
|
-
# Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
|
22
|
-
|
23
|
-
# Checks for pending migrations before tests are run.
|
24
|
-
# If you are not using ActiveRecord, you can remove this line.
|
25
|
-
ActiveRecord::Migration.maintain_test_schema!
|
26
|
-
|
27
|
-
RSpec.configure do |config|
|
28
|
-
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
29
|
-
# config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
30
|
-
|
31
|
-
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
32
|
-
# examples within a transaction, remove the following line or assign false
|
33
|
-
# instead of true.
|
34
|
-
config.use_transactional_fixtures = true
|
35
|
-
|
36
|
-
# RSpec Rails can automatically mix in different behaviours to your tests
|
37
|
-
# based on their file location, for example enabling you to call `get` and
|
38
|
-
# `post` in specs under `spec/controllers`.
|
39
|
-
#
|
40
|
-
# You can disable this behaviour by removing the line below, and instead
|
41
|
-
# explicitly tag your specs with their type, e.g.:
|
42
|
-
#
|
43
|
-
# RSpec.describe UsersController, :type => :controller do
|
44
|
-
# # ...
|
45
|
-
# end
|
46
|
-
#
|
47
|
-
# The different available types are documented in the features, such as in
|
48
|
-
# https://relishapp.com/rspec/rspec-rails/docs
|
49
|
-
config.infer_spec_type_from_file_location!
|
50
|
-
end
|
51
|
-
|
52
|
-
Commontator::ApplicationController.class_eval do
|
53
|
-
include ApplicationHelper
|
54
|
-
end
|
55
|
-
|
56
|
-
def setup_model_spec
|
57
|
-
@user = DummyUser.create
|
58
|
-
@commontable = DummyModel.create
|
59
|
-
@thread = @commontable.thread
|
60
|
-
end
|
61
|
-
|
62
|
-
def setup_controller_spec
|
63
|
-
class_eval {include ApplicationHelper}
|
64
|
-
sign_out
|
65
|
-
setup_model_spec
|
66
|
-
end
|
67
|
-
|
68
|
-
def setup_helper_spec
|
69
|
-
end
|
70
|
-
|
71
|
-
def setup_mailer_spec
|
72
|
-
setup_model_spec
|
73
|
-
end
|
74
|
-
|