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

Fixes #16389 - enable taxable object creation in specific context #3801

Closed
wants to merge 1 commit into from

Conversation

ares
Copy link
Member

@ares ares commented Aug 31, 2016

No description provided.

org = FactoryGirl.create :organization
FactoryGirl.create(:domain, :organizations => [ org ])
original_org, Organization.current = Organization.current, org
$debug = true

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not introduce global variables.

@ehelms
Copy link
Member

ehelms commented Sep 1, 2016

[test]

@iNecas
Copy link
Member

iNecas commented Sep 1, 2016

APJ, if there was emoji for :respect: I would use one :)

tax_ids = taxable_ids
# we need to generate part of SQL query as a string, otherwise the default scope would set id on each
# new instance and the same taxable_id on taxable_taxonomy objects
scope = scope.where("#{self.table_name}.id IN (#{tax_ids.join(',')})", ) if tax_ids

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space inside parentheses detected.

@ares
Copy link
Member Author

ares commented Sep 1, 2016

@iNecas one more change was needed, we have to be explicit about the table name and we can't escape the values inside IN (), these injections should be always safe though. Please take another look, thanks.

@dLobatog
Copy link
Member

dLobatog commented Sep 2, 2016

Merged as 35ed04f, thanks @ares!

@dLobatog dLobatog closed this Sep 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants