Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails 6.1 - Replace deprecated update_attributes method with update on comment_spec/comment #398

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def remove_upvote!(voter)
end

def soft_destroy
update_attributes is_deleted: true, body: 'This comment has been deleted'
update is_deleted: true, body: 'This comment has been deleted'
mentions.destroy_all
group_mentions.destroy_all
tags.destroy_all
Expand Down
10 changes: 5 additions & 5 deletions spec/models/comment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -464,14 +464,14 @@ def mention(subject)

describe '#update_tags' do
let(:comment){ create :comment, body: '#tag1 not#atag #Tag' }
before(:each){ comment.update_attributes body: '#TAG1' }
before(:each){ comment.update body: '#TAG1' }

it 'should maintain case' do
expect(comment.reload.tags.first.name).to eql 'tag1'
end

context 'when removing' do
before(:each){ comment.update_attributes body: '#tag1' }
before(:each){ comment.update body: '#tag1' }

it 'should destroy removed tags on update' do
expect(comment.reload.tags.where(name: 'tag').exists?).to be false
Expand All @@ -484,7 +484,7 @@ def mention(subject)

context 'when adding' do
let(:subject2){ create :subject }
before(:each){ comment.update_attributes body: '#tag #newtag' }
before(:each){ comment.update body: '#tag #newtag' }

it 'should create added tags on update' do
expect(comment.reload.tags.where(name: 'newtag').exists?).to be true
Expand Down Expand Up @@ -540,7 +540,7 @@ def mention(subject)

context 'when preference is disabled' do
before(:each) do
commenting_user.preference_for(:participating_discussions).update_attributes enabled: false
commenting_user.preference_for(:participating_discussions).update enabled: false
end

it 'should not subscribe the user' do
Expand Down Expand Up @@ -570,7 +570,7 @@ def mention(subject)
before(:each) do
participating_users.each{ |user| user.subscribe_to discussion, :participating_discussions }
following_user.subscribe_to discussion, :followed_discussions
unsubscribed_user.preference_for(:participating_discussions).update_attributes enabled: false
unsubscribed_user.preference_for(:participating_discussions).update enabled: false
end

it 'should create notifications for subscribed users' do
Expand Down
2 changes: 1 addition & 1 deletion spec/policies/comment_policy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@

context 'with a locked discussion' do
let(:user){ create :user }
before(:each){ record.discussion.update_attributes locked: true }
before(:each){ record.discussion.update locked: true }
it_behaves_like 'a policy permitting', :index, :show, :upvote, :remove_upvote
it_behaves_like 'a policy forbidding', :create, :update, :destroy, :move

Expand Down
Loading