<commit_before>feature "Editing a course" do
  let!(:course) { create(:course) }
  let!(:admin) { create(:user, :admin) }
  before { signin_user admin }

  scenario "using valid attributes" do
    visit courses_path
    expect(page).to have_link("edit")
    click_on "edit"
    expect(page).to have_title(full_title("Edit Course"))
    expect(page).to have_content(course.full_id)
    course.department = "ECON"
    fill_course_form(course)
    course_in_database = Course.find_by(id: course.id)
    expect(course_in_database.department).to eq("ECON")
  end

  scenario "using invalid attributes" do
    visit edit_course_path(course)
    course.level = -99
    fill_course_form(course)
    course_in_database = Course.find_by(id: course.id)
    expect(course_in_database.level).not_to eq(-99)
    expect(page).to have_selector(".alert", "Error updating course.")
  end
end<commit_msg>add course edit spec tests for visitor and non-admi<commit_after>feature "Editing a course" do
  let!(:course) { create(:course) }
  feature "as an admin" do
    let!(:admin) { create(:user, :admin) }
    before { signin_user admin }

    scenario "using valid attributes" do
      visit courses_path
      expect(page).to have_link("edit")
      click_on "edit"
      expect(page).to have_title(full_title("Edit Course"))
      expect(page).to have_content(course.full_id)
      course.department = "ECON"
      fill_course_form(course)
      course_in_database = Course.find_by(id: course.id)
      expect(course_in_database.department).to eq("ECON")
    end

    scenario "using invalid attributes" do
      visit edit_course_path(course)
      course.level = -99
      fill_course_form(course)
      course_in_database = Course.find_by(id: course.id)
      expect(course_in_database.level).not_to eq(-99)
      expect(page).to have_selector(".alert", "Error updating course.")
    end
  end

  feature "as a non-admin" do
    let!(:user) { create(:user) }
    before { signin_user user }

    scenario "is not possible" do
      visit courses_path
      expect(page).not_to have_link("edit")
    end
  end

  feature "as a visitor" do
    scenario "is not possible" do
      visit courses_path
      expect(page).not_to have_link("edit")
    end
  end
end
{'fraction_non_alphanumeric': 0.11185383244206773, 'fraction_numerical': 0.0035650623885918, 'mean_word_length': 3.5537525354969572, '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': '6876222', 'n_tokens_mistral': 732, 'n_tokens_neox': 722, 'n_words': 170}