Skip to content

Commit 3ed9d79

Browse files
committed
Merge pull request #157 from ar3/fix-string-vs-symbol-issue
The only and exclude options weren't working for me...
2 parents 484df63 + f59ead8 commit 3ed9d79

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/rails_erd/diagram.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ def callbacks
150150

151151
def filtered_entities
152152
@domain.entities.reject { |entity|
153-
options.exclude && entity.model && [options.exclude].flatten.include?(entity.name.to_sym) or
154-
options.only && entity.model && ![options.only].flatten.include?(entity.name.to_sym) or
153+
options.exclude && entity.model && [options.exclude].flatten.map(&:to_sym).include?(entity.name.to_sym) or
154+
options.only && entity.model && ![options.only].flatten.map(&:to_sym).include?(entity.name.to_sym) or
155155
!options.inheritance && entity.specialized? or
156156
!options.polymorphism && entity.generalized? or
157157
!options.disconnected && entity.disconnected?

test/unit/diagram_test.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ def calls
149149
assert_equal [Author, Editor], retrieve_entities(:only => [:Author, :Editor]).map(&:model)
150150
end
151151

152+
test "generate should include only specified entities (With the class names as strings)" do
153+
create_model "Book"
154+
create_model "Author"
155+
create_model "Editor"
156+
assert_equal [Author, Editor], retrieve_entities(:only => ['Author', 'Editor']).map(&:model)
157+
end
158+
152159
test "generate should filter disconnected entities if disconnected is false" do
153160
create_model "Book", :author => :references do
154161
belongs_to :author

0 commit comments

Comments
 (0)