From d77924de292987e770c148e4f81ef0bd2cd2ba4c Mon Sep 17 00:00:00 2001 From: Hagen Schink Date: Thu, 17 Apr 2014 13:49:36 +0200 Subject: [PATCH 1/4] Add acts as event specs --- spec/models/document_spec.rb | 7 +++++++ 1 file changed, 7 insertions(+) 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 From 07a821c6d6f07654d7f85643544663155b909cbf Mon Sep 17 00:00:00 2001 From: Timothy Overly Date: Tue, 15 Apr 2014 10:25:51 -0400 Subject: [PATCH 2/4] Documents don't have a the default 'created_at' for acts as event --- app/models/document.rb | 1 + 1 file changed, 1 insertion(+) 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) From 38789604ff1f51ef085f7126c88a4fa5799dd8a6 Mon Sep 17 00:00:00 2001 From: Hagen Schink Date: Thu, 17 Apr 2014 16:42:42 +0200 Subject: [PATCH 3/4] Fix README --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) 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 -------------- From 6a962f79e5b89e6fc315c67094598fbc96dcbcb3 Mon Sep 17 00:00:00 2001 From: Hagen Schink Date: Thu, 17 Apr 2014 16:48:45 +0200 Subject: [PATCH 4/4] Add changelog entry --- doc/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) 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