<commit_before># frozen_string_literal: true

require "rails_helper"

RSpec.describe "Managing User Details", :aggregate_failures, feature_setting: { create_users: true, user_based_price_groups: true, reload_routes: true } do

  let(:facility) { FactoryBot.create(:facility) }
  let(:admin) { FactoryBot.create(:user, :netid, :administrator) }

  before do
    login_as admin
  end

  describe "create", js: true do
    let(:user) { FactoryBot.build(:user, :netid, username: "user123") }

    it "creates an external user" do
      visit new_external_facility_users_path(facility)

      fill_in "First name", with: user.first_name
      fill_in "Last name", with: user.last_name
      fill_in "Email", with: user.email

      click_on "Create"

      expect(page).to have_content("You just created a new user, #{user.full_name} (#{user.email})")

      expect(page).to have_content("if this user is entitled to internal rates.")
    end

  end

  describe "edit" do
    describe "as a facility admin" do
      let(:user) { FactoryBot.create(:user, :netid, username: "user123") }

      before do
        visit facility_user_path(facility, user)
      end

      it "allows admin to edit internal/external pricing" do
        expect(page).to have_content("Internal Pricing")

        click_link "Edit"
<commit_msg>Tech task - Handle user creation for all schools (#3050)<commit_after># frozen_string_literal: true

require "rails_helper"

RSpec.describe "Managing User Details", :aggregate_failures, feature_setting: { create_users: true, user_based_price_groups: true, reload_routes: true } do

  let(:facility) { FactoryBot.create(:facility) }
  let(:admin) { FactoryBot.create(:user, :netid, :administrator) }

  before do
    login_as admin
  end

  describe "create", js: true do
    let(:user) { FactoryBot.build(:user, :netid, username: "user123") }

    it "creates an external user" do
      visit new_external_facility_users_path(facility)

      fill_in "First name", with: user.first_name
      fill_in "Last name", with: user.last_name
      fill_in "Email", with: user.email

      check("user[no_netid]") if UsersController.user_form_class.new(user).respond_to? :no_netid

      click_on "Create"

      expect(page).to have_content("You just created a new user, #{user.full_name} (#{user.email})")

      expect(page).to have_content("if this user is entitled to internal rates.")
    end

  end

  describe "edit" do
    describe "as a facility admin" do
      let(:user) { FactoryBot.create(:user, :netid, username: "user123") }

      before do
        visit facility_user_path(facility, user)
      end

      it "allows admin to edit internal/external pricing" do
        expect(page).to have_content("Internal Pricing")

        click_link "Edit"

{'fraction_non_alphanumeric': 0.1094257854821235, 'fraction_numerical': 0.00577825929938606, 'mean_word_length': 3.735042735042735, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4809822', 'n_tokens_mistral': 897, 'n_tokens_neox': 848, 'n_words': 244}