lolita 3.0.3 → 3.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +24 -24
 - data/VERSION +1 -1
 - data/app/controllers/lolita/rest_controller.rb +8 -6
 - data/app/views/components/lolita/field/_text.html.erb +24 -1
 - data/app/views/components/lolita/shared/_header.html.erb +6 -4
 - data/app/views/components/lolita/tabs/_display.html.erb +9 -22
 - data/config/locales/en.yml +10 -8
 - data/lib/lolita.rb +9 -0
 - data/lib/lolita/configuration/base.rb +1 -1
 - data/lib/lolita/configuration/tab.rb +23 -4
 - data/lib/lolita/configuration/tab/content.rb +15 -0
 - data/lib/lolita/configuration/tabs.rb +1 -1
 - data/lib/lolita/controllers/view_user_helpers.rb +13 -0
 - data/lib/lolita/errors.rb +1 -0
 - data/lib/lolita/modules/rest.rb +2 -1
 - data/lib/lolita/rails.rb +2 -0
 - data/lolita.gemspec +3 -1
 - data/public/javascripts/lolita/tab.js +38 -37
 - data/public/javascripts/tinymce/themes/simple/editor_template_src.js +83 -83
 - data/public/javascripts/tinymce/tiny_mce_src.js +14724 -14724
 - data/public/javascripts/tinymce/utils/editable_selects.js +70 -70
 - data/public/javascripts/tinymce/utils/form_utils.js +207 -207
 - data/public/javascripts/tinymce/utils/mctabs.js +161 -161
 - data/public/javascripts/tinymce/utils/validate.js +252 -252
 - data/public/stylesheets/lolita/style.css +7 -3
 - data/spec/configuration/base_spec.rb +44 -44
 - data/spec/configuration/column_spec.rb +45 -45
 - data/spec/configuration/list_spec.rb +76 -76
 - data/spec/dbi/base_spec.rb +34 -34
 - data/spec/lolita_spec.rb +1 -1
 - data/spec/spec_helper.rb +47 -47
 - metadata +4 -2
 
| 
         @@ -59,9 +59,13 @@ header nav .username {margin-right: 15px;} 
     | 
|
| 
       59 
59 
     | 
    
         
             
              width: 100%; 
         
     | 
| 
       60 
60 
     | 
    
         
             
              -moz-box-sizing: border-box;
         
     | 
| 
       61 
61 
     | 
    
         
             
              -webkit-box-sizing: border-box;
         
     | 
| 
       62 
     | 
    
         
            -
              box-sizing: border-box; 
     | 
| 
      
 62 
     | 
    
         
            +
              box-sizing: border-box;  /* IE7 does not support it, IE8 does */
         
     | 
| 
       63 
63 
     | 
    
         
             
            }
         
     | 
| 
       64 
64 
     | 
    
         | 
| 
      
 65 
     | 
    
         
            +
            #main .box .save {padding: 20px 10px;}
         
     | 
| 
      
 66 
     | 
    
         
            +
            #main .box .last-save {color: #808080; margin-bottom: 5px;}
         
     | 
| 
      
 67 
     | 
    
         
            +
            #main .box .save button {width: 100%; padding: 10px 0; font-size: 24px; background: #ab8def; color: #ffd;}
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
       65 
69 
     | 
    
         
             
            /* navigation styles on left */
         
     | 
| 
       66 
70 
     | 
    
         
             
            #main nav {position: absolute; left: 0; min-width: 150px; margin-top: 5px;} /* width just for now */ 
         
     | 
| 
       67 
71 
     | 
    
         
             
            #main nav ul {margin-bottom: 50px;}
         
     | 
| 
         @@ -80,8 +84,8 @@ header nav .username {margin-right: 15px;} 
     | 
|
| 
       80 
84 
     | 
    
         | 
| 
       81 
85 
     | 
    
         
             
            /* main content part */
         
     | 
| 
       82 
86 
     | 
    
         
             
            #content {overflow: visible; position: relative;} /* overflow for clearing containing floats */
         
     | 
| 
       83 
     | 
    
         
            -
            #content .secondary {position: absolute; right: 0; width:  
     | 
| 
       84 
     | 
    
         
            -
            #content.with-secondary {padding-right:  
     | 
| 
      
 87 
     | 
    
         
            +
            #content .secondary {position: absolute; right: 0; width: 23%;}
         
     | 
| 
      
 88 
     | 
    
         
            +
            #content.with-secondary {padding-right: 25%;}
         
     | 
| 
       85 
89 
     | 
    
         
             
            /* --------------------------------------------- */
         
     | 
| 
       86 
90 
     | 
    
         | 
| 
       87 
91 
     | 
    
         
             
            footer {height: 50px;} /* for not leaving empty space in bottom */
         
     | 
| 
         @@ -1,44 +1,44 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            describe Lolita::Configuration::Base do
         
     | 
| 
       4 
     | 
    
         
            -
            #    before(:each) do
         
     | 
