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

Fix check_scope to work on lists with array scopes #81

Merged
merged 2 commits into from
Jul 2, 2013

Conversation

conzett
Copy link
Contributor

@conzett conzett commented Apr 12, 2013

Adds tests for several scenarios. Squashed commits an rebased. Build now passing on 1.8.7

@swanandp
Copy link
Contributor

Can you please add 1.8.7 compatibility, a lot of users are still on 1.8.7?

@conzett
Copy link
Contributor Author

conzett commented Apr 12, 2013

@swanandp No problem, I'll try and get that in as soon as possible.

@conzett
Copy link
Contributor Author

conzett commented Jun 28, 2013

@swanandp Sorry I haven't had a chance to work back on this, 1.8.7 is EOLed in 2 days, do you still require support for that?

conzett added 2 commits June 28, 2013 11:47
Squashed commits follow:

Fix issue with old order not being set

When moving an item between lists, previously the old order was not being set on the record before calling `decrement_positions_on_lower_items`. This had the side effect of leaving the previous list with duplicate or incorrect order numbers if you moved the item to a new list with a different position.

TODO: Add support for multiple scope conditions when moving an item between lists. Refactor `check_scope` for clarity and DRYness.

Conflicts:
	lib/acts_as_list/active_record/acts/list.rb

Add failing tests

Add failing tests for moving items between lists with multiple scopes

Implement moving between lists with array scope

When check_scope is called it checks if there have been any changes to scope properties. This is handled by a new private method, scope_changed? which looks at a new method 'scope' which returns the raw scope data. If the scope has changed, swap_changed attributes is called, this sets all the changes back to the objects previous state so we can update it's previous list. The changes are then swapped back using the same method and we add it to the new list.

TODO:

- Consider changing check_scope to a better name like update_previous_list?
- How should this handle scopes that use string interpolation? Should the scope always be considered changed?

Remove scope_name function

Add comments to private methods

Add tests for changing only one scope property

Previous tests only covered changing all scope properties at once.

Add tests for moving to empty list

Add scope_name function back in

Pass move_within_scope tests
@conzett
Copy link
Contributor Author

conzett commented Jun 29, 2013

@swanandp Should be passing 1.8.7 now, rebased.

swanandp added a commit that referenced this pull request Jul 2, 2013
Fix check_scope to work on lists with array scopes
@swanandp swanandp merged commit 7c1016f into brendon:master Jul 2, 2013
@swanandp
Copy link
Contributor

swanandp commented Jul 2, 2013

@conzett Thanks! 👍

@filipkis
Copy link

This has not made it into latest gem on Rubygems (there the latest one is 0.2.0 from Feb 28.) Can you make sure this update is available there as well.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants