-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a6e0d3
commit 70e3bcd
Showing
7 changed files
with
148 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# frozen_string_literal: true | ||
|
||
# == Schema Information | ||
# | ||
# Table name: customer_service_auths | ||
# | ||
# id :bigint not null, primary key | ||
# auth_key :string | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# customer_id :bigint not null | ||
# | ||
# Indexes | ||
# | ||
# index_customer_service_auths_on_customer_id (customer_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (customer_id => customers.id) | ||
# | ||
|
||
class CustomerServiceAuth < ApplicationRecord | ||
belongs_to :customer | ||
|
||
before_create :generate_auth_key | ||
|
||
private | ||
|
||
def generate_auth_key | ||
self.auth_key = SecureRandom.hex(10) # Generates a random hex string of 20 characters | ||
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,12 @@ | ||
# frozen_string_literal: true | ||
|
||
class CreateCustomerApiAuth < ActiveRecord::Migration[7.0] | ||
def change | ||
create_table :customer_api_auths do |t| | ||
t.string :auth_key | ||
t.references :customer, null: false, foreign_key: true | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
12 changes: 12 additions & 0 deletions
12
db/migrate/20240605181504_create_customer_service_auths.rb
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,12 @@ | ||
# frozen_string_literal: true | ||
|
||
class CreateCustomerServiceAuths < ActiveRecord::Migration[7.0] | ||
def change | ||
create_table :customer_service_auths do |t| | ||
t.string :auth_key | ||
t.references :customer, null: false, foreign_key: true | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,26 @@ | ||
# frozen_string_literal: true | ||
|
||
# == Schema Information | ||
# | ||
# Table name: customer_service_auths | ||
# | ||
# id :bigint not null, primary key | ||
# auth_key :string | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# customer_id :bigint not null | ||
# | ||
# Indexes | ||
# | ||
# index_customer_service_auths_on_customer_id (customer_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (customer_id => customers.id) | ||
# | ||
FactoryBot.define do | ||
factory :customer_service_auth do | ||
auth_key { 'MyString' } | ||
customer { nil } | ||
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,25 @@ | ||
# frozen_string_literal: true | ||
|
||
# == Schema Information | ||
# | ||
# Table name: customer_service_auths | ||
# | ||
# id :bigint not null, primary key | ||
# auth_key :string | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# customer_id :bigint not null | ||
# | ||
# Indexes | ||
# | ||
# index_customer_service_auths_on_customer_id (customer_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (customer_id => customers.id) | ||
# | ||
require 'rails_helper' | ||
|
||
RSpec.describe CustomerServiceAuth, type: :model do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
end |