diff --git a/app/models/concerns/build_list_observer.rb b/app/models/concerns/build_list_observer.rb index fc3596cd7..ef0ec95c1 100644 --- a/app/models/concerns/build_list_observer.rb +++ b/app/models/concerns/build_list_observer.rb @@ -9,14 +9,14 @@ module BuildListObserver def update_average_build_time if status_changed? - started_at = Time.now if status == self.class::BUILD_STARTED + self.started_at = Time.now if status == self.class::BUILD_STARTED if [self.class::BUILD_ERROR, self.class::SUCCESS, self.class::BUILD_CANCELING, self.class::TESTS_FAILED, self.class::BUILD_CANCELED].include? status # stores time interval beetwin build start and finish in seconds - duration = current_duration if started_at + duration = current_duration if self.started_at if status == self.class::SUCCESS # Update project average build time diff --git a/spec/models/build_list_observer_spec.rb b/spec/models/build_list_observer_spec.rb index 78ea54d44..dbedfe1b2 100644 --- a/spec/models/build_list_observer_spec.rb +++ b/spec/models/build_list_observer_spec.rb @@ -1,5 +1,15 @@ require 'spec_helper' describe BuildListObserver do - pending "add some examples to (or delete) #{__FILE__}" + + before { stub_symlink_methods } + + let(:build_list) { FactoryGirl.create(:build_list) } + + it 'updates started_at when build started' do + expect(build_list.started_at).to be_nil + build_list.start_build + expect(build_list.started_at).to_not be_nil + end + end