| 
       5 
     | 
    
         
            -
            #      @base = Lolita::Configuration::Base.new
         
     | 
| 
       6 
     | 
    
         
            -
            #    end
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
              it "should define configuration without block" do
         
     | 
| 
       9 
     | 
    
         
            -
                Post.lolita.should_not be_nil
         
     | 
| 
       10 
     | 
    
         
            -
              end
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
              it "should define configuration with block" do
         
     | 
| 
       13 
     | 
    
         
            -
                Profile.lolita.should_not be_nil
         
     | 
| 
       14 
     | 
    
         
            -
              end
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
              it "should not initialize instance methods for configuration without calling them" do
         
     | 
| 
       17 
     | 
    
         
            -
                Profile.lolita.list.to_s.should match(/Lolita::LazyLoader/)
         
     | 
| 
       18 
     | 
    
         
            -
                Post.lolita.list.to_s.should match(/Lolita::LazyLoader/)
         
     | 
| 
       19 
     | 
    
         
            -
              end
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
              it "should return real object when calling it" do
         
     | 
| 
       22 
     | 
    
         
            -
                define_config do
         
     | 
| 
       23 
     | 
    
         
            -
                  list
         
     | 
| 
       24 
     | 
    
         
            -
                end
         
     | 
| 
       25 
     | 
    
         
            -
                Post.lolita.list.class.to_s.should == "Lolita::Configuration::List"
         
     | 
| 
       26 
     | 
    
         
            -
              end
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
              it "should return tabs" do
         
     | 
| 
       29 
     | 
    
         
            -
                define_config
         
     | 
| 
       30 
     | 
    
         
            -
                Post.lolita.tabs.class.should == Lolita::Configuration::Tabs
         
     | 
| 
       31 
     | 
    
         
            -
              end
         
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
              it "should allow add tabs" do
         
     | 
| 
       34 
     | 
    
         
            -
                define_config do
         
     | 
| 
       35 
     | 
    
         
            -
                  tab(:content)
         
     | 
| 
       36 
     | 
    
         
            -
                end
         
     | 
| 
       37 
     | 
    
         
            -
                Post.lolita.tabs.size.should == 1
         
     | 
| 
       38 
     | 
    
         
            -
              end
         
     | 
| 
       39 
     | 
    
         
            -
              
         
     | 
| 
       40 
     | 
    
         
            -
              def define_config &block
         
     | 
| 
       41 
     | 
    
         
            -
                Post.lolita=Lolita::Configuration::Base.new(Post,&block)
         
     | 
| 
       42 
     | 
    
         
            -
              end
         
     | 
| 
       43 
     | 
    
         
            -
            end
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Lolita::Configuration::Base do
         
     | 
| 
      
 4 
     | 
    
         
            +
            #    before(:each) do
         
     | 
| 
      
 5 
     | 
    
         
            +
            #      @base = Lolita::Configuration::Base.new
         
     | 
| 
      
 6 
     | 
    
         
            +
            #    end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              it "should define configuration without block" do
         
     | 
| 
      
 9 
     | 
    
         
            +
                Post.lolita.should_not be_nil
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              it "should define configuration with block" do
         
     | 
| 
      
 13 
     | 
    
         
            +
                Profile.lolita.should_not be_nil
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              it "should not initialize instance methods for configuration without calling them" do
         
     | 
| 
      
 17 
     | 
    
         
            +
                Profile.lolita.list.to_s.should match(/Lolita::LazyLoader/)
         
     | 
| 
      
 18 
     | 
    
         
            +
                Post.lolita.list.to_s.should match(/Lolita::LazyLoader/)
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              it "should return real object when calling it" do
         
     | 
| 
      
 22 
     | 
    
         
            +
                define_config do
         
     | 
| 
      
 23 
     | 
    
         
            +
                  list
         
     | 
| 
      
 24 
     | 
    
         
            +
                end
         
     | 
| 
      
 25 
     | 
    
         
            +
                Post.lolita.list.class.to_s.should == "Lolita::Configuration::List"
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
              it "should return tabs" do
         
     | 
| 
      
 29 
     | 
    
         
            +
                define_config
         
     | 
| 
      
 30 
     | 
    
         
            +
                Post.lolita.tabs.class.should == Lolita::Configuration::Tabs
         
     | 
| 
      
 31 
     | 
    
         
            +
              end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
              it "should allow add tabs" do
         
     | 
| 
      
 34 
     | 
    
         
            +
                define_config do
         
     | 
| 
      
 35 
     | 
    
         
            +
                  tab(:content)
         
     | 
| 
      
 36 
     | 
    
         
            +
                end
         
     | 
| 
      
 37 
     | 
    
         
            +
                Post.lolita.tabs.size.should == 1
         
     | 
| 
      
 38 
     | 
    
         
            +
              end
         
     | 
| 
      
 39 
     | 
    
         
            +
              
         
     | 
| 
      
 40 
     | 
    
         
            +
              def define_config &block
         
     | 
