Sha256: 13913daed4576e2d302ec1507461babbe850699397134cb3c4ea0a573aeb0d6d

Contents?: true

Size: 1.14 KB

Versions: 5

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true
require "spec_helper"

module SocialNetworking
  module Reports
    RSpec.describe Like do
      fixtures :all

      def data
        @data ||= SocialNetworking::Reports::Like.all
      end

      describe ".all" do
        context "when no likes performed" do
          it "returns an empty array" do
            SocialNetworking::Like.destroy_all

            expect(data).to be_empty
          end
        end

        context "when likes performed" do
          it "returns accurate summaries" do
            participant = participants(:participant1)
            like = SocialNetworking::Like
                   .find_by_participant_id(participant.id)
            item = (like.item.try(:item) || like.item)

            expect(data.count).to eq SocialNetworking::Like.count
            expect(data).to include(
              participant_id: participant.study_id,
              occurred_at: like.created_at.iso8601,
              item_type: item.class.to_s,
              item_participant_id: item.participant.study_id,
              item_content: like.item_description
            )
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
social_networking-0.13.3 spec/models/social_networking/reports/like_report_spec.rb
social_networking-0.13.2 spec/models/social_networking/reports/like_report_spec.rb
social_networking-0.13.1 spec/models/social_networking/reports/like_report_spec.rb
social_networking-0.13.0 spec/models/social_networking/reports/like_report_spec.rb
social_networking-0.12.0 spec/models/social_networking/reports/like_report_spec.rb