Skip to content

Commit

Permalink
Replace update_attributes by update in specs
Browse files Browse the repository at this point in the history
Method update_attributes is deprecated and will be removed from Rails
6.1.
  • Loading branch information
saraycp committed May 6, 2020
1 parent 19ec22b commit ce69984
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/api/spec/controllers/status/reports_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
let!(:check) { create(:check, status_report: status_report, name: 'ExampleCI') }

before do
repository.update_attributes!(required_checks: ['openQA'])
repository.update!(required_checks: ['openQA'])
end

subject! { get :show, params: { project_name: project.name, repository_name: repository.name, report_uuid: status_report.uuid }, format: :xml }
Expand All @@ -50,7 +50,7 @@
let!(:check) { create(:check, status_report: status_report, name: 'ExampleCI') }

before do
repository_architecture.update_attributes!(required_checks: ['openQA'])
repository_architecture.update!(required_checks: ['openQA'])
end

subject! do
Expand Down
2 changes: 1 addition & 1 deletion src/api/spec/controllers/webui/request_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@
end

it 'with invalid transition' do
request_with_review.update_attributes(state: 'declined')
request_with_review.update(state: 'declined')
post :modify_review, params: { comment: 'yeah',
review_id: request_with_review.reviews.first,
new_state: 'Approve' }
Expand Down
2 changes: 1 addition & 1 deletion src/api/spec/controllers/webui/session_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
end

it 'updates last_logged_in_at' do
user.update_attributes(last_logged_in_at: nil)
user.update(last_logged_in_at: nil)

get :new
expect(user.reload.last_logged_in_at).to eq(Time.zone.today)
Expand Down
8 changes: 4 additions & 4 deletions src/api/spec/controllers/webui/webui_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ def edit

describe 'GET index as nobody' do
it 'is allowed when Configuration.anonymous is true' do
Configuration.update_attributes(anonymous: true)
Configuration.update(anonymous: true)

get :index
expect(response).to have_http_status(:success)
end

it 'is not allowed when Configuration.anonymous is false' do
Configuration.update_attributes(anonymous: false)
Configuration.update(anonymous: false)

get :index
expect(response).to redirect_to(root_path)
Expand All @@ -47,12 +47,12 @@ def edit
describe 'GET index as a user' do
it 'is always allowed' do
login(create(:confirmed_user))
Configuration.update_attributes(anonymous: true)
Configuration.update(anonymous: true)

get :index
expect(response).to have_http_status(:success)

Configuration.update_attributes(anonymous: false)
Configuration.update(anonymous: false)

get :index
expect(response).to have_http_status(:success)
Expand Down
4 changes: 2 additions & 2 deletions src/api/spec/db/data/regenerate_notifications_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
source_package: another_package,
created_at: 3.days.ago,
updated_at: 2.days.ago)
bs_request_to_decline.update_attributes(state: 'declined')
bs_request_to_decline.update(state: 'declined')
bs_request_to_decline
end
let!(:old_declined_bs_request) do
Expand All @@ -39,7 +39,7 @@
target_package: package,
source_package: another_package,
created_at: 101.days.ago)
bs_request_to_decline.update_attributes(state: 'declined')
bs_request_to_decline.update(state: 'declined')
bs_request_to_decline
end
let!(:revoked_bs_request) { create(:bs_request, type: 'maintenance_release', state: :revoked) } # This shouldn't regenerate notification
Expand Down
2 changes: 1 addition & 1 deletion src/api/spec/decorators/staging/project_decorator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

context 'when the project has a title' do
before do
staging_project.update_attributes(title: 'A')
staging_project.update(title: 'A')
end

it 'returns the title' do
Expand Down
2 changes: 1 addition & 1 deletion src/api/spec/factories/bs_requests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
state = evaluator.state
state ||= :review if evaluator.reviews.present?
if state
request.update_attributes(state: state)
request.update(state: state)
request.reload
end
end
Expand Down
6 changes: 3 additions & 3 deletions src/api/spec/features/webui/requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,11 @@

describe 'shows the correct auto accepted message' do
before do
bs_request.update_attributes(accept_at: Time.now)
bs_request.update(accept_at: Time.now)
end

scenario 'when request is in a final state' do
bs_request.update_attributes(state: :accepted)
bs_request.update(state: :accepted)
visit request_show_path(bs_request)
expect(page).to have_text("Auto-accept was set to #{I18n.localize bs_request.accept_at, format: :only_date}.")
end
Expand All @@ -328,7 +328,7 @@
end