| 
      
 41 
     | 
    
         
            +
                Post.lolita=Lolita::Configuration::Base.new(Post,&block)
         
     | 
| 
      
 42 
     | 
    
         
            +
              end
         
     | 
| 
      
 43 
     | 
    
         
            +
            end
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
         @@ -1,45 +1,45 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            describe Lolita::Configuration::Column do
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
              
         
     | 
| 
       6 
     | 
    
         
            -
              it "should create new column with Hash attributes" do
         
     | 
| 
       7 
     | 
    
         
            -
                column=Lolita::Configuration::Column.new(:name=>"col1",:title=>"Col1",:type=>String)
         
     | 
| 
       8 
     | 
    
         
            -
                column.name.should == "col1"
         
     | 
| 
       9 
     | 
    
         
            -
              end
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
              it "should create new column with Proc as block given" do
         
     | 
| 
       12 
     | 
    
         
            -
                p=Proc.new{
         
     | 
| 
       13 
     | 
    
         
            -
                  name "col1"
         
     | 
| 
       14 
     | 
    
         
            -
                  title "Col one"
         
     | 
| 
       15 
     | 
    
         
            -
                  type String
         
     | 
| 
       16 
     | 
    
         
            -
                }
         
     | 
| 
       17 
     | 
    
         
            -
                column=Lolita::Configuration::Column.new &p
         
     | 
| 
       18 
     | 
    
         
            -
                column.type.should == String
         
     | 
| 
       19 
     | 
    
         
            -
              end
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
              it "should create new column with block given" do
         
     | 
| 
       22 
     | 
    
         
            -
                column=Lolita::Configuration::Column.new do
         
     | 
| 
       23 
     | 
    
         
            -
                  name "col1"
         
     | 
| 
       24 
     | 
    
         
            -
                  title "Col one"
         
     | 
| 
       25 
     | 
    
         
            -
                  type String
         
     | 
| 
       26 
     | 
    
         
            -
                end
         
     | 
| 
       27 
     | 
    
         
            -
                column.title.size.should > 0
         
     | 
| 
       28 
     | 
    
         
            -
              end
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
              it "should create new column when String or Symbol is given" do
         
     | 
| 
       31 
     | 
    
         
            -
                column=Lolita::Configuration::Column.new(:col1)
         
     | 
| 
       32 
     | 
    
         
            -
                column.name.should == "col1"
         
     | 
| 
       33 
     | 
    
         
            -
                column=Lolita::Configuration::Column.new("col2")
         
     | 
| 
       34 
     | 
    
         
            -
                column.name.should == "col2"
         
     | 
| 
       35 
     | 
    
         
            -
              end
         
     | 
| 
       36 
     | 
    
         
            -
              
         
     | 
| 
       37 
     | 
    
         
            -
              it "should raise error when no name is provided for column" do
         
     | 
| 
       38 
     | 
    
         
            -
                lambda{
         
     | 
| 
       39 
     | 
    
         
            -
                  Lolita::Configuration::Column.new do
         
     | 
| 
       40 
     | 
    
         
            -
                    title "Col one"
         
     | 
| 
       41 
     | 
    
         
            -
                  end
         
     | 
| 
       42 
     | 
    
         
            -
                }.should raise_error(ArgumentError, "Column must have name.")
         
     | 
| 
       43 
     | 
    
         
            -
              end
         
     | 
| 
       44 
     | 
    
         
            -
            end
         
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Lolita::Configuration::Column do
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
              
         
     | 
| 
      
 6 
     | 
    
         
            +
              it "should create new column with Hash attributes" do
         
     | 
| 
      
 7 
     | 
    
         
            +
                column=Lolita::Configuration::Column.new(:name=>"col1",:title=>"Col1",:type=>String)
         
     | 
| 
      
 8 
     | 
    
         
            +
                column.name.should == "col1"
         
     | 
| 
      
 9 
     | 
    
         
            +
              end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
              it "should create new column with Proc as block given" do
         
     | 
| 
      
 12 
     | 
    
         
            +
                p=Proc.new{
         
     | 
| 
      
 13 
     | 
    
         
            +
                  name "col1"
         
     | 
| 
      
 14 
     | 
    
         
            +
                  title "Col one"
         
     | 
| 
      
 15 
     | 
    
         
            +
                  type String
         
     | 
| 
      
 16 
     | 
    
         
            +
                }
         
     | 
| 
      
 17 
     | 
    
         
            +
                column=Lolita::Configuration::Column.new &p
         
     | 
| 
      
 18 
     | 
    
         
            +
                column.type.should == String
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              it "should create new column with block given" do
         
     | 
| 
      
 22 
     | 
    
         
            +
                column=Lolita::Configuration::Column.new do
         
     | 
| 
      
 23 
     | 
    
         
            +
                  name "col1"
         
     | 
| 
      
 24 
     | 
    
         
            +
                  title "Col one"
         
     | 
