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

test_app within extensions fails to run devise-migrations #1966

Closed
berkes opened this Issue Sep 14, 2012 · 9 comments

Comments

Projects
None yet
3 participants
@berkes

berkes commented Sep 14, 2012

When running rake test_app, the database is migrated, but some migrations are not available and not run. These are migrations from Devise, trough spree_auth before Spree 1.2 and spree_device_auth in Spree 1.2.

If, in the specs of the extension, you then refer to Spree::User, an error will be raised undefined methodpassword_salt=' for #Spree::User:0xb5675664`.

One of the devise-migrations introduces a password_salt column, which is required by spree_auth and spree_devise_auth in the Spree::User model.

Two missing columns are "password_salt" and "encrypted_password".

The test_app raketask should probably check for migrations in any included gem and run them too. In this case, it should probably find the devise-migrations when devise is required by the extension.

@berkes

This comment has been minimized.

Show comment
Hide comment
@berkes

berkes Sep 14, 2012

Not sure if related, but after adding password_salt and encrypted_password manually to the test-datbase, an error occurs about a relation not being found: Association named 'spree_roles' was not found; perhaps you misspelled it?.

This seems to be caused by a migration in spree_devise_auth not being ran.

berkes commented Sep 14, 2012

Not sure if related, but after adding password_salt and encrypted_password manually to the test-datbase, an error occurs about a relation not being found: Association named 'spree_roles' was not found; perhaps you misspelled it?.

This seems to be caused by a migration in spree_devise_auth not being ran.

@radar

This comment has been minimized.

Show comment
Hide comment
@radar

radar Sep 14, 2012

Member

Are you running that command within Spree itself or within an application?

Member

radar commented Sep 14, 2012

Are you running that command within Spree itself or within an application?

@berkes

This comment has been minimized.

Show comment
Hide comment
@berkes

berkes Sep 15, 2012

Within the extension.

Here is how to reproduce (on a clean RVM gemset):

rvm gemset create spree_issue_1966 && rvm gemset use spree_issue_1966
gem install spree
spree_cmd extension foo
cd spree_foo
bundle install
rake test_app

Now note the database having a spree_user table, but lacking several columns.

E.g. by:

sqlite3  spec/dummy/db/spree_test.sqlite3 
.shema spree_users

There should be a column password_salt and one called hashed_password. Instead there are several obsoleted columns (like salt). one may recognise an old table scheme here. Which it is: several devise-releases and upgrades worth of migrations have not been ran on this table.

berkes commented Sep 15, 2012

Within the extension.

Here is how to reproduce (on a clean RVM gemset):

rvm gemset create spree_issue_1966 && rvm gemset use spree_issue_1966
gem install spree
spree_cmd extension foo
cd spree_foo
bundle install
rake test_app

Now note the database having a spree_user table, but lacking several columns.

E.g. by:

sqlite3  spec/dummy/db/spree_test.sqlite3 
.shema spree_users

There should be a column password_salt and one called hashed_password. Instead there are several obsoleted columns (like salt). one may recognise an old table scheme here. Which it is: several devise-releases and upgrades worth of migrations have not been ran on this table.

@radar

This comment has been minimized.

Show comment
Hide comment
@radar

radar Sep 15, 2012

Member

That's typically caused by Spree.user_class not being set correctly in Config/initializers/spree.rb. What's its value now? It should be Spree::User.

On 14/09/2012, at 17:15, Bèr Kessels notifications@github.com wrote:

Not sure if related, but after adding password_salt and encrypted_password manually to the test-datbase, an error occurs about a relation not being found: Association named 'spree_roles' was not found; perhaps you misspelled it?.

This seems to be caused by a migration in spree_devise_auth not being ran.


Reply to this email directly or view it on GitHub.

Member

radar commented Sep 15, 2012

That's typically caused by Spree.user_class not being set correctly in Config/initializers/spree.rb. What's its value now? It should be Spree::User.

On 14/09/2012, at 17:15, Bèr Kessels notifications@github.com wrote:

Not sure if related, but after adding password_salt and encrypted_password manually to the test-datbase, an error occurs about a relation not being found: Association named 'spree_roles' was not found; perhaps you misspelled it?.

This seems to be caused by a migration in spree_devise_auth not being ran.


Reply to this email directly or view it on GitHub.

@berkes

This comment has been minimized.

Show comment
Hide comment
@berkes

berkes Sep 18, 2012

spec/dummy/config/initializers/spree.rb contains Spree.user_class = "Spree::LegacyUser".

I will see if changing this to Spree::User changes the migrations and allows me to run them.

berkes commented Sep 18, 2012

spec/dummy/config/initializers/spree.rb contains Spree.user_class = "Spree::LegacyUser".

I will see if changing this to Spree::User changes the migrations and allows me to run them.

@radar

This comment has been minimized.

Show comment
Hide comment
@radar

radar Sep 18, 2012

Member

Right, but you shouldn't need to change that manually. Something's up. Will investigate this week most likely.

Member

radar commented Sep 18, 2012

Right, but you shouldn't need to change that manually. Something's up. Will investigate this week most likely.

@berkes

This comment has been minimized.

Show comment
Hide comment
@berkes

berkes Sep 19, 2012

Note that in spree 1.0.0 the migrations for Devise are not ran on the User either. It is not something that was introduced between 1.0.0 and 1.2.x, but something that existed already; just FYI.

berkes commented Sep 19, 2012

Note that in spree 1.0.0 the migrations for Devise are not ran on the User either. It is not something that was introduced between 1.0.0 and 1.2.x, but something that existed already; just FYI.

@radar

This comment has been minimized.

Show comment
Hide comment
@radar

radar Nov 7, 2012

Member

I can't reproduce this issue on 1-2-stable. Going to close it now, because I assume it's been fixed.

Member

radar commented Nov 7, 2012

I can't reproduce this issue on 1-2-stable. Going to close it now, because I assume it's been fixed.

@radar radar closed this Nov 7, 2012

@chriscummings

This comment has been minimized.

Show comment
Hide comment
@chriscummings

chriscummings Feb 26, 2013

I'm having this issue with Spree 1-3-stable (1.3.2) as of now.

spec/dummy/config/initializers/spree.rb contains Spree.user_class = "Spree::LegacyUser" the same as berkes' case.

I don't seem to butt into this issue until I attempt to start writing request specs with a user factory to login.

Manually altering the dummy app's spree initialize to use Spree.user_class = "Spree::User" alleviates the issue.

chriscummings commented Feb 26, 2013

I'm having this issue with Spree 1-3-stable (1.3.2) as of now.

spec/dummy/config/initializers/spree.rb contains Spree.user_class = "Spree::LegacyUser" the same as berkes' case.

I don't seem to butt into this issue until I attempt to start writing request specs with a user factory to login.

Manually altering the dummy app's spree initialize to use Spree.user_class = "Spree::User" alleviates the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment