diff --git a/README.md b/README.md index ef2aaf2313..4c32438568 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,31 @@ This plugin contains migrations. To migrate the database, run: `rake db:migrate` +Tests +----- + +Assuming you have to following directory structure: + +``` +. +├── openproject +├── openproject-documents +``` + +Replace the openproject-document ``gemfile.plugins`` entry with the following: + +``` +gem "openproject-documents", path: "../openproject-documents" +``` + +You run the specs with the following commands: + +``` +cd openproject +rake db:test:load # this needs to be done only once +rspec ../openproject-documents +``` + Deinstallation -------------- diff --git a/app/models/document.rb b/app/models/document.rb index fd3a4d1d93..c73dca1bf4 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -39,6 +39,7 @@ class Document < ActiveRecord::Base acts_as_journalized acts_as_event title: Proc.new { |o| "#{Document.model_name.human}: #{o.title}" }, url: Proc.new { |o| { controller: '/documents', action: 'show', id: o.id } }, + datetime: :created_on, author: ( Proc.new do |o| o.attachments.find(:first, order: "#{Attachment.table_name}.created_on ASC").try(:author) end) diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index 294e1752bc..6f658cf3d8 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -32,6 +32,8 @@ See doc/COPYRIGHT.rdoc for more details. # Changelog +* Fix: Acts as event datetime + ## 1.0.1 * `#5361` Add missing journal data migration diff --git a/spec/models/document_spec.rb b/spec/models/document_spec.rb index a082006310..23dd839d35 100644 --- a/spec/models/document_spec.rb +++ b/spec/models/document_spec.rb @@ -101,4 +101,11 @@ describe Document do end end + describe "acts as event" do + let(:now) { Time.now } + let(:document) { FactoryGirl.build(:document, + created_on: now) } + + it { expect(document.event_datetime).to eq(now) } + end end