| 
      
 25 
     | 
    
         
            +
                  type String
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
      
 27 
     | 
    
         
            +
                column.title.size.should > 0
         
     | 
| 
      
 28 
     | 
    
         
            +
              end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
              it "should create new column when String or Symbol is given" do
         
     | 
| 
      
 31 
     | 
    
         
            +
                column=Lolita::Configuration::Column.new(:col1)
         
     | 
| 
      
 32 
     | 
    
         
            +
                column.name.should == "col1"
         
     | 
| 
      
 33 
     | 
    
         
            +
                column=Lolita::Configuration::Column.new("col2")
         
     | 
| 
      
 34 
     | 
    
         
            +
                column.name.should == "col2"
         
     | 
| 
      
 35 
     | 
    
         
            +
              end
         
     | 
| 
      
 36 
     | 
    
         
            +
              
         
     | 
| 
      
 37 
     | 
    
         
            +
              it "should raise error when no name is provided for column" do
         
     | 
| 
      
 38 
     | 
    
         
            +
                lambda{
         
     | 
| 
      
 39 
     | 
    
         
            +
                  Lolita::Configuration::Column.new do
         
     | 
| 
      
 40 
     | 
    
         
            +
                    title "Col one"
         
     | 
| 
      
 41 
     | 
    
         
            +
                  end
         
     | 
| 
      
 42 
     | 
    
         
            +
                }.should raise_error(ArgumentError, "Column must have name.")
         
     | 
| 
      
 43 
     | 
    
         
            +
              end
         
     | 
| 
      
 44 
     | 
    
         
            +
            end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
         @@ -1,76 +1,76 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            describe Lolita::Configuration::List do
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
              before(:each) do
         
     | 
| 
       6 
     | 
    
         
            -
                @dbi=Lolita::DBI::Base.new(Post)
         
     | 
| 
       7 
     | 
    
         
            -
              end
         
     | 
| 
       8 
     | 
    
         
            -
              
         
     | 
| 
       9 
     | 
    
         
            -
              after(:each) do
         
     | 
| 
       10 
     | 
    
         
            -
                @recs||=[]
         
     | 
| 
       11 
     | 
    
         
            -
                @recs.each{|r| r.destroy}
         
     | 
| 
       12 
     | 
    
         
            -
              end
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
              it "should create new list with block" do
         
     | 
| 
       15 
     | 
    
         
            -
                Lolita::Configuration::List.new(@dbi) do
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
                end
         
     | 
| 
       18 
     | 
    
         
            -
              end
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
              it "should create new list without block" do
         
     | 
| 
       21 
     | 
    
         
            -
                Lolita::Configuration::List.new(@dbi)
         
     | 
| 
       22 
     | 
    
         
            -
              end
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
              it "should generate columns if none is given" do
         
     | 
| 
       25 
     | 
    
         
            -
                list=Lolita::Configuration::List.new(@dbi)
         
     | 
| 
       26 
     | 
    
         
            -
                list.columns.size.should == @dbi.fields.size
         
     | 
| 
       27 
     | 
    
         
            -
                list=Lolita::Configuration::List.new(@dbi){}
         
     | 
| 
       28 
     | 
    
         
            -
                list.columns.size.should == @dbi.fields.size
         
     | 
| 
       29 
     | 
    
         
            -
              end
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
              it "should not generate columns if one or more is given" do
         
     | 
| 
       32 
     | 
    
         
            -
                list=Lolita::Configuration::List.new(@dbi,:columns=>[{:name=>"C1"}])
         
     | 
| 
       33 
     | 
    
         
            -
                list.columns.size.should == 1
         
     | 
| 
       34 
     | 
    
         
            -
                list=Lolita::Configuration::List.new(@dbi) do
         
     | 
| 
       35 
     | 
    
         
            -
                  column :name=>"Col1"
         
     | 
| 
       36 
     | 
    
         
            -
                  column :name=>"col3"
         
     | 
| 
       37 
     | 
    
         
            -
                  column do
         
     | 
| 
       38 
     | 
    
         
            -
                    name "col2"
         
     | 
| 
       39 
     | 
    
         
            -
                    title "Column two"
         
     | 
| 
       40 
     | 
    
         
            -
                  end
         
     | 
| 
       41 
     | 
    
         
            -
                end
         
     | 
| 
       42 
     | 
    
         
            -
                list.columns.size.should==3
         
     | 
| 
       43 
     | 
    
         
            -
              end
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
              it "should get records for list page" do
         
     | 
| 
       46 
     | 
    
         
            -
                1.upto(5) { Factory.create(:post)}
         
     | 
| 
       47 
     | 
    
         
            -
                list=Lolita::Configuration::List.new(@dbi,:per_page=>1)
         
     | 
| 
       48 
     | 
    
         
            -
                list.paginate(1,:per_page=>2).size.should == 2
         
     | 
| 
       49 
     | 
    
         
            -
                list.paginate(1).size.should == 1
         
     | 
