3 changed files with 89 additions and 1 deletions
@ -0,0 +1,33 @@ |
|||||||
|
ActiveAdmin.register User do |
||||||
|
permit_params :name, :email, :password, :password_confirmation, :organisation_id |
||||||
|
|
||||||
|
index do |
||||||
|
selectable_column |
||||||
|
id_column |
||||||
|
column :name |
||||||
|
column :email |
||||||
|
column :organisation |
||||||
|
column :current_sign_in_at |
||||||
|
column :sign_in_count |
||||||
|
column :created_at |
||||||
|
actions |
||||||
|
end |
||||||
|
|
||||||
|
filter :email |
||||||
|
filter :name |
||||||
|
filter :organisation |
||||||
|
filter :current_sign_in_at |
||||||
|
filter :sign_in_count |
||||||
|
filter :created_at |
||||||
|
|
||||||
|
form do |f| |
||||||
|
f.inputs do |
||||||
|
f.input :name |
||||||
|
f.input :email |
||||||
|
f.input :password |
||||||
|
f.input :password_confirmation |
||||||
|
f.input :organisation |
||||||
|
end |
||||||
|
f.actions |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,55 @@ |
|||||||
|
require "rails_helper" |
||||||
|
require_relative "../../support/devise" |
||||||
|
|
||||||
|
describe Admin::UsersController, type: :controller do |
||||||
|
render_views |
||||||
|
let!(:user) { FactoryBot.create(:user) } |
||||||
|
let(:organisation) { FactoryBot.create(:organisation) } |
||||||
|
let(:page) { Capybara::Node::Simple.new(response.body) } |
||||||
|
let(:resource_title) { "Users" } |
||||||
|
let(:valid_session) { {} } |
||||||
|
login_admin_user |
||||||
|
|
||||||
|
describe "Get users" do |
||||||
|
before do |
||||||
|
get :index, session: valid_session |
||||||
|
end |
||||||
|
|
||||||
|
it "returns a table of users" do |
||||||
|
expect(page).to have_content(resource_title) |
||||||
|
expect(page).to have_table("index_table_users") |
||||||
|
expect(page).to have_link(user.id.to_s) |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
describe "Create users" do |
||||||
|
let(:params) do |
||||||
|
{ |
||||||
|
user: { |
||||||
|
email: "test5@example.com", |
||||||
|
name: "Jane", |
||||||
|
password: "pAssword1", |
||||||
|
organisation_id: organisation.id, |
||||||
|
}, |
||||||
|
} |
||||||
|
end |
||||||
|
|
||||||
|
it "creates a new users" do |
||||||
|
expect { post :create, session: valid_session, params: params }.to change(User, :count).by(1) |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
describe "Update users" do |
||||||
|
before do |
||||||
|
get :edit, session: valid_session, params: { id: user.id } |
||||||
|
end |
||||||
|
|
||||||
|
it "shows an edit form" do |
||||||
|
expect(page).to have_field("user_email") |
||||||
|
expect(page).to have_field("user_name") |
||||||
|
expect(page).to have_field("user_organisation_id") |
||||||
|
expect(page).to have_field("user_password") |
||||||
|
expect(page).to have_field("user_password_confirmation") |
||||||
|
end |
||||||
|
end |
||||||
|
end |
Loading…
Reference in new issue