scenario 'when request auto_accept is in the future and not in a final state' do
bs_request.update_attributes(accept_at: Time.now + 1.day)
bs_request.update(accept_at: Time.now + 1.day)
visit request_show_path(bs_request)
expect(page).
to have_text("This request will be automatically accepted in #{ApplicationController.helpers.time_ago_in_words(bs_request.accept_at)}.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@

let(:path) { "#{CONFIG['source_url']}/source/#{another_source_project}/#{another_source_package}?#{params.to_param}" }
before do
request.update_attributes(superseded_by: superseding_request.number, state: :superseded)
request.update(superseded_by: superseding_request.number, state: :superseded)
end

subject! { BsRequestActionWebuiInfosJob.new.perform(superseding_request_action) }
Expand Down
2 changes: 1 addition & 1 deletion src/api/spec/lib/statistics_calculations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def package_result_for(package)

before do
# We need to be able to identify the project
package_3.project.update_attributes!(name: 'my_project')
package_3.project.update!(name: 'my_project')
end

it { expect(subject.length).to eq(2) }
Expand Down
2 changes: 1 addition & 1 deletion src/api/spec/models/download_repository_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
subject(:download_repository) { create(:download_repository) }

it {
expect { download_repository.update_attributes!(arch: 's390x') }.to raise_error(
expect { download_repository.update!(arch: 's390x') }.to raise_error(
ActiveRecord::RecordInvalid, 'Validation failed: Architecture has to be available via repository association'
)
}
Expand Down
16 changes: 8 additions & 8 deletions src/api/spec/models/owner_search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
# the User.owner is only interesting for locked accounts
it 'does not respect User.owner' do
create(:relationship_package_user, package: package, user: user, role: Role.find_by_title('bugowner'))
user.update_attributes(owner: develuser)
user.update(owner: develuser)

subject = OwnerSearch::Container.new(devel: false, filter: 'bugowner').for(package).first
expect(subject.users['bugowner']).to eq([user])
end

it 'respects User.state' do
create(:relationship_package_user, package: package, user: user, role: Role.find_by_title('bugowner'))
user.update_attributes(state: :locked)
user.update(state: :locked)

subject = OwnerSearch::Container.new(devel: false, filter: 'bugowner').for(package)
expect(subject).to eq([])
Expand Down Expand Up @@ -68,7 +68,7 @@

it 'respects User.state' do
create(:relationship_package_user, package: package, user: user, role: Role.find_by_title('bugowner'))
user.update_attributes(state: :locked)
user.update(state: :locked)

subject = OwnerSearch::Missing.new(devel: false, filter: 'bugowner').find.first
expect(subject.rootproject).to eq('home:Iggy')
Expand All @@ -79,12 +79,12 @@

it 'respects User.owner' do
create(:relationship_package_user, package: package, user: user, role: Role.find_by_title('bugowner'))
user.update_attributes(owner: develuser)
user.update(owner: develuser)

subject = OwnerSearch::Missing.new(devel: false, filter: 'bugowner').find
expect(subject).to eq([])

develuser.update_attributes(state: :locked)
develuser.update(state: :locked)

subject = OwnerSearch::Missing.new(devel: false, filter: 'bugowner').find.first
expect(subject.rootproject).to eq('home:Iggy')
Expand All @@ -95,7 +95,7 @@

context 'in maintenance projects' do
let(:project) { Project.find_by(name: 'home:Iggy') }
let!(:project_kind) { project.update_attributes(kind: 'maintenance_release') }
let!(:project_kind) { project.update(kind: 'maintenance_release') }
let(:other_user) { create(:confirmed_user, login: 'hans') }

# A package with bugowner develuser
Expand All @@ -106,7 +106,7 @@
# A local link to package.42 with bugowner other_user
let(:package) { create(:package, name: 'package', project: project) }
# FIXME: package link should be a transitive argument to the package factory
let!(:package_link) { package.build_backend_package.update_attributes(links_to_id: package_42) }
let!(:package_link) { package.build_backend_package.update(links_to_id: package_42) }
let!(:other_bugowner) { create(:relationship_package_user_as_bugowner, user: other_user, package: package) }

# A patchinfo with bugowner maintenance_user
Expand All @@ -130,7 +130,7 @@
context 'with owned user' do
let(:owning) { create(:confirmed_user) }
before do
other_user.update_attributes(owner: owning, state: :subaccount)
other_user.update(owner: owning, state: :subaccount)
end

it 'still returns the owned user as bugowner' do
Expand Down
2 changes: 1 addition & 1 deletion src/api/spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@

describe '.mark_login!' do
before do
user.update_attributes!(login_failure_count: 7, last_logged_in_at: Time.zone.yesterday)
user.update!(login_failure_count: 7, last_logged_in_at: Time.zone.yesterday)
user.mark_login!
end

Expand Down

0 comments on commit ce69984

Please sign in to comment.