Bug Fix #28

Open
wants to merge 7 commits into
from

2 participants

@lrgalego

Hi!
I fixed the bug report related here: https://github.com/pilu/web-app-theme/issues#issue/23
The problem occurs because when the user has a model that is inside a module the Kernel.const_get couldn't find the class.
I fixed it and added some new specs to deal with it.

Cheers.

Lucas Galego

@lrgalego lrgalego commented on the diff Mar 21, 2011
spec/spec_helper.rb
@@ -0,0 +1,5 @@
+require "rubygems"
+require "rspec"
+require "rails"
+require "rails/generators"
+require File.dirname(__FILE__) + "/../lib/generators/web_app_theme/themed/themed_generator"
@lrgalego
lrgalego added a line comment Mar 21, 2011

Fixed the spec requires

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@lrgalego lrgalego commented on the diff Mar 21, 2011
spec/themed_generator_spec.rb
+ end
+
+ it "should set the right plural_model_name" do
+ @generator.send(:plural_model_name).should == "Posts"
+ end
+
+ it "should set the right resource_name" do
+ @generator.send(:resource_name).should == "post"
+ end
+
+ it "should set the right plural_resource_name" do
+ @generator.send(:plural_resource_name).should == "posts"
+ end
+
+ it "should get the right model class" do
+ @generator.send(:model_class).to_s.should == "Post"
@lrgalego
lrgalego added a line comment Mar 21, 2011

Added a new spec to method model_class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@lrgalego lrgalego commented on the diff Mar 21, 2011
spec/themed_generator_spec.rb
+
+ it "should set the right resource_name" do
+ @generator.send(:resource_name).should == "picture"
+ end
+
+ it "should set the right plural_resource_name" do
+ @generator.send(:plural_resource_name).should == "pictures"
+ end
+
+ it "should get the right model class" do
+ @generator.send(:model_class).to_s.should == "Picture"
+ end
+
+end
+
+describe WebAppTheme::ThemedGenerator, "width 'script/generate themed admin/gallery Admin::Gallery'" do
@lrgalego
lrgalego added a line comment Mar 21, 2011

Added a new case os specification receving the model with module

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@lrgalego lrgalego commented on the diff Mar 21, 2011
lib/generators/web_app_theme/themed/themed_generator.rb
end
end
+ def model_class
@lrgalego
lrgalego added a line comment Mar 21, 2011

BugFix now the code iterates over the namespace to get the model class

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