Skip to content

Commit

Permalink
create events with date sub-records insead of timestamps
Browse files Browse the repository at this point in the history
  • Loading branch information
jambun committed Mar 7, 2016
1 parent d3fc787 commit 5a1c1c8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
4 changes: 2 additions & 2 deletions backend/model/mixins/initial_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ def create_from_json(json, opts = {})

def create_events_for(obj)
cfg = AppConfig[:accession_events]
time_now = Time.now.utc.iso8601
time_now = Time.now

cfg[:event_types].each do |type|
event = {
"event_type" => type,
"outcome" => cfg[:outcome],
"timestamp" => time_now,
"date" => {"date_type" => "single", "label" => "event", "begin" => time_now.strftime("%Y-%m-%d")},
"linked_records" => [
{
"role" => cfg[:accession_role],
Expand Down
22 changes: 20 additions & 2 deletions backend/spec/model_initial_events_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ def stub_config(hash)
describe 'InitialEvents mixin model' do

it "adds events to new accessions" do

stub_config({
:agent => 'admin',
:agent_uri => '/agents/people/1',
:agent_role => 'authorizer',
:accession_role => 'source',
:outcome => '',
Expand All @@ -32,4 +31,23 @@ def stub_config(hash)
end


it "creates the events with date sub-records" do
stub_config({
:agent_uri => '/agents/people/1',
:agent_role => 'authorizer',
:accession_role => 'source',
:outcome => '',
:event_types => [
'agreement_sent',
'agreement_signed',
]
})


accession = Accession.create_from_json(build(:json_accession))
events = Accession[accession[:id]].related_records(:event_link)

events[0].date[0].begin.should eq(Time.now.strftime("%Y-%m-%d"))
end

end

0 comments on commit 5a1c1c8

Please sign in to comment.