| 
       50 
     | 
    
         
            -
              end
         
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
              it "should define columns when Symbols are given as args" do
         
     | 
| 
       53 
     | 
    
         
            -
                list=Lolita::Configuration::List.new do
         
     | 
| 
       54 
     | 
    
         
            -
                  columns :col1,:col2,:col3
         
     | 
| 
       55 
     | 
    
         
            -
                end
         
     | 
| 
       56 
     | 
    
         
            -
                list.columns.size.should == 3
         
     | 
| 
       57 
     | 
    
         
            -
              end
         
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
              
         
     | 
| 
       60 
     | 
    
         
            -
              it "should move columns to right or left" do
         
     | 
| 
       61 
     | 
    
         
            -
                pending
         
     | 
| 
       62 
     | 
    
         
            -
            #    list = Lolita::Configuration::List.new do
         
     | 
| 
       63 
     | 
    
         
            -
            #      column :name=>"col1"
         
     | 
| 
       64 
     | 
    
         
            -
            #      column :name=>"col2"
         
     | 
| 
       65 
     | 
    
         
            -
            #      column :name=>"col3"
         
     | 
| 
       66 
     | 
    
         
            -
            #    end
         
     | 
| 
       67 
     | 
    
         
            -
            #    list.columns.first.name.should == "col1"
         
     | 
| 
       68 
     | 
    
         
            -
            #    list.move(:col2).before(:col1)
         
     | 
| 
       69 
     | 
    
         
            -
            #    list.columns[:col_index].move_after(:col1)
         
     | 
| 
       70 
     | 
    
         
            -
            #    list.columns.first.name.should == "col2"
         
     | 
| 
       71 
     | 
    
         
            -
            #    list.move(:col2).after(:col1)
         
     | 
| 
       72 
     | 
    
         
            -
            #    list.columns.first.name.should == "col1"
         
     | 
| 
       73 
     | 
    
         
            -
              end
         
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
       75 
     | 
    
         
            -
            end
         
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Lolita::Configuration::List do
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
              before(:each) do
         
     | 
| 
      
 6 
     | 
    
         
            +
                @dbi=Lolita::DBI::Base.new(Post)
         
     | 
| 
      
 7 
     | 
    
         
            +
              end
         
     | 
| 
      
 8 
     | 
    
         
            +
              
         
     | 
| 
      
 9 
     | 
    
         
            +
              after(:each) do
         
     | 
| 
      
 10 
     | 
    
         
            +
                @recs||=[]
         
     | 
| 
      
 11 
     | 
    
         
            +
                @recs.each{|r| r.destroy}
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              it "should create new list with block" do
         
     | 
| 
      
 15 
     | 
    
         
            +
                Lolita::Configuration::List.new(@dbi) do
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                end
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              it "should create new list without block" do
         
     | 
| 
      
 21 
     | 
    
         
            +
                Lolita::Configuration::List.new(@dbi)
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              it "should generate columns if none is given" do
         
     | 
| 
      
 25 
     | 
    
         
            +
                list=Lolita::Configuration::List.new(@dbi)
         
     | 
| 
      
 26 
     | 
    
         
            +
                list.columns.size.should == @dbi.fields.size
         
     | 
| 
      
 27 
     | 
    
         
            +
                list=Lolita::Configuration::List.new(@dbi){}
         
     | 
| 
      
 28 
     | 
    
         
            +
                list.columns.size.should == @dbi.fields.size
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
              it "should not generate columns if one or more is given" do
         
     | 
| 
      
 32 
     | 
    
         
            +
                list=Lolita::Configuration::List.new(@dbi,:columns=>[{:name=>"C1"}])
         
     | 
| 
      
 33 
     | 
    
         
            +
                list.columns.size.should == 1
         
     | 
| 
      
 34 
     | 
    
         
            +
                list=Lolita::Configuration::List.new(@dbi) do
         
     | 
| 
      
 35 
     | 
    
         
            +
                  column :name=>"Col1"
         
     | 
| 
      
 36 
     | 
    
         
            +
                  column :name=>"col3"
         
     | 
| 
      
 37 
     | 
    
         
            +
                  column do
         
     | 
| 
      
 38 
     | 
    
         
            +
                    name "col2"
         
     | 
| 
      
 39 
     | 
    
         
            +
                    title "Column two"
         
     | 
| 
      
 40 
     | 
    
         
            +
                  end
         
     | 
| 
      
 41 
     | 
    
         
            +
                end
         
     | 
| 
      
 42 
     | 
    
         
            +
                list.columns.size.should==3
         
     | 
| 
      
 43 
     | 
    
         
            +
              end
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
              it "should get records for list page" do
         
     | 
| 
      
 46 
     | 
    
         
            +
                1.upto(5) { Factory.create(:post)}
         
     | 
| 
      
 47 
     | 
    
         
            +
                list=Lolita::Configuration::List.new(@dbi,:per_page=>1)
         
     | 
