summaryrefslogtreecommitdiff
path: root/spec/migrations/20221012033107_add_password_last_changed_at_to_user_details_spec.rb
blob: e2c508938fdefe4aaa0d4a585514d35bb0316ef5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# frozen_string_literal: true

require 'spec_helper'

require_migration!

RSpec.describe AddPasswordLastChangedAtToUserDetails, feature_category: :users do
  let!(:namespace) { table(:namespaces).create!(name: 'user', path: 'user') }
  let!(:users) { table(:users) }
  let!(:user) { create_user! }
  let(:user_detail) { table(:user_details).create!(user_id: user.id, provisioned_by_group_id: namespace.id) }

  describe "#up" do
    it 'allows to read password_last_changed_at' do
      migrate!

      expect(user_detail.password_last_changed_at).to eq nil
    end
  end

  private

  def create_user!(name: "Example User", email: "user@example.com", user_type: nil)
    users.create!(
      name: name,
      email: email,
      username: name,
      projects_limit: 0,
      user_type: user_type,
      confirmed_at: Time.current
    )
  end
end