These variables can be considered a block, and so removing them doesn't make the test much harder to undestand. Sometimes these variables formed the setup, sometimes they formed an isolated part of the setup, and sometimes they were the part of the test that made the test different from other tests.
28 lines
749 B
Ruby
28 lines
749 B
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe Community, type: :model do
|
|
|
|
it "is valid when create proposal" do
|
|
proposal = create(:proposal)
|
|
|
|
expect(proposal.community).to be_valid
|
|
end
|
|
|
|
describe "#participants" do
|
|
|
|
it "returns participants without duplicates" do
|
|
proposal = create(:proposal)
|
|
community = proposal.community
|
|
user1 = create(:user)
|
|
user2 = create(:user)
|
|
|
|
topic1 = create(:topic, community: community, author: user1)
|
|
create(:comment, commentable: topic1, author: user1)
|
|
create(:comment, commentable: topic1, author: user2)
|
|
create(:topic, community: community, author: user2)
|
|
|
|
expect(community.participants).to match_array [user1, user2, proposal.author]
|
|
end
|
|
end
|
|
end
|