Skip to content

Commit

Permalink
fix(CE): remove unique validation of organization name (#477) (#407)
Browse files Browse the repository at this point in the history
Co-authored-by: datafloyd <[email protected]>
  • Loading branch information
github-actions[bot] and subintp authored Oct 11, 2024
1 parent 1aedb25 commit fd4eaee
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 10 deletions.
2 changes: 1 addition & 1 deletion server/app/models/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# updated_at :datetime not null
#
class Organization < ApplicationRecord
validates :name, presence: true, uniqueness: { case_sensitive: false }
validates :name, presence: true

has_many :workspaces, dependent: :destroy
has_many :workspace_users, through: :workspaces
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class RemoveNameUniqueIndexFromOrganization < ActiveRecord::Migration[7.1]
def change
remove_index :organizations, :name
end
end
3 changes: 1 addition & 2 deletions server/db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 21 additions & 6 deletions server/spec/interactors/authentication/signup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,31 @@
}
end

it "fails" do
expect(context).to be_failure
it "succeeds" do
expect(context).to be_success
end

it "creates and does not confirm the user" do
expect { context }.to change(User, :count).by(1)
user = User.find_by(email: params[:email])
expect(user).not_to be_nil
expect(user.confirmed_at).to be_nil
end

it "creates a new user" do
expect { context }.to change(User, :count).by(1)
end

it "creates a new organization" do
expect { context }.to change(Organization, :count).by(1)
end

it "does not create a new user" do
expect { context }.not_to change(User, :count)
it "creates a new workspace" do
expect { context }.to change(Workspace, :count).by(1)
end

it "provides error messages related to company name" do
expect(context.errors).to eq("Signup failed: Company name has already been taken")
it "returns a success message" do
expect(context.message).to eq("Signup successful! Please check your email to confirm your account.")
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion server/spec/models/organization_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# Test validations
describe "validations" do
it { should validate_presence_of(:name) }
it { should validate_uniqueness_of(:name).case_insensitive }
# it { should validate_uniqueness_of(:name).case_insensitive }
# Add other validations here
end

Expand Down

0 comments on commit fd4eaee

Please sign in to comment.