@@ -1933,61 +1933,6 @@ class DiscriminatorChild2 < DiscriminatorParent
1933
1933
end
1934
1934
end
1935
1935
1936
- describe '.configure DSL' do
1937
-
1938
- context '.type method' do
1939
- around do |example |
1940
- klass = Mongoid ::Fields ::FieldTypes
1941
- klass . instance_variable_set ( :@mapping , klass ::DEFAULT_MAPPING . dup )
1942
- example . run
1943
- klass . instance_variable_set ( :@mapping , klass ::DEFAULT_MAPPING . dup )
1944
- end
1945
-
1946
- it 'can define a custom type' do
1947
- described_class . configure do
1948
- define_type :my_type , Integer
1949
- end
1950
-
1951
- expect ( described_class ::FieldTypes . get ( :my_type ) ) . to eq Integer
1952
- end
1953
-
1954
- it 'can override and existing type' do
1955
- described_class . configure do
1956
- define_type :integer , String
1957
- end
1958
-
1959
- expect ( described_class ::FieldTypes . get ( :integer ) ) . to eq String
1960
- end
1961
- end
1962
-
1963
- context '.option method' do
1964
- after do
1965
- described_class . instance_variable_set ( :@options , { } )
1966
- end
1967
-
1968
- it 'can define a custom field option' do
1969
- described_class . configure do
1970
- option :my_required do |model , field , value |
1971
- model . validates_presence_of field . name if value
1972
- end
1973
- end
1974
-
1975
- klass = Class . new do
1976
- include Mongoid ::Document
1977
- field :my_field , my_required : true
1978
-
1979
- def self . model_name
1980
- OpenStruct . new ( human : 'Klass' )
1981
- end
1982
- end
1983
-
1984
- instance = klass . new
1985
- expect ( instance . valid? ) . to eq false
1986
- expect ( instance . errors . full_messages ) . to eq [ "My field can't be blank" ]
1987
- end
1988
- end
1989
- end
1990
-
1991
1936
describe '::TYPE_MAPPINGS' do
1992
1937
it 'returns the default mapping' do
1993
1938
expect ( described_class ::TYPE_MAPPINGS ) . to eq ::Mongoid ::Fields ::FieldTypes ::DEFAULT_MAPPING
0 commit comments