-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f1ba09
commit d67073c
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
describe Decidim::StatsUsersCount do | ||
subject { described_class.new(organization, start_at, end_at) } | ||
|
||
let(:organization) { create(:organization) } | ||
let(:start_at) { nil } | ||
let(:end_at) { nil } | ||
|
||
context "without start and end date" do | ||
it "returns the number of confirmed users" do | ||
create(:user, :confirmed) | ||
create(:user, :confirmed, organization: organization) | ||
create(:user, :confirmed, :published, organization: organization) | ||
create(:user, organization: organization) | ||
|
||
expect(subject.query).to eq(2) | ||
end | ||
end | ||
|
||
context "with start date" do | ||
let(:start_at) { 1.week.ago } | ||
|
||
it "returns the number of confirmed user created equal or after this date" do | ||
create(:user, :confirmed, organization: organization, created_at: 2.weeks.ago) | ||
create(:user, :confirmed, organization: organization) | ||
create(:user, :confirmed, :published, organization: organization) | ||
|
||
expect(subject.query).to eq(2) | ||
end | ||
end | ||
|
||
context "with end date" do | ||
let(:end_at) { 1.week.from_now } | ||
|
||
it "returns the number of confirmed user created equal or after this date" do | ||
create(:user, :confirmed, organization: organization, created_at: 2.weeks.from_now) | ||
create(:user, :confirmed, organization: organization) | ||
create(:user, :confirmed, :published, organization: organization) | ||
|
||
expect(subject.query).to eq(2) | ||
end | ||
end | ||
|
||
context "with blocked and deleted users" do | ||
it "will exclude all the users blocked or with deleted account" do | ||
create(:user, :confirmed, organization: organization, blocked: true) | ||
create(:user, :confirmed, organization: organization, deleted_at: 1.day.ago) | ||
create(:user, :confirmed, organization: organization) | ||
create(:user, :confirmed, :published, organization: organization) | ||
|
||
expect(subject.query).to eq(2) | ||
end | ||
end | ||
end |