<commit_before>require 'test_helper'

class SuspensionsControllerTest < ActionController::TestCase

  context "organisation admin" do
    should "be unable to control suspension of a user outside their organisation" do
      user = create(:suspended_user, reason_for_suspension: "Negligence")
      admin = create(:organisation_admin)
      sign_in admin

      put :update, id: user.id, user: { suspended: "0" }

      assert_true user.reload.suspended?
    end

    should "be able to control suspension of a user within their organisation" do
      admin = create(:organisation_admin)
      sign_in admin
      user = create(:suspended_user, reason_for_suspension: "Negligence", organisation: admin.organisation)

      put :update, id: user.id, user: { suspended: "0" }

      assert_false user.reload.suspended?
    end
  end

  context "PUT update" do
    setup do
      user = create(:admin_user)
      sign_in user
    end

    should "be able to suspend the user and redirect to user's edit page" do
      another_user = create(:user)
      put :update, id: another_user.id, user: { suspended: "1", reason_for_suspension: "Negligence" }<commit_msg>More `assert` method renaming<commit_after>require 'test_helper'

class SuspensionsControllerTest < ActionController::TestCase

  context "organisation admin" do
    should "be unable to control suspension of a user outside their organisation" do
      user = create(:suspended_user, reason_for_suspension: "Negligence")
      admin = create(:organisation_admin)
      sign_in admin

      put :update, id: user.id, user: { suspended: "0" }

      assert user.reload.suspended?
    end

    should "be able to control suspension of a user within their organisation" do
      admin = create(:organisation_admin)
      sign_in admin
      user = create(:suspended_user, reason_for_suspension: "Negligence", organisation: admin.organisation)

      put :update, id: user.id, user: { suspended: "0" }

      refute user.reload.suspended?
    end
  end

  context "PUT update" do
    setup do
      user = create(:admin_user)
      sign_in user
    end

    should "be able to suspend the user and redirect to user's edit page" do
      another_user = create(:user)
      put :update, id: another_user.id, user: { suspended: "1", reason_for_suspension: "Negligence" }
{'fraction_non_alphanumeric': 0.08451918930573524, 'fraction_numerical': 0.00258732212160414, 'mean_word_length': 3.4787644787644787, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5706130', 'n_tokens_mistral': 688, 'n_tokens_neox': 657, 'n_words': 223}