Permalink
Browse files

added clearance_views generator. by default, creates formtastic views…

… which pass all tests and features.
  • Loading branch information...
1 parent 73a4612 commit cd85f72e21542adc11c6abd189aaf3e79538b3cd @croaky croaky committed Aug 4, 2009
Showing with 5,017 additions and 12 deletions.
  1. +1 −0 .gitignore
  2. +7 −0 CHANGELOG.textile
  3. +36 −9 Rakefile
  4. +3 −3 generators/clearance_features/clearance_features_generator.rb
  5. 0 generators/clearance_views/USAGE
  6. +27 −0 generators/clearance_views/clearance_views_generator.rb
  7. +21 −0 generators/clearance_views/templates/formtastic/passwords/edit.html.erb
  8. +15 −0 generators/clearance_views/templates/formtastic/passwords/new.html.erb
  9. +22 −0 generators/clearance_views/templates/formtastic/sessions/new.html.erb
  10. +6 −0 generators/clearance_views/templates/formtastic/users/_inputs.html.erb
  11. +10 −0 generators/clearance_views/templates/formtastic/users/new.html.erb
  12. +3 −0 test/rails_root/config/environment.rb
  13. +67 −0 test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/.specification
  14. +20 −0 test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/MIT-LICENSE
  15. +383 −0 test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/README.textile
  16. +58 −0 test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/Rakefile
  17. +21 −0 ...stinfrench-formtastic-0.2.1/generators/formtastic_stylesheets/formtastic_stylesheets_generator.rb
  18. +136 −0 ...dor/gems/justinfrench-formtastic-0.2.1/generators/formtastic_stylesheets/templates/formtastic.css
  19. +10 −0 .../justinfrench-formtastic-0.2.1/generators/formtastic_stylesheets/templates/formtastic_changes.css
  20. +1,236 −0 test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/lib/formtastic.rb
  21. +10 −0 test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/lib/justin_french/formtastic.rb
  22. +8 −0 test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/lib/locale/en.yml
  23. +3 −0 test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/rails/init.rb
  24. +2,900 −0 test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/spec/formtastic_spec.rb
  25. +14 −0 test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/spec/test_helper.rb
