isolate_namespace Spree causes the migrations not be copied with install. #1580

Closed
peterberkenbosch opened this Issue May 22, 2012 · 14 comments

Projects

None yet

3 participants

@peterberkenbosch
Spree Commerce member

Working on a very simple extension right now.. some specs are all green.. but when I try to install it into a sample spree (1.1.1) store the migrations won't make it.

When I uncomment the isolate_namespace part all is working again..

Have some more doubts about the isolate_namespace part. There are a lot of extra steps to make when using the rails (resource) generators. .everything needs to be namespaced with Spree.. not sure if that's a good idea.

@peterberkenbosch
Spree Commerce member

found out some more..
when running rake -T | grep spree in the hosted app you will see the correct rake task. Since the Spree namespace is isolated. the task has a different name :

rake spree_brands_engine_spree:install:migrations  # Copy migrations from spree_brands_engine_spree to application

in this sample the engine is spree_brands

engine_name 'spree_brands'
isolate_namespace Spree

we might need to adjust the install generator? or is this a rails issue..since calling this rake task

rake railties:install:migrations FROM=spree_brands

does not work..

@radar
Spree Commerce member

What happens if you swap the engine_name and isolate_namespace calls? The reason I ask is because isolate_namespace calls engine_name again: https://github.com/rails/rails/blob/3-2-stable/railties/lib/rails/engine.rb#L380.

@radar radar added a commit that referenced this issue Jun 4, 2012
@radar radar Reverse order of isolate_namespace and engine_name call in extension …
…engine template

This is a potential fix for #1580
408ac9c
@radar radar added a commit that referenced this issue Jun 4, 2012
@radar radar Reverse order of isolate_namespace and engine_name call in extension …
…engine template

This is a potential fix for #1580
655d70f
@peterberkenbosch
Spree Commerce member

that could be the solution indeed.. let me try it!

@radar
Spree Commerce member
@peterberkenbosch
Spree Commerce member

Yes I just did and it worked!

@ethier

I'm still experiencing an issue similar to this. When I try to generate a resource in an extension folder it throws a NameError on the ::Engine::Spree constant. If I comment out the isolate_namespace line the generators work as expected.

I've tried swapping the lines but the error persists as long as the isolate_namespace line is present.

@ethier

If I require spree/core at the top of the engine file and comment out the engine_name line (as it is called in isolate_namespace) the generators work fine.

I'm not sure if this is correct though.

@peterberkenbosch
Spree Commerce member

have diner in a minute.. will dive in after.. also..I will try to write to some specs for this.. perhaps using Aruba or something similar.. this must be testable after all..

@radar
Spree Commerce member

Some Aruba tests would be handy for this kind of thing. Let me see what I can come up with today.

@radar radar added a commit that referenced this issue Jun 6, 2012
@radar radar Ensure that an extension can have a model generated in it
Adds a regression test for #1580
9c60156
@radar radar added a commit that referenced this issue Jun 6, 2012
@radar radar Ensure that migrations are created within the dummy app
This is a regression test for #1580
373b86e
@radar radar added a commit that referenced this issue Jun 6, 2012
@radar radar Ensure that migrations are created within the dummy app
This is a regression test for #1580
151d2f4
@radar radar added a commit that referenced this issue Jun 6, 2012
@radar radar Ensure that an extension can have a model generated in it
Adds a regression test for #1580
d12212b
@radar
Spree Commerce member

I've added an Aruba feature to cmd with @9c60156. That seems to be generating a model within the extension just fine. Then I added another commit with @373b86e that checks that the migration gets copied over to spec/dummy.

Therefore, I think this bug is fixed now. Sorry it took so long!

@radar radar closed this Jun 6, 2012
@radar radar added a commit that referenced this issue Jun 6, 2012
@radar radar Reverse order of isolate_namespace and engine_name call in extension …
…engine template

This is a potential fix for #1580
d4d7e97
@radar radar added a commit that referenced this issue Jun 6, 2012
@radar radar Ensure that an extension can have a model generated in it
Adds a regression test for #1580
d67a8ae
@radar radar added a commit that referenced this issue Jun 6, 2012
@radar radar Ensure that migrations are created within the dummy app
This is a regression test for #1580
33dc896
@peterberkenbosch
Spree Commerce member

Sweet! Thanks

@ethier

I'm still struggling with this but it might be an unrelated issue. I've updated my spree dependencies to the 1-1-stable branch to get these commits and now I'm getting this in my newly created extension folders. This is generated by running bundle install or rails generators in the spree_test extension folder.

Could not find gem 'spree_core (~> 1.1.2.beta) ruby', which is required by gem 'spree_test (>= 0) ruby', in any of the sources.
@radar
Spree Commerce member
@ethier

I've figured it out. The 1-1-stable branch has a dependency in the spree_cmd extension generator for spree 1.1.2.beta. Once I change the generated dependency in the gemspec for the extension the bundle installer works as expected.

The generators and dummy app rake tasks work as expected as well.

@radar radar added a commit that referenced this issue Jun 20, 2012
@radar radar Ensure that an extension can have a model generated in it
Adds a regression test for #1580
814cc01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment