ref: master
plugins/recent_activities/test/unit/recent_activities_test.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
require 'test_helper' class RecentActivitiesPluginTest < ActiveSupport::TestCase def setup @environment = Environment.default @environment.enable_plugin(RecentActivitiesPlugin) end should 'have label for events' do person = fast_create(Person) event = build(Event, { name: 'Event', start_date: DateTime.new(2020, 1, 1) }) event.profile = person event.save! activity = create_activity(person, event) assert_equal 'events', activity.label end should 'have label for communities' do person = fast_create(Person) community = fast_create(Community) activity = create_activity(person, community) assert_equal 'communities', activity.label end should 'have label for people' do person = fast_create(Person) friendship = fast_create(Friendship) activity = create_activity(person, friendship) assert_equal 'people', activity.label end should 'have label for posts' do person = fast_create(Person) article = fast_create(Article) activity = create_activity(person, article) assert_equal 'posts', activity.label end protected def create_activity(person, target) activity = ActionTracker::Record.create! verb: :leave_scrap, user: person, target: target ProfileActivity.create! profile_id: target.id, activity: activity activity.reload end end |