View
@@ -3,4 +3,5 @@ test/rails_root/log/*.log
*.swp
.rake_tasks
test/rails_root/*
+!test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1
*.gem
View
@@ -1,3 +1,10 @@
+h2. 0.7.0 (08/04/2009)
+
+* Redirect signed in user who clicks confirmation link again. (Dan Croak)
+* Redirect signed out user who clicks confirmation link again. (Dan Croak)
+* Added signed_out? convenience method for controllers, helpers, views. (Dan
+Croak)
+
h2. 0.6.9 (07/04/2009)
* Added timestamps to create users migration. (Dan Croak)
View
@@ -5,8 +5,16 @@ require 'rake/testtask'
require 'cucumber/rake/task'
namespace :test do
- Rake::TestTask.new(:all => ["generator:cleanup",
- "generator:generate"]) do |task|
+ Rake::TestTask.new(:basic => ["generator:cleanup",
+ "generator:clearance",
+ "generator:clearance_features"]) do |task|
+ task.libs << "lib"
+ task.libs << "test"
+ task.pattern = "test/**/*_test.rb"
+ task.verbose = false
+ end
+
+ Rake::TestTask.new(:views => ["generator:clearance_views"]) do |task|
task.libs << "lib"
task.libs << "test"
task.pattern = "test/**/*_test.rb"
@@ -17,9 +25,14 @@ namespace :test do
t.cucumber_opts = "--format progress"
t.feature_pattern = "test/rails_root/features/*.feature"
end
+
+ Cucumber::Rake::Task.new(:features_for_views) do |t|
+ t.cucumber_opts = "--format progress"
+ t.feature_pattern = "test/rails_root/features/*.feature"
+ end
end
-generators = %w(clearance clearance_features)
+generators = %w(clearance clearance_features clearance_views)
namespace :generator do
desc "Cleans up the test app before running the generator"
@@ -34,22 +47,36 @@ namespace :generator do
FileList["test/rails_root/db/**/*"].each do |each|
FileUtils.rm_rf(each)
end
+
FileUtils.rm_rf("test/rails_root/vendor/plugins/clearance")
FileUtils.mkdir_p("test/rails_root/vendor/plugins")
clearance_root = File.expand_path(File.dirname(__FILE__))
system("ln -s #{clearance_root} test/rails_root/vendor/plugins/clearance")
+
+ FileUtils.rm_rf("test/rails_root/app/views/passwords")
+ FileUtils.rm_rf("test/rails_root/app/views/sessions")
+ FileUtils.rm_rf("test/rails_root/app/views/users")
end
- desc "Run the generator on the tests"
- task :generate do
- generators.each do |generator|
- system "cd test/rails_root && ./script/generate #{generator} && rake db:migrate db:test:prepare"
- end
+ desc "Run the clearance generator"
+ task :clearance do
+ system "cd test/rails_root && ./script/generate clearance && rake db:migrate db:test:prepare"
+ end
+
+ desc "Run the clearance features generator"
+ task :clearance_features do
+ system "cd test/rails_root && ./script/generate clearance_features"
+ end
+
+ desc "Run the clearance views generator"
+ task :clearance_views do
+ system "cd test/rails_root && ./script/generate clearance_views"
end
end
desc "Run the test suite"
-task :default => ['test:all', 'test:features']
+task :default => ['test:basic', 'test:features',
+ 'test:views', 'test:features_for_views']
gem_spec = Gem::Specification.new do |gem_spec|
gem_spec.name = "clearance"
@@ -1,10 +1,10 @@
class ClearanceFeaturesGenerator < Rails::Generator::Base
-
+
def manifest
record do |m|
m.directory File.join("features", "step_definitions")
m.directory File.join("features", "support")
-
+
["features/step_definitions/clearance_steps.rb",
"features/step_definitions/factory_girl_steps.rb",
"features/support/paths.rb",
@@ -16,5 +16,5 @@ def manifest
end
end
end
-
+
end
No changes.
@@ -0,0 +1,27 @@
+class ClearanceViewsGenerator < Rails::Generator::Base
+
+ def manifest
+ record do |m|
+ strategy = "formtastic"
+ template_strategy = "erb"
+
+ m.directory File.join("app", "views", "users")
+ m.file "#{strategy}/users/new.html.#{template_strategy}",
+ "app/views/users/new.html.#{template_strategy}"
+ m.file "#{strategy}/users/_inputs.html.#{template_strategy}",
+ "app/views/users/_inputs.html.#{template_strategy}"
+
+ m.directory File.join("app", "views", "sessions")
+ m.file "#{strategy}/sessions/new.html.#{template_strategy}",
+ "app/views/sessions/new.html.#{template_strategy}"
+
+ m.directory File.join("app", "views", "passwords")
+ m.file "#{strategy}/passwords/new.html.#{template_strategy}",
+ "app/views/passwords/new.html.#{template_strategy}"
+ m.file "#{strategy}/passwords/edit.html.#{template_strategy}",
+ "app/views/passwords/edit.html.#{template_strategy}"
+ end
+ end
+
+end
+
@@ -0,0 +1,21 @@
+<h2>Change your password</h2>
+
+<p>
+ Your password has been reset. Choose a new password below.
+</p>
+
+<% semantic_form_for(:user,
+ :url => user_password_path(@user, :token => @user.token),
+ :html => { :method => :put }) do |form| %>
+ <%= form.error_messages %>
+ <% form.inputs do -%>
+ <%= form.input :password, :as => :password,
+ :label => "Choose password" %>
+ <%= form.input :password_confirmation, :as => :password,
+ :label => "Confirm password" %>
+ <% end -%>
+ <% form.buttons do -%>
+ <%= form.commit_button "Save this password" %>
+ <% end -%>
+<% end %>
+
@@ -0,0 +1,15 @@
+<h2>Reset your password</h2>
+
+<p>
+ We will email you a link to reset your password.
+</p>
+
+<% semantic_form_for :password, :url => passwords_path do |form| -%>
+ <% form.inputs do -%>
+ <%= form.input :email, :label => "Email address" %>
+ <% end -%>
+ <% form.buttons do -%>
+ <%= form.commit_button "Reset password" %>
+ <% end -%>
+<% end -%>
+
@@ -0,0 +1,22 @@
+<h2>Sign in</h2>
+
+<% semantic_form_for :session, :url => session_path do |form| %>
+ <% form.inputs do %>
+ <%= form.input :email %>
+ <%= form.input :password, :as => :password %>
+ <%= form.input :remember_me, :as => :boolean, :required => false %>
+ <% end %>
+ <% form.buttons do %>
+ <%= form.commit_button "Sign in" %>
+ <% end %>
+<% end %>
+
+<ul>
+ <li>
+ <%= link_to "Sign up", new_user_path %>
+ </li>
+ <li>
+ <%= link_to "Forgot password?", new_password_path %>
+ </li>
+</ul>
+
@@ -0,0 +1,6 @@
+<% form.inputs do %>
+ <%= form.input :email %>
+ <%= form.input :password %>
+ <%= form.input :password_confirmation, :label => "Confirm password" %>
+<% end %>
+
@@ -0,0 +1,10 @@
+<h2>Sign up</h2>
+
+<% semantic_form_for @user do |form| %>
+ <%= form.error_messages %>
+ <%= render :partial => "/users/inputs", :locals => { :form => form } %>
+ <% form.buttons do %>
+ <%= form.commit_button "Sign up" %>
+ <% end %>
+<% end %>
+
@@ -8,6 +8,9 @@
:session_key => "_clearance_session",
:secret => ['clearance', 'random', 'words', 'here'].map {|k| Digest::MD5.hexdigest(k) }.join
}
+ config.gem "justinfrench-formtastic",
+ :lib => 'formtastic',
+ :source => 'http://gems.github.com'
end
DO_NOT_REPLY = "donotreply@example.com"
@@ -0,0 +1,67 @@
+--- !ruby/object:Gem::Specification
+name: justinfrench-formtastic
+version: !ruby/object:Gem::Version
+ version: 0.2.1
+platform: ruby
+authors:
+- Justin French
+autorequire: formtastic
+bindir: bin
+cert_chain: []
+
+date: 2009-06-17 00:00:00 -04:00
+default_executable:
+dependencies: []
+
+description: A Rails form builder plugin/gem with semantically rich and accessible markup
+email: justin@indent.com.au
+executables: []
+
+extensions: []
+
+extra_rdoc_files:
+- README.textile
+files:
+- MIT-LICENSE
+- README.textile
+- Rakefile
+- generators/formtastic_stylesheets/formtastic_stylesheets_generator.rb
+- generators/formtastic_stylesheets/templates/formtastic.css
+- generators/formtastic_stylesheets/templates/formtastic_changes.css
+- lib/formtastic.rb
+- lib/justin_french/formtastic.rb
+- lib/locale/en.yml
+- rails/init.rb
+- spec/formtastic_spec.rb
+- spec/test_helper.rb
+has_rdoc: true
+homepage: http://github.com/justinfrench/formtastic/tree/master
+licenses: []
+
+post_install_message:
+rdoc_options:
+- --charset=UTF-8
+require_paths:
+- lib
+required_ruby_version: !ruby/object:Gem::Requirement
+ requirements:
+ - - ">="
+ - !ruby/object:Gem::Version
+ version: "0"
+ version:
+required_rubygems_version: !ruby/object:Gem::Requirement
+ requirements:
+ - - ">="
+ - !ruby/object:Gem::Version
+ version: "0"
+ version:
+requirements: []
+
+rubyforge_project:
+rubygems_version: 1.3.4
+signing_key:
+specification_version: 3
+summary: A Rails form builder plugin/gem with semantically rich and accessible markup
+test_files:
+- spec/formtastic_spec.rb
+- spec/test_helper.rb
@@ -0,0 +1,20 @@
+Copyright (c) 2008 Justin French
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Oops, something went wrong.

0 comments on commit cd85f72

Please sign in to comment.