This repository has been archived by the owner on May 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improving validation, adding test coverage
- Loading branch information
Showing
13 changed files
with
66 additions
and
54 deletions.
There are no files selected for viewing
This file was deleted.
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
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
class EphemeraProject < ApplicationRecord | ||
has_many :ephemera_fields | ||
|
||
validates :name, presence: true | ||
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 |
---|---|---|
@@ -1,12 +1,8 @@ | ||
class AuthorityFinder | ||
def self.for(property:, project:) | ||
return unless property.starts_with?("EphemeraFolder.") && project | ||
begin | ||
fields = EphemeraField.where name: "#{property}", ephemera_project: project | ||
Qa::Authorities::Local.subauthority_for(fields.first.vocabulary.label) if fields.first | ||
rescue Qa::InvalidSubAuthority | ||
Rails.logger.debug("Non-existent sub-authority requested for property #{property}") | ||
nil | ||
end | ||
|
||
fields = EphemeraField.where name: "#{property}", ephemera_project: project | ||
VocabularySubauthority.new(fields.first.vocabulary.label, fields.first.vocabulary) if fields.first | ||
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
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 was deleted.
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 |
---|---|---|
@@ -1,5 +1,20 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe EphemeraField, type: :model do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
let(:project) { FactoryGirl.build :ephemera_project } | ||
let(:vocab) { FactoryGirl.build :vocabulary } | ||
|
||
subject { described_class.new name: "EphemeraFolder.subject", ephemera_project: project, vocabulary: vocab } | ||
|
||
it "has a name" do | ||
expect(subject.name).to eq("EphemeraFolder.subject") | ||
end | ||
|
||
it "has a project" do | ||
expect(subject.ephemera_project).to eq(project) | ||
end | ||
|
||
it "has a vocabulary" do | ||
expect(subject.vocabulary).to eq(vocab) | ||
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 |
---|---|---|
@@ -1,5 +1,8 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe EphemeraProject, type: :model do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
it "has a name" do | ||
project = described_class.new name: "Test Project" | ||
expect(project.name).to eq("Test Project") | ||
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