-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mange inventory-pools, roles, and suspensions
- Loading branch information
Showing
43 changed files
with
2,122 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule database
updated
3 files
+18 −0 | db/migrate/530_remove_ar_deleted_at.rb | |
+50 −0 | db/migrate/531_suspensions.rb | |
+59 −28 | db/structure.sql |
Submodule shared-clj
updated
5 files
+13 −6 | src/leihs/core/auth/session.clj | |
+8 −0 | src/leihs/core/ds.clj | |
+10 −6 | src/leihs/core/icons.cljs | |
+23 −14 | src/leihs/core/ring_exception.clj | |
+1 −2 | src/leihs/core/user/permissions.clj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class InventoryPool < Sequel::Model(:inventory_pools) | ||
end | ||
|
||
FactoryBot.define do | ||
factory :inventory_pool do | ||
name { Faker::Company.name } | ||
email { Faker::Internet.email } | ||
|
||
after :build do |inventory_pool| | ||
inventory_pool.shortname = inventory_pool.name.split(" ").map(&:first).join | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
require 'spec_helper' | ||
require 'pry' | ||
|
||
feature 'Manage inventory-pools', type: :feature do | ||
|
||
context 'an admin user' do | ||
|
||
before :each do | ||
@admin = FactoryBot.create :admin | ||
sign_in_as @admin | ||
end | ||
|
||
let(:name) { Faker::Company.name} | ||
let(:description) { Faker::Markdown.sandwich } | ||
let(:shortname) { Faker::Name.initials } | ||
let(:email) { Faker::Internet.email } | ||
|
||
scenario 'adding a new inventory-pool ' do | ||
|
||
visit '/admin/' | ||
click_on 'Inventory-Pools' | ||
click_on 'Add' | ||
fill_in 'name', with: name | ||
fill_in 'description', with: description | ||
fill_in 'shortname', with: shortname | ||
fill_in 'email', with: email | ||
check 'is_active' | ||
|
||
click_on 'Add' | ||
|
||
wait_until { current_path.match "^\/admin\/inventory-pools\/.+" } | ||
|
||
@inventory_pool_path = current_path | ||
@inventory_pool_id = current_path.match(/.*\/([^\/]+)/)[1] | ||
|
||
expect(page).to have_content name | ||
expect(page).to have_content shortname | ||
expect(page).to have_content email | ||
expect(page).to have_content description | ||
|
||
# The inventory pools path includes the newly created inventory pool and | ||
# we can get to it via clicking its name | ||
click_on "Inventory-Pools" | ||
wait_until { current_path == "/admin/inventory-pools/" } | ||
expect(page).to have_content name | ||
click_on name | ||
wait_until { current_path == @inventory_pool_path } | ||
|
||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require 'spec_helper' | ||
require 'pry' | ||
|
||
|
||
feature 'Manage inventory-pools', type: :feature do | ||
|
||
context ' an admin and several pools ' do | ||
|
||
before :each do | ||
@admin = FactoryBot.create :admin | ||
@pools = 10.times.map { FactoryBot.create :inventory_pool } | ||
sign_in_as @admin | ||
end | ||
|
||
scenario 'deleting an inventory pool' do | ||
|
||
visit '/admin/' | ||
click_on 'Inventory-Pools' | ||
|
||
@pools.each { |pool| expect(page).to have_content pool.name } | ||
|
||
click_on @pools.first.name | ||
@inventory_pool_path = current_path | ||
|
||
click_on 'Delete' # delete page | ||
click_on 'Delete' # submit / confirm | ||
|
||
wait_until { current_path == "/admin/inventory-pools/" } | ||
|
||
@pools.drop(1).each { |pool| expect(page).to have_content pool.name } | ||
|
||
expect(page).not_to have_content @pools.first.name | ||
|
||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
require 'spec_helper' | ||
require 'pry' | ||
|
||
|
||
feature 'Manage inventory-pools', type: :feature do | ||
|
||
context ' an admin and several pools ' do | ||
|
||
before :each do | ||
@admin = FactoryBot.create :admin | ||
@pools = 10.times.map { FactoryBot.create :inventory_pool } | ||
sign_in_as @admin | ||
end | ||
|
||
scenario 'edit an inventory pool' do | ||
|
||
visit '/admin/' | ||
click_on 'Inventory-Pools' | ||
|
||
@pools.each { |pool| expect(page).to have_content pool.name } | ||
|
||
click_on @pools.first.name | ||
@inventory_pool_path = current_path | ||
|
||
click_on 'Edit' | ||
|
||
fill_in 'name', with: 'The New Name' | ||
fill_in 'description', with: 'Foo Bar Baz' | ||
fill_in 'shortname', with: 'TNN' | ||
fill_in 'email', with: 'new-name@example.com' | ||
uncheck 'is_active' | ||
|
||
click_on 'Save' | ||
|
||
wait_until {current_path == @inventory_pool_path} | ||
|
||
expect(page).to have_content 'The New Name' | ||
expect(page).to have_content 'Foo Bar Baz' | ||
expect(page).to have_content 'TNN' | ||
expect(page).to have_content 'new-name@example.com' | ||
|
||
click_on 'Inventory-Pools' | ||
wait_until { current_path == "/admin/inventory-pools/" } | ||
expect(page).to have_content 'The New Name' | ||
|
||
end | ||
|
||
end | ||
|
||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
require 'spec_helper' | ||
require 'pry' | ||
|
||
|
||
|
||
feature 'Manage inventory-pool users ', type: :feature do | ||
|
||
context ' an admin, a pool, and several users ' do | ||
|
||
before :each do | ||
@admin = FactoryBot.create :admin | ||
@pool = FactoryBot.create :inventory_pool | ||
@users = 10.times.map{ FactoryBot.create :user } | ||
sign_in_as @admin | ||
end | ||
|
||
scenario ' managing roles of a user' do | ||
|
||
visit "/admin/inventory-pools/#{@pool.id}" | ||
click_on "Users" | ||
fill_in 'users-search-term', with: @users.first.lastname | ||
wait_until { all("table.users tbody tr").count == 1 } | ||
expect(page.find("table.users")).not_to have_content "customer" | ||
expect(page.find("table.users")).not_to have_content "inventory_manager" | ||
click_on "none" | ||
@user_overview_page = current_path | ||
|
||
click_on "Direct Roles" | ||
check "customer" | ||
click_on "Save" | ||
wait_until { current_path == @user_overview_page } | ||
click_on "Manage Direct Roles" | ||
check "inventory_manager" | ||
click_on "Save" | ||
|
||
click_on "Users" | ||
visit current_path # force full reload to make sure we not only see a fiction of the SPA | ||
# test filtering by role: | ||
select 'inventory_manager', from: 'Role' | ||
wait_until { all("table.users tbody tr").count == 1 } | ||
# the following also tests the current hierarchy within roles and will | ||
# break once we change that | ||
expect(page.find("table.users")).to have_content "customer" | ||
expect(page.find("table.users")).to have_content "group_manager" | ||
expect(page.find("table.users")).to have_content "lending_manager" | ||
expect(page.find("table.users")).to have_content "inventory_manager" | ||
|
||
end | ||
end | ||
end | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
require 'spec_helper' | ||
require 'pry' | ||
|
||
|
||
feature 'Manage inventory-pool users ', type: :feature do | ||
|
||
context ' an admin, a pool, and several users ' do | ||
|
||
before :each do | ||
@admin = FactoryBot.create :admin | ||
@pool = FactoryBot.create :inventory_pool | ||
@users = 10.times.map{ FactoryBot.create :user } | ||
sign_in_as @admin | ||
end | ||
|
||
scenario ' managing the suspension of a user' do | ||
|
||
visit "/admin/inventory-pools/#{@pool.id}" | ||
click_on "Users" | ||
fill_in 'users-search-term', with: @users.first.lastname | ||
wait_until { all("table.users tbody tr").count == 1 } | ||
click_on "unsuspended" | ||
@user_overview_page = current_path | ||
|
||
click_on "Suspension" | ||
fill_in 'suspended_until', with: Date.today.iso8601 | ||
fill_in 'suspended_reason', with: 'Some reason' | ||
click_on 'Save' | ||
wait_until {current_path == @user_overview_page} | ||
expect(page).to have_content 'is suspended' | ||
|
||
# remove suspension | ||
click_on 'Remove Suspension' | ||
expect(page).to have_content 'Not suspended' | ||
|
||
|
||
click_on 'Manage Suspension' | ||
fill_in 'suspended_until', with: (Date.today + 100.years).iso8601 | ||
click_on 'Save' | ||
click_on 'Users' | ||
check "Suspended" | ||
wait_until { all("table.users tbody tr").count == 1 } | ||
expect(page.find("table.users")).to have_content 'forever' | ||
|
||
end | ||
end | ||
end | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.