diff --git a/app/controllers/bulk_grant_permission_sets_controller.rb b/app/controllers/bulk_grant_permission_sets_controller.rb deleted file mode 100644 index b6ca4c539..000000000 --- a/app/controllers/bulk_grant_permission_sets_controller.rb +++ /dev/null @@ -1,31 +0,0 @@ -class BulkGrantPermissionSetsController < ApplicationController - layout "admin_layout" - - before_action :authenticate_user! - - def new - @bulk_grant_permission_set = BulkGrantPermissionSet.new - authorize @bulk_grant_permission_set - end - - def create - @bulk_grant_permission_set = BulkGrantPermissionSet.new(user: current_user) - application = Doorkeeper::Application.find_by(id: params[:application_id]) - @bulk_grant_permission_set.supported_permission_ids = [application.signin_permission.id] - authorize @bulk_grant_permission_set - - if @bulk_grant_permission_set.save - @bulk_grant_permission_set.enqueue - flash[:notice] = "Scheduled grant of #{@bulk_grant_permission_set.supported_permission_ids.count} permissions to all users" - redirect_to bulk_grant_permission_set_path(@bulk_grant_permission_set) - else - flash.now[:alert] = "Couldn't schedule granting #{@bulk_grant_permission_set.supported_permission_ids.count} permissions to all users, please try again" - render :new - end - end - - def show - @bulk_grant_permission_set = BulkGrantPermissionSet.find(params[:id]) - authorize @bulk_grant_permission_set - end -end diff --git a/app/helpers/bulk_grant_permission_sets_helper.rb b/app/helpers/bulk_grant_permission_sets_helper.rb deleted file mode 100644 index d522c21a9..000000000 --- a/app/helpers/bulk_grant_permission_sets_helper.rb +++ /dev/null @@ -1,42 +0,0 @@ -module BulkGrantPermissionSetsHelper - def bulk_grant_permission_set_applications - Pundit.policy_scope(current_user, :user_permission_manageable_application) - .reject(&:retired?) - end - - def bulk_grant_permissions_by_application(bulk_grant_permission_set) - bulk_grant_permission_set - .supported_permissions - .includes(:application) - .order("oauth_applications.name, supported_permissions.name") - .group_by(&:application) - end - - def formatted_row(application, permissions) - [ - { text: formatted_application_name(application) }, - { text: formatted_application_access(application, permissions) }, - { text: formatted_other_permissions(application, permissions) }, - ] - end - - def formatted_application_name(application) - if application.retired? - "#{application.name} (retired)" - else - application.name - end - end - - def formatted_application_access(application, permissions) - if permissions.include?(application.signin_permission) - "Yes" - else - "No" - end - end - - def formatted_other_permissions(application, permissions) - (permissions - [application.signin_permission]).map(&:name).to_sentence - end -end diff --git a/app/jobs/bulk_grant_permission_set_job.rb b/app/jobs/bulk_grant_permission_set_job.rb deleted file mode 100644 index 014b3403e..000000000 --- a/app/jobs/bulk_grant_permission_set_job.rb +++ /dev/null @@ -1,5 +0,0 @@ -class BulkGrantPermissionSetJob < ApplicationJob - def perform(id, options = {}) - BulkGrantPermissionSet.find(id).perform(options) - end -end diff --git a/app/models/bulk_grant_permission_set.rb b/app/models/bulk_grant_permission_set.rb deleted file mode 100644 index 140e4ae94..000000000 --- a/app/models/bulk_grant_permission_set.rb +++ /dev/null @@ -1,53 +0,0 @@ -class BulkGrantPermissionSet < ApplicationRecord - belongs_to :user - has_many :bulk_grant_permission_set_application_permissions, inverse_of: :bulk_grant_permission_set, dependent: :destroy - has_many :supported_permissions, through: :bulk_grant_permission_set_application_permissions - - validates :user, presence: true - validates :outcome, inclusion: { in: %w[success fail], allow_nil: true } - validate :must_have_at_least_one_supported_permission - - def in_progress? - outcome.nil? - end - - def successful? - outcome == "success" - end - - def enqueue - BulkGrantPermissionSetJob.perform_later(id) - end - - def perform(_options = {}) - update_column(:total_users, User.count) - User.find_each do |user_to_change| - permissions_granted = supported_permissions.select do |permission| - granted_permission = user_to_change.application_permissions.where(supported_permission_id: permission.id).first_or_create! - # if 'id' changed then it was a new permission, otherwise it - # already existed - granted_permission.previous_changes.key? "id" - end - permissions_granted.group_by(&:application_id).each do |application_id, permissions| - EventLog.record_event( - user_to_change, - EventLog::PERMISSIONS_ADDED, - initiator: user, - application_id:, - trailing_message: "(#{permissions.map(&:name).join(', ')})", - ) - end - self.class.increment_counter(:processed_users, id) - end - update_column(:outcome, "success") - rescue StandardError - update_column(:outcome, "fail") - raise - end - -private - - def must_have_at_least_one_supported_permission - errors.add(:supported_permissions, "must not be blank. Choose at least one permission to grant to all users.") if bulk_grant_permission_set_application_permissions.empty? - end -end diff --git a/app/models/bulk_grant_permission_set_application_permission.rb b/app/models/bulk_grant_permission_set_application_permission.rb deleted file mode 100644 index ac50f5e5f..000000000 --- a/app/models/bulk_grant_permission_set_application_permission.rb +++ /dev/null @@ -1,7 +0,0 @@ -class BulkGrantPermissionSetApplicationPermission < ApplicationRecord - belongs_to :bulk_grant_permission_set, inverse_of: :bulk_grant_permission_set_application_permissions - belongs_to :supported_permission - - validates :bulk_grant_permission_set, :supported_permission, presence: true - validates :supported_permission_id, uniqueness: { scope: :bulk_grant_permission_set_id, case_sensitive: true } -end diff --git a/app/models/user.rb b/app/models/user.rb index 3937790bf..e22fcf577 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -15,10 +15,10 @@ class User < ApplicationRecord USER_STATUS_INVITED = "invited".freeze USER_STATUS_LOCKED = "locked".freeze USER_STATUS_ACTIVE = "active".freeze - USER_STATUSES = [USER_STATUS_SUSPENDED, + USER_STATUSES = [USER_STATUS_ACTIVE, + USER_STATUS_SUSPENDED, USER_STATUS_INVITED, - USER_STATUS_LOCKED, - USER_STATUS_ACTIVE].freeze + USER_STATUS_LOCKED].freeze TWO_STEP_STATUS_ENABLED = "enabled".freeze TWO_STEP_STATUS_NOT_SET_UP = "not_set_up".freeze diff --git a/app/policies/bulk_grant_permission_set_policy.rb b/app/policies/bulk_grant_permission_set_policy.rb deleted file mode 100644 index 3e29c7742..000000000 --- a/app/policies/bulk_grant_permission_set_policy.rb +++ /dev/null @@ -1,9 +0,0 @@ -class BulkGrantPermissionSetPolicy < BasePolicy - def new? - return true if current_user.govuk_admin? - - false - end - alias_method :create?, :new? - alias_method :show?, :new? -end diff --git a/app/views/bulk_grant_permission_sets/new.html.erb b/app/views/bulk_grant_permission_sets/new.html.erb deleted file mode 100644 index 0ef3600d2..000000000 --- a/app/views/bulk_grant_permission_sets/new.html.erb +++ /dev/null @@ -1,32 +0,0 @@ -<% content_for :title, "Grant access to all users" %> -<% content_for :breadcrumbs, - render("govuk_publishing_components/components/breadcrumbs", { - collapse_on_mobile: true, - breadcrumbs: [ - { - title: "Home", - url: root_path, - }, - { - title: "Users", - url: users_path, - }, - { - title: "Grant access to all users", - }, - ] - }) -%> - -<%= form_for @bulk_grant_permission_set do |f| %> - <%= render "govuk_publishing_components/components/select", { - id: "application_id", - label: "Application", - name: "application_id", - options: bulk_grant_permission_set_applications.map { |application| { text: application.name, value: application.id } } - } %> - - <%= render "govuk_publishing_components/components/button", { - text: "Grant access to all users" - } %> -<% end %> diff --git a/app/views/bulk_grant_permission_sets/show.html.erb b/app/views/bulk_grant_permission_sets/show.html.erb deleted file mode 100644 index 9180853ec..000000000 --- a/app/views/bulk_grant_permission_sets/show.html.erb +++ /dev/null @@ -1,54 +0,0 @@ -<% content_for :title, "Result" %> -<% content_for :breadcrumbs, - render("govuk_publishing_components/components/breadcrumbs", { - collapse_on_mobile: true, - breadcrumbs: [ - { - title: "Home", - url: root_path, - }, - { - title: "Users", - url: users_path, - }, - { - title: "Grant access to all users", - url: new_bulk_grant_permission_set_path, - }, - { - title: "Result", - } - ] - }) -%> - -<% if @bulk_grant_permission_set.in_progress? %> - <% content_for(:head) do %> - - <% end %> -<% end %> - -<% if @bulk_grant_permission_set.in_progress? %> - <%= render "govuk_publishing_components/components/notice", { - title: "In progress. #{@bulk_grant_permission_set.processed_users} of #{@bulk_grant_permission_set.total_users} users processed." - } %> -<% elsif @bulk_grant_permission_set.successful? %> - <%= render "govuk_publishing_components/components/success_alert", { - message: "All #{@bulk_grant_permission_set.processed_users} users processed." - } %> -<% else %> - <%= render "govuk_publishing_components/components/error_alert", { - message: "Only #{@bulk_grant_permission_set.processed_users} of #{@bulk_grant_permission_set.total_users} users processed." - } %> -<% end %> - -<%= render "govuk_publishing_components/components/table", { - head: [ - { text: "Application" }, - { text: "Has access to?" }, - { text: "Other Permissions" }, - ], - rows: bulk_grant_permissions_by_application(@bulk_grant_permission_set).map { |(application, permissions)| - formatted_row(application, permissions) - }, -} %> diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index c50858579..af82ebb2b 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -29,14 +29,6 @@ margin_bottom: 4, } %> <% end %> - <% if policy(BulkGrantPermissionSet).new? %> - <%= render "govuk_publishing_components/components/button", { - text: "Grant access to all users", - href: new_bulk_grant_permission_set_path, - secondary: true, - margin_bottom: 4, - } %> - <% end %> <% end %> diff --git a/config/routes.rb b/config/routes.rb index 464d26df1..67c0ee9d0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -60,7 +60,6 @@ controller: :batch_invitation_permissions end - resources :bulk_grant_permission_sets, only: %i[new create show] resources :organisations, only: %i[index edit update] resources :suspensions, only: %i[edit update] resources :two_step_verification_exemptions, only: %i[edit update] diff --git a/db/migrate/20230918141453_drop_bulk_grant_permission_sets_et_al.rb b/db/migrate/20230918141453_drop_bulk_grant_permission_sets_et_al.rb new file mode 100644 index 000000000..9004e3f9d --- /dev/null +++ b/db/migrate/20230918141453_drop_bulk_grant_permission_sets_et_al.rb @@ -0,0 +1,27 @@ +class DropBulkGrantPermissionSetsEtAl < ActiveRecord::Migration[7.0] + def change + drop_table :bulk_grant_permission_set_application_permissions do |t| + t.belongs_to :bulk_grant_permission_set, + null: false, + index: { name: "index_bulk_grant_permissions_on_bulk_grant_permission_set_id" } + t.belongs_to :supported_permission, + null: false, + index: { name: "index_bulk_grant_permissions_on_permission_id" } + + t.timestamps + + t.index %i[bulk_grant_permission_set_id supported_permission_id], + name: "index_bulk_grant_permissions_on_permission_id_and_bulk_grant_id", + unique: true + end + + drop_table :bulk_grant_permission_sets do |t| + t.belongs_to :user + t.string :outcome + t.integer :processed_users, default: 0, null: false + t.integer :total_users, default: 0, null: false + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index f1b958e1b..a1db393a8 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_09_11_092404) do +ActiveRecord::Schema[7.0].define(version: 2023_09_18_141453) do create_table "batch_invitation_application_permissions", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.integer "batch_invitation_id", null: false t.integer "supported_permission_id", null: false @@ -40,23 +40,6 @@ t.index ["outcome"], name: "index_batch_invitations_on_outcome" end - create_table "bulk_grant_permission_set_application_permissions", id: :integer, charset: "utf8mb3", force: :cascade do |t| - t.integer "bulk_grant_permission_set_id", null: false - t.integer "supported_permission_id", null: false - t.datetime "created_at", precision: nil - t.datetime "updated_at", precision: nil - t.index ["bulk_grant_permission_set_id", "supported_permission_id"], name: "index_app_permissions_on_bulk_grant_permission_set", unique: true - end - - create_table "bulk_grant_permission_sets", id: :integer, charset: "utf8mb3", force: :cascade do |t| - t.integer "user_id", null: false - t.string "outcome" - t.integer "processed_users", default: 0, null: false - t.integer "total_users", default: 0, null: false - t.datetime "created_at", precision: nil - t.datetime "updated_at", precision: nil - end - create_table "event_logs", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.string "uid" t.datetime "created_at", precision: nil, null: false diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb index 07b482526..3fa965f02 100644 --- a/test/controllers/users_controller_test.rb +++ b/test/controllers/users_controller_test.rb @@ -256,12 +256,6 @@ def change_user_password(user_factory, new_password) assert_select "a", text: "Upload a batch of users" end - should "display 'Grant access to all users' button" do - get :index - - assert_select "a", text: "Grant access to all users" - end - should "display 'Export N users as CSV' button" do get :index @@ -950,12 +944,6 @@ def change_user_password(user_factory, new_password) assert_select "a", text: "Upload a batch of users", count: 0 end - should "not display 'Grant access to all users' button" do - get :index - - assert_select "a", text: "Grant access to all users", count: 0 - end - should "not display organisations filter" do get :index diff --git a/test/factories/bulk_grant_permission_set.rb b/test/factories/bulk_grant_permission_set.rb deleted file mode 100644 index cef374266..000000000 --- a/test/factories/bulk_grant_permission_set.rb +++ /dev/null @@ -1,16 +0,0 @@ -FactoryBot.define do - factory :bulk_grant_permission_set do - transient do - with_permissions { [create(:supported_permission)] } - end - - association :user, factory: :admin_user - after(:build) do |permission_set, evaluator| - if evaluator.with_permissions - evaluator.with_permissions.each do |supported_permission| - permission_set.bulk_grant_permission_set_application_permissions.build(supported_permission:) - end - end - end - end -end diff --git a/test/helpers/bulk_grant_permission_sets_helper_test.rb b/test/helpers/bulk_grant_permission_sets_helper_test.rb deleted file mode 100644 index 8931cf15e..000000000 --- a/test/helpers/bulk_grant_permission_sets_helper_test.rb +++ /dev/null @@ -1,33 +0,0 @@ -require "test_helper" - -class BulkGrantPermissionSetsHelperTest < ActionView::TestCase - attr_reader :current_user - - context "#bulk_grant_permission_set_applications" do - setup do - @first_application = create(:application, name: "Application A") - @second_application = create(:application, name: "Application B") - @retired_application = create(:application, retired: true) - end - - context "for a superadmin" do - setup do - @current_user = create(:superadmin_user) - end - - should "return all non-retired applications in alphabetical order" do - assert_equal [@first_application, @second_application], bulk_grant_permission_set_applications - end - end - - context "for an admin" do - setup do - @current_user = create(:admin_user) - end - - should "return all non-retired applications in alphabetical order" do - assert_equal [@first_application, @second_application], bulk_grant_permission_set_applications - end - end - end -end diff --git a/test/integration/bulk_granting_permisions_test.rb b/test/integration/bulk_granting_permisions_test.rb deleted file mode 100644 index bb6ed85e0..000000000 --- a/test/integration/bulk_granting_permisions_test.rb +++ /dev/null @@ -1,81 +0,0 @@ -require "test_helper" - -class BulkGrantingPermissionsTest < ActionDispatch::IntegrationTest - include ActiveJob::TestHelper - - setup do - @users = create_list(:user, 2) - @org_admins = create_list(:organisation_admin_user, 2) - @admins = create_list(:admin_user, 2) - @superadmins = create_list(:superadmin_user, 2) - - @application = create(:application, with_supported_permissions: [SupportedPermission::SIGNIN_NAME]) - end - - should "superadmin user can grant multiple permissions to all users in one go" do - user = create(:superadmin_user) - - perform_bulk_grant_as_user(user, @application) - end - - should "admin user can grant multiple permissions to all users in one go" do - user = create(:admin_user) - - perform_bulk_grant_as_user(user, @application) - end - - should "super organisation admin user can not grant multiple permissions to all users in one go" do - user = create(:super_organisation_admin_user) - - visit root_path - signin_with(user) - - visit new_bulk_grant_permission_set_path - assert_equal root_path, current_path - end - - should "organisation admin user can not grant multiple permissions to all users in one go" do - user = create(:organisation_admin_user) - - visit root_path - signin_with(user) - - visit new_bulk_grant_permission_set_path - assert_equal root_path, current_path - end - - should "normal user can not grant multiple permissions to all users in one go" do - user = create(:user) - - visit root_path - signin_with(user) - - visit new_bulk_grant_permission_set_path - assert_equal root_path, current_path - end - - def perform_bulk_grant_as_user(acting_user, application) - perform_enqueued_jobs do - visit root_path - signin_with(acting_user) - - visit new_bulk_grant_permission_set_path - - select application.name, from: "Application" - - click_button "Grant access to all users" - - assert_response_contains("Scheduled grant of 1 permissions to all users") - assert_response_contains("Result") - assert_response_contains("All #{User.all.count} users processed") - - app_permissions_line = "#{application.name} Yes" - assert_response_contains app_permissions_line - - [acting_user, @users, @org_admins, @admins, @superadmins].flatten.each do |user| - user.reload - assert_equal [SupportedPermission::SIGNIN_NAME], user.permissions_for(application) - end - end - end -end diff --git a/test/models/bulk_grant_permission_set_test.rb b/test/models/bulk_grant_permission_set_test.rb deleted file mode 100644 index 4496f8ba3..000000000 --- a/test/models/bulk_grant_permission_set_test.rb +++ /dev/null @@ -1,185 +0,0 @@ -require "test_helper" - -class BulkGrantPermissionSetTest < ActiveSupport::TestCase - setup do - @app = create(:application) - @permission_set = create(:bulk_grant_permission_set, with_permissions: [@app.signin_permission]) - end - - should "require a user" do - permission_set = build(:bulk_grant_permission_set, user: nil) - - assert_not permission_set.valid? - assert_equal ["can't be blank"], permission_set.errors[:user] - end - - should "require at least one supported permission" do - permission_set = build(:bulk_grant_permission_set, with_permissions: []) - - assert_not permission_set.valid? - assert_equal ["must not be blank. Choose at least one permission to grant to all users."], permission_set.errors[:supported_permissions] - end - - context "validating #outcome" do - should "allow nil" do - permission_set = build(:bulk_grant_permission_set, outcome: nil) - - assert permission_set.valid? - end - - should "allow 'success'" do - permission_set = build(:bulk_grant_permission_set, outcome: "success") - - assert permission_set.valid? - end - - should "allow 'fail'" do - permission_set = build(:bulk_grant_permission_set, outcome: "fail") - - assert permission_set.valid? - end - - should "reject other values" do - permission_set = build(:bulk_grant_permission_set, outcome: "unsucessful") - - assert_not permission_set.valid? - assert_equal ["is not included in the list"], permission_set.errors[:outcome] - end - end - - context "perform" do - should "grant the supplied permissions to all users" do - user = create(:user) - admin_user = create(:admin_user) - superadmin_user = create(:superadmin_user) - orgadmin_user = create(:organisation_admin_user) - - @permission_set.perform - - assert_equal [SupportedPermission::SIGNIN_NAME], user.permissions_for(@app) - assert_equal [SupportedPermission::SIGNIN_NAME], admin_user.permissions_for(@app) - assert_equal [SupportedPermission::SIGNIN_NAME], superadmin_user.permissions_for(@app) - assert_equal [SupportedPermission::SIGNIN_NAME], orgadmin_user.permissions_for(@app) - end - - should "record the total number of users to be processed" do - create_list(:user, 4) - - @permission_set.perform - - # we created 4 but there's already one for the permission_set's own user - assert_equal 5, @permission_set.reload.total_users - end - - should "record the outcome against the BulkGrantPermissionSet" do - @permission_set.perform - assert_equal "success", @permission_set.outcome - end - - should "record the total number of users that actually were processed" do - create_list(:user, 4) - - @permission_set.perform - - # we created 4 but there's already one for the permission_set's own user - assert_equal 5, @permission_set.reload.processed_users - end - - should "not fail if a user already has one of the supplied permissions" do - user = create(:user, with_permissions: { @app => [SupportedPermission::SIGNIN_NAME] }) - - @permission_set.perform - - assert_equal [SupportedPermission::SIGNIN_NAME], user.permissions_for(@app) - end - - should "not remove permissions a user has that are not part of the supplied ones for the bulk grant set" do - other_app = create(:application, with_supported_permissions: %w[editor]) - create(:supported_permission, application: @app, name: "admin") - user = create(:user, with_permissions: { other_app => %w[editor], @app => %w[admin] }) - - @permission_set.perform - - assert_equal %w[editor], user.permissions_for(other_app) - assert_equal [SupportedPermission::SIGNIN_NAME, "admin"].sort, user.permissions_for(@app).sort - end - - should "mark it as failed if there is an error during processing and pass the error on for the worker to record the error details" do - UserApplicationPermission.any_instance.stubs(:save!).raises("ArbitraryError") - - assert_raises RuntimeError, "ArbitraryError" do - @permission_set.perform - end - assert_equal "fail", @permission_set.outcome - end - - should "mark how many users it managed to process if it fails" do - create_list(:user, 4) - UserApplicationPermission.any_instance.stubs(:save!).returns(true).then.returns(true).then.raises("ArbitraryError") - - assert_raises RuntimeError, "ArbitraryError" do - @permission_set.perform - end - assert_equal 2, @permission_set.reload.processed_users - end - - context "recording events against users" do - setup do - @app2 = create(:application, with_supported_permissions: [SupportedPermission::SIGNIN_NAME, "editor"]) - @permission_set.supported_permissions += @app2.supported_permissions - @permission_set.save! - end - - should "record a permissions added event for each app that we grant permissions for" do - user = create(:user) - user.event_logs.destroy_all - @permission_set.perform - - recorded_events = user.event_logs - assert_equal 2, recorded_events.length - - assert_equal EventLog::PERMISSIONS_ADDED, recorded_events[0].entry - assert_equal @app2, recorded_events[0].application - assert_equal "(editor, signin)", recorded_events[0].trailing_message - - assert_equal EventLog::PERMISSIONS_ADDED, recorded_events[1].entry - assert_equal @app, recorded_events[1].application - assert_equal "(signin)", recorded_events[1].trailing_message - end - - should "not include a permission in the event if the user already has it" do - user = create(:user, with_permissions: { @app2 => %w[editor] }) - user.event_logs.destroy_all - @permission_set.perform - - recorded_events = user.event_logs - assert_equal 2, recorded_events.length - - assert_equal EventLog::PERMISSIONS_ADDED, recorded_events[0].entry - assert_equal @app2, recorded_events[0].application - assert_equal "(signin)", recorded_events[0].trailing_message - end - - should "not create an event log for the app if the user already has all the permissions we are trying to grant for that app" do - user = create(:user, with_permissions: { @app => [SupportedPermission::SIGNIN_NAME] }) - user.event_logs.destroy_all - @permission_set.perform - - recorded_events = user.event_logs - assert_equal 1, recorded_events.length - - assert_equal EventLog::PERMISSIONS_ADDED, recorded_events[0].entry - assert_equal @app2, recorded_events[0].application - end - - should "not create any event logs if the user already has all the permissions we are trying to grant" do - user = create(:user, with_permissions: { @app => [SupportedPermission::SIGNIN_NAME], @app2 => [SupportedPermission::SIGNIN_NAME, "editor"] }) - user.event_logs.destroy_all - @permission_set.perform - - recorded_events = user.event_logs - assert_equal 0, recorded_events.length - end - end - end -end diff --git a/test/models/users_filter_test.rb b/test/models/users_filter_test.rb index 55b1c05b5..3db9b54ef 100644 --- a/test/models/users_filter_test.rb +++ b/test/models/users_filter_test.rb @@ -84,10 +84,10 @@ class UsersFilterTest < ActiveSupport::TestCase options = filter.status_option_select_options expected_options = [ + { label: "Active", value: "active", checked: false }, { label: "Suspended", value: "suspended", checked: false }, { label: "Invited", value: "invited", checked: false }, { label: "Locked", value: "locked", checked: false }, - { label: "Active", value: "active", checked: false }, ] assert_equal expected_options, options end @@ -99,10 +99,10 @@ class UsersFilterTest < ActiveSupport::TestCase options = filter.status_option_select_options expected_options = [ + { label: "Active", value: "active", checked: true }, { label: "Suspended", value: "suspended", checked: false }, { label: "Invited", value: "invited", checked: true }, { label: "Locked", value: "locked", checked: false }, - { label: "Active", value: "active", checked: true }, ] assert_equal expected_options, options end diff --git a/test/policies/bulk_grant_permission_set_policy_test.rb b/test/policies/bulk_grant_permission_set_policy_test.rb deleted file mode 100644 index 04f8bb620..000000000 --- a/test/policies/bulk_grant_permission_set_policy_test.rb +++ /dev/null @@ -1,17 +0,0 @@ -require "test_helper" -require "support/policy_helpers" - -class BulkGrantPermissionSetPolicyTest < ActiveSupport::TestCase - include PolicyHelpers - - context "new" do - should "allow only for superadmins and admins" do - assert permit?(create(:superadmin_user), User, :new) - assert permit?(create(:admin_user), User, :new) - - assert forbid?(create(:super_organisation_admin_user), User, :new) - assert forbid?(create(:organisation_admin_user), User, :new) - assert forbid?(create(:user), User, :new) - end - end -end