Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table enhancements #54

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/pickle/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ def convert_models_to_attributes(ar_class, attrs)
Pickle::Adapter.column_names(ar_class).include?("#{key}_id")
conditions["#{key}_id"] = val.id
conditions["#{key}_type"] = val.class.base_class.name if ar_class.column_names.include?("#{key}_type")
elsif val.nil? && Pickle::Adapter.column_names(ar_class).include?("#{key}_id") &&
!Pickle::Adapter.column_names(ar_class).include?("#{key}")
else
conditions[key] = val
end
Expand Down
5 changes: 5 additions & 0 deletions rails_generators/pickle/templates/pickle_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
find_models_from_table(plural_factory, table).should_not be_any(&:nil?)
end

# not find models with a table
Then(/^the following #{capture_plural_factory} should not exists?:?$/) do |plural_factory, table|
find_models_from_table(plural_factory, table).should be_all(&:nil?)
end

# find exactly n models
Then(/^(\d+) #{capture_plural_factory} should exist(?: with #{capture_fields})?$/) do |count, plural_factory, fields|
find_models(plural_factory.singularize, fields).size.should == count.to_i
Expand Down