nifty-generators 0.2.4 → 0.3.0
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/CHANGELOG +26 -0
- data/Manifest +2 -1
- data/README.rdoc +20 -8
- data/Rakefile +1 -1
- data/nifty-generators.gemspec +165 -28
- data/rails_generators/nifty_authentication/USAGE +7 -3
- data/rails_generators/nifty_authentication/nifty_authentication_generator.rb +26 -16
- data/rails_generators/nifty_authentication/templates/authentication.rb +26 -2
- data/rails_generators/nifty_authentication/templates/authlogic_session.rb +2 -0
- data/rails_generators/nifty_authentication/templates/fixtures.yml +14 -2
- data/rails_generators/nifty_authentication/templates/migration.rb +9 -4
- data/rails_generators/nifty_authentication/templates/sessions_controller.rb +25 -2
- data/rails_generators/nifty_authentication/templates/sessions_helper.rb +1 -1
- data/rails_generators/nifty_authentication/templates/tests/rspec/sessions_controller.rb +15 -1
- data/rails_generators/nifty_authentication/templates/tests/rspec/user.rb +2 -0
- data/rails_generators/nifty_authentication/templates/tests/rspec/users_controller.rb +2 -0
- data/rails_generators/nifty_authentication/templates/tests/shoulda/sessions_controller.rb +15 -1
- data/rails_generators/nifty_authentication/templates/tests/shoulda/user.rb +2 -0
- data/rails_generators/nifty_authentication/templates/tests/shoulda/users_controller.rb +2 -0
- data/rails_generators/nifty_authentication/templates/tests/testunit/sessions_controller.rb +15 -1
- data/rails_generators/nifty_authentication/templates/tests/testunit/user.rb +2 -0
- data/rails_generators/nifty_authentication/templates/tests/testunit/users_controller.rb +2 -0
- data/rails_generators/nifty_authentication/templates/user.rb +4 -0
- data/rails_generators/nifty_authentication/templates/users_controller.rb +2 -0
- data/rails_generators/nifty_authentication/templates/views/erb/login.html.erb +16 -1
- data/rails_generators/nifty_authentication/templates/views/haml/login.html.haml +16 -1
- data/rails_generators/nifty_layout/templates/helper.rb +1 -2
- data/rails_generators/nifty_scaffold/templates/actions/create.rb +1 -1
- data/rails_generators/nifty_scaffold/templates/actions/destroy.rb +1 -1
- data/rails_generators/nifty_scaffold/templates/actions/update.rb +1 -1
- data/rails_generators/nifty_scaffold/templates/model.rb +1 -0
- data/rails_generators/nifty_scaffold/templates/views/haml/edit.html.haml +1 -1
- data/test/test_nifty_authentication_generator.rb +77 -1
- data/test/test_nifty_scaffold_generator.rb +3 -2
- metadata +6 -7
    
        data/CHANGELOG
    CHANGED
    
    | @@ -1,3 +1,16 @@ | |
| 1 | 
            +
            0.3.0 (August 15th, 2009)
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            * adding attr_accessible to models in nifty_scaffold
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            * adding authlogic support with --authlogic option in nifty_authentication
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            * pluralize second argument for controller in nifty_authentication
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            * don't convert javascript/stylesheet arguments to strings in nifty_layout
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            * store request location and redirect to it when logging in under nifty_authentication
         | 
| 12 | 
            +
             | 
| 13 | 
            +
             | 
| 1 14 | 
             
            0.2.4 (May 5th, 2009)
         | 
| 2 15 |  | 
| 3 16 | 
             
            * using root_url when no index action in nifty_scaffold
         | 
| @@ -6,12 +19,14 @@ | |
| 6 19 |  | 
| 7 20 | 
             
            * adding filter_parameter_logging :password in nifty_authentication
         | 
| 8 21 |  | 
| 22 | 
            +
             | 
| 9 23 | 
             
            0.2.3 (February 20th, 2009)
         | 
| 10 24 |  | 
| 11 25 | 
             
            * fixing nifty_authentication to work with Rails 2.3 application_controller.rb
         | 
| 12 26 |  | 
| 13 27 | 
             
            * fixing password field in HAML signup page in nifty_authentication
         | 
| 14 28 |  | 
| 29 | 
            +
             | 
| 15 30 | 
             
            0.2.2 (November 11th, 2008)
         | 
| 16 31 |  | 
| 17 32 | 
             
            * fixing sessions_path reference in nifty_authentication
         | 
| @@ -20,36 +35,43 @@ | |
| 20 35 |  | 
| 21 36 | 
             
            * cleaning up nifty_layout stylesheet
         | 
| 22 37 |  | 
| 38 | 
            +
             | 
| 23 39 | 
             
            0.2.1 (November 10th, 2008)
         | 
| 24 40 |  | 
| 25 41 | 
             
            * adding missing nifty_authentication files
         | 
| 26 42 |  | 
| 43 | 
            +
             | 
| 27 44 | 
             
            0.2.0 (November 4th, 2008)
         | 
| 28 45 |  | 
| 29 46 | 
             
            * adding nifty_authentication
         | 
| 30 47 |  | 
| 48 | 
            +
             | 
| 31 49 | 
             
            0.1.8 (October 3rd, 2008)
         | 
| 32 50 |  | 
| 33 51 | 
             
            * compatibility with RubyGems 1.3
         | 
| 34 52 |  | 
| 35 53 | 
             
            * using f.error_messages instead of error_messages_for (thanks Zach Langley)
         | 
| 36 54 |  | 
| 55 | 
            +
             | 
| 37 56 | 
             
            0.1.7 (August 15th, 2008)
         | 
| 38 57 |  | 
| 39 58 | 
             
            * fixing shoulda tests
         | 
| 40 59 |  | 
| 60 | 
            +
             | 
| 41 61 | 
             
            0.1.6 (August 7th, 2008)
         | 
| 42 62 |  | 
| 43 63 | 
             
            * adding option to specify Shoulda as testing framework in nifty_scaffold generator
         | 
| 44 64 |  | 
| 45 65 | 
             
            * adding options to manually specify rspec or testunit framework in nifty_scaffold generator
         | 
| 46 66 |  | 
| 67 | 
            +
             | 
| 47 68 | 
             
            0.1.5 (August 7th, 2008)
         | 
| 48 69 |  | 
| 49 70 | 
             
            * adding option to nifty layout to generate HAML views and SASS stylesheets
         | 
| 50 71 |  | 
| 51 72 | 
             
            * adding option to nifty scaffold to generate HAML views
         | 
| 52 73 |  | 
| 74 | 
            +
             | 
| 53 75 | 
             
            0.1.4 (July 21st, 2008)
         | 
| 54 76 |  | 
| 55 77 | 
             
            * using same logic as model spec in model test for scaffold
         | 
| @@ -58,22 +80,26 @@ | |
| 58 80 |  | 
| 59 81 | 
             
            * adding error_messages_for to form partial
         | 
| 60 82 |  | 
| 83 | 
            +
             | 
| 61 84 | 
             
            0.1.3 (June 20th, 2008)
         | 
| 62 85 |  | 
| 63 86 | 
             
            * using _url in controllers instead of _path
         | 
| 64 87 |  | 
| 65 88 | 
             
            * improving the nifty_config default example YAML file
         | 
| 66 89 |  | 
| 90 | 
            +
             | 
| 67 91 | 
             
            0.1.2 (May 16th, 2008)
         | 
| 68 92 |  | 
| 69 93 | 
             
            * mentioning nifty_layout in nifty_scaffold generator
         | 
| 70 94 |  | 
| 71 95 | 
             
            * adding nifty_config generator
         | 
| 72 96 |  | 
| 97 | 
            +
             | 
| 73 98 | 
             
            0.1.1 (May 9th, 2008)
         | 
| 74 99 |  | 
| 75 100 | 
             
            * adding tests and specs to scaffold generator
         | 
| 76 101 |  | 
| 102 | 
            +
             | 
| 77 103 | 
             
            0.1.0 (May 8th, 2008)
         | 
| 78 104 |  | 
| 79 105 | 
             
            * initial release
         | 
    
        data/Manifest
    CHANGED
    
    | @@ -1,9 +1,11 @@ | |
| 1 1 | 
             
            CHANGELOG
         | 
| 2 2 | 
             
            lib/nifty_generators.rb
         | 
| 3 3 | 
             
            LICENSE
         | 
| 4 | 
            +
            Manifest
         | 
| 4 5 | 
             
            rails_generators/nifty_authentication/lib/insert_commands.rb
         | 
| 5 6 | 
             
            rails_generators/nifty_authentication/nifty_authentication_generator.rb
         | 
| 6 7 | 
             
            rails_generators/nifty_authentication/templates/authentication.rb
         | 
| 8 | 
            +
            rails_generators/nifty_authentication/templates/authlogic_session.rb
         | 
| 7 9 | 
             
            rails_generators/nifty_authentication/templates/fixtures.yml
         | 
| 8 10 | 
             
            rails_generators/nifty_authentication/templates/migration.rb
         | 
| 9 11 | 
             
            rails_generators/nifty_authentication/templates/sessions_controller.rb
         | 
| @@ -96,4 +98,3 @@ test/test_nifty_config_generator.rb | |
| 96 98 | 
             
            test/test_nifty_layout_generator.rb
         | 
| 97 99 | 
             
            test/test_nifty_scaffold_generator.rb
         | 
| 98 100 | 
             
            TODO
         | 
| 99 | 
            -
            Manifest
         | 
    
        data/README.rdoc
    CHANGED
    
    | @@ -31,12 +31,24 @@ using the script/generate or script/destroy command. | |
| 31 31 | 
             
            * nifty_config: generates a config YAML file and loader.
         | 
| 32 32 | 
             
            * nifty_authentication: generates user model with sign up and log in.
         | 
| 33 33 |  | 
| 34 | 
            -
             | 
| 34 | 
            +
            To view the README for each generator, run it with the +--help+ option.
         | 
| 35 35 |  | 
| 36 36 | 
             
              script/generate nifty_layout --help
         | 
