Submit social housing lettings and sales data (CORE)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
2.0 KiB

require "rails_helper"
RSpec.describe TabNavHelper do
let(:organisation) { FactoryBot.create(:organisation) }
let(:user) { FactoryBot.build(:user, organisation:) }
let(:scheme) { FactoryBot.build(:scheme, service_name: "Some name") }
describe "#user_cell" do
it "returns user link and email separated by a newline character" do
expected_html = "<a class=\"govuk-link\" href=\"/users\">#{user.name}</a>\n<span class=\"govuk-visually-hidden\">User </span><span class=\"govuk-!-font-weight-regular app-!-colour-muted\">#{user.email}</span>"
expect(user_cell(user)).to match(expected_html)
end
end
describe "#org_cell" do
it "returns the users org name and role separated by a newline character" do
expected_html = "DLUHC\n<span class=\"app-!-colour-muted\">Data provider</span>"
expect(org_cell(user)).to match(expected_html)
end
end
describe "#scheme_cell" do
CLDC-1290 Permitted user can create a new scheme (#671) * added test to find link to create a new scheme * added button to create a new scheme * testing arriving to the new scheme form * non exsiting link to controller new action * SPIKEEEE * first page complete * posting to create * refactored scheme to enums * refactored new scheme page to use enums as well * views * SPIKE WIP * SPIKE WIP * SPIKE WIP * drawing list of scheme details * expanded on feature seeing more fields to fill in * expanded on feature seeing more fields to fill in 2nd page * refactored * working back buttons * working flash * more change in wip * default value for org * working spike * some spacing * filling answers * spike finished * correct name for details * testing fill in details * removed gem and further tests * Add has other client group field to schemes. Display it in the check answers. Fix tests and routing * remove details view and path Co-authored-by: baarkerlounger <baarkerlounger@users.noreply.github.com> * WIP change update paths * Implement changing answers (except the details one) * Add details page back for editing scheme details * added missing test for support questions and nested check answers under correct context * checking the back functionality * rubo and lint * checking the back functionality for primary gourp * checking the back functionality for confirm secondary * checking the back functionality for secondary group * checking the back functionality for support answers * checking the back functionality for returning to check answers from details page * checking the back functionality for returning to check answers from primary group page * checking the back functionality for secondary group confirm yes * checking the back functionality for secondary group confirm yes - fixed * checking the back functionality for secondary group * checking the back functionality for secondary group -fixed * checking the back functionality for returning from support page * Do not display secondary client group if the scheme doesn't have one * Add details path to schemes controller update method * Add more tests for back button * Add tests for new controller method * Add tests for creating schemes as data coordinator * fixed schema * added test for missing params when creating scheme * create for support user with or withotu required param * code to get controller render errors when required param is missing * code to implement correct validation * code to implement correct validation - part 2 * highlight missing field * doing silly dance to get correct field highlighted on the error * testing patch for schemes * testing patch for schemes - correct path * small refactoring * testing primary client group update via regular path * testing primary client group update via check answers page * testing confirm secondary group update with YES NO and returning from check answers page * testing updating secondary client group update and returning from check answers page * testing support answers and returning from check answers page * testing details and returning from check answers page * weird path when no names supplied * rubocop * lost in rebasing * started id to code refactoring * model specs remastered * fixed scheme controller specs * further refactorings * fixing feature schemes * final touches * removed code from db * remaining code purged * rubocop * included check for owning org field * checking for stock owning org selection * added stock owning org * added stock owning org on new page * added stock owning org to details * removed total units * managing related schems properly via Org * managing related schems properly via Org - rubocop * small refactoring * small refactoring - 2 * small refactoring - 3 * tests for owned_schemes and managed_schemes * rubocop * added tests for support user creating scheme * rubocop -a * tests for a primary-client-group * tests for a secondary-client-group * tests for a confirm-secondary-client-group * tests for a check-answers * tests for a details * rubocop * redundant action in controller * Trigger WF * switched to int for confirm * flashing test * flashing test for support user * flashing test rubocop Co-authored-by: Kat <katrina@madetech.com> Co-authored-by: baarkerlounger <baarkerlounger@users.noreply.github.com>
2 years ago
it "returns the scheme link service name and primary user group separated by a newline character" do
expected_html = "<a class=\"govuk-link\" href=\"/schemes\">#{scheme.service_name}</a>\n<span class=\"govuk-visually-hidden\">Scheme </span><span class=\"govuk-!-font-weight-regular app-!-colour-muted\">#{scheme.primary_client_group}</span>"
expect(scheme_cell(scheme)).to match(expected_html)
end
end
describe "#tab_items" do
context "when user is a data_coordinator" do
let(:user) { FactoryBot.build(:user, :data_coordinator, organisation:) }
it "returns details and user tabs" do
result = tab_items(user).map { |i| i[:name] }
expect(result.count).to eq(2)
expect(result.first).to match("Details")
expect(result.second).to match("Users")
end
end
context "when user is a data_provider" do
it "returns details and user tabs" do
result = tab_items(user).map { |i| i[:name] }
expect(result.count).to eq(2)
expect(result.first).to match("Details")
expect(result.second).to match("Users")
end
end
end
end