active-fedora 9.12.0 → 9.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/active-fedora.gemspec +1 -0
  4. data/lib/active_fedora.rb +1 -0
  5. data/lib/active_fedora/associations.rb +38 -3
  6. data/lib/active_fedora/associations/basic_contains_association.rb +12 -51
  7. data/lib/active_fedora/associations/builder/aggregation.rb +1 -1
  8. data/lib/active_fedora/associations/builder/basic_contains.rb +7 -0
  9. data/lib/active_fedora/associations/builder/{contains.rb → has_subresource.rb} +2 -2
  10. data/lib/active_fedora/associations/contains_association.rb +19 -1
  11. data/lib/active_fedora/associations/directly_contains_association.rb +1 -15
  12. data/lib/active_fedora/associations/has_subresource_association.rb +61 -0
  13. data/lib/active_fedora/attached_files.rb +6 -9
  14. data/lib/active_fedora/autosave_association.rb +1 -1
  15. data/lib/active_fedora/base.rb +0 -1
  16. data/lib/active_fedora/common.rb +1 -0
  17. data/lib/active_fedora/fedora.rb +14 -19
  18. data/lib/active_fedora/file.rb +1 -1
  19. data/lib/active_fedora/file/attributes.rb +4 -0
  20. data/lib/active_fedora/file_persistence.rb +9 -1
  21. data/lib/active_fedora/initializing_connection.rb +64 -0
  22. data/lib/active_fedora/ldp_cache.rb +1 -2
  23. data/lib/active_fedora/ldp_resource_service.rb +7 -1
  24. data/lib/active_fedora/persistence.rb +12 -1
  25. data/lib/active_fedora/reflection.rb +22 -6
  26. data/lib/active_fedora/simple_datastream.rb +2 -0
  27. data/lib/active_fedora/version.rb +1 -1
  28. data/lib/generators/active_fedora/config/fedora/fedora_generator.rb +1 -0
  29. data/lib/generators/active_fedora/config/fedora/templates/.fcrepo_wrapper +1 -0
  30. data/lib/generators/active_fedora/config/fedora/templates/fcrepo_wrapper_test.yml +4 -0
  31. data/lib/generators/active_fedora/config/solr/solr_generator.rb +1 -0
  32. data/lib/generators/active_fedora/config/solr/templates/.solr_wrapper +3 -0
  33. data/lib/generators/active_fedora/config/solr/templates/solr_wrapper_test.yml +8 -0
  34. data/spec/integration/attached_files_spec.rb +77 -18
  35. data/spec/integration/attributes_spec.rb +3 -4
  36. data/spec/integration/autosave_association_spec.rb +0 -1
  37. data/spec/integration/base_spec.rb +19 -66
  38. data/spec/integration/basic_contains_association_spec.rb +108 -0
  39. data/spec/integration/complex_rdf_datastream_spec.rb +1 -1
  40. data/spec/integration/field_to_solr_name_spec.rb +12 -11
  41. data/spec/integration/file_fixity_spec.rb +1 -1
  42. data/spec/integration/file_spec.rb +4 -1
  43. data/spec/integration/generators/fedora_generator_spec.rb +26 -0
  44. data/spec/integration/generators/solr_generator_spec.rb +26 -0
  45. data/spec/integration/has_and_belongs_to_many_associations_spec.rb +6 -16
  46. data/spec/integration/has_many_associations_spec.rb +6 -16
  47. data/spec/integration/{contains_association_spec.rb → has_subresource_spec.rb} +1 -1
  48. data/spec/integration/json_serialization_spec.rb +11 -5
  49. data/spec/integration/model_spec.rb +7 -13
  50. data/spec/integration/ntriples_datastream_spec.rb +2 -2
  51. data/spec/integration/om_datastream_spec.rb +1 -1
  52. data/spec/integration/persistence_spec.rb +0 -3
  53. data/spec/integration/query_result_builder_spec.rb +1 -1
  54. data/spec/integration/relation_delegation_spec.rb +3 -8
  55. data/spec/integration/scoped_query_spec.rb +5 -7
  56. data/spec/integration/solr_hit_spec.rb +10 -4
  57. data/spec/integration/solr_instance_loader_spec.rb +11 -4
  58. data/spec/integration/versionable_spec.rb +3 -3
  59. data/spec/spec_helper.rb +5 -1
  60. data/spec/unit/active_fedora_spec.rb +1 -1
  61. data/spec/unit/attached_files_spec.rb +32 -21
  62. data/spec/unit/attributes_spec.rb +21 -23
  63. data/spec/unit/base_active_model_spec.rb +13 -10
  64. data/spec/unit/base_spec.rb +2 -24
  65. data/spec/unit/callback_spec.rb +0 -8
  66. data/spec/unit/core_spec.rb +3 -5
  67. data/spec/unit/inheritance_spec.rb +15 -9
  68. data/spec/unit/ntriples_datastream_spec.rb +1 -1
  69. data/spec/unit/om_datastream_spec.rb +1 -1
  70. data/spec/unit/persistence_spec.rb +21 -0
  71. data/spec/unit/query_spec.rb +8 -0
  72. data/spec/unit/rdf_datastream_spec.rb +1 -1
  73. data/spec/unit/rdf_resource_datastream_spec.rb +1 -1
  74. data/spec/unit/simple_datastream_spec.rb +8 -2
  75. data/spec/unit/solr_config_options_spec.rb +1 -1
  76. data/spec/unit/validations_spec.rb +2 -8
  77. metadata +27 -6
  78. data/spec/integration/bug_spec.rb +0 -40
  79. data/spec/integration/full_featured_model_spec.rb +0 -160