| 37 37 |  | 
| 38 38 |  | 
| 39 | 
            -
            == Troubleshooting
         | 
| 39 | 
            +
            == Troubleshooting and FAQs
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            <b>What is the difference between nifty_scaffold and built-in scaffold?</b>
         | 
| 42 | 
            +
             | 
| 43 | 
            +
            One of the primary differences is that nifty_scaffold allows you to choose which
         | 
| 44 | 
            +
            controller actions to generate.
         | 
| 45 | 
            +
             | 
| 46 | 
            +
              script/generate nifty_scaffold post name:string index new edit
         | 
| 47 | 
            +
             | 
| 48 | 
            +
            There are a few changes to the generated code as well, such as no XML format by default.
         | 
| 49 | 
            +
             | 
| 50 | 
            +
            It also offers support for HAML, Shoulda, and RSpec.
         | 
| 51 | 
            +
             | 
| 40 52 |  | 
| 41 53 | 
             
            <b>I get "undefined method 'title'" error.</b>
         | 
| 42 54 |  | 
| @@ -45,6 +57,11 @@ you can just change the templates to whatever approach you prefer for | |
| 45 57 | 
             
            setting the title.
         | 
| 46 58 |  | 
| 47 59 |  | 
| 60 | 
            +
            <b>I can't set new attributes in my model.</b>
         | 
| 61 | 
            +
             | 
| 62 | 
            +
            Add the attribute to the attr_accessible line in the model.
         | 
| 63 | 
            +
             | 
| 64 | 
            +
             | 
| 48 65 | 
             
            <b>I get "undefined method 'root_url'" error.</b>
         | 
| 49 66 |  | 
| 50 67 | 
             
            Some generators default redirecting to the root_url. Set this in your
         | 
| @@ -58,17 +75,12 @@ routes.rb file like this (substituting your controller name). | |
| 58 75 | 
             
            Run <tt>rake db:migrate</tt>.
         | 
| 59 76 |  | 
| 60 77 |  | 
| 61 | 
            -
            <b> | 
| 78 | 
            +
            <b>I get a routing error when I try to submit a form.</b>
         | 
| 62 79 |  | 
| 63 80 | 
             
            Try restarting your development server. Sometimes it doesn't detect the
         | 
| 64 81 | 
             
            change in the routing.
         | 
| 65 82 |  | 
| 66 83 |  | 
| 67 | 
            -
            <b>I can't set new attributes in my User model.</b>
         | 
| 68 | 
            -
             | 
| 69 | 
            -
            Add the attribute to the attr_accessible line in the model.
         | 
| 70 | 
            -
             | 
| 71 | 
            -
             | 
| 72 84 | 
             
            <b>The tests/specs don't work.</b>
         | 
| 73 85 |  | 
| 74 86 | 
             
            Make sure you have mocha installed and require it in your spec/test helper.
         | 
    
        data/Rakefile
    CHANGED
    
    | @@ -2,7 +2,7 @@ require 'rubygems' | |
| 2 2 | 
             
            require 'rake'
         | 
| 3 3 | 
             
            require 'echoe'
         | 
