-
Notifications
You must be signed in to change notification settings - Fork 25
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
Showing
13 changed files
with
120 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class Attribute < ActiveRecord::Base | ||
belongs_to :attribute_subject, polymorphic: true | ||
validates :attribute_subject, presence: true | ||
validates_presence_of :type, :value | ||
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,3 @@ | ||
class Attribute::Import < Attribute | ||
validates_presence_of :import_predicate | ||
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,4 @@ | ||
class Attribute::Internal < Attribute | ||
belongs_to :predicate, foreign_key: :controlled_vocabulary_term_id | ||
validates :predicate, 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class ControlledVocabularyTerm::Predicate < ActiveRecord::Base | ||
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,14 @@ | ||
class CreateAttributes < ActiveRecord::Migration | ||
def change | ||
create_table :attributes do |t| | ||
t.string :type | ||
t.integer :attribute_subject_id | ||
t.string :attribute_subject_type | ||
t.integer :controlled_vocabularly_term_id | ||
t.string :import_predicate | ||
t.string :value | ||
|
||
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,6 @@ | ||
# Read about factories at https://github.com/thoughtbot/factory_girl | ||
|
||
FactoryGirl.define do | ||
factory :attribute_import, :class => 'Attribute::Import' do | ||
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,6 @@ | ||
# Read about factories at https://github.com/thoughtbot/factory_girl | ||
|
||
FactoryGirl.define do | ||
factory :attribute_internal, :class => 'Attribute::Internal' do | ||
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 @@ | ||
# Read about factories at https://github.com/thoughtbot/factory_girl | ||
|
||
FactoryGirl.define do | ||
factory :attribute do | ||
type "" | ||
attribute_subject_id 1 | ||
attribute_subject_type "MyString" | ||
controlled_vocabularly_term_id 1 | ||
import_predicate "MyString" | ||
value "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,6 @@ | ||
# Read about factories at https://github.com/thoughtbot/factory_girl | ||
|
||
FactoryGirl.define do | ||
factory :controlled_vocabulary_term_predicate, :class => 'ControlledVocabularyTerm::Predicate' do | ||
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,17 @@ | ||
require 'spec_helper' | ||
|
||
describe Attribute::Import do | ||
let (:attribute) {Attribute::Import.new} | ||
|
||
context 'validation' do | ||
before(:each) { | ||
attribute.valid? | ||
} | ||
context 'requires' do | ||
specify 'import_predicate' do | ||
expect(attribute.errors.include?(:import_predicate)).to be_true | ||
end | ||
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,16 @@ | ||
require 'spec_helper' | ||
|
||
describe Attribute::Internal do | ||
let (:attribute) {Attribute::Internal.new} | ||
|
||
context 'validation' do | ||
before(:each) { | ||
attribute.valid? | ||
} | ||
context 'requires' do | ||
specify 'predicate' do | ||
expect(attribute.errors.include?(:predicate)).to be_true | ||
end | ||
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,24 @@ | ||
require 'spec_helper' | ||
|
||
describe Attribute do | ||
let (:attribute) {Attribute.new} | ||
|
||
context 'validation' do | ||
before(:each) { | ||
attribute.valid? | ||
} | ||
context 'requires' do | ||
specify 'attribute_subject' do | ||
expect(attribute.errors.include?(:attribute_subject)).to be_true | ||
end | ||
|
||
specify 'value' do | ||
expect(attribute.errors.include?(:value)).to be_true | ||
end | ||
|
||
specify 'type' do | ||
expect(attribute.errors.include?(:type)).to be_true | ||
end | ||
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,5 @@ | ||
require 'spec_helper' | ||
|
||
describe ControlledVocabularyTerm::Predicate do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
end |