10 changed files with 135 additions and 42 deletions
@ -0,0 +1,7 @@
|
||||
module Constants::User |
||||
ROLES = { |
||||
"data_accessor" => 0, |
||||
"data_provider" => 1, |
||||
"data_coordinator" => 2, |
||||
}.freeze |
||||
end |
@ -0,0 +1,15 @@
|
||||
class ChangeUserRoleToEnum < ActiveRecord::Migration[6.1] |
||||
def up |
||||
change_table :users, bulk: true do |t| |
||||
t.remove :role |
||||
t.column :role, :integer |
||||
end |
||||
end |
||||
|
||||
def down |
||||
change_table :users, bulk: true do |t| |
||||
t.remove :role |
||||
t.column :role, :string |
||||
end |
||||
end |
||||
end |
@ -1,58 +1,99 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe OrganisationsController, type: :request do |
||||
let(:user) { FactoryBot.create(:user) } |
||||
let(:organisation) { user.organisation } |
||||
let(:headers) { { "Accept" => "text/html" } } |
||||
let(:page) { Capybara::Node::Simple.new(response.body) } |
||||
|
||||
context "details tab" do |
||||
before do |
||||
sign_in user |
||||
get "/organisations/#{organisation.id}", headers: headers, params: {} |
||||
end |
||||
context "As a data coordinator user" do |
||||
let(:user) { FactoryBot.create(:user, :data_coordinator) } |
||||
|
||||
it "shows the tab navigation" do |
||||
expected_html = "<nav class=\"app-tab-navigation\"" |
||||
expect(response.body).to include(expected_html) |
||||
end |
||||
context "details tab" do |
||||
before do |
||||
sign_in user |
||||
get "/organisations/#{organisation.id}", headers: headers, params: {} |
||||
end |
||||
|
||||
it "shows the tab navigation" do |
||||
expected_html = "<nav class=\"app-tab-navigation\"" |
||||
expect(response.body).to include(expected_html) |
||||
end |
||||
|
||||
it "shows a summary list of org details" do |
||||
expected_html = "<dl class=\"govuk-summary-list\"" |
||||
expect(response.body).to include(expected_html) |
||||
expect(response.body).to include(organisation.name) |
||||
end |
||||
|
||||
it "shows a summary list of org details" do |
||||
expected_html = "<dl class=\"govuk-summary-list\"" |
||||
expect(response.body).to include(expected_html) |
||||
expect(response.body).to include(organisation.name) |
||||
it "has a hidden header title" do |
||||
expected_html = "<h2 class=\"govuk-visually-hidden\"> Details" |
||||
expect(response.body).to include(expected_html) |
||||
end |
||||
end |
||||
|
||||
it "has a hidden header title" do |
||||
expected_html = "<h2 class=\"govuk-visually-hidden\"> Details" |
||||
expect(response.body).to include(expected_html) |
||||
context "users tab" do |
||||
before do |
||||
sign_in user |
||||
get "/organisations/#{organisation.id}/users", headers: headers, params: {} |
||||
end |
||||
|
||||
it "shows the tab navigation" do |
||||
expected_html = "<nav class=\"app-tab-navigation\"" |
||||
expect(response.body).to include(expected_html) |
||||
end |
||||
|
||||
it "shows a new user button" do |
||||
expect(page).to have_link("Invite user") |
||||
end |
||||
|
||||
it "shows a table of users" do |
||||
expected_html = "<table class=\"govuk-table\"" |
||||
expect(response.body).to include(expected_html) |
||||
expect(response.body).to include(user.email) |
||||
end |
||||
|
||||
it "has a hidden header title" do |
||||
expected_html = "<h2 class=\"govuk-visually-hidden\"> Users" |
||||
expect(response.body).to include(expected_html) |
||||
end |
||||
end |
||||
end |
||||
|
||||
context "users tab" do |
||||
before do |
||||
sign_in user |
||||
get "/organisations/#{organisation.id}/users", headers: headers, params: {} |
||||
end |
||||
context "As a data provider user" do |
||||
let(:user) { FactoryBot.create(:user) } |
||||
|
||||
it "shows the tab navigation" do |
||||
expected_html = "<nav class=\"app-tab-navigation\"" |
||||
expect(response.body).to include(expected_html) |
||||
end |
||||
context "details tab" do |
||||
before do |
||||
sign_in user |
||||
get "/organisations/#{organisation.id}", headers: headers, params: {} |
||||
end |
||||
|
||||
it "shows a new user button" do |
||||
expect(page).to have_link("Invite user") |
||||
end |
||||
it "shows the tab navigation" do |
||||
expected_html = "<nav class=\"app-tab-navigation\"" |
||||
expect(response.body).to include(expected_html) |
||||
end |
||||
|
||||
it "shows a summary list of org details" do |
||||
expected_html = "<dl class=\"govuk-summary-list\"" |
||||
expect(response.body).to include(expected_html) |
||||
expect(response.body).to include(organisation.name) |
||||
end |
||||
|
||||
it "shows a table of users" do |
||||
expected_html = "<table class=\"govuk-table\"" |
||||
expect(response.body).to include(expected_html) |
||||
expect(response.body).to include(user.email) |
||||
it "has a hidden header title" do |
||||
expected_html = "<h2 class=\"govuk-visually-hidden\"> Details" |
||||
expect(response.body).to include(expected_html) |
||||
end |
||||
end |
||||
|
||||
it "has a hidden header title" do |
||||
expected_html = "<h2 class=\"govuk-visually-hidden\"> Users" |
||||
expect(response.body).to include(expected_html) |
||||
context "users tab" do |
||||
before do |
||||
sign_in user |
||||
get "/organisations/#{organisation.id}/users", headers: headers, params: {} |
||||
end |
||||
|
||||
it "should return unauthorised 401" do |
||||
expect(response).to have_http_status(:unauthorized) |
||||
end |
||||
end |
||||
end |
||||
end |
||||
|
Loading…
Reference in new issue