Skip to content

Commit

Permalink
Fixed xcdatamodeld current_version not being set correctly
Browse files Browse the repository at this point in the history
Updated spec.
  • Loading branch information
Ashton-W committed Aug 19, 2013
1 parent 93f5d20 commit 77bcf03
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
9 changes: 5 additions & 4 deletions lib/xcodeproj/project/object/group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,15 @@ def new_xcdatamodeld(path, sub_group_path = nil)
if path.exist?
path.children.each do |child_path|
if File.extname(child_path) == '.xcdatamodel'
child_ref = ref.new_file_reference(child_path)
child_ref = ref.new_file_reference(File.basename(child_path))
child_ref.source_tree = '<group>'
last_child_ref = child_ref
elsif File.basename(child_path) == '.xccurrentversion'
xccurrentversion = ref.files.select { |obj| obj.path == Xcodeproj.read_plist(child_path)['_XCCurrentVersionName'] }.first
xccurrentversion = Xcodeproj.read_plist(child_path)['_XCCurrentVersionName']
end
end
ref.current_version = xccurrentversion || last_child_ref
ref.current_version = ref.children.select { |obj| obj.path == xccurrentversion }.first if xccurrentversion
ref.current_version = last_child_ref unless xccurrentversion
end

parent_group = find_subpath(sub_group_path, true)
Expand Down Expand Up @@ -299,7 +300,7 @@ def new_bundle(product_name)
# @return [XCVersionGroup] The new group.
#
def new_xcdatamodel_group(xcdatamodel_path)
g = @project.new(XCVersionGroup)
g = project.new(XCVersionGroup)
g.path = xcdatamodel_path
g.version_group_type = 'wrapper.xcdatamodel'
file = g.new_file(xcdatamodel_path.sub(/xcdatamodeld$/, 'xcdatamodel'))
Expand Down
6 changes: 1 addition & 5 deletions spec/project/object/group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ module ProjectSpecs
ref.path.should == 'Model.xcdatamodeld'
ref.source_tree.should == '<group>'
ref.version_group_type.should == 'wrapper.xcdatamodel'
ref.children.map(&:path).should == ['Model.xcdatamodel', 'Model 2.xcdatamodel']
ref.children.map{ |x| File.basename(x.path) }.should == ['Model.xcdatamodel', 'Model 2.xcdatamodel']
ref.current_version.isa.should == 'PBXFileReference'
ref.current_version.path.should == 'Model 2.xcdatamodel'
ref.current_version.last_known_file_type.should == 'wrapper.xcdatamodel'
Expand All @@ -94,10 +94,6 @@ module ProjectSpecs
ref.current_version.path.should.include 'VersionedModel 2.xcdatamodel'
ref.current_version.last_known_file_type.should == 'wrapper.xcdatamodel'
ref.current_version.source_tree.should == '<group>'
puts "DEBUG: #{ref.debug_children}"
puts "DEBUG: #{ref.debug_plist}"
puts ref.children.to_s
puts ref.current_version.path.to_s
@group.children.should.include(ref)
end
end
Expand Down

0 comments on commit 77bcf03

Please sign in to comment.