active-fedora 11.1.2 → 11.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b27e9aa8b8f46d2a0e3207ba20da3aa25d553bac
4
- data.tar.gz: 8aac94771d8015432aa789bf807e514c6211be15
3
+ metadata.gz: 6fbb07414e2177fa95ea8349817976b1b37a765c
4
+ data.tar.gz: 6d2310b2bd54270c779e9f3c183b3aad790b68ad
5
5
  SHA512:
6
- metadata.gz: 7bc2ac85b840d7a5c8085a3d80d6407a6e3f315bf51fe7bd804b29818e375a939c9baf71560e6c1459f149d6cc6835af14e71128229d3255d87edaf818d3851e
7
- data.tar.gz: d0c5f0849a3de8577174e28feda066fa61c53f5a8d30b6d27b6ffc1c2f4eb45c4c353a8ff6a188afb36eec98ebcac5f3111da7cbe0c51c9bd875b719b55420e7
6
+ metadata.gz: 4fa39573b64bac45e116fbe334e657ef3f1b01e15a8a93cade30080c4d55fa2628e2b5de5bb15482880951f401fcea90b5736744ee141190f4ee03847015edd0
7
+ data.tar.gz: 14bf26166bc2d0a1e52455686a952922748036d3dd6a756be9e9264c3802032420ce0a0ddc608dcbb49050cea8d26ac3e339b38e3250b2177df4718e1eea2592
@@ -221,6 +221,10 @@ Style/ZeroLengthPredicate:
221
221
  Exclude:
222
222
  - 'lib/active_fedora/file/attributes.rb'
223
223
 
224
+ Performance/RedundantMerge:
225
+ Exclude:
226
+ - 'lib/active_fedora/railtie.rb'
227
+
224
228
  Rails:
225
229
  Enabled: true
226
230
 
@@ -3,6 +3,13 @@
3
3
  We want your help to make Project Hydra great.
4
4
  There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things.
5
5
 
