👋 update_attributes

You served us well...
This commit is contained in:
Henne Vogelsang 2022-02-14 17:53:58 +01:00
parent ca80b753e7
commit 85dae98a76
No known key found for this signature in database
GPG key ID: 97DDB66BDAF8D4D6
46 changed files with 109 additions and 109 deletions

View file

@ -17,7 +17,7 @@ describe Admin::VersionsController do
end
it 'reverts all changes for update actions' do
conference.update_attributes(short_title: 'testtitle', description: 'Some random text')
conference.update(short_title: 'testtitle', description: 'Some random text')
get :revert_object, params: { id: conference.versions.last.id }
conference.reload
expect(conference.short_title).to eq 'exampletitle'
@ -62,7 +62,7 @@ describe Admin::VersionsController do
end
it 'reverts specified change for update actions' do
conference.update_attributes(short_title: 'testtitle', description: 'Some random text')
conference.update(short_title: 'testtitle', description: 'Some random text')
get :revert_attribute, params: { id: conference.versions.last.id, attribute: 'short_title' }
conference.reload
expect(conference.short_title).to eq 'exampletitle'
@ -70,8 +70,8 @@ describe Admin::VersionsController do
end
it 'shows correct flash on trying to revert to the current state' do
conference.update_attributes(short_title: 'testtitle', description: 'Some random text')
conference.update_attributes(short_title: 'exampletitle')
conference.update(short_title: 'testtitle', description: 'Some random text')
conference.update_attribute(:short_title, 'exampletitle')
get :revert_attribute, params: { id: conference.versions[-2].id, attribute: 'short_title' }
expect(flash[:error]).to match('The item is already in the state that you are trying to revert it back to')
expect(conference.short_title).to eq 'exampletitle'
@ -79,7 +79,7 @@ describe Admin::VersionsController do
it 'fails on trying to revert deleted object' do
event_type = conference.program.event_types.first
event_type.update_attributes(title: 'New Event Title')
event_type.update_attribute(:title, 'New Event Title')
event_type.destroy
get :revert_attribute, params: { id: event_type.versions[-2].id, attribute: 'title' }
conference.reload
@ -93,7 +93,7 @@ describe Admin::VersionsController do
end
it 'revert fails when attribute is invalid' do
conference.update_attributes(short_title: 'testtitle', description: 'Some random text')
conference.update(short_title: 'testtitle', description: 'Some random text')
before_conference_title = conference.title
# Note: even though title is a valid attribute of conference, it was not updated in the change we are trying to revert
get :revert_attribute, params: { id: conference.versions.last.id, attribute: 'title' }
@ -117,12 +117,12 @@ describe Admin::VersionsController do
before :each do
@user = create(:user)
conference.update_attributes(short_title: 'testtitle', description: 'Some random text')
conference.update(short_title: 'testtitle', description: 'Some random text')
@version_organizer = conference.versions.last
cfp = create(:cfp, program: conference.program)
@version_cfp = cfp.versions.last
registration = create(:registration, conference: conference)
registration.update_attributes(attended: true)
registration.update_attribute(:attended, true)
@version_info_desk = registration.versions.last
end

View file

