active-fedora 7.0.0 → 7.0.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0fa25da6ae7e46eb73b51e82f7497d6cf68a7e81
4
- data.tar.gz: e8a47ec380de5f2b7cb8af447239aeab4774fdfd
3
+ metadata.gz: 3c10a4702718ed6d75d2ae3a50d68f2f7df312ed
4
+ data.tar.gz: 1f789a3692431f14efbda9e097f0e2edfdb87881
5
5
  SHA512:
6
- metadata.gz: dfbda832810e935c5d17b07baa68d14fb9c42727858d7c7b7fd5739698dc03a7f06251bcd1e52b55af0ead5614ca3d7867dd0893681c1ba3576071da4cf3c938
7
- data.tar.gz: 05de3e9a1c2f039bec9699fdb827571ff3125a14df0cecca96789928b01e1a14a140a972d702da16aaf61ee6624bed7c930ac4cd3d6145ff7415e176ee542432
6
+ metadata.gz: 2a00cdb7d97f144159944cee46347cd092fc8251b54317c23aea390ba35861906077fac78890f28e7976c53f5ddcfae1320998c8532a4ecbcf752360035c97ce
7
+ data.tar.gz: 8e73ac6816f0ca3bd51a3724c6654bdb1031d75ae938d6464b1e88423a590e5a5e725c0b986548dcbfb8c4ea85851fcf00365bf4ecc5d6ebb16dc63a109a771e
@@ -90,6 +90,21 @@ module ActiveFedora
90
90
  end
91
91
  end
92
92
 
93
+ # Returns true if the collection is empty.
94
+ #
95
+ # If the collection has been loaded it is equivalent to <tt>collection.
96
+ # size.zero?</tt>. If the collection has not been loaded, it is equivalent to
97
+ # <tt>collection.count_records == 0</tt>. If the collection has not already been
98
+ # loaded and you are going to fetch the records anyway it is better to
99
+ # check <tt>collection.length.zero?</tt>.
100
+ def empty?
101
+ if loaded?
102
+ size.zero?
103
+ else
104
+ @target.blank? && count_records == 0
105
+ end
106
+ end
107
+
93
108
  # Replace this collection with +other_array+
94
109
  # This will perform a diff and delete/add only records that have changed.
95
110
  def replace(other_array)
@@ -1,3 +1,3 @@
1
1
  module ActiveFedora
2
- VERSION = "7.0.0"
2
+ VERSION = "7.0.1"
3
3
  end
@@ -123,24 +123,40 @@ describe ActiveFedora::Base do
123
123
 
124
124
  let (:book) { Book.create }
125
125
  let (:collection) { Collection.create }
126
- before do
127
- book.collections << collection
128
- book.save!
129
- end
130
- after do
131
- collection.delete
132
- book.delete
133
- end
134
- it "should have a collection" do
135
- book.relationships(:is_member_of_collection).should == [collection.internal_uri]
136
- book.collections.should == [collection]
137
- end
138
- it "habtm should not set foreign relationships if :inverse_of is not specified" do
139
- collection.relationships(:is_member_of_collection).should == []
126
+
127
+ context "when the book is a member of the collection" do
128
+ before do
129
+ book.collections << collection
130
+ book.save!
131
+ end
132
+ after do
133
+ collection.delete
134
+ book.delete
135
+ end
136
+
137
+ it "should have a collection" do
138
+ book.relationships(:is_member_of_collection).should == [collection.internal_uri]
139
+ book.collections.should == [collection]
140
+ end
141
+ it "habtm should not set foreign relationships if :inverse_of is not specified" do
142
+ collection.relationships(:is_member_of_collection).should == []
143
+ end
144
+ it "should load the collections" do
145
+ reloaded = Book.find(book.pid)
146
+ reloaded.collections.should == [collection]
147
+ end
148
+
149
+ describe "#empty?" do
150
+ subject { book.collections }
151
+ its(:empty?) { should be_false }
152
+ end
140
153
  end
141
- it "should load the collections" do
142
- reloaded = Book.find(book.pid)
143
- reloaded.collections.should == [collection]
154
+
155
+ context "when a book isn't in a collection" do
156
+ describe "#empty?" do
157
+ subject { book.collections }
158
+ its(:empty?) { should be_true }
159
+ end
144
160
  end
145
161
  end
146
162
 
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: 7.0.0
4
+ version: 7.0.1
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: 2014-03-31 00:00:00.000000000 Z
13
+ date: 2014-04-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rsolr