hydra_attribute 0.2.0 → 0.3.0.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +74 -68
- data/cucumber.yml +1 -0
- data/features/attributes/create.feature +22 -0
- data/features/attributes/destroy.feature +18 -0
- data/features/attributes/update.feature +19 -0
- data/features/create.feature +47 -0
- data/features/define.feature +33 -0
- data/features/query_methods/group.feature +13 -14
- data/features/query_methods/order.feature +63 -52
- data/features/query_methods/select.feature +36 -37
- data/features/query_methods/where.feature +36 -38
- data/features/step_definitions/model_steps.rb +23 -19
- data/features/step_definitions/query_methods.rb +6 -2
- data/features/step_definitions/record_steps.rb +28 -10
- data/features/support/env.rb +12 -6
- data/features/support/schema.rb +62 -35
- data/features/support/world.rb +14 -5
- data/features/update.feature +114 -0
- data/gemfiles/3.1.gemfile.lock +10 -10
- data/gemfiles/3.2.gemfile.lock +10 -10
- data/lib/hydra_attribute/active_record/association.rb +77 -0
- data/lib/hydra_attribute/active_record/association_preloader.rb +82 -0
- data/lib/hydra_attribute/active_record/attribute_methods.rb +145 -37
- data/lib/hydra_attribute/active_record/migration.rb +21 -0
- data/lib/hydra_attribute/active_record/reflection.rb +16 -0
- data/lib/hydra_attribute/active_record/relation/query_methods.rb +73 -71
- data/lib/hydra_attribute/active_record/relation.rb +1 -24
- data/lib/hydra_attribute/active_record.rb +16 -2
- data/lib/hydra_attribute/association_builder.rb +44 -20
- data/lib/hydra_attribute/builder.rb +15 -13
- data/lib/hydra_attribute/configuration.rb +9 -30
- data/lib/hydra_attribute/entity_callbacks.rb +46 -0
- data/lib/hydra_attribute/hydra_attribute.rb +27 -0
- data/lib/hydra_attribute/migrator.rb +106 -0
- data/lib/hydra_attribute/railtie.rb +2 -0
- data/lib/hydra_attribute/version.rb +2 -2
- data/lib/hydra_attribute.rb +8 -6
- data/lib/rails/generators/hydra_attribute/install/templates/hydra_attribute.txt +4 -0
- data/spec/spec_helper.rb +1 -2
- metadata +42 -60
- data/features/attribute_methods.feature +0 -146
- data/features/define_attributes.feature +0 -56
- data/features/load_associations.feature +0 -40
- data/features/step_definitions/class_steps.rb +0 -32
- data/features/typecast_attributes.feature +0 -24
- data/lib/generators/hydra_attribute/install/templates/hydra_attribute.txt +0 -11
- data/lib/hydra_attribute/active_record/attribute_methods/before_type_cast.rb +0 -16
- data/lib/hydra_attribute/active_record/attribute_methods/read.rb +0 -13
- data/lib/hydra_attribute/attribute_builder.rb +0 -57
- data/lib/hydra_attribute/attribute_proxy.rb +0 -16
- data/lib/hydra_attribute/migration.rb +0 -27
- data/spec/hydra_attribute/active_record/relation/query_methods_spec.rb +0 -334
- data/spec/hydra_attribute/active_record/relation_spec.rb +0 -67
- data/spec/hydra_attribute/active_record/scoping_spec.rb +0 -23
- data/spec/hydra_attribute/active_record_spec.rb +0 -18
- data/spec/hydra_attribute/association_builder_spec.rb +0 -95
- data/spec/hydra_attribute/attribute_builder_spec.rb +0 -70
- data/spec/hydra_attribute/attribute_helpers_spec.rb +0 -70
- data/spec/hydra_attribute/builder_spec.rb +0 -39
- data/spec/hydra_attribute/configuration_spec.rb +0 -65
- data/spec/hydra_attribute_spec.rb +0 -20
- /data/lib/{generators → rails/generators}/hydra_attribute/install/USAGE +0 -0
- /data/lib/{generators → rails/generators}/hydra_attribute/install/install_generator.rb +0 -0
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe HydraAttribute::Builder do
|
4
|
-
|
5
|
-
let(:klass) { Class.new }
|
6
|
-
let!(:builder) { HydraAttribute::Builder.new(klass) }
|
7
|
-
|
8
|
-
describe '#initialzie' do
|
9
|
-
it 'should include HydraAttribute::ActiveRecord::Scoping to class' do
|
10
|
-
klass.should include(HydraAttribute::ActiveRecord::Scoping)
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'should include HydraAttribute::ActiveRecord::AttributeMethods to class' do
|
14
|
-
klass.should include(HydraAttribute::ActiveRecord::AttributeMethods)
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'should respond to all supported types' do
|
18
|
-
HydraAttribute::SUPPORT_TYPES.each do |type|
|
19
|
-
builder.should respond_to(type)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe '#string' do
|
25
|
-
let(:association_instance) { mock(:association_instance) }
|
26
|
-
let(:attribute_instance) { mock(:attribute_instance) }
|
27
|
-
|
28
|
-
before do
|
29
|
-
HydraAttribute::AssociationBuilder.should_receive(:new).with(klass, :string).and_return(association_instance)
|
30
|
-
HydraAttribute::AttributeBuilder.should_receive(:new).with(klass, :name, :string).and_return(attribute_instance)
|
31
|
-
|
32
|
-
[association_instance, attribute_instance].each { |instance| instance.should_receive(:build) }
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'should build association' do
|
36
|
-
builder.string :name
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe HydraAttribute::Configuration do
|
4
|
-
let(:config) { HydraAttribute::Configuration.new }
|
5
|
-
|
6
|
-
describe '#table_name' do
|
7
|
-
describe 'with table prefix' do
|
8
|
-
before { config.table_prefix = 'table_' }
|
9
|
-
|
10
|
-
it 'should return table name' do
|
11
|
-
config.table_name(:string).should == :table_string_attributes
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe 'without table prefix' do
|
16
|
-
before { config.table_prefix = '' }
|
17
|
-
|
18
|
-
it 'should return table name' do
|
19
|
-
config.table_name(:string).should == :string_attributes
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe '#association' do
|
25
|
-
describe 'with association prefix' do
|
26
|
-
before { config.association_prefix = 'assoc_' }
|
27
|
-
|
28
|
-
it 'should return association name' do
|
29
|
-
config.association(:string).should == :assoc_string_attributes
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe 'without association prefix' do
|
34
|
-
before { config.association_prefix = '' }
|
35
|
-
|
36
|
-
it 'should return association name' do
|
37
|
-
config.association(:string).should == :string_attributes
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe '#associated_model_name' do
|
43
|
-
describe 'use module wrapper' do
|
44
|
-
before { config.use_module_for_associated_models = true }
|
45
|
-
|
46
|
-
it 'should return associated model name' do
|
47
|
-
config.associated_model_name(:string).should == 'HydraAttribute::StringAttribute'
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe 'don not use module wrapper' do
|
52
|
-
before { config.use_module_for_associated_models = false }
|
53
|
-
|
54
|
-
it 'should return associated model name' do
|
55
|
-
config.associated_model_name(:string).should == 'StringAttribute'
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe '#associated_const_name' do
|
61
|
-
it 'should return constant name for new model' do
|
62
|
-
config.associated_const_name(:string).should == :StringAttribute
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe HydraAttribute do
|
4
|
-
describe '.config' do
|
5
|
-
it 'should return and instance of HydraAttribute::Configuration' do
|
6
|
-
HydraAttribute.config.should be_a_kind_of(HydraAttribute::Configuration)
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'should cache config object' do
|
10
|
-
HydraAttribute.config.should be_equal(HydraAttribute.config)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
describe '.setup' do
|
15
|
-
it 'should allow to change default configuration' do
|
16
|
-
HydraAttribute.setup { |config| config.table_prefix = 'custom_table_prefix' }
|
17
|
-
HydraAttribute.config.table_prefix.should == 'custom_table_prefix'
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
File without changes
|
File without changes
|