Ops può correggere dati clienti errati (es. email titolare) dalla scheda società senza interventi manuali sul DB. Co-authored-by: Cursor <cursoragent@cursor.com>
47 lines
1.3 KiB
Ruby
47 lines
1.3 KiB
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe Admin::UpdateClubData do
|
|
let!(:club) do
|
|
Club.create!(
|
|
name: "Svc Club",
|
|
sport: "pallavolo",
|
|
primary_color: "#e53935",
|
|
secondary_color: "#ffffff"
|
|
)
|
|
end
|
|
let!(:owner) do
|
|
user = User.create!(email: "svc-owner@test.it", name: "Owner", password: "Password123", role: "coach")
|
|
ClubMembership.create!(user: user, club: club, role: "owner")
|
|
user
|
|
end
|
|
|
|
it "updates club and owner email" do
|
|
described_class.call(
|
|
club: club,
|
|
club_attrs: {
|
|
name: "Svc Club Updated",
|
|
billing_email: "bill@test.it",
|
|
billing_province: "bz"
|
|
},
|
|
owner_attrs: { email: "owner-fixed@test.it", name: "Owner Fixed" }
|
|
)
|
|
|
|
expect(club.reload.name).to eq("Svc Club Updated")
|
|
expect(club.billing_email).to eq("bill@test.it")
|
|
expect(club.billing_province).to eq("BZ")
|
|
expect(owner.reload.email).to eq("owner-fixed@test.it")
|
|
end
|
|
|
|
it "raises when email is already taken" do
|
|
User.create!(email: "taken@test.it", name: "Other", password: "Password123", role: "coach")
|
|
|
|
expect do
|
|
described_class.call(
|
|
club: club,
|
|
club_attrs: {},
|
|
owner_attrs: { email: "taken@test.it" }
|
|
)
|
|
end.to raise_error(Admin::UpdateClubData::Error)
|
|
end
|
|
end
|