@ -316,7 +316,7 @@ describe ConferenceRegistrationsController, type: :controller do
context 'update fails' do
before do
allow_any_instance_of(Registration).to receive(:update_attributes).and_return(false)
allow_any_instance_of(Registration).to receive(:update).and_return(false)
patch :update, params: {
registration: attributes_for(:registration, volunteer: true),
conference_id: conference.short_title

View file

@ -415,7 +415,7 @@ describe ProposalsController do
end
describe 'PATCH #confirm' do
before { event.update_attributes(state: 'unconfirmed') }
before { event.update_attribute(:state, 'unconfirmed') }
context 'confirmed successfully' do
describe 'when require_registration is set' do
@ -501,7 +501,7 @@ describe ProposalsController do
context 'event save fails' do
before do
event.update_attributes(state: 'unconfirmed')
event.update_attribute(:state, 'unconfirmed')
allow_any_instance_of(Event).to receive(:save).and_return(false)
patch :confirm, params: { conference_id: conference.short_title, id: event.id }
end
@ -521,7 +521,7 @@ describe ProposalsController do
end
describe 'PATCH #restart' do
before { event.update_attributes(state: 'withdrawn') }
before { event.update_attribute(:state, 'withdrawn') }
it 'assigns url variable' do
patch :restart, params: { conference_id: conference.short_title, id: event.id }

View file

@ -33,7 +33,7 @@ FactoryBot.define do
# Contact/Program is created by Conference callbacks
conference.contact.destroy
conference.contact = create(:contact, conference: conference)
conference.program.update_attributes(schedule_public: true)
conference.program.update_attribute(:schedule_public, true)
create(:cfp, program: conference.program)
create_list(:track, 2, program: conference.program)

View file

@ -35,7 +35,7 @@ feature 'Version' do
end
scenario 'display changes in cfp', feature: true, versioning: true, js: true do
cfp.update_attributes(start_date: (Time.zone.today + 1).strftime('%d/%m/%Y'), end_date: (Time.zone.today + 3).strftime('%d/%m/%Y'))
cfp.update(start_date: (Time.zone.today + 1).strftime('%d/%m/%Y'), end_date: (Time.zone.today + 3).strftime('%d/%m/%Y'))
cfp_id = cfp.id
cfp.destroy
@ -47,7 +47,7 @@ feature 'Version' do
scenario 'display changes in registration_period', feature: true, versioning: true, js: true do
registration_period = create(:registration_period, conference: conference)
registration_period.update_attributes(start_date: (Time.zone.today + 1).strftime('%d/%m/%Y'), end_date: (Time.zone.today + 3).strftime('%d/%m/%Y'))
registration_period.update(start_date: (Time.zone.today + 1).strftime('%d/%m/%Y'), end_date: (Time.zone.today + 3).strftime('%d/%m/%Y'))
registration_period_id = registration_period.id
registration_period.destroy
@ -60,7 +60,7 @@ feature 'Version' do
scenario 'display changes in conference', feature: true, versioning: true, js: true do
new_conference = create(:conference, title: 'Test Conference')
organizer.add_role :organizer, new_conference
new_conference.update_attributes(title: 'New Con', short_title: 'NewCon')
new_conference.update(title: 'New Con', short_title: 'NewCon')
visit admin_revision_history_path
select '100', from: 'versionstable_length'
@ -72,7 +72,7 @@ feature 'Version' do
scenario 'display changes in event_type', feature: true, versioning: true, js: true do
event_type = create(:event_type, program: conference.program, name: 'Discussion')
event_type.update_attributes(length: 90, maximum_abstract_length: 10000)
event_type.update(length: 90, maximum_abstract_length: 10000)
event_type_id = event_type.id
event_type.destroy
@ -84,7 +84,7 @@ feature 'Version' do
scenario 'display changes in lodging', feature: true, versioning: true, js: true do
lodging = create(:lodging, conference: conference, name: 'Hotel XYZ')
lodging.update_attributes(description: 'Nice view,close to venue', website_link: 'http://www.example.com')
lodging.update(description: 'Nice view,close to venue', website_link: 'http://www.example.com')
lodging_id = lodging.id
lodging.destroy
@ -106,7 +106,7 @@ feature 'Version' do
scenario 'display changes in room', feature: true, versioning: true, js: true do
venue = create(:venue, conference: conference)
room = create(:room, venue: venue, name: 'Auditorium')
room.update_attributes(size: 120)
room.update_attribute(:size, 120)
room_id = room.id
room.destroy
@ -119,7 +119,7 @@ feature 'Version' do
scenario 'display changes in sponsor', feature: true, versioning: true, js: true do
conference.sponsorship_levels << create_list(:sponsorship_level, 2, conference: conference)
sponsor = create(:sponsor, conference: conference, name: 'SUSE', sponsorship_level: conference.sponsorship_levels.first)
sponsor.update_attributes(website_url: 'https://www.suse.com/company/history', sponsorship_level: conference.sponsorship_levels.second)
sponsor.update(website_url: 'https://www.suse.com/company/history', sponsorship_level: conference.sponsorship_levels.second)
sponsor.destroy
sponsor_id = sponsor.id
@ -131,7 +131,7 @@ feature 'Version' do
scenario 'display changes in sponsorship_level', feature: true, versioning: true, js: true do
sponsorship_level = create(:sponsorship_level, conference: conference)
sponsorship_level.update_attributes(title: 'Gold')
sponsorship_level.update_attribute(:title, 'Gold')
sponsorship_level_id = sponsorship_level.id
sponsorship_level.destroy
@ -143,7 +143,7 @@ feature 'Version' do
scenario 'display changes in ticket', feature: true, versioning: true, js: true do
ticket = create(:ticket, conference: conference, title: 'Gold')
ticket.update_attributes(price: 50, description: 'Premium Ticket')
ticket.update(price: 50, description: 'Premium Ticket')
ticket_id = ticket.id
ticket.destroy
@ -155,7 +155,7 @@ feature 'Version' do
scenario 'display changes in track', feature: true, versioning: true, js: true do
track = create(:track, program: conference.program, name: 'Distribution')
track.update_attributes(description: 'Events about Linux distributions')
track.update_attribute(:description, 'Events about Linux distributions')
track_id = track.id
track.destroy
@ -167,7 +167,7 @@ feature 'Version' do
scenario 'display changes in venue', feature: true, versioning: true, js: true do
venue = create(:venue, conference: conference, name: 'Example University')
venue.update_attributes(website: 'www.example.com new', description: 'Just another beautiful venue')
venue.update(website: 'www.example.com new', description: 'Just another beautiful venue')
venue_id = venue.id
venue.destroy
@ -221,7 +221,7 @@ feature 'Version' do
scenario 'display changes in difficulty levels', feature: true, versioning: true, js: true do
difficulty_level = create(:difficulty_level, program: conference.program, title: 'Expert')
difficulty_level.update_attributes(description: 'Only for Experts')
difficulty_level.update_attribute(:description, 'Only for Experts')
difficulty_level_id = difficulty_level.id
difficulty_level.destroy
@ -273,7 +273,7 @@ feature 'Version' do
scenario 'display changes in conference commercials', feature: true, versioning: true, js: true do
conference_commercial = create(:conference_commercial, commercialable: conference)
conference_commercial.update_attributes(url: 'https://www.youtube.com/watch?v=VNkDJk5_9eU')
conference_commercial.update_attribute(:url, 'https://www.youtube.com/watch?v=VNkDJk5_9eU')
conference_commercial.destroy
visit admin_revision_history_path
@ -284,7 +284,7 @@ feature 'Version' do
scenario 'display changes in event commercials', feature: true, versioning: true, js: true do
event_commercial
event_commercial.update_attributes(url: 'https://www.youtube.com/watch?v=VNkDJk5_9eU')
event_commercial.update_attribute(:url, 'https://www.youtube.com/watch?v=VNkDJk5_9eU')
event_commercial.destroy
visit admin_revision_history_path
@ -354,7 +354,7 @@ feature 'Version' do
end
scenario 'display changes in email settings', feature: true, versioning: true, js: true do
conference.email_settings.update_attributes(registration_subject: 'xxxxx', registration_body: 'yyyyy', accepted_subject: 'zzzzz')
conference.email_settings.update(registration_subject: 'xxxxx', registration_body: 'yyyyy', accepted_subject: 'zzzzz')
visit admin_revision_history_path
expect(page).to have_text("Someone (probably via the console) updated registration body, registration subject and accepted subject of email settings in conference #{conference.short_title}")
@ -374,7 +374,7 @@ feature 'Version' do
registration = Registration.create(user: organizer, conference: conference)
event = create(:event, program: conference.program, title: 'My second event')
EventsRegistration.create(registration: registration, event: event)
EventsRegistration.first.update_attributes(attended: true)
EventsRegistration.first.update_attribute(:attended, true)
EventsRegistration.last.destroy
# Here registration is deleted to ensure the event registration related change still displays the associated user's name
registration.destroy
@ -433,7 +433,7 @@ feature 'Version' do
scenario 'display updates to user', feature: true, versioning: true, js: true do
user = create(:user)
user.update_attributes(nickname: 'testnick', affiliation: 'openSUSE')
user.update(nickname: 'testnick', affiliation: 'openSUSE')
visit admin_revision_history_path
expect(page).to have_text("Someone (probably via the console) updated nickname and affiliation of user #{user.name}")

View file

@ -29,7 +29,7 @@ describe ApplicationHelper, type: :helper do
before :each do
@other_event = create(:event, program: conference.program, state: 'confirmed')
schedule = create(:schedule, program: conference.program)
conference.program.update_attributes!(selected_schedule: schedule)
conference.program.update_attribute(:selected_schedule, schedule)
@event_schedule = create(:event_schedule, event: event, start_time: conference.start_date + conference.start_hour.hours, room: create(:room), schedule: schedule)
@other_event_schedule = create(:event_schedule, event: @other_event, start_time: conference.start_date + conference.start_hour.hours, room: create(:room), schedule: schedule)
end
@ -40,7 +40,7 @@ describe ApplicationHelper, type: :helper do
end
it 'when event is in between the other event' do
@event_schedule.update_attributes!(start_time: @other_event_schedule.start_time + 10.minutes)
@event_schedule.update_attribute(:start_time, @other_event_schedule.start_time + 10.minutes)
expect(concurrent_events(event).include?(@other_event)).to eq true
end
end
@ -52,12 +52,12 @@ describe ApplicationHelper, type: :helper do
end
it 'when one event starts and other ends at the same time' do
@event_schedule.update_attributes!(start_time: @other_event_schedule.end_time)
@event_schedule.update_attribute(:start_time, @other_event_schedule.end_time)
expect(concurrent_events(event).present?).to eq false
end
it 'when conference program does not have a selected schedule' do
conference.program.update_attributes!(selected_schedule_id: nil)
conference.program.update_attribute(:selected_schedule_id, nil)
expect(concurrent_events(event).present?).to eq false
end
end
@ -83,7 +83,7 @@ describe ApplicationHelper, type: :helper do
context 'first sponsorship_level' do
before do
first_sponsorship_level = create(:sponsorship_level, position: 1)
sponsor.update_attributes(sponsorship_level: first_sponsorship_level)
sponsor.update_attribute(:sponsorship_level, first_sponsorship_level)
end
it 'returns correct url' do
@ -94,7 +94,7 @@ describe ApplicationHelper, type: :helper do
context 'second sponsorship_level' do
before do
second_sponsorship_level = create(:sponsorship_level, position: 2)
sponsor.update_attributes(sponsorship_level: second_sponsorship_level)
sponsor.update_attribute(:sponsorship_level, second_sponsorship_level)
end
it 'returns correct url' do
@ -105,7 +105,7 @@ describe ApplicationHelper, type: :helper do
context 'other sponsorship_level' do
before do
other_sponsorship_level = create(:sponsorship_level, position: 3)
sponsor.update_attributes(sponsorship_level: other_sponsorship_level)
sponsor.update_attribute(:sponsorship_level, other_sponsorship_level)
end
it 'returns correct url' do

View file

@ -7,7 +7,7 @@ describe Mailbot do
let!(:email_settings) { create(:email_settings, conference: conference) }
let(:user) { create(:user, email: 'user@example.com') }
before { conference.contact.update_attributes(email: 'conf@domain.com') }
before { conference.contact.update_attribute(:email, 'conf@domain.com') }
context 'onboarding and proposal' do
let(:event) { create(:event, program: conference.program, submitter: user) }
@ -39,9 +39,9 @@ describe Mailbot do
describe '.acceptance_mail' do
before do
conference.email_settings.update_attributes(send_on_accepted: true,
accepted_subject: 'Lorem Ipsum Dolsum',
accepted_body: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit')
conference.email_settings.update(send_on_accepted: true,
accepted_subject: 'Lorem Ipsum Dolsum',
accepted_body: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit')
end
include_examples 'mailer actions' do
@ -51,9 +51,9 @@ describe Mailbot do
describe '.rejection_mail' do
before do
conference.email_settings.update_attributes(send_on_rejected: true,
rejected_subject: 'Lorem Ipsum Dolsum',
rejected_body: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit')
conference.email_settings.update(send_on_rejected: true,
rejected_subject: 'Lorem Ipsum Dolsum',
rejected_body: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit')
end
include_examples 'mailer actions' do
@ -63,9 +63,9 @@ describe Mailbot do
describe '.confirm_reminder_mail' do
before do
conference.email_settings.update_attributes(send_on_confirmed_without_registration: true,
confirmed_without_registration_subject: 'Lorem Ipsum Dolsum',
confirmed_without_registration_body: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit')
conference.email_settings.update(send_on_confirmed_without_registration: true,
confirmed_without_registration_subject: 'Lorem Ipsum Dolsum',
confirmed_without_registration_body: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit')
end
include_examples 'mailer actions' do

View file

@ -32,7 +32,7 @@ describe EmailSettings do
context 'user does not have name' do
before do
user.update_attributes(name: nil)
user.update(name: nil)
username_hash = { 'name' => 'johnd' }
expected_hash.merge!(username_hash)
end
@ -59,7 +59,7 @@ describe EmailSettings do
context 'conference has venue' do
before do
conference.update_attributes(venue: create(:venue))
conference.venue = create(:venue)
venue_hash = { 'venue' => conference.venue.name, 'venue_address' => conference.venue.address }
expected_hash.merge!(venue_hash)
end
@ -71,9 +71,9 @@ describe EmailSettings do
context 'conference has registration period' do
before do
conference.update_attributes(registration_period: create(:registration_period,
start_date: Date.new(2014, 05, 03),
end_date: Date.new(2014, 05, 05)))
conference.registration_period = create(:registration_period,
start_date: Date.new(2014, 05, 03),
end_date: Date.new(2014, 05, 05))
registration_period_hash = { 'registration_start_date' => Date.new(2014, 05, 03), 'registration_end_date' => Date.new(2014, 05, 05) }
expected_hash.merge!(registration_period_hash)
end

View file

@ -192,8 +192,8 @@ describe Program do
program.schedule_interval = 5
program.save!
program.event_types.first.update_attributes length: 5
program.event_types.last.update_attributes length: 25
program.event_types.first.update_attribute(:length, 5)
program.event_types.last.update_attribute(:length, 25)
create(:event_type, program: program, length: 30)
program.schedule_interval = 10

View file

@ -84,7 +84,7 @@ describe Ticket do
end
context 'user has paid' do
before { ticket_purchase.update_attributes(paid: true) }
before { ticket_purchase.update_attribute(:paid, true) }
it 'returns false' do
expect(ticket.unpaid?(user)).to eq(false)
@ -120,7 +120,7 @@ describe Ticket do
context 'user has paid' do
let!(:ticket_purchase) { create(:ticket_purchase, user: user, ticket: ticket, quantity: 20) }
before { ticket_purchase.update_attributes(paid: true) }
before { ticket_purchase.update_attribute(:paid, true) }
it 'returns the correct value if the user has bought and paid for this ticket' do
expect(ticket.quantity_bought_by(user, paid: true)).to eq(20)
@ -145,7 +145,7 @@ describe Ticket do
context 'user has paid' do
let!(:ticket_purchase) { create(:ticket_purchase, user: user, ticket: ticket, quantity: 20) }
before { ticket_purchase.update_attributes(paid: true) }
before { ticket_purchase.update_attribute(:paid, true) }
it 'returns the correct value if the user has bought this ticket' do
expect(ticket.total_price(user, paid: true)).to eq(Money.new(100000, 'USD'))
@ -203,7 +203,7 @@ describe Ticket do
it 'should allow currency update' do
free_ticket = Ticket.first
expect { free_ticket.update_attributes(price_currency: 'INR') }.to change { free_ticket.reload.price_currency }.from('USD').to('INR')
expect { free_ticket.update_attribute(:price_currency, 'INR') }.to change { free_ticket.reload.price_currency }.from('USD').to('INR')
end
end
end

View file

@ -118,7 +118,7 @@ describe User do
describe '#attended_event?' do
context 'user has attended to the event' do
before do
events_registration.update_attributes(attended: true)
events_registration.update_attribute(:attended, true)
end
it 'returns true' do
@ -201,7 +201,7 @@ describe User do
end
describe '.for_ichain_username' do
before { user.update_attributes(current_sign_in_at: Date.new(2014, 12, 12)) }
before { user.update_attribute(:current_sign_in_at, Date.new(2014, 12, 12)) }
context 'user exists' do
it 'updates last_sign_in_at of user' do
@ -220,7 +220,7 @@ describe User do
end
context 'user is disabled' do
before { user.update_attributes(is_disabled: true) }
before { user.update_attribute(:is_disabled, true) }
it 'User.for_ichain_username raises exception if user is disabled' do
expect{ User.for_ichain_username(user.username, email: user.email) }
@ -292,7 +292,7 @@ describe User do
let(:conf2_organizer_role) { Role.find_by(name: 'organizer', resource: conference2) }
before do
user.update_attributes(role_ids: [organizer_role.id, cfp_role.id, conf2_organizer_role.id])
user.update_attribute(:role_ids, [organizer_role.id, cfp_role.id, conf2_organizer_role.id])
end
it 'returns hash of role and conference' do
@ -351,7 +351,7 @@ describe User do
end
context 'unconfirmed user' do
before { user.update_attributes(confirmed_at: nil) }
before { user.update_attribute(:confirmed_at, nil) }
it 'returns false' do
expect(user.confirmed?).to eq false

View file

@ -18,7 +18,7 @@ describe SpeakerSerializer, type: :serializer do
end
context 'speaker has biography' do
before{ speaker.update_attributes(biography: 'Doest of all Jon Does') }
before{ speaker.update_attribute(:biography, 'Doest of all Jon Does') }
it 'sets name, affiliation and biography' do
expected_json = {