| 
      
 48 
     | 
    
         
            +
                list.paginate(1,:per_page=>2).size.should == 2
         
     | 
| 
      
 49 
     | 
    
         
            +
                list.paginate(1).size.should == 1
         
     | 
| 
      
 50 
     | 
    
         
            +
              end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
              it "should define columns when Symbols are given as args" do
         
     | 
| 
      
 53 
     | 
    
         
            +
                list=Lolita::Configuration::List.new do
         
     | 
| 
      
 54 
     | 
    
         
            +
                  columns :col1,:col2,:col3
         
     | 
| 
      
 55 
     | 
    
         
            +
                end
         
     | 
| 
      
 56 
     | 
    
         
            +
                list.columns.size.should == 3
         
     | 
| 
      
 57 
     | 
    
         
            +
              end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
              
         
     | 
| 
      
 60 
     | 
    
         
            +
              it "should move columns to right or left" do
         
     | 
| 
      
 61 
     | 
    
         
            +
                pending
         
     | 
| 
      
 62 
     | 
    
         
            +
            #    list = Lolita::Configuration::List.new do
         
     | 
| 
      
 63 
     | 
    
         
            +
            #      column :name=>"col1"
         
     | 
| 
      
 64 
     | 
    
         
            +
            #      column :name=>"col2"
         
     | 
| 
      
 65 
     | 
    
         
            +
            #      column :name=>"col3"
         
     | 
| 
      
 66 
     | 
    
         
            +
            #    end
         
     | 
| 
      
 67 
     | 
    
         
            +
            #    list.columns.first.name.should == "col1"
         
     | 
| 
      
 68 
     | 
    
         
            +
            #    list.move(:col2).before(:col1)
         
     | 
| 
      
 69 
     | 
    
         
            +
            #    list.columns[:col_index].move_after(:col1)
         
     | 
| 
      
 70 
     | 
    
         
            +
            #    list.columns.first.name.should == "col2"
         
     | 
| 
      
 71 
     | 
    
         
            +
            #    list.move(:col2).after(:col1)
         
     | 
| 
      
 72 
     | 
    
         
            +
            #    list.columns.first.name.should == "col1"
         
     | 
| 
      
 73 
     | 
    
         
            +
              end
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
            end
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
    
        data/spec/dbi/base_spec.rb
    CHANGED
    
    | 
         @@ -1,34 +1,34 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            describe Lolita::DBI::Base do
         
     | 
| 
       4 
     | 
    
         
            -
            #  before(:each) do
         
     | 
| 
       5 
     | 
    
         
            -
            #    @base = Base.new
         
     | 
| 
       6 
     | 
    
         
            -
            #  end
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
              it "should raise error when not ORM class is given" do
         
     | 
| 
       9 
     | 
    
         
            -
                lambda{
         
     | 
| 
       10 
     | 
    
         
            -
                  Lolita::DBI::Base.new(String)
         
     | 
| 
       11 
     | 
    
         
            -
                }.should raise_error Lolita::NotORMClassError
         
     | 
| 
       12 
     | 
    
         
            -
                lambda{
         
     | 
| 
       13 
     | 
    
         
            -
                  Lolita::DBI::Base.new()
         
     | 
| 
       14 
     | 
    
         
            -
                }.should raise_error ArgumentError
         
     | 
| 
       15 
     | 
    
         
            -
              end
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
              it "should detect adapter" do
         
     | 
| 
       18 
     | 
    
         
            -
                dbi=Lolita::DBI::Base.new(Post)
         
     | 
| 
       19 
     | 
    
         
            -
                dbi.klass.should == Post
         
     | 
| 
       20 
     | 
    
         
            -
                Lolita::DBI::Base.adapters.should include(dbi.adapter_name)
         
     | 
| 
       21 
     | 
    
         
            -
              end
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
              it "should connect adapter" do
         
     | 
| 
       24 
     | 
    
         
            -
                dbi=Lolita::DBI::Base.new(Post)
         
     | 
| 
       25 
     | 
    
         
            -
                lambda{
         
     | 
| 
       26 
     | 
    
         
            -
                  dbi.fields
         
     | 
| 
       27 
     | 
    
         
            -
                }.should_not raise_error
         
     | 
| 
       28 
     | 
    
         
            -
              end
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
              it "should display all adapter available" do
         
     | 
| 
       31 
     | 
    
         
            -
                Lolita::DBI::Base.adapters.size.should > 0
         
     | 
| 
       32 
     | 
    
         
            -
              end
         
     | 
| 
       33 
     | 
    
         
            -
            end
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Lolita::DBI::Base do
         
     | 
| 
      
 4 
     | 
    
         
            +
            #  before(:each) do
         
     | 
| 
      
 5 
     | 
    
         
            +
            #    @base = Base.new
         
     | 
| 
      
 6 
     | 
    
         
            +
            #  end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              it "should raise error when not ORM class is given" do
         
     | 