6
+ ## Code of Conduct
7
+
8
+ The Hydra community is dedicated to providing a welcoming and positive experience for all its
9
+ members, whether they are at a formal gathering, in a social setting, or taking part in activities
10
+ online. Please see our [Code of Conduct](https://wiki.duraspace.org/display/hydra/Code+of+Conduct)
11
+ for more information.
12
+
6
13
  ## Hydra Project Intellectual Property Licensing and Ownership
7
14
 
8
15
  All code contributors must have an Individual Contributor License Agreement (iCLA) on file with the Hydra Project Steering Group.
@@ -16,8 +23,10 @@ You should also add yourself to the `CONTRIBUTORS.md` file in the root of the pr
16
23
 
17
24
  * Reporting Issues
18
25
  * Making Changes
26
+ * Documenting Code
27
+ * Committing Changes
19
28
  * Submitting Changes
20
- * Merging Changes
29
+ * Reviewing and Merging Changes
21
30
 
22
31
  ### Reporting Issues
23
32
 
@@ -38,8 +47,28 @@ You should also add yourself to the `CONTRIBUTORS.md` file in the root of the pr
38
47
  * Then checkout the new branch with `git checkout fix/master/my_contribution`.
39
48
  * Please avoid working directly on the `master` branch.
40
49
  * You may find the [hub suite of commands](https://github.com/defunkt/hub) helpful
50
+ * Make sure you have added sufficient tests and documentation for your changes.
51
+ * Test functionality with RSpec; est features / UI with Capybara.
52
+ * Run _all_ the tests to assure nothing else was accidentally broken.
53
+
54
+ ### Documenting Code
55
+
56
+ * All new public methods, modules, and classes should include inline documentation in [YARD](http://yardoc.org/).
57
+ * Documentation should seek to answer the question "why does this code exist?"
58
+ * Document private / protected methods as desired.
59
+ * If you are working in a file with no prior documentation, do try to document as you gain understanding of the code.
60
+ * If you don't know exactly what a bit of code does, it is extra likely that it needs to be documented. Take a stab at it and ask for feedback in your pull request. You can use the 'blame' button on GitHub to identify the original developer of the code and @mention them in your comment.
61
+ * This work greatly increases the usability of the code base and supports the on-ramping of new committers.
62
+ * We will all be understanding of one another's time constraints in this area.
63
+ * YARD examples:
64
+ * [Hydra::Works::RemoveGenericFile](https://github.com/projecthydra-labs/hydra-works/blob/master/lib/hydra/works/services/generic_work/remove_generic_file.rb)
65
+ * [ActiveTriples::LocalName::Minter](https://github.com/ActiveTriples/active_triples-local_name/blob/master/lib/active_triples/local_name/minter.rb)
66
+ * [Getting started with YARD](http://www.rubydoc.info/gems/yard/file/docs/GettingStarted.md)
67
+
68
+ ### Committing changes
69
+
41
70
  * Make commits of logical units.
42
- * Your commit should include a high level description of your work in HISTORY.textile
71
+ * Your commit should include a high level description of your work in HISTORY.textile
43
72
  * Check for unnecessary whitespace with `git diff --check` before committing.
44
73
  * Make sure your commit messages are [well formed](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
45
74
  * If you created an issue, you can close it by including "Closes #issue" in your commit message. See [Github's blog post for more details](https://github.com/blog/1386-closing-issues-via-commit-messages)
@@ -60,7 +89,9 @@ You should also add yourself to the `CONTRIBUTORS.md` file in the root of the pr
60
89
 
61
90
  class PostsController
62
91
  def index
63
- respond_with Post.limit(10)
92
+ respond_to do |wants|
93
+ wants.html { render 'index' }
94
+ end
64
95
  end
65
96
  end
66
97
 
@@ -72,38 +103,53 @@ You should also add yourself to the `CONTRIBUTORS.md` file in the root of the pr
72
103
  long to fit in 72 characters
73
104
  ```
74
105
 
75
- * Make sure you have added the necessary tests for your changes.
76
- * Run _all_ the tests to assure nothing else was accidentally broken.
77
- * When you are ready to submit a pull request
78
-
79
106
  ### Submitting Changes
80
107
 
81
- [Detailed Walkthrough of One Pull Request per Commit](http://ndlib.github.io/practices/one-commit-per-pull-request/)
82
-
83
108
  * Read the article ["Using Pull Requests"](https://help.github.com/articles/using-pull-requests) on GitHub.
84
109
  * Make sure your branch is up to date with its parent branch (i.e. master)
85
110
  * `git checkout master`
86
111
  * `git pull --rebase`
87
112
  * `git checkout <your-branch>`
88
113
  * `git rebase master`
89
- * It is likely a good idea to run your tests again.
90
- * Squash the commits for your branch into one commit
91
- * `git rebase --interactive HEAD~<number-of-commits>` ([See Github help](https://help.github.com/articles/interactive-rebase))
92
- * To determine the number of commits on your branch: `git log master..<your-branch> --oneline | wc -l`
114
+ * It is a good idea to run your tests again.
115
+ * If you've made more than one commit take a moment to consider whether squashing commits together would help improve their logical grouping.
116
+ * [Detailed Walkthrough of One Pull Request per Commit](http://ndlib.github.io/practices/one-commit-per-pull-request/)
117
+ * `git rebase --interactive master` ([See Github help](https://help.github.com/articles/interactive-rebase))
93
118
  * Squashing your branch's changes into one commit is "good form" and helps the person merging your request to see everything that is going on.
94
119
  * Push your changes to a topic branch in your fork of the repository.
95
120
  * Submit a pull request from your fork to the project.
96
121
 
97
- ### Merging Changes
122
+ ### Reviewing and Merging Changes
123
+
124
+ We adopted [Github's Pull Request Review](https://help.github.com/articles/about-pull-request-reviews/) for our repositories.
125
+ Common checks that may occur in our repositories:
126
+
127
+ 1. Travis CI - where our automated tests are running
128
+ 2. Hound CI - where we check for style violations
129
+ 3. Approval Required - Github enforces at least one person approve a pull request. Also, all reviewers that have chimed in must approve.
130
+ 4. CodeClimate - is our code remaining healthy (at least according to static code analysis)
131
+
132
+ If one or more of the required checks failed (or are incomplete), the code should not be merged (and the UI will not allow it). If all of the checks have passed, then anyone on the project (including the pull request submitter) may merge the code.
133
+
134
+ *Example: Carolyn submits a pull request, Justin reviews the pull request and approves. However, Justin is still waiting on other checks (Travis CI is usually the culprit), so he does not merge the pull request. Eventually, all of the checks pass. At this point, Carolyn or anyone else may merge the pull request.*
135
+
136
+ #### Things to Consider When Reviewing
137
+
138
+ First, the person contributing the code is putting themselves out there. Be mindful of what you say in a review.
139
+
140
+ * Ask clarifying questions
141
+ * State your understanding and expectations
142
+ * Provide example code or alternate solutions, and explain why
143
+
144
+ This is your chance for a mentoring moment of another developer. Take time to give an honest and thorough review of what has changed. Things to consider:
98
145
 
99
- * It is considered "poor from" to merge your own request.
100
- * Please take the time to review the changes and get a sense of what is being changed. Things to consider:
101
146
  * Does the commit message explain what is going on?
102
- * Does the code changes have tests? _Not all changes need new tests, some changes are refactorings_
147
+ * Does the code changes have tests? _Not all changes need new tests, some changes are refactors_
148
+ * Do new or changed methods, modules, and classes have documentation?
103
149
  * Does the commit contain more than it should? Are two separate concerns being addressed in one commit?
104
- * Did the Travis tests complete successfully?
105
- * If you are uncertain, bring other contributors into the conversation by creating a comment that includes their @username.
106
- * If you like the pull request, but want others to chime in, create a +1 comment and tag a user.
150
+ * Does the description of the new/changed specs match your understanding of what the spec is doing?
151
+
152
+ If you are uncertain, bring other contributors into the conversation by assigning them as a reviewer.
107
153
 
108
154
  # Additional Resources
109
155
 
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.required_ruby_version = '~> 2.0'
16
16
 
17
17
  s.add_dependency 'rsolr', '>= 1.1.2', '< 3'
18
- s.add_dependency 'solrizer', '~> 3.4'
18
+ s.add_dependency 'solrizer', '>= 3.4', '< 5'
19
19
  s.add_dependency "activesupport", '>= 4.2.4', '< 6'
20
20
  s.add_dependency "activemodel", '>= 4.2', '< 6'
21
21
  s.add_dependency "active-triples", '~> 0.11.0'
@@ -17,6 +17,16 @@ module ActiveFedora
17
17
  record.base_path_for_resource = owner.uri.to_s
18
18
  super
19
19
  end
20
+
21
+ def reset
22
+ # Update the membership triples (and no other triples) on the the owner's resource
23
+ if owner.persisted?
24
+ pattern = ::RDF::Query::Pattern.new(predicate: options[:predicate])
25
+ new_resource = owner.dup.reload.resource
26
+ owner.resource.delete_insert([pattern], new_resource.query(pattern))
27
+ end
28
+ super
29
+ end
20
30
  end
21
31
  end
22
32
  end
@@ -41,6 +41,15 @@ module ActiveFedora
41
41
 
42
42
  alias update_attributes update
43
43
 
44
+ # Updates its receiver just like #update but calls #save! instead
45
+ # of +save+, so an exception is raised if the record is invalid and saving will fail.
46
+ def update!(attributes)
47
+ assign_attributes(attributes)
48
+ save!
49
+ end
50
+
51
+ alias update_attributes! update!
52
+
44
53
  # Deletes an object from Fedora and deletes the indexed record from Solr.
45
54
  # Delete does not run any callbacks, so consider using _destroy_ instead.
46
55
  # @param [Hash] opts
@@ -2,6 +2,10 @@ module ActiveFedora
2
2
  class Railtie < Rails::Railtie
3
3
  config.app_middleware.insert_after ::ActionDispatch::Callbacks,
4
4
  ActiveFedora::LdpCache
5
+ config.action_dispatch.rescue_responses.merge!(
6
+ "ActiveFedora::ObjectNotFoundError" => :not_found
7
+ )
8
+
5
9
  config.eager_load_namespaces << ActiveFedora
6
10
 
7
11
  initializer 'active_fedora.autoload', before: :set_autoload_paths do |app|
@@ -112,7 +112,7 @@ module ActiveFedora
112
112
  result = search_with_conditions({ id: id }, opts)
113
113
 
114
114
  if result.empty?
115
- raise ActiveFedora::ObjectNotFoundError, "Object #{id} not found in solr"
115
+ raise ActiveFedora::ObjectNotFoundError, "Object '#{id}' not found in solr"
116
116
  end
117
117
 
118
118
  result.first
@@ -191,10 +191,15 @@ module ActiveFedora
191
191
  def load_from_fedora(id, cast)
192
192
  raise ActiveFedora::ObjectNotFoundError if id.empty?
193
193
  resource = ActiveFedora.fedora.ldp_resource_service.build(klass, id)
194
- raise ActiveFedora::ObjectNotFoundError if resource.new?
194
+ raise_record_not_found_exception!(id) if resource.new?
195
195
  class_to_load(resource, cast).allocate.init_with_resource(resource) # Triggers the find callback
196
196
  end
197
197
 
198
+ def raise_record_not_found_exception!(id)
199
+ name = @klass.name
200
+ raise ActiveFedora::ObjectNotFoundError, "Couldn't find #{name} with 'id'=#{id}"
201
+ end
202
+
198
203
  def class_to_load(resource, cast)
199
204
  if @klass == ActiveFedora::Base && cast == false
200
205
  ActiveFedora::Base
@@ -1,3 +1,3 @@
1
1
  module ActiveFedora
2
- VERSION = "11.1.2".freeze
2
+ VERSION = "11.1.3".freeze
3
3
  end
@@ -1,8 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe ActiveFedora::Base do
4
- let(:model) { Source.new }
5
-
3
+ describe ActiveFedora::Associations::BasicContainsAssociation do
6
4
  context "with a file" do
7
5
  before do
8
6
  class Source < ActiveFedora::Base
@@ -10,6 +8,8 @@ describe ActiveFedora::Base do
10
8
  end
11
9
  end
12
10
 
11
+ let(:model) { Source.new }
12
+
13
13
  after do
14
14
  Object.send(:remove_const, :Source)
15
15
  end
@@ -104,5 +104,18 @@ describe ActiveFedora::Base do
104
104
  .and change { Thing.count }.by(-2)
105
105
  end
106
106
  end
107
+
108
+ describe "#reload" do
109
+ before do
110
+ model.save!
111
+ child = model.contains.create(title: ['title 1'])
112
+ model.reload # Cause the model to load its graph that contains the child ids.
113
+ ActiveFedora::Base.find(child.id).destroy
114
+ end
115
+
116
+ it "can reload without attempting to load any deleted objects" do
117
+ expect { model.contains.reload }.not_to raise_error
118
+ end
119
+ end
107
120
  end
108
121
  end
@@ -101,7 +101,7 @@ describe ActiveFedora::FinderMethods do
101
101
  end
102
102
 
103
103
  it "returns the document" do
104
- expect { finder.search_by_id('x') }.to raise_error ActiveFedora::ObjectNotFoundError
104
+ expect { finder.search_by_id('x') }.to raise_error ActiveFedora::ObjectNotFoundError, "Object 'x' not found in solr"
105
105
  end
106
106
  end
107
107
  end
@@ -56,7 +56,7 @@ describe ActiveFedora::Base do
56
56
  describe "with :cast false" do
57
57
  describe "and an id is specified" do
58
58
  it "raises an exception if it is not found" do
59
- expect { SpecModel::Basic.find("_ID_") }.to raise_error ActiveFedora::ObjectNotFoundError
59
+ expect { SpecModel::Basic.find("_ID_") }.to raise_error ActiveFedora::ObjectNotFoundError, "Couldn't find SpecModel::Basic with 'id'=_ID_"
60
60
  end
61
61
  end
62
62
  end
@@ -41,11 +41,34 @@ describe ActiveFedora::Base do
41
41
  end
42
42
 
43
43
  describe "#save!" do
44
- before { allow(validation_stub).to receive(:_create_record) } # prevent saving to Fedora/Solr
44
+ before { expect(validation_stub).to receive(:_create_record) } # prevent saving to Fedora/Solr
45
45
 
46
46
  it "validates only once" do
47
47
  expect(validation_stub).to receive(:perform_validations).once.and_return(true)
48
48
  validation_stub.save!
49
49
  end
50
50
  end
51
+
52
+ describe "#update!" do
53
+ before do
54
+ allow(validation_stub).to receive(:new_record?).and_return(false)
55
+ end
56
+ context "when validations work" do
57
+ it "saves the record" do
58
+ expect(validation_stub).to receive(:_update_record) # prevent saving to Fedora/Solr
59
+ expect(validation_stub).to receive(:perform_validations).once.and_return(true)
60
+ validation_stub.update!(fubar: ['here'], swank: 'long enough')
61
+ expect(validation_stub.fubar).to eq ['here']
62
+ end
63
+ end
64
+
65
+ context "when validations fail" do
66
+ it "raises an error" do
67
+ expect(validation_stub).not_to receive(:_update_record)
68
+ expect(validation_stub).to receive(:perform_validations).once.and_return(false)
69
+ expect { validation_stub.update!(fubar: ['here'], swank: 'long enough') }.to raise_error ActiveFedora::RecordInvalid
70
+ expect(validation_stub.fubar).to eq ['here']
71
+ end
72
+ end
73
+ end
51
74
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active-fedora
3
3
  version: !ruby/object:Gem::Version
4
- version: 11.1.2
4
+ version: 11.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Zumwalt
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-01-25 00:00:00.000000000 Z
13
+ date: 2017-02-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rsolr
@@ -36,16 +36,22 @@ dependencies:
36
36
  name: solrizer
37
37
  requirement: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - "~>"
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '3.4'
42
+ - - "<"
43
+ - !ruby/object:Gem::Version
44
+ version: '5'
42
45
  type: :runtime
43
46
  prerelease: false
44
47
  version_requirements: !ruby/object:Gem::Requirement
45
48
  requirements:
46
- - - "~>"
49
+ - - ">="
47
50
  - !ruby/object:Gem::Version
48
51
  version: '3.4'
52
+ - - "<"
53
+ - !ruby/object:Gem::Version
54
+ version: '5'
49
55
  - !ruby/object:Gem::Dependency
50
56
  name: activesupport
51
57
  requirement: !ruby/object:Gem::Requirement