Sha256: 7b576469675c4f18356b22737d92846d9575ba17a8a66cb46980a5fb5f22ff0d

Contents?: true

Size: 1.1 KB

Versions: 4

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true
require "spec_helper"

module SocialNetworking
  describe Comment, type: :model do
    fixtures(:participants, :"social_networking/goals")
    let(:participant1) { participants(:participant1) }
    let(:goal) { social_networking_goals(:participant2_goal_alpha) }

    it "should return the number of comments made today" do
      expect do
        Comment.create(
          participant_id: participant1.id,
          item: goal,
          text: "love this test",
          created_at: Time.zone.today
        )
      end.to change { Comment.for_today.count }.by(1)
    end

    it "should return the number of comments made in the past seven days" do
      expect do
        Comment.create(
          participant_id: participant1.id,
          item: goal,
          text: "love this test",
          created_at: Time.zone.today - 1.day
        )

        Comment.create(
          participant_id: participant1.id,
          item: goal,
          text: "love this test",
          created_at: Time.zone.today - 8.days
        )
      end.to change { Comment.for_week.count }.by(1)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
social_networking-0.13.2 spec/models/social_networking/comment_spec.rb
social_networking-0.13.1 spec/models/social_networking/comment_spec.rb
social_networking-0.13.0 spec/models/social_networking/comment_spec.rb
social_networking-0.12.0 spec/models/social_networking/comment_spec.rb