Commit 73dc8efa9fc6be1b75af534ec91947f012bd9b8c
1 parent
e6f99d39
Exists in
staging
and in
5 other branches
Ticket #116: Expose event information in API
Showing
2 changed files
with
37 additions
and
0 deletions
Show diff stats
plugins/recent_activities/test/unit/recent_activities_block_test.rb
| @@ -68,6 +68,31 @@ class RecentActivitiesBlockViewTest < ActionView::TestCase | @@ -68,6 +68,31 @@ class RecentActivitiesBlockViewTest < ActionView::TestCase | ||
| 68 | block = RecentActivitiesPlugin::ActivitiesBlock.new | 68 | block = RecentActivitiesPlugin::ActivitiesBlock.new |
| 69 | block.stubs(:owner).returns(profile) | 69 | block.stubs(:owner).returns(profile) |
| 70 | 70 | ||
| 71 | + api_activity = block.api_content['activities'].last | ||
| 71 | assert_equal [a.id], block.api_content['activities'].map{ |a| a[:id] } | 72 | assert_equal [a.id], block.api_content['activities'].map{ |a| a[:id] } |
| 73 | + assert_not_nil api_activity[:label] | ||
| 74 | + assert_nil api_activity[:start_date] | ||
| 75 | + end | ||
| 76 | + | ||
| 77 | + should 'return event information in api_content' do | ||
| 78 | + person = fast_create(Person) | ||
| 79 | + event = build(Event, { name: 'Event', start_date: DateTime.new(2020, 1, 1) }) | ||
| 80 | + event.profile = person | ||
| 81 | + event.save! | ||
| 82 | + activity = create_activity(person, event) | ||
| 83 | + | ||
| 84 | + block = RecentActivitiesPlugin::ActivitiesBlock.new | ||
| 85 | + block.stubs(:owner).returns(person) | ||
| 86 | + | ||
| 87 | + api_activity = block.api_content['activities'].last | ||
| 88 | + assert_not_nil api_activity[:start_date] | ||
| 89 | + end | ||
| 90 | + | ||
| 91 | + protected | ||
| 92 | + | ||
| 93 | + def create_activity(person, target) | ||
| 94 | + activity = ActionTracker::Record.create! verb: :leave_scrap, user: person, target: target | ||
| 95 | + ProfileActivity.create! profile_id: target.id, activity: activity | ||
| 96 | + activity.reload | ||
| 72 | end | 97 | end |
| 73 | end | 98 | end |