Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add more spec for rectricted configured columns

  • Loading branch information...
commit ab59a96a5174831dd491260b24d7178174205d39 1 parent e12eb24
Paweł Kondzior authored
Showing with 7 additions and 1 deletion.
  1. +1 −1  lib/sequel_nested_set.rb
  2. +6 −0 spec/nested_set_spec.rb
View
2  lib/sequel_nested_set.rb
@@ -68,7 +68,7 @@ def self.apply(model, options = {})
model.before_create { set_default_left_and_right }
model.before_destroy { prune_from_tree }
- model.set_restricted_columns :left, :right, :parent_id
+ model.set_restricted_columns(*([:left, :right, :parent_id, options[:parent_column], options[:left_column], options[:right_column]].uniq))
end
module DatasetMethods
View
6 spec/nested_set_spec.rb
@@ -93,6 +93,12 @@
Client.new.protected_methods.include?("parent_id=").should be_true
end
+ it "shoud have faild on new when passing keys configured as right_column, left_column, parent_column" do
+ lambda { Client.new(Client.nested_set_options[:left_column] => 1) }.should raise_error(Sequel::Error)
+ lambda { Client.new(Client.nested_set_options[:right_column] => 2) }.should raise_error(Sequel::Error)
+ lambda { Client.new(Client.nested_set_options[:parent_column] => nil) }.should raise_error(Sequel::Error)
+ end
+
it "Client.new with {:left => 1, :right => 2, :parent_id => nil} should raise NoMethodError exception" do
lambda { Client.new({:left => 1, :right => 2, :parent_id => nil}) }.should raise_error(Sequel::Error)
end
Please sign in to comment.
Something went wrong with that request. Please try again.