Skip to content

Commit

Permalink
Merge pull request #152 from wurma/patch-1
Browse files Browse the repository at this point in the history
Fixed 'No entities found' error when using filter
  • Loading branch information
kerrizor committed Jul 3, 2015
2 parents 9cf8935 + 649056f commit bb64666
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/rails_erd/diagram.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ def callbacks

def filtered_entities
@domain.entities.reject { |entity|
options.exclude && entity.model && [options.exclude].flatten.include?(entity.name.to_s) or
options.only && entity.model && ![options.only].flatten.include?(entity.name.to_s) or
options.exclude && entity.model && [options.exclude].flatten.include?(entity.name.to_sym) or
options.only && entity.model && ![options.only].flatten.include?(entity.name.to_sym) or
!options.inheritance && entity.specialized? or
!options.polymorphism && entity.generalized? or
!options.disconnected && entity.disconnected?
Expand Down
8 changes: 4 additions & 4 deletions test/unit/diagram_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,27 +126,27 @@ def calls
test "generate should filter excluded entity" do
create_model "Book"
create_model "Author"
assert_equal [Book], retrieve_entities(:exclude => ['Author']).map(&:model)
assert_equal [Book], retrieve_entities(:exclude => [:Author]).map(&:model)
end

test "generate should filter excluded entities" do
create_model "Book"
create_model "Author"
create_model "Editor"
assert_equal [Book], retrieve_entities(:exclude => ['Author', 'Editor']).map(&:model)
assert_equal [Book], retrieve_entities(:exclude => [:Author, :Editor]).map(&:model)
end

test "generate should include only specified entity" do
create_model "Book"
create_model "Author"
assert_equal [Book], retrieve_entities(:only => ['Book']).map(&:model)
assert_equal [Book], retrieve_entities(:only => [:Book]).map(&:model)
end

test "generate should include only specified entities" do
create_model "Book"
create_model "Author"
create_model "Editor"
assert_equal [Author, Editor], retrieve_entities(:only => ['Author', 'Editor']).map(&:model)
assert_equal [Author, Editor], retrieve_entities(:only => [:Author, :Editor]).map(&:model)
end

test "generate should filter disconnected entities if disconnected is false" do
Expand Down

0 comments on commit bb64666

Please sign in to comment.