| 
      
 9 
     | 
    
         
            +
                lambda{
         
     | 
| 
      
 10 
     | 
    
         
            +
                  Lolita::DBI::Base.new(String)
         
     | 
| 
      
 11 
     | 
    
         
            +
                }.should raise_error Lolita::NotORMClassError
         
     | 
| 
      
 12 
     | 
    
         
            +
                lambda{
         
     | 
| 
      
 13 
     | 
    
         
            +
                  Lolita::DBI::Base.new()
         
     | 
| 
      
 14 
     | 
    
         
            +
                }.should raise_error ArgumentError
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              it "should detect adapter" do
         
     | 
| 
      
 18 
     | 
    
         
            +
                dbi=Lolita::DBI::Base.new(Post)
         
     | 
| 
      
 19 
     | 
    
         
            +
                dbi.klass.should == Post
         
     | 
| 
      
 20 
     | 
    
         
            +
                Lolita::DBI::Base.adapters.should include(dbi.adapter_name)
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              it "should connect adapter" do
         
     | 
| 
      
 24 
     | 
    
         
            +
                dbi=Lolita::DBI::Base.new(Post)
         
     | 
| 
      
 25 
     | 
    
         
            +
                lambda{
         
     | 
| 
      
 26 
     | 
    
         
            +
                  dbi.fields
         
     | 
| 
      
 27 
     | 
    
         
            +
                }.should_not raise_error
         
     | 
| 
      
 28 
     | 
    
         
            +
              end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
              it "should display all adapter available" do
         
     | 
| 
      
 31 
     | 
    
         
            +
                Lolita::DBI::Base.adapters.size.should > 0
         
     | 
| 
      
 32 
     | 
    
         
            +
              end
         
     | 
| 
      
 33 
     | 
    
         
            +
            end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
    
        data/spec/lolita_spec.rb
    CHANGED
    
    
    
        data/spec/spec_helper.rb
    CHANGED
    
    | 
         @@ -1,48 +1,48 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            #require 'cover_me'
         
     | 
| 
       2 
     | 
    
         
            -
            #CoverMe.config do |c|
         
     | 
| 
       3 
     | 
    
         
            -
            #  # where is your project's root:
         
     | 
| 
       4 
     | 
    
         
            -
            #  c.project.root="c:/a_work/ruby_docs/lolita3" # => "Rails.root" (default)
         
     | 
| 
       5 
     | 
    
         
            -
            #
         
     | 
| 
       6 
     | 
    
         
            -
            #  # what files are you interested in coverage for:
         
     | 
| 
       7 
     | 
    
         
            -
            #  #c.file_pattern # => /(#{CoverMe.config.project.root}\/app\/.+\.rb|#{CoverMe.config.project.root}\/lib\/.+\.rb)/i (default)
         
     | 
| 
       8 
     | 
    
         
            -
            #
         
     | 
| 
       9 
     | 
    
         
            -
            #  # where do you want the HTML generated:
         
     | 
| 
       10 
     | 
    
         
            -
            #  c.html_formatter.output_path # => File.join(CoverMe.config.project.root, 'coverage') (default)
         
     | 
| 
       11 
     | 
    
         
            -
            #
         
     | 
| 
       12 
     | 
    
         
            -
            #  # what do you want to happen when it finishes:
         
     | 
| 
       13 
     | 
    
         
            -
            #  c.at_exit # => Proc.new {
         
     | 
| 
       14 
     | 
    
         
            -
            #  if CoverMe.config.formatter == CoverMe::HtmlFormatter
         
     | 
| 
       15 
     | 
    
         
            -
            #    index = File.join(CoverMe.config.html_formatter.output_path, 'index.html')
         
     | 
| 
       16 
     | 
    
         
            -
            #    if File.exists?(index)
         
     | 
| 
       17 
     | 
    
         
            -
            #      `open #{index}`
         
     | 
| 
       18 
     | 
    
         
            -
            #    end
         
     | 
| 
       19 
     | 
    
         
            -
            #  end
         
     | 
| 
       20 
     | 
    
         
            -
            #
         
     | 
| 
       21 
     | 
    
         
            -
            #end
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
            require 'rubygems'
         
     | 
| 
       24 
     | 
    
         
            -
            #require 'ruby-debug'
         
     | 
| 
       25 
     | 
    
         
            -
            LOLITA_ORM=:mongoid
         
     | 
| 
       26 
     | 
    
         
            -
            require "orm/#{LOLITA_ORM}"
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
            require "rails_app/config/environment"
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
            require 'rspec/rails'
         
     | 
| 
       31 
     | 
    
         
            -
            require 'ffaker'
         
     | 
| 
       32 
     | 
    
         
            -
            require 'factory_girl'
         
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
            Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
         
     | 
| 
       35 
     | 
    
         
            -
            RSpec.configure do |config|
         
     | 
| 
       36 
     | 
    
         
            -
            # config.mock_with :mocha
         
     | 
| 
       37 
     | 
    
         
            -
            # config.mock_with :flexmock
         
     | 
