Skip to content

Commit

Permalink
Services::Users::Index specs added
Browse files Browse the repository at this point in the history
  • Loading branch information
alex223125 committed Sep 14, 2022
1 parent 431f3e8 commit 2903926
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion spec/factories/users.rb
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
Expand Down
42 changes: 42 additions & 0 deletions spec/services/users/index_spec.rb
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

0 comments on commit 2903926

Please sign in to comment.