@@ -1,160 +0,0 @@
1
- require 'spec_helper'
2
- require 'rexml/document'
3
-
4
- include ActiveFedora
5
-
6
- describe ActiveFedora::Base do
7
- before(:all) do
8
- class OralHistory < ActiveFedora::Base
9
- # These are all the properties that don't quite fit into Qualified DC
10
- # Put them on the object itself (in the properties datastream) for now.
11
- has_metadata name: "properties", type: ActiveFedora::SimpleDatastream do |m|
12
- m.field "narrator", :string
13
- m.field "interviewer", :string
14
- m.field "transcript_editor", :text
15
- m.field "bio", :string
16
- m.field "notes", :text
17
- m.field "hard_copy_availability", :text
18
- m.field "hard_copy_location", :text
19
- m.field "other_contributor", :string
20
- m.field "restrictions", :text
21
- m.field "series", :string
22
- m.field "location", :string
23
- end
24
-
25
- has_metadata name: "mods_article", type: Hydra::ModsArticleDatastream
26
-
27
- has_metadata name: "dublin_core", type: ActiveFedora::QualifiedDublinCoreDatastream do |_m|
28
- # Default :multiple => true
29
- #
30
- # on retrieval, these will be pluralized and returned as arrays
31
- # ie. subject_entries = my_oral_history.dublin_core.subjects
32
- #
33
- # aimint to use method-missing to support calling methods like
34
- # my_oral_history.subjects OR my_oral_history.titles OR EVEN my_oral_history.title whenever possible
35
-
36
- # Setting new Types for dates and text content
37
- # m.field "creation_date", :date, :xml_node => "date"
38
- # m.field "abstract", :text, :xml_node => "abstract"
39
- # m.field "rights", :text, :xml_node => "rights"
40
-
41
- # Setting up special named fields
42
- # m.field "subject_heading", :string, :xml_node => "subject", :encoding => "LCSH"
43
- # m.field "spatial_coverage", :string, :xml_node => "spatial", :encoding => "TGN"
44
- # m.field "temporal_coverage", :string, :xml_node => "temporal", :encoding => "Period"
45
- # m.field "type", :string, :xml_node => "type", :encoding => "DCMITYPE"
46
- # m.field "alt_title", :string, :xml_node => "alternative"
47
- end
48
-
49
- has_metadata name: "significant_passages", type: ActiveFedora::SimpleDatastream do |m|
50
- m.field "significant_passage", :text
51
- end
52
-
53
- has_metadata name: "sensitive_passages", type: ActiveFedora::SimpleDatastream do |m|
54
- m.field "sensitive_passage", :text
55
- end
56
- end
57
- sample_location = "Boston, Massachusetts"
58
- sample_notes = 'Addelson, Frances. (1973?) "The Induced Abortion," American Journal of Ortho-Psychiatry, Addelson, Frances. "Abortion: Source of Guilt or Growth," National Journal of Gynecology and Obstetrics., Addelson, Frances. "First Zionist Novel," Jewish Frontier.'
59
- sample_other_contributor = 'any other contributors, people or corporate names (eg. Temple Israel)'
60
- sample_transcript_editor = 'Siegel, Cheryl'
61
- sample_hard_copy_availability = <<-END
62
- Yes, please contact the Jewish Women\\\'s Archive for more information on using this source.
63
- END
64
- sample_narrator = 'Addelson, Frances'
65
- sample_bio = <<-END
66
- Rochelle Ruthchild interviewed Frances Addleson on October 18, November 14, and December 10, 1997. The interview thoroughly examined the trajectory of Frances\' life from birth until the time of the interview. As a young child, Frances\' father died during the influenza eidemic, and her mother was not equipped to care for her and her siblings. Consequently, they were placed in a Jewish foster home. Although her experience was mostly positive, this experience would leave life-long effects. Frances attended Radcliffe upon the urging of a mentor and later obtained her Master\'s degree in social work from Simmons College in 1954. In the 1940\'s, she returned to work while her children were still young; a rather unusual event for that time period. While working as a social worker at Beth Israel Hospital in the early 1970\'s, she helped counsel countless women who came to the hospital seeking abortions before the procedure was officially legalized during the landmark Roe vs. Wade decision in 1973. Frances would later write two articles that were published in medical journals about her experience during this time. Although not a very religious person, Frances felt connected to the Jewish notion of social justice and remained very active until an accident in the late 1990\'s.
67
- END
68
- sample_interviewer = "Ruthchild, & Rochelle"
69
-
70
- @properties_sample_values2 = Hash[narrator: "Narrator1 & Narrator2", interviewer: "Interviewer", transcript_editor: "Transcript Editor", bio: "Biographic info",
71
- notes: "My Note\\\'s a good one", hard_copy_availability: "Yes", hard_copy_location: "Archives", other_contributor: "Sally Ride",
72
- restrictions: "None", series: "My Series", location: "location"]
73
-
74
- @properties_sample_values = Hash[narrator: sample_narrator, interviewer: sample_interviewer, transcript_editor: sample_transcript_editor, bio: sample_bio,
75
- notes: sample_notes, hard_copy_availability: sample_hard_copy_availability, hard_copy_location: "Archives", other_contributor: sample_other_contributor,
76
- restrictions: "None", series: "My Series", location: sample_location]
77
-
78
- @dublin_core_sample_values = Hash[creator: 'Matt && McClain', publisher: "Jewish Womens's Archive", description: "description", identifier: "jwa:sample_id",
79
- title: "title",
80
- #:alt_title => "alt_title", :subject => "subject",
81
- #:subject_heading => "subject heading",
82
- #:creation_date => "2008-07-02T05:09:42.015Z",
83
- language: "language",
84
- #:spatial_coverage => "spatial coverage",
85
- #:temporal_coverage => "temporal coverage",
86
- #:abstract => "abstract",
87
- rights: "rights", type: "type",
88
- #:extent => "extent",
89
- format: "format", medium: "medium"]
90
- @signigicant_passages_sample_values = {}
91
- @sensitive_passages_sample_values = {}
92
- @sample_xml = "<xml><fields><system_create_date>REMOVED</system_create_date><system_modified_date>REMOVED</system_modified_date><active_fedora_model_s>OralHistory</active_fedora_model_s><id>changeme:14527</id><subject_heading>subject heading</subject_heading><type>type</type><rights>rights</rights><publisher>publisher</publisher><creation_date>creation date</creation_date><identifier>jwa:sample_id</identifier><format>format</format><extent>extent</extent><language>language</language><description>description</description><title>title</title><medium>medium</medium><spatial_coverage>spatial coverage</spatial_coverage><alt_title>alt_title</alt_title><temporal_coverage>temporal coverage</temporal_coverage><subject>subject</subject><creator>creator</creator><abstract>abstract</abstract><other_contributor>Sally Ride</other_contributor><transcript_editor>Transcript Editor</transcript_editor><restrictions>None</restrictions><bio>Biographic info</bio><series>My Series</series><notes>My Note</notes><location>location</location><hard_copy_availability>Yes</hard_copy_availability><narrator>Narrator</narrator><hard_copy_location>Archives</hard_copy_location><interviewer>Interviewer</interviewer></fields><content/></xml>"
93
- end
94
-
95
- before(:each) do
96
- @test_history = OralHistory.new
97
- end
98
-
99
- after(:each) do
100
- end
101
-
102
- after(:all) do
103
- Object.send(:remove_const, :OralHistory)
104
- end
105
-
106
- it "is an instance of ActiveFedora::Base" do
107
- expect(@test_history).to be_kind_of(described_class)
108
- end
109
-
110
- it "creates proxies to all the attached_files" do
111
- properties_ds = @test_history.attached_files["properties"]
112
- expect(@test_history.properties).to be properties_ds
113
- expect(@test_history).to respond_to(:properties)
114
- expect(OralHistory.new).to respond_to(:properties)
115
- end
116
-
117
- it "pushes all of the metadata fields into solr" do
118
- # TODO: test must test values using solr symbol names (ie. _field, _text and _date)
119
- properties_ds = @test_history.attached_files["properties"]
120
- dublin_core_ds = @test_history.attached_files["dublin_core"]
121
-
122
- @properties_sample_values.each_pair do |field, value|
123
- next if field == :hard_copy_availability # FIXME: HYDRA-824
124
- properties_ds.send("#{field}=", [value])
125
- end
126
-
127
- @dublin_core_sample_values.each_pair do |field, value|
128
- next if [:format, :type].include?(field) # format and type are methods declared on Object
129
- dublin_core_ds.send("#{field}=", [value])
130
- end
131
-
132
- @test_history.save
133
-
134
- @solr_result = OralHistory.search_with_conditions(id: @test_history.id)[0]
135
- @properties_sample_values.each_pair do |field, value|
136
- next if field == :hard_copy_availability # FIXME: HYDRA-824
137
- next if field == :location # FIXME HYDRA-825
138
- expect((@solr_result[ActiveFedora.index_field_mapper.solr_name(field, type: :string)] || @solr_result[ActiveFedora.index_field_mapper.solr_name(field, type: :date)])).to eq [::Solrizer::Extractor.format_node_value(value)]
139
- end
140
-
141
- @dublin_core_sample_values.each_pair do |field, value|
142
- next if [:format, :type].include?(field) # format and type are methods declared on Object
143
- expect(dublin_core_ds.send(field.to_s)).to eq [value]
144
- end
145
- end
146
-
147
- it "has Qualified Dublin core, with custom accessors" do
148
- dublin_core_ds = @test_history.attached_files["dublin_core"]
149
-
150
- dublin_core_ds.subject = "My Subject Heading"
151
- dc_xml = REXML::Document.new(dublin_core_ds.to_xml)
152
-
153
- expect(dc_xml.root.elements["dcterms:subject"].text).to eq "My Subject Heading"
154
- end
155
-
156
- it "supports #search_with_conditions" do
157
- solr_result = OralHistory.search_with_conditions({})
158
- expect(solr_result).to_not be_nil
159
- end
160
- end