We were very inconsistent regarding these rules. Personally I prefer no empty lines around blocks, clases, etc... as recommended by the Ruby style guide [1], and they're the default values in rubocop, so those are the settings I'm applying. The exception is the `private` access modifier, since we were leaving empty lines around it most of the time. That's the default rubocop rule as well. Personally I don't have a strong preference about this one. [1] https://rubystyle.guide/#empty-lines-around-bodies
26 lines
747 B
Ruby
26 lines
747 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
|