| 
       38 
     | 
    
         
            -
            # config.mock_with :rr
         
     | 
| 
       39 
     | 
    
         
            -
            config.mock_with :rspec
         
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
            if LOLITA_ORM==:active_record
         
     | 
| 
       42 
     | 
    
         
            -
              #config.fixture_path = "#{::Rails.root}/spec/fixtures"
         
     | 
| 
       43 
     | 
    
         
            -
              config.use_transactional_fixtures = true
         
     | 
| 
       44 
     | 
    
         
            -
            end
         
     | 
| 
       45 
     | 
    
         
            -
            end
         
     | 
| 
       46 
     | 
    
         
            -
            #CoverMe.complete!
         
     | 
| 
       47 
     | 
    
         
            -
            #require 'simplecov'
         
     | 
| 
      
 1 
     | 
    
         
            +
            #require 'cover_me'
         
     | 
| 
      
 2 
     | 
    
         
            +
            #CoverMe.config do |c|
         
     | 
| 
      
 3 
     | 
    
         
            +
            #  # where is your project's root:
         
     | 
| 
      
 4 
     | 
    
         
            +
            #  c.project.root="c:/a_work/ruby_docs/lolita3" # => "Rails.root" (default)
         
     | 
| 
      
 5 
     | 
    
         
            +
            #
         
     | 
| 
      
 6 
     | 
    
         
            +
            #  # what files are you interested in coverage for:
         
     | 
| 
      
 7 
     | 
    
         
            +
            #  #c.file_pattern # => /(#{CoverMe.config.project.root}\/app\/.+\.rb|#{CoverMe.config.project.root}\/lib\/.+\.rb)/i (default)
         
     | 
| 
      
 8 
     | 
    
         
            +
            #
         
     | 
| 
      
 9 
     | 
    
         
            +
            #  # where do you want the HTML generated:
         
     | 
| 
      
 10 
     | 
    
         
            +
            #  c.html_formatter.output_path # => File.join(CoverMe.config.project.root, 'coverage') (default)
         
     | 
| 
      
 11 
     | 
    
         
            +
            #
         
     | 
| 
      
 12 
     | 
    
         
            +
            #  # what do you want to happen when it finishes:
         
     | 
| 
      
 13 
     | 
    
         
            +
            #  c.at_exit # => Proc.new {
         
     | 
| 
      
 14 
     | 
    
         
            +
            #  if CoverMe.config.formatter == CoverMe::HtmlFormatter
         
     | 
| 
      
 15 
     | 
    
         
            +
            #    index = File.join(CoverMe.config.html_formatter.output_path, 'index.html')
         
     | 
| 
      
 16 
     | 
    
         
            +
            #    if File.exists?(index)
         
     | 
| 
      
 17 
     | 
    
         
            +
            #      `open #{index}`
         
     | 
| 
      
 18 
     | 
    
         
            +
            #    end
         
     | 
| 
      
 19 
     | 
    
         
            +
            #  end
         
     | 
| 
      
 20 
     | 
    
         
            +
            #
         
     | 
| 
      
 21 
     | 
    
         
            +
            #end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            require 'rubygems'
         
     | 
| 
      
 24 
     | 
    
         
            +
            #require 'ruby-debug'
         
     | 
| 
      
 25 
     | 
    
         
            +
            LOLITA_ORM=:mongoid
         
     | 
| 
      
 26 
     | 
    
         
            +
            require "orm/#{LOLITA_ORM}"
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            require "rails_app/config/environment"
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            require 'rspec/rails'
         
     | 
| 
      
 31 
     | 
    
         
            +
            require 'ffaker'
         
     | 
| 
      
 32 
     | 
    
         
            +
            require 'factory_girl'
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
            Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
         
     | 
| 
      
 35 
     | 
    
         
            +
            RSpec.configure do |config|
         
     | 
| 
      
 36 
     | 
    
         
            +
            # config.mock_with :mocha
         
     | 
| 
      
 37 
     | 
    
         
            +
            # config.mock_with :flexmock
         
     | 
| 
      
 38 
     | 
    
         
            +
            # config.mock_with :rr
         
     | 
| 
      
 39 
     | 
    
         
            +
            config.mock_with :rspec
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
            if LOLITA_ORM==:active_record
         
     | 
| 
      
 42 
     | 
    
         
            +
              #config.fixture_path = "#{::Rails.root}/spec/fixtures"
         
     | 
| 
      
 43 
     | 
    
         
            +
              config.use_transactional_fixtures = true
         
     | 
| 
      
 44 
     | 
    
         
            +
            end
         
     | 
| 
      
 45 
     | 
    
         
            +
            end
         
     | 
| 
      
 46 
     | 
    
         
            +
            #CoverMe.complete!
         
     | 
| 
      
 47 
     | 
    
         
            +
            #require 'simplecov'
         
     | 
| 
       48 
48 
     | 
    
         
             
            #SimpleCov.start 'rails'
         
     |