Skip to content

Commit

Permalink
got rid of boneheaded tracked attribute mistake and unwanted test com…
Browse files Browse the repository at this point in the history
…menting
  • Loading branch information
ethn committed Oct 26, 2010
1 parent cc2e32c commit 11810c6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
3 changes: 2 additions & 1 deletion app/models/role.rb
Expand Up @@ -66,7 +66,8 @@ def find_configurables
end

def [](codename)
self.cache[codename.to_s] ||= Integer===codename ? Role.find(codename) : Role.find_by_codename(codename.to_s)
# self.cache[codename.to_s] ||= Role.find_by_codename(codename.to_s)
self.cache[codename.to_s] ||= (Integer===codename ? Role.find(codename) : Role.find_by_codename(codename.to_s))
end
end
end
5 changes: 3 additions & 2 deletions lib/cardlib/permissions.rb
Expand Up @@ -109,9 +109,10 @@ def permit(task, party) #assign permissions
end

def who_can(operation)
#perm = permissions.reject { |perm| perm.task != operation.to_s }.first
#perm && perm.party ? perm.party : nil
perm = Permission.find(:first, :conditions=>{:card_id=>self.id, :task=>operation.to_s })
# perm = permissions.reject { |perm| perm.task != operation.to_s }.first
perm && Role[perm.party_id] #? perm.party : nil
perm && Role[perm.party_id.to_i]
end

def personal_user
Expand Down
2 changes: 1 addition & 1 deletion lib/cardlib/tracked_attributes.rb
Expand Up @@ -116,7 +116,7 @@ def set_permissions(perms)

def set_reader(party)
self.reader = party
if name.junction? && !party.anonymous?
if !party.anonymous?
junctions.each do |dep| #note: this could be faster with WQL, but I'm not sure this WQL actually works correctly
unless authenticated?(party) and !dep.who_can(:read).anonymous?
dep.permit :read, party
Expand Down
18 changes: 9 additions & 9 deletions spec/models/wiki_reference_spec.rb
Expand Up @@ -17,15 +17,15 @@

it "on template creation" do
Card::Cardtype.create! :name=>"SpecialForm"
# Card::SpecialForm.create! :name=>"Form1", :content=>"foo"
# c = Card.find_by_name("Form1")
# c.references_expired.should be_nil
# Card.create! :name=>"SpecialForm+*type+*content", :content=>"{{+bar}}"
# Card["Form1"].references_expired.should be_true
# Slot.new(Card["Form1"]).render(:naked_content)
# c = Card.find_by_name("Form1")
# c.references_expired.should be_nil
# Card["Form1"].out_references.plot(:referenced_name).should == ["form1+bar"]
Card::SpecialForm.create! :name=>"Form1", :content=>"foo"
c = Card.find_by_name("Form1")
c.references_expired.should be_nil
Card.create! :name=>"SpecialForm+*type+*content", :content=>"{{+bar}}"
Card["Form1"].references_expired.should be_true
Slot.new(Card["Form1"]).render(:naked_content)
c = Card.find_by_name("Form1")
c.references_expired.should be_nil
Card["Form1"].out_references.plot(:referenced_name).should == ["form1+bar"]
end

it "on template update" do
Expand Down

0 comments on commit 11810c6

Please sign in to comment.