-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name might not be included long term.
- Loading branch information
Showing
11 changed files
with
209 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module ServiceScopes | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
scope :placements, -> { where placements: true } | ||
scope :claims, -> { where claims: true } | ||
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,19 @@ | ||
# == Schema Information | ||
# | ||
# Table name: providers | ||
# | ||
# id :uuid not null, primary key | ||
# claims :boolean default(FALSE) | ||
# name :string | ||
# placements :boolean default(FALSE) | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# accredited_provider_id :string | ||
# | ||
# Indexes | ||
# | ||
# index_providers_on_accredited_provider_id (accredited_provider_id) | ||
# | ||
class Provider < ApplicationRecord | ||
include ServiceScopes | ||
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,19 @@ | ||
# == Schema Information | ||
# | ||
# Table name: schools | ||
# | ||
# id :uuid not null, primary key | ||
# claims :boolean default(FALSE) | ||
# name :string | ||
# placements :boolean default(FALSE) | ||
# urn :string | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
# Indexes | ||
# | ||
# index_schools_on_urn (urn) | ||
# | ||
class School < ApplicationRecord | ||
include ServiceScopes | ||
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 @@ | ||
class CreateSchools < ActiveRecord::Migration[7.1] | ||
def change | ||
create_table :schools, id: :uuid do |t| | ||
t.string :urn, index: true | ||
t.string :name | ||
t.boolean :placements, default: false | ||
t.boolean :claims, default: false | ||
|
||
t.timestamps | ||
end | ||
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 @@ | ||
class CreateProviders < ActiveRecord::Migration[7.1] | ||
def change | ||
create_table :providers, id: :uuid do |t| | ||
t.string :accredited_provider_id, index: true | ||
t.string :name | ||
t.boolean :placements, default: false | ||
t.boolean :claims, default: false | ||
|
||
t.timestamps | ||
end | ||
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
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,22 @@ | ||
# == Schema Information | ||
# | ||
# Table name: providers | ||
# | ||
# id :uuid not null, primary key | ||
# claims :boolean default(FALSE) | ||
# name :string | ||
# placements :boolean default(FALSE) | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# accredited_provider_id :string | ||
# | ||
# Indexes | ||
# | ||
# index_providers_on_accredited_provider_id (accredited_provider_id) | ||
# | ||
FactoryBot.define do | ||
factory :provider do | ||
name { Faker::Educator.university } | ||
accredited_provider_id { SecureRandom.uuid } | ||
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,22 @@ | ||
# == Schema Information | ||
# | ||
# Table name: schools | ||
# | ||
# id :uuid not null, primary key | ||
# claims :boolean default(FALSE) | ||
# name :string | ||
# placements :boolean default(FALSE) | ||
# urn :string | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
# Indexes | ||
# | ||
# index_schools_on_urn (urn) | ||
# | ||
FactoryBot.define do | ||
factory :school do | ||
name { Faker::Educator.secondary_school } | ||
urn { SecureRandom.uuid } | ||
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,23 @@ | ||
# == Schema Information | ||
# | ||
# Table name: providers | ||
# | ||
# id :uuid not null, primary key | ||
# claims :boolean default(FALSE) | ||
# name :string | ||
# placements :boolean default(FALSE) | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# accredited_provider_id :string | ||
# | ||
# Indexes | ||
# | ||
# index_providers_on_accredited_provider_id (accredited_provider_id) | ||
# | ||
require "rails_helper" | ||
|
||
RSpec.describe Provider, type: :model do | ||
context "scopes" do | ||
include_examples "service scopes" | ||
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,23 @@ | ||
# == Schema Information | ||
# | ||
# Table name: schools | ||
# | ||
# id :uuid not null, primary key | ||
# claims :boolean default(FALSE) | ||
# name :string | ||
# placements :boolean default(FALSE) | ||
# urn :string | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
# Indexes | ||
# | ||
# index_schools_on_urn (urn) | ||
# | ||
require "rails_helper" | ||
|
||
RSpec.describe School, type: :model do | ||
context "scopes" do | ||
include_examples "service scopes" | ||
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,18 @@ | ||
require "rails_helper" | ||
|
||
RSpec.shared_examples "service scopes" do | ||
let!(:placements_on) { create(described_class.model_name.param_key.to_sym, placements: true) } | ||
let!(:claims_on) { create(described_class.model_name.param_key.to_sym, claims: true) } | ||
|
||
describe "#placements" do | ||
it "only returns instances with placements on" do | ||
expect(described_class.placements).to contain_exactly(placements_on) | ||
end | ||
end | ||
|
||
describe "#claims" do | ||
it "only returns instance with claims on" do | ||
expect(described_class.claims).to contain_exactly(claims_on) | ||
end | ||
end | ||
end |