-
Notifications
You must be signed in to change notification settings - Fork 0
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
431f3e8
commit 2903926
Showing
2 changed files
with
43 additions
and
1 deletion.
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
FactoryBot.define do | ||
factory :user do | ||
email { "[email protected]" } | ||
sequence(:email) { |n| "test_email#{n}@test.com" } | ||
is_archived { true } | ||
password { "12345" } | ||
end | ||
|
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,42 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe 'Update' do | ||
|
||
describe '#call' do | ||
|
||
context 'when user tries to get records' do | ||
|
||
let!(:archived_users) { create_list(:user, 3, is_archived: true) } | ||
let!(:not_archived_users) { create_list(:user, 5, is_archived: false) } | ||
|
||
before do | ||
@service = Services::Users::Index.new(params) | ||
@service.call | ||
end | ||
|
||
context "archived users" do | ||
|
||
let(:params) { {"is_archived" => "true"} } | ||
|
||
it 'should return archived users' do | ||
result = @service.users.count | ||
expected_result = 3 | ||
expect(result).to eql(expected_result) | ||
end | ||
|
||
end | ||
|
||
context "not archived users" do | ||
|
||
let(:params) { {"is_archived" => "false"} } | ||
|
||
it 'should return not archived users' do | ||
result = @service.users.count | ||
expected_result = 5 | ||
expect(result).to eql(expected_result) | ||
end | ||
|
||
end | ||
end | ||
end | ||
end |