Skip to content

Commit

Permalink
fixed different typos
Browse files Browse the repository at this point in the history
  • Loading branch information
yrudman committed Aug 7, 2019
1 parent b989704 commit ef41d44
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
13 changes: 5 additions & 8 deletions app/models/miq_widget.rb
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ def sync_schedule(schedule_info)
raise _("Unsupported interval '%{interval}'") % {:interval => interval}
end

sched = existing_scheduler
sched = existing_schedule
sched ||= MiqSchedule.create!(
:name => description,
:description => description,
Expand All @@ -537,20 +537,17 @@ def sync_schedule(schedule_info)
sched
end

def existing_scheduler
def existing_schedule
return nil if (sched = MiqSchedule.find_by(:name => description)).nil?

# return existing sheduler if filter referr to the same widget
return sched if sched.filter == filter_for_schedule

# change name of existed schedule in case it is in use

suff = Time.new.utc.to_s
_log.warn("Schedule #{sched.name} already exists, renaming it to `#{sched.name} #{suff}`")
sched.name = "#{sched.name} #{suff}"
sched.description = "#{sched.description} #{suff}"
sched.save

suffix = Time.new.utc.to_s
_log.warn("Schedule #{sched.name} already exists, renaming it to `#{sched.name} #{suffix}`")
sched.update(:name => "#{sched.name} #{suffix}", :description => "#{sched.description} #{suffix}")
nil
end

Expand Down
6 changes: 3 additions & 3 deletions spec/models/miq_widget_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
describe "#sync_schedule" do
let(:schedule) do
filter = @widget_chart_vendor_and_guest_os.filter_for_schedule
FactoryBot.create(:miq_schedule, :filter => filter,
:resource_type => "MiqWidget", :name => @widget_chart_vendor_and_guest_os.name)
FactoryBot.create(:miq_schedule, :filter => filter, :resource_type => "MiqWidget",
:name => @widget_chart_vendor_and_guest_os.name)
end

it "uses existing schedule if link between widget and schedule broken" do
Expand All @@ -78,7 +78,7 @@
expect(@widget_chart_vendor_and_guest_os.miq_schedule.id).to eq(schedule.id)
end

it "rename existing scheduler by adding timestamp go name if existing scheduler use different filter" do
it "rename existing scheduler by adding timestamp to name if existing scheduler use different filter" do
schedule.update(:filter => "\"=\" => {\"field\" => \"MiqWidget-id\", \"value\" => 9999}")

time_now = Time.now.utc
Expand Down

0 comments on commit ef41d44

Please sign in to comment.