Extract method to get a user segment name
We're going to add geozones as user segments, so it's handy to have the method in the UserSegments class. We're also changing the `user_segment_emails` parameter name for consistency and simplicity.
This commit is contained in:
@@ -5,6 +5,22 @@ describe UserSegments do
|
||||
let(:user2) { create(:user) }
|
||||
let(:user3) { create(:user) }
|
||||
|
||||
describe ".segment_name" do
|
||||
it "returns a readable name of the segment" do
|
||||
expect(UserSegments.segment_name("all_users")).to eq "All users"
|
||||
expect(UserSegments.segment_name("administrators")).to eq "Administrators"
|
||||
expect(UserSegments.segment_name("proposal_authors")).to eq "Proposal authors"
|
||||
end
|
||||
|
||||
it "accepts symbols as parameters" do
|
||||
expect(UserSegments.segment_name(:all_users)).to eq "All users"
|
||||
end
|
||||
|
||||
it "returns nil for invalid segments" do
|
||||
expect(UserSegments.segment_name("invalid")).to be nil
|
||||
end
|
||||
end
|
||||
|
||||
describe ".all_users" do
|
||||
it "returns all active users enabled" do
|
||||
active_user = create(:user)
|
||||
|
||||
Reference in New Issue
Block a user