Fix event type retrieval in work packages activity provider (#3723)

pull/804/head
Till Breuer 11 years ago
parent 4ddcc62e5c
commit 4443d8b762
  1. 2
      app/models/activity/work_package_activity_provider.rb
  2. 27
      spec/models/activity/work_package_activity_provider_spec.rb

@ -68,7 +68,7 @@ class Activity::WorkPackageActivityProvider < Activity::BaseActivityProvider
if journal.changed_data.empty? && !journal.initial?
state = '-note'
else
state = event['status_closed'] ? '-closed' : '-edit'
state = ActiveRecord::ConnectionAdapters::Column.value_to_boolean(event['status_closed']) ? '-closed' : '-edit'
end
"work_package#{state}"

@ -0,0 +1,27 @@
require 'spec_helper'
describe Activity::WorkPackageActivityProvider do
let(:event_scope) { 'work_packages' }
let(:work_package_edit_event) { 'work_package-edit' }
let(:work_package_closed_event) { 'work_package-closed' }
let(:user) { FactoryGirl.create :admin }
let(:status_closed) { FactoryGirl.create :closed_status }
let(:work_package) { FactoryGirl.build :work_package }
let(:subject) { Activity::WorkPackageActivityProvider.find_events(event_scope, user, Date.today, Date.tomorrow, {}).last.try :event_type }
describe 'latest event' do
context 'when a work package has been created' do
before { work_package.save }
it { should == work_package_edit_event }
context 'and has been closed' do
before { work_package.update_attributes status_id: status_closed.id }
it { should == work_package_closed_event }
end
end
end
end
Loading…
Cancel
Save