| 4 4 |  | 
| 5 | 
            -
            Echoe.new('nifty-generators', '0. | 
| 5 | 
            +
            Echoe.new('nifty-generators', '0.3.0') do |p|
         | 
| 6 6 | 
             
              p.project        = "niftygenerators"
         | 
| 7 7 | 
             
              p.description    = "A collection of useful generator scripts for Rails."
         | 
| 8 8 | 
             
              p.url            = "http://github.com/ryanb/nifty-generators"
         | 
    
        data/nifty-generators.gemspec
    CHANGED
    
    | @@ -1,32 +1,169 @@ | |
| 1 | 
            -
            # -*- encoding: utf-8 -*-
         | 
| 2 1 |  | 
| 3 | 
            -
            Gem::Specification | 
| 4 | 
            -
             | 
| 5 | 
            -
              s.version = "0.2.4"
         | 
| 2 | 
            +
            # Gem::Specification for Nifty-generators-0.3.0
         | 
| 3 | 
            +
            # Originally generated by Echoe
         | 
| 6 4 |  | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
               | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
              s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Nifty-generators", "--main", "README.rdoc"]
         | 
| 17 | 
            -
              s.require_paths = ["lib"]
         | 
| 18 | 
            -
              s.rubyforge_project = %q{niftygenerators}
         | 
| 19 | 
            -
              s.rubygems_version = %q{1.3.2}
         | 
| 20 | 
            -
              s.summary = %q{A collection of useful generator scripts for Rails.}
         | 
| 21 | 
            -
              s.test_files = ["test/test_helper.rb", "test/test_nifty_authentication_generator.rb", "test/test_nifty_config_generator.rb", "test/test_nifty_layout_generator.rb", "test/test_nifty_scaffold_generator.rb"]
         | 
| 5 | 
            +
            --- !ruby/object:Gem::Specification 
         | 
| 6 | 
            +
            name: nifty-generators
         | 
| 7 | 
            +
            version: !ruby/object:Gem::Version 
         | 
| 8 | 
            +
              version: 0.3.0
         | 
| 9 | 
            +
            platform: ruby
         | 
| 10 | 
            +
            authors: 
         | 
| 11 | 
            +
            - Ryan Bates
         | 
| 12 | 
            +
            autorequire: 
         | 
| 13 | 
            +
            bindir: bin
         | 
| 22 14 |  | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 15 | 
            +
            date: 2009-08-15 00:00:00 -07:00
         | 
| 16 | 
            +
            default_executable: 
         | 
| 17 | 
            +
            dependencies: []
         | 
| 26 18 |  | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 19 | 
            +
            description: A collection of useful generator scripts for Rails.
         | 
| 20 | 
            +
            email: ryan (at) railscasts (dot) com
         | 
| 21 | 
            +
            executables: []
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            extensions: []
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            extra_rdoc_files: 
         | 
| 26 | 
            +
            - CHANGELOG
         | 
| 27 | 
            +
            - lib/nifty_generators.rb
         | 
| 28 | 
            +
            - LICENSE
         | 
| 29 | 
            +
            - README.rdoc
         | 
| 30 | 
            +
            - tasks/deployment.rake
         | 
| 31 | 
            +
            - TODO
         | 
| 32 | 
            +
            files: 
         | 
| 33 | 
            +
            - CHANGELOG
         | 
| 34 | 
            +
            - lib/nifty_generators.rb
         | 
| 35 | 
            +
            - LICENSE
         | 
| 36 | 
            +
            - Manifest
         | 
| 37 | 
            +
            - rails_generators/nifty_authentication/lib/insert_commands.rb
         | 
| 38 | 
            +
            - rails_generators/nifty_authentication/nifty_authentication_generator.rb
         | 
| 39 | 
            +
            - rails_generators/nifty_authentication/templates/authentication.rb
         | 
| 40 | 
            +
            - rails_generators/nifty_authentication/templates/authlogic_session.rb
         | 
| 41 | 
            +
            - rails_generators/nifty_authentication/templates/fixtures.yml
         | 
| 42 | 
            +
            - rails_generators/nifty_authentication/templates/migration.rb
         | 
| 43 | 
            +
            - rails_generators/nifty_authentication/templates/sessions_controller.rb
         | 
| 44 | 
            +
            - rails_generators/nifty_authentication/templates/sessions_helper.rb
         | 
| 45 | 
            +
            - rails_generators/nifty_authentication/templates/tests/rspec/sessions_controller.rb
         | 
| 46 | 
            +
            - rails_generators/nifty_authentication/templates/tests/rspec/user.rb
         | 
| 47 | 
            +
            - rails_generators/nifty_authentication/templates/tests/rspec/users_controller.rb
         | 
| 48 | 
            +
            - rails_generators/nifty_authentication/templates/tests/shoulda/sessions_controller.rb
         | 
| 49 | 
            +
            - rails_generators/nifty_authentication/templates/tests/shoulda/user.rb
         | 
| 50 | 
            +
            - rails_generators/nifty_authentication/templates/tests/shoulda/users_controller.rb
         | 
| 51 | 
            +
            - rails_generators/nifty_authentication/templates/tests/testunit/sessions_controller.rb
         | 
| 52 | 
            +
            - rails_generators/nifty_authentication/templates/tests/testunit/user.rb
         | 
| 53 | 
            +
            - rails_generators/nifty_authentication/templates/tests/testunit/users_controller.rb
         | 
| 54 | 
            +
            - rails_generators/nifty_authentication/templates/user.rb
         | 
| 55 | 
            +
            - rails_generators/nifty_authentication/templates/users_controller.rb
         | 
| 56 | 
            +
            - rails_generators/nifty_authentication/templates/users_helper.rb
         | 
| 57 | 
            +
            - rails_generators/nifty_authentication/templates/views/erb/login.html.erb
         | 
| 58 | 
            +
            - rails_generators/nifty_authentication/templates/views/erb/signup.html.erb
         | 
| 59 | 
            +
            - rails_generators/nifty_authentication/templates/views/haml/login.html.haml
         | 
| 60 | 
            +
            - rails_generators/nifty_authentication/templates/views/haml/signup.html.haml
         | 
| 61 | 
            +
            - rails_generators/nifty_authentication/USAGE
         | 
| 62 | 
            +
            - rails_generators/nifty_config/nifty_config_generator.rb
         | 
| 63 | 
            +
            - rails_generators/nifty_config/templates/config.yml
         | 
| 64 | 
            +
            - rails_generators/nifty_config/templates/load_config.rb
         | 
| 65 | 
            +
            - rails_generators/nifty_config/USAGE
         | 
| 66 | 
            +
            - rails_generators/nifty_layout/nifty_layout_generator.rb
         | 
| 67 | 
            +
            - rails_generators/nifty_layout/templates/helper.rb
         | 
| 68 | 
            +
            - rails_generators/nifty_layout/templates/layout.html.erb
         | 
| 69 | 
            +
            - rails_generators/nifty_layout/templates/layout.html.haml
         | 
| 70 | 
            +
            - rails_generators/nifty_layout/templates/stylesheet.css
         | 
| 71 | 
            +
            - rails_generators/nifty_layout/templates/stylesheet.sass
         | 
| 72 | 
            +
            - rails_generators/nifty_layout/USAGE
         | 
| 73 | 
            +
            - rails_generators/nifty_scaffold/nifty_scaffold_generator.rb
         | 
| 74 | 
            +
            - rails_generators/nifty_scaffold/templates/actions/create.rb
         | 
| 75 | 
            +
            - rails_generators/nifty_scaffold/templates/actions/destroy.rb
         | 
| 76 | 
            +
            - rails_generators/nifty_scaffold/templates/actions/edit.rb
         | 
| 77 | 
            +
            - rails_generators/nifty_scaffold/templates/actions/index.rb
         | 
| 78 | 
            +
            - rails_generators/nifty_scaffold/templates/actions/new.rb
         | 
| 79 | 
            +
            - rails_generators/nifty_scaffold/templates/actions/show.rb
         | 
| 80 | 
            +
            - rails_generators/nifty_scaffold/templates/actions/update.rb
         | 
| 81 | 
            +
            - rails_generators/nifty_scaffold/templates/controller.rb
         | 
| 82 | 
            +
            - rails_generators/nifty_scaffold/templates/fixtures.yml
         | 
| 83 | 
            +
            - rails_generators/nifty_scaffold/templates/helper.rb
         | 
| 84 | 
            +
            - rails_generators/nifty_scaffold/templates/migration.rb
         | 
| 85 | 
            +
            - rails_generators/nifty_scaffold/templates/model.rb
         | 
| 86 | 
            +
            - rails_generators/nifty_scaffold/templates/tests/rspec/actions/create.rb
         | 
| 87 | 
            +
            - rails_generators/nifty_scaffold/templates/tests/rspec/actions/destroy.rb
         | 
| 88 | 
            +
            - rails_generators/nifty_scaffold/templates/tests/rspec/actions/edit.rb
         | 
| 89 | 
            +
            - rails_generators/nifty_scaffold/templates/tests/rspec/actions/index.rb
         | 
| 90 | 
            +
            - rails_generators/nifty_scaffold/templates/tests/rspec/actions/new.rb
         | 
| 91 | 
            +
            - rails_generators/nifty_scaffold/templates/tests/rspec/actions/show.rb
         | 
| 92 | 
            +
            - rails_generators/nifty_scaffold/templates/tests/rspec/actions/update.rb
         | 
| 93 | 
            +
            - rails_generators/nifty_scaffold/templates/tests/rspec/controller.rb
         | 
| 94 | 
            +
            - rails_generators/nifty_scaffold/templates/tests/rspec/model.rb
         | 
| 95 | 
            +
            - rails_generators/nifty_scaffold/templates/tests/shoulda/actions/create.rb
         | 
| 96 | 
            +
            - rails_generators/nifty_scaffold/templates/tests/shoulda/actions/destroy.rb
         | 
| 97 | 
            +
            - rails_generators/nifty_scaffold/templates/tests/shoulda/actions/edit.rb
         | 
| 98 | 
            +
            - rails_generators/nifty_scaffold/templates/tests/shoulda/actions/index.rb
         | 
| 99 | 
            +
            - rails_generators/nifty_scaffold/templates/tests/shoulda/actions/new.rb
         | 
| 100 | 
            +
            - rails_generators/nifty_scaffold/templates/tests/shoulda/actions/show.rb
         | 
| 101 | 
            +
            - rails_generators/nifty_scaffold/templates/tests/shoulda/actions/update.rb
         | 
| 102 | 
            +
            - rails_generators/nifty_scaffold/templates/tests/shoulda/controller.rb
         | 
| 103 | 
            +
            - rails_generators/nifty_scaffold/templates/tests/shoulda/model.rb
         | 
| 104 | 
            +
            - rails_generators/nifty_scaffold/templates/tests/testunit/actions/create.rb
         | 
| 105 | 
            +
            - rails_generators/nifty_scaffold/templates/tests/testunit/actions/destroy.rb
         | 
| 106 | 
            +
            - rails_generators/nifty_scaffold/templates/tests/testunit/actions/edit.rb
         | 
| 107 | 
            +
            - rails_generators/nifty_scaffold/templates/tests/testunit/actions/index.rb
         | 
| 108 | 
            +
            - rails_generators/nifty_scaffold/templates/tests/testunit/actions/new.rb
         | 
| 109 | 
            +
            - rails_generators/nifty_scaffold/templates/tests/testunit/actions/show.rb
         | 
| 110 | 
            +
            - rails_generators/nifty_scaffold/templates/tests/testunit/actions/update.rb
         | 
| 111 | 
            +
            - rails_generators/nifty_scaffold/templates/tests/testunit/controller.rb
         | 
| 112 | 
            +
            - rails_generators/nifty_scaffold/templates/tests/testunit/model.rb
         | 
| 113 | 
            +
            - rails_generators/nifty_scaffold/templates/views/erb/_form.html.erb
         | 
| 114 | 
            +
            - rails_generators/nifty_scaffold/templates/views/erb/edit.html.erb
         | 
| 115 | 
            +
            - rails_generators/nifty_scaffold/templates/views/erb/index.html.erb
         | 
| 116 | 
            +
            - rails_generators/nifty_scaffold/templates/views/erb/new.html.erb
         | 
| 117 | 
            +
            - rails_generators/nifty_scaffold/templates/views/erb/show.html.erb
         | 
| 118 | 
            +
            - rails_generators/nifty_scaffold/templates/views/haml/_form.html.haml
         | 
| 119 | 
            +
            - rails_generators/nifty_scaffold/templates/views/haml/edit.html.haml
         | 
| 120 | 
            +
            - rails_generators/nifty_scaffold/templates/views/haml/index.html.haml
         | 
| 121 | 
            +
            - rails_generators/nifty_scaffold/templates/views/haml/new.html.haml
         | 
| 122 | 
            +
            - rails_generators/nifty_scaffold/templates/views/haml/show.html.haml
         | 
| 123 | 
            +
            - rails_generators/nifty_scaffold/USAGE
         | 
| 124 | 
            +
            - Rakefile
         | 
| 125 | 
            +
            - README.rdoc
         | 
| 126 | 
            +
            - tasks/deployment.rake
         | 
| 127 | 
            +
            - test/test_helper.rb
         | 
| 128 | 
            +
            - test/test_nifty_authentication_generator.rb
         | 
| 129 | 
            +
            - test/test_nifty_config_generator.rb
         | 
| 130 | 
            +
            - test/test_nifty_layout_generator.rb
         | 
| 131 | 
            +
            - test/test_nifty_scaffold_generator.rb
         | 
| 132 | 
            +
            - TODO
         | 
| 133 | 
            +
            - nifty-generators.gemspec
         | 
| 134 | 
            +
            has_rdoc: true
         | 
| 135 | 
            +
            homepage: http://github.com/ryanb/nifty-generators
         | 
| 136 | 
            +
            post_install_message: 
         | 
| 137 | 
            +
            rdoc_options: 
         | 
| 138 | 
            +
            - --line-numbers
         | 
| 139 | 
            +
            - --inline-source
         | 
| 140 | 
            +
            - --title
         | 
| 141 | 
            +
            - Nifty-generators
         | 
| 142 | 
            +
            - --main
         | 
| 143 | 
            +
            - README.rdoc
         | 
| 144 | 
            +
            require_paths: 
         | 
| 145 | 
            +
            - lib
         | 
| 146 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement 
         | 
| 147 | 
            +
              requirements: 
         | 
| 148 | 
            +
              - - ">="
         | 
| 149 | 
            +
                - !ruby/object:Gem::Version 
         | 
| 150 | 
            +
                  version: "0"
         | 
| 151 | 
            +
              version: 
         | 
| 152 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement 
         | 
| 153 | 
            +
              requirements: 
         | 
| 154 | 
            +
              - - ">="
         | 
| 155 | 
            +
                - !ruby/object:Gem::Version 
         | 
| 156 | 
            +
                  version: "1.2"
         | 
| 157 | 
            +
              version: 
         | 
| 158 | 
            +
            requirements: []
         | 
| 159 | 
            +
             | 
| 160 | 
            +
            rubyforge_project: niftygenerators
         | 
| 161 | 
            +
            rubygems_version: 1.3.1
         | 
| 162 | 
            +
            specification_version: 2
         | 
| 163 | 
            +
            summary: A collection of useful generator scripts for Rails.
         | 
| 164 | 
            +
            test_files: 
         | 
| 165 | 
            +
            - test/test_helper.rb
         | 
| 166 | 
            +
            - test/test_nifty_authentication_generator.rb
         | 
| 167 | 
            +
            - test/test_nifty_config_generator.rb
         | 
| 168 | 
            +
            - test/test_nifty_layout_generator.rb
         | 
| 169 | 
            +
            - test/test_nifty_scaffold_generator.rb
         | 
| @@ -9,9 +9,13 @@ Description: | |
| 9 9 |  | 
| 10 10 | 
             
            Usage:
         | 
| 11 11 | 
             
                If you do not pass any arguments, the model name will default to "user", and
         | 
| 12 | 
            -
                the authentication controller will default to " | 
| 12 | 
            +
                the authentication controller will default to "session". You can override
         | 
| 13 13 | 
             
                each of these respectively by passing one or two arguments. Either name can
         | 
| 14 14 | 
             
                be CamelCased or under_scored.
         | 
| 15 | 
            +
                
         | 
| 16 | 
            +
                Make sure to setup the authlogic gem if you are using that option.
         | 
| 17 | 
            +
                
         | 
| 18 | 
            +
                  config.gem "authlogic"
         | 
| 15 19 |  | 
| 16 20 | 
             
            Examples:
         | 
| 17 21 | 
             
                script/generate nifty_authentication
         | 
| @@ -22,9 +26,9 @@ Examples: | |
| 22 26 |  | 
| 23 27 | 
             
                    Creates account model, accounts_controller, and sessions_controller.
         | 
| 24 28 |  | 
| 25 | 
            -
                script/generate nifty_authentication Account  | 
| 29 | 
            +
                script/generate nifty_authentication Account UserSession
         | 
| 26 30 |  | 
| 27 | 
            -
                    Creates account model, accounts_controller, and  | 
| 31 | 
            +
                    Creates account model, accounts_controller, and user_sessions_controller.
         | 
| 28 32 |  | 
| 29 33 | 
             
            Methods:
         | 
| 30 34 | 
             
                There are several methods generated which you can use in your application.
         | 
| @@ -1,12 +1,12 @@ | |
| 1 1 | 
             
            require File.expand_path(File.dirname(__FILE__) + "/lib/insert_commands.rb")
         | 
| 2 2 | 
             
            class NiftyAuthenticationGenerator < Rails::Generator::Base
         | 
| 3 | 
            -
              attr_accessor :user_name, : | 
| 3 | 
            +
              attr_accessor :user_name, :session_name
         | 
| 4 4 |  | 
| 5 5 | 
             
              def initialize(runtime_args, runtime_options = {})
         | 
| 6 6 | 
             
                super
         | 
| 7 7 |  | 
| 8 8 | 
             
                @user_name = @args[0] || 'user'
         | 
| 9 | 
            -
                @ | 
| 9 | 
            +
                @session_name = @args[1] || (options[:authlogic] ? @user_name + '_session' : 'session')
         | 
| 10 10 | 
             
              end
         | 
| 11 11 |  | 
| 12 12 | 
             
              def manifest
         | 
| @@ -19,22 +19,23 @@ class NiftyAuthenticationGenerator < Rails::Generator::Base | |
| 19 19 |  | 
| 20 20 | 
             
                  m.directory "app/views/#{user_plural_name}"
         | 
| 21 21 | 
             
                  m.template "user.rb", "app/models/#{user_singular_name}.rb"
         | 
| 22 | 
            +
                  m.template "authlogic_session.rb", "app/models/#{user_singular_name}_session.rb" if options[:authlogic]
         | 
| 22 23 | 
             
                  m.template "users_controller.rb", "app/controllers/#{user_plural_name}_controller.rb"
         | 
| 23 24 | 
             
                  m.template "users_helper.rb", "app/helpers/#{user_plural_name}_helper.rb"
         | 
| 24 25 | 
             
                  m.template "views/#{view_language}/signup.html.#{view_language}", "app/views/#{user_plural_name}/new.html.#{view_language}"
         | 
| 25 26 |  | 
| 26 | 
            -
                  m.directory "app/views/#{ | 
| 27 | 
            -
                  m.template "sessions_controller.rb", "app/controllers/#{ | 
| 28 | 
            -
                  m.template "sessions_helper.rb", "app/helpers/#{ | 
| 29 | 
            -
                  m.template "views/#{view_language}/login.html.#{view_language}", "app/views/#{ | 
| 27 | 
            +
                  m.directory "app/views/#{session_plural_name}"
         | 
| 28 | 
            +
                  m.template "sessions_controller.rb", "app/controllers/#{session_plural_name}_controller.rb"
         | 
| 29 | 
            +
                  m.template "sessions_helper.rb", "app/helpers/#{session_plural_name}_helper.rb"
         | 
| 30 | 
            +
                  m.template "views/#{view_language}/login.html.#{view_language}", "app/views/#{session_plural_name}/new.html.#{view_language}"
         | 
| 30 31 |  | 
| 31 32 | 
             
                  m.template "authentication.rb", "lib/authentication.rb"
         | 
| 32 33 | 
             
                  m.migration_template "migration.rb", "db/migrate", :migration_file_name => "create_#{user_plural_name}"
         | 
| 33 34 |  | 
| 34 35 | 
             
                  m.route_resources user_plural_name
         | 
| 35 | 
            -
                  m.route_resources  | 
| 36 | 
            -
                  m.route_name :login, 'login', :controller =>  | 
| 37 | 
            -
                  m.route_name :logout, 'logout', :controller =>  | 
| 36 | 
            +
                  m.route_resources session_plural_name
         | 
| 37 | 
            +
                  m.route_name :login, 'login', :controller => session_plural_name, :action => 'new'
         | 
| 38 | 
            +
                  m.route_name :logout, 'logout', :controller => session_plural_name, :action => 'destroy'
         | 
| 38 39 | 
             
                  m.route_name :signup, 'signup', :controller => user_plural_name, :action => 'new'
         | 
| 39 40 |  | 
| 40 41 | 
             
                  m.insert_into "app/controllers/#{application_controller_name}.rb", 'include Authentication'
         | 
| @@ -47,7 +48,7 @@ class NiftyAuthenticationGenerator < Rails::Generator::Base | |
| 47 48 | 
             
                    m.template "fixtures.yml", "spec/fixtures/#{user_plural_name}.yml"
         | 
| 48 49 | 
             
                    m.template "tests/rspec/user.rb", "spec/models/#{user_singular_name}_spec.rb"
         | 
| 49 50 | 
             
                    m.template "tests/rspec/users_controller.rb", "spec/controllers/#{user_plural_name}_controller_spec.rb"
         | 
| 50 | 
            -
                    m.template "tests/rspec/sessions_controller.rb", "spec/controllers/#{ | 
| 51 | 
            +
                    m.template "tests/rspec/sessions_controller.rb", "spec/controllers/#{session_plural_name}_controller_spec.rb"
         | 
| 51 52 | 
             
                  else
         | 
| 52 53 | 
             
                    m.directory "test"
         | 
| 53 54 | 
             
                    m.directory "test/fixtures"
         | 
| @@ -56,7 +57,7 @@ class NiftyAuthenticationGenerator < Rails::Generator::Base | |
| 56 57 | 
             
                    m.template "fixtures.yml", "test/fixtures/#{user_plural_name}.yml"
         | 
| 57 58 | 
             
                    m.template "tests/#{test_framework}/user.rb", "test/unit/#{user_singular_name}_test.rb"
         | 
| 58 59 | 
             
                    m.template "tests/#{test_framework}/users_controller.rb", "test/functional/#{user_plural_name}_controller_test.rb"
         | 
| 59 | 
            -
                    m.template "tests/#{test_framework}/sessions_controller.rb", "test/functional/#{ | 
| 60 | 
            +
                    m.template "tests/#{test_framework}/sessions_controller.rb", "test/functional/#{session_plural_name}_controller_test.rb"
         | 
| 60 61 | 
             
                  end
         | 
| 61 62 | 
             
                end
         | 
| 62 63 | 
             
              end
         | 
| @@ -76,13 +77,21 @@ class NiftyAuthenticationGenerator < Rails::Generator::Base | |
| 76 77 | 
             
              def user_plural_class_name
         | 
| 77 78 | 
             
                user_plural_name.camelize
         | 
| 78 79 | 
             
              end
         | 
| 79 | 
            -
             | 
| 80 | 
            -
              def  | 
| 81 | 
            -
                 | 
| 80 | 
            +
              
         | 
| 81 | 
            +
              def session_singular_name
         | 
| 82 | 
            +
                session_name.underscore
         | 
| 83 | 
            +
              end
         | 
| 84 | 
            +
              
         | 
| 85 | 
            +
              def session_plural_name
         | 
| 86 | 
            +
                session_singular_name.pluralize
         | 
| 82 87 | 
             
              end
         | 
| 83 88 |  | 
| 84 | 
            -
              def  | 
| 85 | 
            -
                 | 
| 89 | 
            +
              def session_class_name
         | 
| 90 | 
            +
                session_name.camelize
         | 
| 91 | 
            +
              end
         | 
| 92 | 
            +
              
         | 
| 93 | 
            +
              def session_plural_class_name
         | 
| 94 | 
            +
                session_plural_name.camelize
         | 
| 86 95 | 
             
              end
         | 
| 87 96 |  | 
| 88 97 | 
             
              def application_controller_name
         | 
| @@ -106,6 +115,7 @@ protected | |
| 106 115 | 
             
                opt.on("--rspec", "Use RSpec for test files.") { options[:test_framework] = :rspec }
         | 
| 107 116 | 
             
                opt.on("--shoulda", "Use Shoulda for test files.") { options[:test_framework] = :shoulda }
         | 
| 108 117 | 
             
                opt.on("--haml", "Generate HAML views instead of ERB.") { |v| options[:haml] = true }
         | 
| 118 | 
            +
                opt.on("--authlogic", "Use Authlogic for authentication.") { |v| options[:authlogic] = true }
         | 
| 109 119 | 
             
              end
         | 
| 110 120 |  | 
| 111 121 | 
             
              def banner
         | 
| @@ -3,7 +3,7 @@ | |
| 3 3 | 
             
            # common example you might add to your application layout file.
         | 
| 4 4 | 
             
            # 
         | 
| 5 5 | 
             
            #   <%% if logged_in? %>
         | 
| 6 | 
            -
            #     Welcome <%%=  | 
| 6 | 
            +
            #     Welcome <%%=h current_<%= user_singular_name %>.username %>! Not you?
         | 
| 7 7 | 
             
            #     <%%= link_to "Log out", logout_path %>
         | 
| 8 8 | 
             
            #   <%% else %>
         | 
| 9 9 | 
             
            #     <%%= link_to "Sign up", signup_path %> or
         | 
| @@ -16,13 +16,25 @@ | |
| 16 16 | 
             
            #   before_filter :login_required, :except => [:index, :show]
         | 
| 17 17 | 
             
            module Authentication
         | 
| 18 18 | 
             
              def self.included(controller)
         | 
| 19 | 
            -
                controller.send :helper_method, :current_<%= user_singular_name %>, :logged_in | 
| 19 | 
            +
                controller.send :helper_method, :current_<%= user_singular_name %>, :logged_in?, :redirect_to_target_or_default
         | 
| 20 20 | 
             
                controller.filter_parameter_logging :password
         | 
| 21 21 | 
             
              end
         | 
| 22 22 |  | 
| 23 | 
            +
            <%- if options[:authlogic] -%>
         | 
| 24 | 
            +
              def current_<%= session_singular_name %>
         | 
| 25 | 
            +
                return @current_<%= session_singular_name %> if defined?(@current_<%= session_singular_name %>)
         | 
| 26 | 
            +
                @current_<%= session_singular_name %> = <%= session_class_name %>.find
         | 
| 27 | 
            +
              end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
              def current_<%= user_singular_name %>
         | 
| 30 | 
            +
                return @current_<%= user_singular_name %> if defined?(@current_<%= user_singular_name %>)
         | 
| 31 | 
            +
                @current_<%= user_singular_name %> = current_<%= session_singular_name %> && current_<%= session_singular_name %>.record
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
            <%- else -%>
         | 
| 23 34 | 
             
              def current_<%= user_singular_name %>
         | 
| 24 35 | 
             
                @current_<%= user_singular_name %> ||= <%= user_class_name %>.find(session[:<%= user_singular_name %>_id]) if session[:<%= user_singular_name %>_id]
         | 
| 25 36 | 
             
              end
         | 
| 37 | 
            +
            <%- end -%>
         | 
| 26 38 |  | 
| 27 39 | 
             
              def logged_in?
         | 
| 28 40 | 
             
                current_<%= user_singular_name %>
         | 
| @@ -31,7 +43,19 @@ module Authentication | |
| 31 43 | 
             
              def login_required
         | 
| 32 44 | 
             
                unless logged_in?
         | 
| 33 45 | 
             
                  flash[:error] = "You must first log in or sign up before accessing this page."
         | 
| 46 | 
            +
                  store_target_location
         | 
| 34 47 | 
             
                  redirect_to login_url
         | 
| 35 48 | 
             
                end
         | 
| 36 49 | 
             
              end
         | 
| 50 | 
            +
              
         | 
| 51 | 
            +
              def redirect_to_target_or_default(default)
         | 
| 52 | 
            +
                redirect_to(session[:return_to] || default)
         | 
| 53 | 
            +
                session[:return_to] = nil
         | 
| 54 | 
            +
              end
         | 
| 55 | 
            +
              
         | 
| 56 | 
            +
              private
         | 
| 57 | 
            +
              
         | 
| 58 | 
            +
              def store_target_location
         | 
| 59 | 
            +
                session[:return_to] = request.request_uri
         | 
| 60 | 
            +
              end
         | 
| 37 61 | 
             
            end
         | 
| @@ -1,12 +1,24 @@ | |
| 1 1 | 
             
            # password: "secret"
         | 
| 2 | 
            -
             | 
| 2 | 
            +
            foo:
         | 
| 3 3 | 
             
              username: foo
         | 
| 4 4 | 
             
              email: foo@example.com
         | 
| 5 | 
            +
            <%- if options[:authlogic] -%>
         | 
| 6 | 
            +
              persistence_token: d5ddba13ed4408ea2b0a12ab18ed2d2eda086279736bdc121ca726a11f1e4b99217d9c534c2cc4ebb22729349c8c5fdbe1529e1f2c3c5859c62ef4dd9feea25c
         | 
| 7 | 
            +
              crypted_password: 3d16c326648cccafe3d4b4cb024475c381dda92f430dfedf6f933e1f61203bacb6bae2437849bdb43b06be335e23790e4aa03902b3c28c3bbbbe27d501e521f3
         | 
| 8 | 
            +
              password_salt: n6z_wtpWoIsHgQb5IcFd
         | 
| 9 | 
            +
            <%- else -%>
         | 
| 5 10 | 
             
              password_hash: 3488f5f7efecab14b91eb96169e5e1ee518a569f
         | 
| 6 11 | 
             
              password_salt: bef65e058905c379436d80d1a32e7374b139e7b0
         | 
| 12 | 
            +
            <%- end -%>
         | 
| 7 13 |  | 
| 8 | 
            -
             | 
| 14 | 
            +
            bar:
         | 
| 9 15 | 
             
              username: bar
         | 
| 10 16 | 
             
              email: bar@example.com
         | 
| 17 | 
            +
            <%- if options[:authlogic] -%>
         | 
| 18 | 
            +
              persistence_token: 19e074bd7cb506ab3e7e53e41f24f0ab3221c8cb68111f4c1aa43965114ad734233979a50a9463537487cdca18c279ac91c4bc83693d589625d446493322394c
         | 
| 19 | 
            +
              crypted_password: 3bc9f4113ca645a186765df3d31a9352d0067bf2304ba0cdd6b08a7f3d58c6668ab1762fa3e76aef466ea2ff188399d8e6c40244fa59312bb4112292dac9f7f0
         | 
| 20 | 
            +
              password_salt: UiAh9ejabnKRxqsiK0xO
         | 
| 21 | 
            +
            <%- else -%>
         | 
| 11 22 | 
             
              password_hash: 3488f5f7efecab14b91eb96169e5e1ee518a569f
         | 
| 12 23 | 
             
              password_salt: bef65e058905c379436d80d1a32e7374b139e7b0
         | 
| 24 | 
            +
            <%- end -%>
         | 
| @@ -1,10 +1,15 @@ | |
| 1 1 | 
             
            class Create<%= user_plural_class_name %> < ActiveRecord::Migration
         | 
| 2 2 | 
             
              def self.up
         | 
| 3 3 | 
             
                create_table :<%= user_plural_name %> do |t|
         | 
| 4 | 
            -
                  t. | 
| 5 | 
            -
                  t. | 
| 6 | 
            -
             | 
| 7 | 
            -
                  t. | 
| 4 | 
            +
                  t.string :username
         | 
| 5 | 
            +
                  t.string :email
         | 
| 6 | 
            +
                <%- if options[:authlogic] -%>
         | 
| 7 | 
            +
                  t.string :persistence_token
         | 
| 8 | 
            +
                  t.string :crypted_password
         | 
| 9 | 
            +
                <%- else -%>
         | 
| 10 | 
            +
                  t.string :password_hash
         | 
| 11 | 
            +
                <%- end -%>
         | 
| 12 | 
            +
                  t.string :password_salt
         | 
| 8 13 | 
             
                  t.timestamps
         | 
| 9 14 | 
             
                end
         | 
| 10 15 | 
             
              end
         | 
| @@ -1,4 +1,26 @@ | |
| 1 | 
            -
            class <%=  | 
| 1 | 
            +
            class <%= session_plural_class_name %>Controller < ApplicationController
         | 
| 2 | 
            +
            <%- if options[:authlogic] -%>
         | 
| 3 | 
            +
              def new
         | 
| 4 | 
            +
                @<%= session_singular_name %> = <%= session_class_name %>.new
         | 
| 5 | 
            +
              end
         | 
| 6 | 
            +
              
         | 
| 7 | 
            +
              def create
         | 
| 8 | 
            +
                @<%= session_singular_name %> = <%= session_class_name %>.new(params[:<%= session_singular_name %>])
         | 
| 9 | 
            +
                if @<%= session_singular_name %>.save
         | 
| 10 | 
            +
                  flash[:notice] = "Logged in successfully."
         | 
| 11 | 
            +
                  redirect_to_target_or_default(root_url)
         | 
| 12 | 
            +
                else
         | 
| 13 | 
            +
                  render :action => 'new'
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
              
         | 
| 17 | 
            +
              def destroy
         | 
| 18 | 
            +
                @<%= session_singular_name %> = <%= session_class_name %>.find
         | 
| 19 | 
            +
                @<%= session_singular_name %>.destroy
         | 
| 20 | 
            +
                flash[:notice] = "You have been logged out."
         | 
| 21 | 
            +
                redirect_to root_url
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
            <%- else -%>
         | 
| 2 24 | 
             
              def new
         | 
| 3 25 | 
             
              end
         | 
| 4 26 |  | 
| @@ -7,7 +29,7 @@ class <%= sessions_class_name %>Controller < ApplicationController | |
| 7 29 | 
             
                if <%= user_singular_name %>
         | 
| 8 30 | 
             
                  session[:<%= user_singular_name %>_id] = <%= user_singular_name %>.id
         | 
| 9 31 | 
             
                  flash[:notice] = "Logged in successfully."
         | 
| 10 | 
            -
                   | 
| 32 | 
            +
                  redirect_to_target_or_default(root_url)
         | 
| 11 33 | 
             
                else
         | 
| 12 34 | 
             
                  flash.now[:error] = "Invalid login or password."
         | 
| 13 35 | 
             
                  render :action => 'new'
         | 
| @@ -19,4 +41,5 @@ class <%= sessions_class_name %>Controller < ApplicationController | |
| 19 41 | 
             
                flash[:notice] = "You have been logged out."
         | 
| 20 42 | 
             
                redirect_to root_url
         | 
| 21 43 | 
             
              end
         | 
| 44 | 
            +
            <%- end -%>
         | 
| 22 45 | 
             
            end
         | 
| @@ -1,2 +1,2 @@ | |
| 1 | 
            -
            module <%=  | 
| 1 | 
            +
            module <%= session_plural_class_name %>Helper
         | 
| 2 2 | 
             
            end
         | 
| @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            require File.dirname(__FILE__) + '/../spec_helper'
         | 
| 2 2 |  | 
| 3 | 
            -
            describe <%=  | 
| 3 | 
            +
            describe <%= session_plural_class_name %>Controller do
         | 
| 4 4 | 
             
              fixtures :all
         | 
| 5 5 | 
             
              integrate_views
         | 
| 6 6 |  | 
| @@ -9,6 +9,19 @@ describe <%= sessions_class_name %>Controller do | |
| 9 9 | 
             
                response.should render_template(:new)
         | 
| 10 10 | 
             
              end
         | 
| 11 11 |  | 
| 12 | 
            +
            <%- if options[:authlogic] -%>
         | 
| 13 | 
            +
              it "create action should render new template when authentication is invalid" do
         | 
| 14 | 
            +
                post :create, :<%= session_singular_name %> => { :username => "foo", :password => "badpassword" }
         | 
| 15 | 
            +
                response.should render_template(:new)
         | 
| 16 | 
            +
                <%= session_class_name %>.find.should be_nil
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
              
         | 
| 19 | 
            +
              it "create action should redirect when authentication is valid" do
         | 
| 20 | 
            +
                post :create, :<%= session_singular_name %> => { :username => "foo", :password => "secret" }
         | 
| 21 | 
            +
                response.should redirect_to(root_url)
         | 
| 22 | 
            +
                <%= session_class_name %>.find.<%= user_singular_name %>.should == <%= user_plural_name %>(:foo)
         | 
| 23 | 
            +
              end
         | 
| 24 | 
            +
            <%- else -%>
         | 
| 12 25 | 
             
              it "create action should render new template when authentication is invalid" do
         | 
| 13 26 | 
             
                <%= user_class_name %>.stubs(:authenticate).returns(nil)
         | 
| 14 27 | 
             
                post :create
         | 
| @@ -22,4 +35,5 @@ describe <%= sessions_class_name %>Controller do | |
| 22 35 | 
             
                response.should redirect_to(root_url)
         | 
| 23 36 | 
             
                session['<%= user_singular_name %>_id'].should == <%= user_class_name %>.first.id
         | 
| 24 37 | 
             
              end
         | 
| 38 | 
            +
            <%- end -%>
         | 
| 25 39 | 
             
            end
         | 
| @@ -1,6 +1,7 @@ | |
| 1 1 | 
             
            require File.dirname(__FILE__) + '/../spec_helper'
         | 
| 2 2 |  | 
| 3 3 | 
             
            describe <%= user_class_name %> do
         | 
| 4 | 
            +
            <%- unless options[:authlogic] -%>
         | 
| 4 5 | 
             
              def new_<%= user_singular_name %>(attributes = {})
         | 
| 5 6 | 
             
                attributes[:username] ||= 'foo'
         | 
| 6 7 | 
             
                attributes[:email] ||= 'foo@example.com'
         | 
| @@ -78,4 +79,5 @@ describe <%= user_class_name %> do | |
| 78 79 | 
             
                new_<%= user_singular_name %>(:username => 'foobar', :password => 'secret').save!
         | 
| 79 80 | 
             
                <%= user_class_name %>.authenticate('foobar', 'badpassword').should be_nil
         | 
| 80 81 | 
             
              end
         | 
| 82 | 
            +
            <%- end -%>
         | 
| 81 83 | 
             
            end
         | 
| @@ -19,6 +19,8 @@ describe <%= user_plural_class_name %>Controller do | |
| 19 19 | 
             
                <%= user_class_name %>.any_instance.stubs(:valid?).returns(true)
         | 
| 20 20 | 
             
                post :create
         | 
| 21 21 | 
             
                response.should redirect_to(root_url)
         | 
| 22 | 
            +
              <%- unless options[:authlogic] -%>
         | 
| 22 23 | 
             
                session['<%= user_singular_name %>_id'].should == assigns['<%= user_singular_name %>'].id
         | 
| 24 | 
            +
              <%- end -%>
         | 
| 23 25 | 
             
              end
         | 
| 24 26 | 
             
            end
         | 
| @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            require 'test_helper'
         | 
| 2 2 |  | 
| 3 | 
            -
            class <%=  | 
| 3 | 
            +
            class <%= session_plural_class_name %>ControllerTest < ActionController::TestCase
         | 
| 4 4 | 
             
              context "new action" do
         | 
| 5 5 | 
             
                should "render new template" do
         | 
| 6 6 | 
             
                  get :new
         | 
| @@ -9,6 +9,19 @@ class <%= sessions_class_name %>ControllerTest < ActionController::TestCase | |
| 9 9 | 
             
              end
         | 
| 10 10 |  | 
| 11 11 | 
             
              context "create action" do
         | 
| 12 | 
            +
              <%- if options[:authlogic] -%>
         | 
| 13 | 
            +
                should "render new template when authentication is invalid" do
         | 
| 14 | 
            +
                  post :create, :<%= session_singular_name %> => { :username => "foo", :password => "badpassword" }
         | 
| 15 | 
            +
                  assert_template 'new'
         | 
| 16 | 
            +
                  assert_nil <%= session_class_name %>.find
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
                
         | 
| 19 | 
            +
                should "redirect when authentication is valid" do
         | 
| 20 | 
            +
                  post :create, :<%= session_singular_name %> => { :username => "foo", :password => "secret" }
         | 
| 21 | 
            +
                  assert_redirected_to root_url
         | 
| 22 | 
            +
                  assert_equal <%= user_plural_name %>(:foo), <%= session_class_name %>.find.<%= user_singular_name %>
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
              <%- else -%>
         | 
| 12 25 | 
             
                should "render new template when authentication is invalid" do
         | 
| 13 26 | 
             
                  <%= user_class_name %>.stubs(:authenticate).returns(nil)
         | 
| 14 27 | 
             
                  post :create
         | 
| @@ -22,5 +35,6 @@ class <%= sessions_class_name %>ControllerTest < ActionController::TestCase | |
| 22 35 | 
             
                  assert_redirected_to root_url
         | 
| 23 36 | 
             
                  assert_equal <%= user_class_name %>.first.id, session['<%= user_singular_name %>_id']
         | 
| 24 37 | 
             
                end
         | 
| 38 | 
            +
              <%- end -%>
         | 
| 25 39 | 
             
              end
         | 
| 26 40 | 
             
            end
         | 
| @@ -1,6 +1,7 @@ | |
| 1 1 | 
             
            require 'test_helper'
         | 
| 2 2 |  | 
| 3 3 | 
             
            class <%= user_class_name %>Test < ActiveSupport::TestCase
         | 
| 4 | 
            +
            <%- unless options[:authlogic] -%>
         | 
| 4 5 | 
             
              def new_<%= user_singular_name %>(attributes = {})
         | 
| 5 6 | 
             
                attributes[:username] ||= 'foo'
         | 
| 6 7 | 
             
                attributes[:email] ||= 'foo@example.com'
         | 
| @@ -80,4 +81,5 @@ class <%= user_class_name %>Test < ActiveSupport::TestCase | |
| 80 81 | 
             
                new_<%= user_singular_name %>(:username => 'foobar', :password => 'secret').save!
         | 
| 81 82 | 
             
                assert_nil <%= user_class_name %>.authenticate('foobar', 'badpassword')
         | 
| 82 83 | 
             
              end
         | 
| 84 | 
            +
            <%- end -%>
         | 
| 83 85 | 
             
            end
         | 
| @@ -19,7 +19,9 @@ class <%= user_plural_class_name %>ControllerTest < ActionController::TestCase | |
| 19 19 | 
             
                  <%= user_class_name %>.any_instance.stubs(:valid?).returns(true)
         | 
| 20 20 | 
             
                  post :create
         | 
| 21 21 | 
             
                  assert_redirected_to root_url
         | 
| 22 | 
            +
                <%- unless options[:authlogic] -%>
         | 
| 22 23 | 
             
                  assert_equal assigns['<%= user_singular_name %>'].id, session['<%= user_singular_name %>_id']
         | 
| 24 | 
            +
                <%- end -%>
         | 
| 23 25 | 
             
                end
         | 
| 24 26 | 
             
              end
         | 
| 25 27 | 
             
            end
         | 
| @@ -1,11 +1,24 @@ | |
| 1 1 | 
             
            require 'test_helper'
         | 
| 2 2 |  | 
| 3 | 
            -
            class <%=  | 
| 3 | 
            +
            class <%= session_plural_class_name %>ControllerTest < ActionController::TestCase
         | 
| 4 4 | 
             
              def test_new
         | 
| 5 5 | 
             
                get :new
         | 
| 6 6 | 
             
                assert_template 'new'
         | 
| 7 7 | 
             
              end
         | 
| 8 8 |  | 
| 9 | 
            +
            <%- if options[:authlogic] -%>
         | 
| 10 | 
            +
              def test_create_invalid
         | 
| 11 | 
            +
                post :create, :<%= session_singular_name %> => { :username => "foo", :password => "badpassword" }
         | 
| 12 | 
            +
                assert_template 'new'
         | 
| 13 | 
            +
                assert_nil <%= session_class_name %>.find
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
              
         | 
| 16 | 
            +
              def test_create_valid
         | 
| 17 | 
            +
                post :create, :<%= session_singular_name %> => { :username => "foo", :password => "secret" }
         | 
| 18 | 
            +
                assert_redirected_to root_url
         | 
| 19 | 
            +
                assert_equal <%= user_plural_name %>(:foo), <%= session_class_name %>.find.<%= user_singular_name %>
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
            <%- else -%>
         | 
| 9 22 | 
             
              def test_create_invalid
         | 
| 10 23 | 
             
                <%= user_class_name %>.stubs(:authenticate).returns(nil)
         | 
| 11 24 | 
             
                post :create
         | 
| @@ -19,4 +32,5 @@ class <%= sessions_class_name %>ControllerTest < ActionController::TestCase | |
| 19 32 | 
             
                assert_redirected_to root_url
         | 
| 20 33 | 
             
                assert_equal <%= user_class_name %>.first.id, session['<%= user_singular_name %>_id']
         | 
| 21 34 | 
             
              end
         | 
| 35 | 
            +
            <%- end -%>
         | 
| 22 36 | 
             
            end
         | 
| @@ -1,6 +1,7 @@ | |
| 1 1 | 
             
            require 'test_helper'
         | 
| 2 2 |  | 
| 3 3 | 
             
            class <%= user_class_name %>Test < ActiveSupport::TestCase
         | 
| 4 | 
            +
            <%- unless options[:authlogic] -%>
         | 
| 4 5 | 
             
              def new_<%= user_singular_name %>(attributes = {})
         | 
| 5 6 | 
             
                attributes[:username] ||= 'foo'
         | 
| 6 7 | 
             
                attributes[:email] ||= 'foo@example.com'
         | 
| @@ -83,4 +84,5 @@ class <%= user_class_name %>Test < ActiveSupport::TestCase | |
| 83 84 | 
             
                new_<%= user_singular_name %>(:username => 'foobar', :password => 'secret').save!
         | 
| 84 85 | 
             
                assert_nil <%= user_class_name %>.authenticate('foobar', 'badpassword')
         | 
| 85 86 | 
             
              end
         | 
| 87 | 
            +
            <%- end -%>
         | 
| 86 88 | 
             
            end
         | 
| @@ -16,6 +16,8 @@ class <%= user_plural_class_name %>ControllerTest < ActionController::TestCase | |
| 16 16 | 
             
                <%= user_class_name %>.any_instance.stubs(:valid?).returns(true)
         | 
| 17 17 | 
             
                post :create
         | 
| 18 18 | 
             
                assert_redirected_to root_url
         | 
| 19 | 
            +
              <%- unless options[:authlogic] -%>
         | 
| 19 20 | 
             
                assert_equal assigns['<%= user_singular_name %>'].id, session['<%= user_singular_name %>_id']
         | 
| 21 | 
            +
              <%- end -%>
         | 
| 20 22 | 
             
              end
         | 
| 21 23 | 
             
            end
         | 
| @@ -1,4 +1,7 @@ | |
| 1 1 | 
             
            class <%= user_class_name %> < ActiveRecord::Base
         | 
| 2 | 
            +
            <%- if options[:authlogic] -%>
         | 
| 3 | 
            +
              acts_as_authentic
         | 
| 4 | 
            +
            <%- else -%>
         | 
| 2 5 | 
             
              # new columns need to be added here to be writable through mass assignment
         | 
| 3 6 | 
             
              attr_accessible :username, :email, :password, :password_confirmation
         | 
| 4 7 |  | 
| @@ -35,4 +38,5 @@ class <%= user_class_name %> < ActiveRecord::Base | |
| 35 38 | 
             
              def encrypt_password(pass)
         | 
| 36 39 | 
             
                Digest::SHA1.hexdigest([pass, password_salt].join)
         | 
| 37 40 | 
             
              end
         | 
| 41 | 
            +
            <%- end -%>
         | 
| 38 42 | 
             
            end
         | 
| @@ -6,7 +6,9 @@ class <%= user_plural_class_name %>Controller < ApplicationController | |
| 6 6 | 
             
              def create
         | 
| 7 7 | 
             
                @<%= user_singular_name %> = <%= user_class_name %>.new(params[:<%= user_singular_name %>])
         | 
| 8 8 | 
             
                if @<%= user_singular_name %>.save
         | 
| 9 | 
            +
                <%- unless options[:authlogic] -%>
         | 
| 9 10 | 
             
                  session[:<%= user_singular_name %>_id] = @<%= user_singular_name %>.id
         | 
| 11 | 
            +
                <%- end -%>
         | 
| 10 12 | 
             
                  flash[:notice] = "Thank you for signing up! You are now logged in."
         | 
| 11 13 | 
             
                  redirect_to root_url
         | 
| 12 14 | 
             
                else
         | 
| @@ -2,7 +2,21 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            <p>Don't have an account? <%%= link_to "Sign up!", signup_path %></p>
         | 
| 4 4 |  | 
| 5 | 
            -
             | 
| 5 | 
            +
            <%- if options[:authlogic] -%>
         | 
| 6 | 
            +
            <%% form_for @<%= session_singular_name %> do |f| %>
         | 
| 7 | 
            +
              <%%= f.error_messages %>
         | 
| 8 | 
            +
              <p>
         | 
| 9 | 
            +
                <%%= f.label :username %><br />
         | 
| 10 | 
            +
                <%%= f.text_field :username %>
         | 
| 11 | 
            +
              </p>
         | 
| 12 | 
            +
              <p>
         | 
| 13 | 
            +
                <%%= f.label :password %><br />
         | 
| 14 | 
            +
                <%%= f.password_field :password %>
         | 
| 15 | 
            +
              </p>
         | 
| 16 | 
            +
              <p><%%= f.submit "Log in" %></p>
         | 
| 17 | 
            +
            <%% end %>
         | 
| 18 | 
            +
            <%- else -%>
         | 
| 19 | 
            +
            <%% form_tag <%= session_plural_name %>_path do %>
         | 
| 6 20 | 
             
              <p>
         | 
| 7 21 | 
             
                <%%= label_tag :login, "Username or Email Address" %><br />
         | 
| 8 22 | 
             
                <%%= text_field_tag :login, params[:login] %>
         | 
| @@ -13,3 +27,4 @@ | |
| 13 27 | 
             
              </p>
         | 
| 14 28 | 
             
              <p><%%= submit_tag "Log in" %></p>
         | 
| 15 29 | 
             
            <%% end %>
         | 
| 30 | 
            +
            <%- end -%>
         | 
| @@ -2,7 +2,21 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            %p== Don't have an account? #{link_to "Sign up!", signup_path}
         | 
| 4 4 |  | 
| 5 | 
            -
             | 
| 5 | 
            +
            <%- if options[:authlogic] -%>
         | 
| 6 | 
            +
            - form_for @<%= session_singular_name %> do |f|
         | 
| 7 | 
            +
              = f.error_messages
         | 
| 8 | 
            +
              %p
         | 
| 9 | 
            +
                = f.label :username
         | 
| 10 | 
            +
                %br
         | 
| 11 | 
            +
                = f.text_field :login
         | 
| 12 | 
            +
              %p
         | 
| 13 | 
            +
                = f.label :password
         | 
| 14 | 
            +
                %br
         | 
| 15 | 
            +
                = f.password_field :password
         | 
| 16 | 
            +
              %p
         | 
| 17 | 
            +
                = f.submit "Log in"
         | 
| 18 | 
            +
            <%- else -%>
         | 
| 19 | 
            +
            - form_tag <%= session_plural_name %>_path do
         | 
| 6 20 | 
             
              %p
         | 
| 7 21 | 
             
                = label_tag :login, "Username or Email Address"
         | 
| 8 22 | 
             
                %br
         | 
| @@ -13,3 +27,4 @@ | |
| 13 27 | 
             
                = password_field_tag :password
         | 
| 14 28 | 
             
              %p
         | 
| 15 29 | 
             
                = submit_tag "Log in"
         | 
| 30 | 
            +
            <%- end -%>
         | 
| @@ -13,11 +13,10 @@ module LayoutHelper | |
| 13 13 | 
             
              end
         | 
| 14 14 |  | 
| 15 15 | 
             
              def stylesheet(*args)
         | 
| 16 | 
            -
                content_for(:head) { stylesheet_link_tag(*args | 
| 16 | 
            +
                content_for(:head) { stylesheet_link_tag(*args) }
         | 
| 17 17 | 
             
              end
         | 
| 18 18 |  | 
| 19 19 | 
             
              def javascript(*args)
         | 
| 20 | 
            -
                args = args.map { |arg| arg == :defaults ? arg : arg.to_s }
         | 
| 21 20 | 
             
                content_for(:head) { javascript_include_tag(*args) }
         | 
| 22 21 | 
             
              end
         | 
| 23 22 | 
             
            end
         | 
| @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
              def create
         | 
| 2 2 | 
             
                @<%= singular_name %> = <%= class_name %>.new(params[:<%= singular_name %>])
         | 
| 3 3 | 
             
                if @<%= singular_name %>.save
         | 
| 4 | 
            -
                  flash[:notice] = "Successfully created <%= name.humanize.downcase %>."
         | 
| 4 | 
            +
                  flash[:notice] = "Successfully created <%= name.underscore.humanize.downcase %>."
         | 
| 5 5 | 
             
                  redirect_to <%= item_path('url') %>
         | 
| 6 6 | 
             
                else
         | 
| 7 7 | 
             
                  render :action => 'new'
         | 
| @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
              def destroy
         | 
| 2 2 | 
             
                @<%= singular_name %> = <%= class_name %>.find(params[:id])
         | 
| 3 3 | 
             
                @<%= singular_name %>.destroy
         | 
| 4 | 
            -
                flash[:notice] = "Successfully destroyed <%= name.humanize.downcase %>."
         | 
| 4 | 
            +
                flash[:notice] = "Successfully destroyed <%= name.underscore.humanize.downcase %>."
         | 
| 5 5 | 
             
                redirect_to <%= items_path('url') %>
         | 
| 6 6 | 
             
              end
         | 
| @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
              def update
         | 
| 2 2 | 
             
                @<%= singular_name %> = <%= class_name %>.find(params[:id])
         | 
| 3 3 | 
             
                if @<%= singular_name %>.update_attributes(params[:<%= singular_name %>])
         | 
| 4 | 
            -
                  flash[:notice] = "Successfully updated <%= name.humanize.downcase %>."
         | 
| 4 | 
            +
                  flash[:notice] = "Successfully updated <%= name.underscore.humanize.downcase %>."
         | 
| 5 5 | 
             
                  redirect_to <%= item_path('url') %>
         | 
| 6 6 | 
             
                else
         | 
| 7 7 | 
             
                  render :action => 'edit'
         | 
| @@ -73,7 +73,7 @@ class TestNiftyAuthenticationGenerator < Test::Unit::TestCase | |
| 73 73 | 
             
                end
         | 
| 74 74 |  | 
| 75 75 | 
             
                context "generator with user and session names" do
         | 
| 76 | 
            -
                  rails_generator :nifty_authentication, "Account", " | 
| 76 | 
            +
                  rails_generator :nifty_authentication, "Account", "CurrentSession"
         | 
| 77 77 | 
             
                  should_generate_file 'app/models/account.rb'
         | 
| 78 78 | 
             
                  should_generate_file 'app/controllers/accounts_controller.rb'
         | 
| 79 79 | 
             
                  should_generate_file 'app/helpers/accounts_helper.rb'
         | 
| @@ -156,5 +156,81 @@ class TestNiftyAuthenticationGenerator < Test::Unit::TestCase | |
| 156 156 | 
             
                  should_generate_file "app/views/users/new.html.haml"
         | 
| 157 157 | 
             
                  should_generate_file "app/views/sessions/new.html.haml"
         | 
| 158 158 | 
             
                end
         | 
| 159 | 
            +
             | 
| 160 | 
            +
                context "generator with authlogic option and custom names" do
         | 
| 161 | 
            +
                  rails_generator :nifty_authentication, "Account", :authlogic => true
         | 
| 162 | 
            +
                  should_generate_file 'app/models/account.rb'
         | 
| 163 | 
            +
                  should_generate_file 'app/controllers/accounts_controller.rb'
         | 
| 164 | 
            +
                  should_generate_file 'app/helpers/accounts_helper.rb'
         | 
| 165 | 
            +
                  should_generate_file 'app/views/accounts/new.html.erb'
         | 
| 166 | 
            +
                  should_generate_file 'app/controllers/account_sessions_controller.rb'
         | 
| 167 | 
            +
                  should_generate_file 'app/helpers/account_sessions_helper.rb'
         | 
| 168 | 
            +
                  should_generate_file 'app/views/account_sessions/new.html.erb'
         | 
| 169 | 
            +
                  should_generate_file 'test/fixtures/accounts.yml'
         | 
| 170 | 
            +
                  should_generate_file 'test/unit/account_test.rb'
         | 
| 171 | 
            +
                  should_generate_file 'test/functional/accounts_controller_test.rb'
         | 
| 172 | 
            +
                  should_generate_file 'test/functional/account_sessions_controller_test.rb'
         | 
| 173 | 
            +
                  should_generate_file 'lib/authentication.rb'
         | 
| 174 | 
            +
                  
         | 
| 175 | 
            +
                  should "only include acts_as_authentic in account model" do
         | 
| 176 | 
            +
                    assert_generated_file "app/models/account.rb" do |body|
         | 
| 177 | 
            +
                      assert_match "acts_as_authentic", body
         | 
| 178 | 
            +
                      assert_no_match(/validates/, body)
         | 
| 179 | 
            +
                      assert_no_match(/def/, body)
         | 
| 180 | 
            +
                    end
         | 
| 181 | 
            +
                  end
         | 
| 182 | 
            +
                  
         | 
| 183 | 
            +
                  should "should generate authentication module with current_account_session method" do
         | 
| 184 | 
            +
                    assert_generated_file "lib/authentication.rb" do |body|
         | 
| 185 | 
            +
                      assert_match "def current_account_session", body
         | 
| 186 | 
            +
                    end
         | 
| 187 | 
            +
                  end
         | 
| 188 | 
            +
                  
         | 
| 189 | 
            +
                  should "should generate AccountSession model" do
         | 
| 190 | 
            +
                    assert_generated_file "app/models/account_session.rb" do |body|
         | 
| 191 | 
            +
                      assert_match "class AccountSession < Authlogic::Session::Base", body
         | 
| 192 | 
            +
                    end
         | 
| 193 | 
            +
                  end
         | 
| 194 | 
            +
                  
         | 
| 195 | 
            +
                  should "should generate restful style actions in sessions controller" do
         | 
| 196 | 
            +
                    assert_generated_file "app/controllers/account_sessions_controller.rb" do |body|
         | 
| 197 | 
            +
                      assert_match "AccountSession.new", body
         | 
| 198 | 
            +
                    end
         | 
| 199 | 
            +
                  end
         | 
| 200 | 
            +
                  
         | 
| 201 | 
            +
                  should "should generate form for account session" do
         | 
| 202 | 
            +
                    assert_generated_file "app/views/account_sessions/new.html.erb" do |body|
         | 
| 203 | 
            +
                      assert_match "form_for @account_session", body
         | 
| 204 | 
            +
                    end
         | 
| 205 | 
            +
                  end
         | 
| 206 | 
            +
                  
         | 
| 207 | 
            +
                  should "should not include tests in account since authlogic is already tested" do
         | 
| 208 | 
            +
                    assert_generated_file "test/unit/account_test.rb" do |body|
         | 
| 209 | 
            +
                      assert_no_match(/def test/, body)
         | 
| 210 | 
            +
                    end
         | 
| 211 | 
            +
                  end
         | 
| 212 | 
            +
                  
         | 
| 213 | 
            +
                  should "should handle session controller tests differently" do
         | 
| 214 | 
            +
                    assert_generated_file "test/functional/account_sessions_controller_test.rb" do |body|
         | 
| 215 | 
            +
                      assert_match "AccountSession.find", body
         | 
| 216 | 
            +
                    end
         | 
| 217 | 
            +
                  end
         | 
| 218 | 
            +
                  
         | 
| 219 | 
            +
                  should "generate migration with authlogic columns" do
         | 
| 220 | 
            +
                    file = Dir.glob("#{RAILS_ROOT}/db/migrate/*.rb").first
         | 
| 221 | 
            +
                    assert file, "migration file doesn't exist"
         | 
| 222 | 
            +
                    assert_match(/[0-9]+_create_accounts.rb$/, file)
         | 
| 223 | 
            +
                    assert_generated_file "db/migrate/#{File.basename(file)}" do |body|
         | 
| 224 | 
            +
                      assert_match "class CreateAccounts", body
         | 
| 225 | 
            +
                      assert_match "t.string :username", body
         | 
| 226 | 
            +
                      assert_match "t.string :email", body
         | 
| 227 | 
            +
                      assert_match "t.string :crypted_password", body
         | 
| 228 | 
            +
                      assert_match "t.string :password_salt", body
         | 
| 229 | 
            +
                      assert_match "t.string :persistence_token", body
         | 
| 230 | 
            +
                      assert_match "t.timestamps", body
         | 
| 231 | 
            +
                      assert_no_match(/password_hash/, body)
         | 
| 232 | 
            +
                    end
         | 
| 233 | 
            +
                  end
         | 
| 234 | 
            +
                end
         | 
| 159 235 | 
             
              end
         | 
| 160 236 | 
             
            end
         | 
| @@ -85,9 +85,10 @@ class TestNiftyScaffoldGenerator < Test::Unit::TestCase | |
| 85 85 | 
             
                    end
         | 
| 86 86 | 
             
                  end
         | 
| 87 87 |  | 
| 88 | 
            -
                  should "generate model with class as camelcase name" do
         | 
| 88 | 
            +
                  should "generate model with class as camelcase name and add attr_accessible for attributes" do
         | 
| 89 89 | 
             
                    assert_generated_file "app/models/line_item.rb" do |body|
         | 
| 90 90 | 
             
                      assert_match "class LineItem < ActiveRecord::Base", body
         | 
| 91 | 
            +
                      assert_match "attr_accessible :name, :description", body
         | 
| 91 92 | 
             
                    end
         | 
| 92 93 | 
             
                  end
         | 
| 93 94 | 
             
                end
         | 
| @@ -120,7 +121,7 @@ class TestNiftyScaffoldGenerator < Test::Unit::TestCase | |
| 120 121 | 
             
                end
         | 
| 121 122 |  | 
| 122 123 | 
             
                context "generator with new and create actions" do
         | 
| 123 | 
            -
                  rails_generator :nifty_scaffold, " | 
| 124 | 
            +
                  rails_generator :nifty_scaffold, "LineItem", "new", "create"
         | 
| 124 125 |  | 
| 125 126 | 
             
                  should_not_generate_file "app/views/line_items/create.html.erb"
         | 
| 126 127 | 
             
                  should_not_generate_file "app/views/line_items/_form.html.erb"
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: nifty-generators
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.3.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors: 
         | 
| 7 7 | 
             
            - Ryan Bates
         | 
| @@ -9,7 +9,7 @@ autorequire: | |
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 11 |  | 
| 12 | 
            -
            date: 2009- | 
| 12 | 
            +
            date: 2009-08-15 00:00:00 -07:00
         | 
| 13 13 | 
             
            default_executable: 
         | 
| 14 14 | 
             
            dependencies: []
         | 
| 15 15 |  | 
| @@ -30,9 +30,11 @@ files: | |
| 30 30 | 
             
            - CHANGELOG
         | 
| 31 31 | 
             
            - lib/nifty_generators.rb
         | 
| 32 32 | 
             
            - LICENSE
         | 
| 33 | 
            +
            - Manifest
         | 
| 33 34 | 
             
            - rails_generators/nifty_authentication/lib/insert_commands.rb
         | 
| 34 35 | 
             
            - rails_generators/nifty_authentication/nifty_authentication_generator.rb
         | 
| 35 36 | 
             
            - rails_generators/nifty_authentication/templates/authentication.rb
         | 
| 37 | 
            +
            - rails_generators/nifty_authentication/templates/authlogic_session.rb
         | 
| 36 38 | 
             
            - rails_generators/nifty_authentication/templates/fixtures.yml
         | 
| 37 39 | 
             
            - rails_generators/nifty_authentication/templates/migration.rb
         | 
| 38 40 | 
             
            - rails_generators/nifty_authentication/templates/sessions_controller.rb
         | 
| @@ -125,12 +127,9 @@ files: | |
| 125 127 | 
             
            - test/test_nifty_layout_generator.rb
         | 
| 126 128 | 
             
            - test/test_nifty_scaffold_generator.rb
         | 
| 127 129 | 
             
            - TODO
         | 
| 128 | 
            -
            - Manifest
         | 
| 129 130 | 
             
            - nifty-generators.gemspec
         | 
| 130 131 | 
             
            has_rdoc: true
         | 
| 131 132 | 
             
            homepage: http://github.com/ryanb/nifty-generators
         | 
| 132 | 
            -
            licenses: []
         | 
| 133 | 
            -
             | 
| 134 133 | 
             
            post_install_message: 
         | 
| 135 134 | 
             
            rdoc_options: 
         | 
| 136 135 | 
             
            - --line-numbers
         | 
| @@ -156,9 +155,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 156 155 | 
             
            requirements: []
         | 
| 157 156 |  | 
| 158 157 | 
             
            rubyforge_project: niftygenerators
         | 
| 159 | 
            -
            rubygems_version: 1.3. | 
| 158 | 
            +
            rubygems_version: 1.3.1
         | 
| 160 159 | 
             
            signing_key: 
         | 
| 161 | 
            -
            specification_version:  | 
| 160 | 
            +
            specification_version: 2
         | 
| 162 161 | 
             
            summary: A collection of useful generator scripts for Rails.
         | 
| 163 162 | 
             
            test_files: 
         | 
| 164 163 | 
             
            - test/test_helper.rb
         |