rename Option to OptionDefinition to be full Rails compliant
This commit is contained in:
parent
aa20013121
commit
76f5e4e6e1
@ -36,7 +36,7 @@ module Merged
|
||||
def save
|
||||
super
|
||||
data = Card.all.collect {|obj| obj.attributes}
|
||||
File.write( Option.full_path , data.to_yaml)
|
||||
File.write( OptionDefinition.full_path , data.to_yaml)
|
||||
end
|
||||
|
||||
def set_index(index)
|
||||
|
@ -11,7 +11,7 @@ module Merged
|
||||
def options_definitions
|
||||
option_defs = []
|
||||
options.each do |name|
|
||||
option = Option.find_by_name(name)
|
||||
option = OptionDefinition.find_by_name(name)
|
||||
raise "no option for #{name}:#{name.class}" if option.blank?
|
||||
option_defs << option
|
||||
end if options
|
||||
|
@ -1,5 +1,5 @@
|
||||
module Merged
|
||||
class Option < ActiveYaml::Base
|
||||
class OptionDefinition < ActiveYaml::Base
|
||||
set_root_path Engine.root + "config"
|
||||
|
||||
fields :name , :default , :description , :values , :type
|
@ -15,7 +15,7 @@ module Merged
|
||||
def options_definitions
|
||||
option_defs = []
|
||||
options.each do |name|
|
||||
option = Option.find_by_name(name)
|
||||
option = OptionDefinition.find_by_name(name)
|
||||
raise "no option for #{name}:#{name.class}" if option.blank?
|
||||
option_defs << option
|
||||
end if options
|
||||
|
@ -5,7 +5,7 @@ module Merged
|
||||
|
||||
def self.load_data
|
||||
# pre-load data
|
||||
Option.all
|
||||
OptionDefinition.all
|
||||
CardStyle.all
|
||||
SectionStyle.all
|
||||
Page.all
|
||||
|
20
spec/models/merged/option_definition_spec.rb
Normal file
20
spec/models/merged/option_definition_spec.rb
Normal file
@ -0,0 +1,20 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Merged
|
||||
RSpec.describe OptionDefinition, type: :model do
|
||||
let(:first) {OptionDefinition.first}
|
||||
|
||||
it "has OptionDefinition.first" do
|
||||
expect(OptionDefinition.first.class).to be OptionDefinition
|
||||
end
|
||||
it "there are options" do
|
||||
expect(OptionDefinition.all.length).to be 16
|
||||
end
|
||||
it "has option objects" do
|
||||
expect(first.class).to be OptionDefinition
|
||||
end
|
||||
it "has values" do
|
||||
expect(first.values.class).to be Array
|
||||
end
|
||||
end
|
||||
end
|
@ -1,20 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Merged
|
||||
RSpec.describe Option, type: :model do
|
||||
let(:first) {Option.first}
|
||||
|
||||
it "has Option.first" do
|
||||
expect(Option.first.class).to be Option
|
||||
end
|
||||
it "there are options" do
|
||||
expect(Option.all.length).to be 16
|
||||
end
|
||||
it "has option objects" do
|
||||
expect(first.class).to be Option
|
||||
end
|
||||
it "has values" do
|
||||
expect(first.values.class).to be Array
|
||||
end
|
||||
end
|
||||
end
|
@ -28,7 +28,7 @@ module Merged
|
||||
it "has option_definitions" do
|
||||
expect(last.option_definitions.class).to be Array
|
||||
expect(last.option_definitions.length).to be 4
|
||||
expect(last.option_definitions.second.class).to be Option
|
||||
expect(last.option_definitions.second.class).to be OptionDefinition
|
||||
expect(last.option_definitions.second.name).to eq "handler"
|
||||
end
|
||||
it "last has previous" do
|
||||
|
Loading…
Reference in New Issue
Block a user