rename Option to OptionDefinition to be full Rails compliant

This commit is contained in:
Torsten 2022-12-11 14:39:32 +02:00
parent aa20013121
commit 76f5e4e6e1
9 changed files with 26 additions and 26 deletions

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -5,7 +5,7 @@ module Merged
def self.load_data
# pre-load data
Option.all
OptionDefinition.all
CardStyle.all
SectionStyle.all
Page.all

View 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

View File

@ -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

View File

@ -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