Commits

Carolina Hadad committed 8e8aca4

fixed another bug in layers load for snapshot. The ID in the ability file should correspond to the layer_history.layer_id and not to the layer_history.id

Comments (0)

Files changed (3)

app/models/ability.rb

     # Same read permissions of Layer
     if !user.is_guest
       can :read, LayerHistory, :collection => { :memberships => { :user_id => user.id, :admin => true } }
-      can :read, LayerHistory, :collection => { :memberships => { :user_id => user.id} }, :id => user.readable_layer_ids
+      can :read, LayerHistory, :collection => { :memberships => { :user_id => user.id} }, :layer_id => user.readable_layer_ids
     else
       can :read, LayerHistory, :collection => {:public => true}
     end

app/models/collection.rb

   end
 
   def visible_layers_for(user, options = {})
-
     current_ability = Ability.new(user)
 
     if options[:snapshot_id]

spec/models/layer_access_spec.rb

 
     it "should return layers form snapshot" do
 
-
       stub_time '2011-01-01 10:00:00 -0500'
       new_layer = collection.layers.make
       new_field = new_layer.text_fields.make collection_id: collection.id
       stub_time '2011-01-01 11:00:00 -0500'
       new_field.name = "new name"
 
-      snapshot = Snapshot.make collection: collection, date: '2011-01-01 11:00:00 -0500'
+      snapshot = Snapshot.make collection: collection, date: '2011-01-01 12:00:00 -0500'
       user_snapshot = UserSnapshot.make user: user, snapshot: snapshot
 
       new_field.name = "other name"
 
-      membership.set_layer_access :verb => :read, :access => true, :layer_id => new_field.id
+      membership.set_layer_access :verb => :read, :access => true, :layer_id => new_layer.id
       membership.set_layer_access :verb => :read, :access => false, :layer_id => layer2.id
 
       layers = collection.visible_layers_for(user, {snapshot_id: snapshot.id})
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.