-
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
baa4f32
commit f43dd5b
Showing
7 changed files
with
133 additions
and
6 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
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,35 @@ | ||
# frozen_string_literal: true | ||
|
||
# == Schema Information | ||
# | ||
# Table name: project_auths | ||
# | ||
# id :bigint not null, primary key | ||
# key :string | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# project_id :bigint not null | ||
# | ||
# Indexes | ||
# | ||
# index_project_auths_on_project_id (project_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (project_id => projects.id) | ||
# | ||
class ProjectAuth < ApplicationRecord | ||
belongs_to :project | ||
|
||
before_create :generate_key, unless: :key_present? | ||
|
||
private | ||
|
||
def generate_key | ||
self.key = SecureRandom.hex(10) # Generates a random hex string of 20 characters | ||
end | ||
|
||
def key_present? | ||
key.present? | ||
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 CreateProjectAuths < ActiveRecord::Migration[7.0] | ||
def change | ||
create_table :project_auths do |t| | ||
t.references :project, null: false, foreign_key: true | ||
t.string :key | ||
|
||
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: project_auths | ||
# | ||
# id :bigint not null, primary key | ||
# key :string | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# project_id :bigint not null | ||
# | ||
# Indexes | ||
# | ||
# index_project_auths_on_project_id (project_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (project_id => projects.id) | ||
# | ||
FactoryBot.define do | ||
factory :project_auth do | ||
project { nil } | ||
key { 'MyString' } | ||
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: project_auths | ||
# | ||
# id :bigint not null, primary key | ||
# key :string | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# project_id :bigint not null | ||
# | ||
# Indexes | ||
# | ||
# index_project_auths_on_project_id (project_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (project_id => projects.id) | ||
# | ||
require 'rails_helper' | ||
|
||
RSpec.describe ProjectAuth, type: :model do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
end |