noodall-devise 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/.gitignore +8 -0
  2. data/Gemfile +21 -0
  3. data/Gemfile.lock +217 -0
  4. data/MIT-LICENSE +20 -0
  5. data/README.rdoc +3 -0
  6. data/Rakefile +38 -0
  7. data/app/controllers/admin/users_controller.rb +85 -0
  8. data/app/helpers/admin/users_helper.rb +3 -0
  9. data/app/models/user.rb +21 -0
  10. data/app/views/admin/users/index.html.erb +39 -0
  11. data/app/views/admin/users/show.html.erb +37 -0
  12. data/config/locales/devise.en.yml +39 -0
  13. data/config/locales/en.yml +5 -0
  14. data/cucumber.yml +8 -0
  15. data/features/manage_users.feature +44 -0
  16. data/features/step_definitions/user_steps.rb +47 -0
  17. data/features/step_definitions/web_steps.rb +219 -0
  18. data/features/support/env.rb +49 -0
  19. data/features/support/paths.rb +19 -0
  20. data/lib/noodall-devise.rb +2 -0
  21. data/lib/noodall/devise/engine.rb +9 -0
  22. data/lib/noodall/devise/version.rb +5 -0
  23. data/noodall-devise.gemspec +24 -0
  24. data/spec/dummy/Rakefile +7 -0
  25. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  26. data/spec/dummy/app/controllers/home_controller.rb +4 -0
  27. data/spec/dummy/app/helpers/application_helper.rb +3 -0
  28. data/spec/dummy/app/views/home/index.html.erb +1 -0
  29. data/spec/dummy/app/views/layouts/application.html.erb +15 -0
  30. data/spec/dummy/config.ru +4 -0
  31. data/spec/dummy/config/application.rb +44 -0
  32. data/spec/dummy/config/boot.rb +10 -0
  33. data/spec/dummy/config/database.yml +15 -0
  34. data/spec/dummy/config/environment.rb +5 -0
  35. data/spec/dummy/config/environments/development.rb +26 -0
  36. data/spec/dummy/config/environments/production.rb +49 -0
  37. data/spec/dummy/config/environments/test.rb +35 -0
  38. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  39. data/spec/dummy/config/initializers/devise.rb +142 -0
  40. data/spec/dummy/config/initializers/inflections.rb +10 -0
  41. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  42. data/spec/dummy/config/initializers/mongo_mapper.rb +13 -0
  43. data/spec/dummy/config/initializers/noodall.rb +2 -0
  44. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  45. data/spec/dummy/config/initializers/session_store.rb +8 -0
  46. data/spec/dummy/config/locales/en.yml +5 -0
  47. data/spec/dummy/config/routes.rb +9 -0
  48. data/spec/dummy/public/404.html +26 -0
  49. data/spec/dummy/public/422.html +26 -0
  50. data/spec/dummy/public/500.html +26 -0
  51. data/spec/dummy/public/favicon.ico +0 -0
  52. data/spec/dummy/script/rails +6 -0
  53. data/spec/factories/user.rb +14 -0
  54. data/spec/integration/navigation_spec.rb +9 -0
  55. data/spec/noodall_devise_spec.rb +7 -0
  56. data/spec/spec_helper.rb +30 -0
  57. metadata +173 -0
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ pkg/*
2
+ *.gem
3
+ log/*.log
4
+ .bundle
5
+ spec/dummy/db/*.sqlite3
6
+ spec/dummy/log/*.log
7
+ spec/dummy/tmp/
8
+ rerun.txt
data/Gemfile ADDED
@@ -0,0 +1,21 @@
1
+ source :rubygems
2
+
3
+ gemspec
4
+
5
+ gem "rails", "3.0.1"
6
+ gem 'noodall-ui', :path => "~/Gems/noodall-ui"
7
+ gem "capybara", ">= 0.3.9"
8
+ gem "rspec-rails", ">= 2.0.0.beta"
9
+ gem 'database_cleaner'
10
+ gem 'cucumber-rails'
11
+ gem 'launchy' # So you can do Then show me the page
12
+ gem 'rmagick', :require => 'RMagick'
13
+ gem 'dragonfly', '~> 0.7.6'
14
+ gem 'factory_girl', '~> 1.3.2'
15
+ gem "faker", "~> 0.3.1"
16
+
17
+
18
+ if RUBY_VERSION < '1.9'
19
+ gem "ruby-debug", ">= 0.10.3"
20
+ end
21
+
data/Gemfile.lock ADDED
@@ -0,0 +1,217 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ noodall-devise (0.0.1)
5
+ devise (~> 1.1.3)
6
+ mm-devise (~> 1.1.6)
7
+
8
+ PATH
9
+ remote: /Users/steve/Gems/noodall-ui
10
+ specs:
11
+ noodall-ui (0.0.2)
12
+ dynamic_form
13
+ noodall-core
14
+ thoughtbot-sortable_table (= 0.0.6)
15
+ will_paginate (~> 3.0.pre2)
16
+
17
+ GEM
18
+ remote: http://rubygems.org/
19
+ specs:
20
+ abstract (1.0.0)
21
+ actionmailer (3.0.1)
22
+ actionpack (= 3.0.1)
23
+ mail (~> 2.2.5)
24
+ actionpack (3.0.1)
25
+ activemodel (= 3.0.1)
26
+ activesupport (= 3.0.1)
27
+ builder (~> 2.1.2)
28
+ erubis (~> 2.6.6)
29
+ i18n (~> 0.4.1)
30
+ rack (~> 1.2.1)
31
+ rack-mount (~> 0.6.12)
32
+ rack-test (~> 0.5.4)
33
+ tzinfo (~> 0.3.23)
34
+ activemodel (3.0.1)
35
+ activesupport (= 3.0.1)
36
+ builder (~> 2.1.2)
37
+ i18n (~> 0.4.1)
38
+ activerecord (3.0.1)
39
+ activemodel (= 3.0.1)
40
+ activesupport (= 3.0.1)
41
+ arel (~> 1.0.0)
42
+ tzinfo (~> 0.3.23)
43
+ activeresource (3.0.1)
44
+ activemodel (= 3.0.1)
45
+ activesupport (= 3.0.1)
46
+ activesupport (3.0.1)
47
+ arel (1.0.1)
48
+ activesupport (~> 3.0.0)
49
+ bcrypt-ruby (2.1.2)
50
+ bson (1.1.1)
51
+ bson_ext (1.0.9)
52
+ builder (2.1.2)
53
+ canable (0.1.1)
54
+ capybara (0.4.0)
55
+ celerity (>= 0.7.9)
56
+ culerity (>= 0.2.4)
57
+ mime-types (>= 1.16)
58
+ nokogiri (>= 1.3.3)
59
+ rack (>= 1.0.0)
60
+ rack-test (>= 0.5.4)
61
+ selenium-webdriver (>= 0.0.27)
62
+ xpath (~> 0.1.2)
63
+ celerity (0.8.2)
64
+ childprocess (0.1.3)
65
+ ffi (~> 0.6.3)
66
+ columnize (0.3.1)
67
+ configuration (1.1.0)
68
+ cucumber (0.9.3)
69
+ builder (~> 2.1.2)
70
+ diff-lcs (~> 1.1.2)
71
+ gherkin (~> 2.2.9)
72
+ json (~> 1.4.6)
73
+ term-ansicolor (~> 1.0.5)
74
+ cucumber-rails (0.3.2)
75
+ cucumber (>= 0.8.0)
76
+ culerity (0.2.12)
77
+ database_cleaner (0.6.0)
78
+ devise (1.1.3)
79
+ bcrypt-ruby (~> 2.1.2)
80
+ warden (~> 0.10.7)
81
+ diff-lcs (1.1.2)
82
+ dragonfly (0.7.6)
83
+ rack
84
+ dynamic_form (1.1.3)
85
+ erubis (2.6.6)
86
+ abstract (>= 1.0.0)
87
+ factory_girl (1.3.2)
88
+ faker (0.3.1)
89
+ ffi (0.6.3)
90
+ rake (>= 0.8.7)
91
+ gherkin (2.2.9)
92
+ json (~> 1.4.6)
93
+ term-ansicolor (~> 1.0.5)
94
+ i18n (0.4.2)
95
+ jnunemaker-validatable (1.8.4)
96
+ activesupport (>= 2.3.4)
97
+ json (1.4.6)
98
+ json_pure (1.4.6)
99
+ launchy (0.3.7)
100
+ configuration (>= 0.0.5)
101
+ rake (>= 0.8.1)
102
+ linecache (0.43)
103
+ mail (2.2.9)
104
+ activesupport (>= 2.3.6)
105
+ i18n (~> 0.4.1)
106
+ mime-types (~> 1.16)
107
+ treetop (~> 1.4.8)
108
+ mime-types (1.16)
109
+ mm-devise (1.1.6)
110
+ bcrypt-ruby (~> 2.1.2)
111
+ bson_ext (~> 1.0.4)
112
+ devise (>= 1.1.1)
113
+ jnunemaker-validatable (~> 1.8.1)
114
+ mongo_mapper (~> 0.8.4)
115
+ rails3-generators (>= 0.13.0)
116
+ sugar-high (~> 0.2.10)
117
+ warden (>= 0.10.7)
118
+ mocha (0.9.9)
119
+ rake
120
+ mongo (1.1.1)
121
+ bson (>= 1.1.1)
122
+ mongo_mapper (0.8.4)
123
+ activesupport (>= 2.3.4)
124
+ jnunemaker-validatable (~> 1.8.4)
125
+ plucky (~> 0.3.5)
126
+ nokogiri (1.4.3.1)
127
+ noodall-core (0.1.0)
128
+ canable (= 0.1.1)
129
+ mongo_mapper (= 0.8.4)
130
+ ramdiv-mongo_mapper_acts_as_tree (= 0.1.1)
131
+ ruby-stemmer
132
+ plucky (0.3.6)
133
+ mongo (~> 1.1)
134
+ polyglot (0.3.1)
135
+ rack (1.2.1)
136
+ rack-mount (0.6.13)
137
+ rack (>= 1.0.0)
138
+ rack-test (0.5.6)
139
+ rack (>= 1.0)
140
+ rails (3.0.1)
141
+ actionmailer (= 3.0.1)
142
+ actionpack (= 3.0.1)
143
+ activerecord (= 3.0.1)
144
+ activeresource (= 3.0.1)
145
+ activesupport (= 3.0.1)
146
+ bundler (~> 1.0.0)
147
+ railties (= 3.0.1)
148
+ rails3-generators (0.14.0)
149
+ railties (3.0.1)
150
+ actionpack (= 3.0.1)
151
+ activesupport (= 3.0.1)
152
+ rake (>= 0.8.4)
153
+ thor (~> 0.14.0)
154
+ rake (0.8.7)
155
+ ramdiv-mongo_mapper_acts_as_tree (0.1.1)
156
+ mongo_mapper (>= 0.6.8)
157
+ require_all (1.2.0)
158
+ rmagick (2.13.1)
159
+ rspec (2.0.1)
160
+ rspec-core (~> 2.0.1)
161
+ rspec-expectations (~> 2.0.1)
162
+ rspec-mocks (~> 2.0.1)
163
+ rspec-core (2.0.1)
164
+ rspec-expectations (2.0.1)
165
+ diff-lcs (>= 1.1.2)
166
+ rspec-mocks (2.0.1)
167
+ rspec-core (~> 2.0.1)
168
+ rspec-expectations (~> 2.0.1)
169
+ rspec-rails (2.0.1)
170
+ rspec (~> 2.0.0)
171
+ ruby-debug (0.10.3)
172
+ columnize (>= 0.1)
173
+ ruby-debug-base (~> 0.10.3.0)
174
+ ruby-debug-base (0.10.3)
175
+ linecache (>= 0.3)
176
+ ruby-stemmer (0.8.2)
177
+ rubyzip (0.9.4)
178
+ selenium-webdriver (0.0.29)
179
+ childprocess (>= 0.0.7)
180
+ ffi (~> 0.6.3)
181
+ json_pure
182
+ rubyzip
183
+ sugar-high (0.2.12)
184
+ mocha (~> 0.9.8)
185
+ require_all (~> 1.2.0)
186
+ term-ansicolor (1.0.5)
187
+ thor (0.14.3)
188
+ thoughtbot-sortable_table (0.0.6)
189
+ treetop (1.4.8)
190
+ polyglot (>= 0.3.1)
191
+ tzinfo (0.3.23)
192
+ warden (0.10.7)
193
+ rack (>= 1.0.0)
194
+ will_paginate (3.0.pre2)
195
+ xpath (0.1.2)
196
+ nokogiri (~> 1.3)
197
+
198
+ PLATFORMS
199
+ ruby
200
+
201
+ DEPENDENCIES
202
+ bundler (>= 1.0.0)
203
+ capybara (>= 0.3.9)
204
+ cucumber-rails
205
+ database_cleaner
206
+ devise (~> 1.1.3)
207
+ dragonfly (~> 0.7.6)
208
+ factory_girl (~> 1.3.2)
209
+ faker (~> 0.3.1)
210
+ launchy
211
+ mm-devise (~> 1.1.6)
212
+ noodall-devise!
213
+ noodall-ui!
214
+ rails (= 3.0.1)
215
+ rmagick
216
+ rspec-rails (>= 2.0.0.beta)
217
+ ruby-debug (>= 0.10.3)
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2010 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = Noodall-component-gallery
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,38 @@
1
+ # encoding: UTF-8
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ Bundler::GemHelper.install_tasks
8
+
9
+ require 'rspec/core'
10
+ require 'rspec/core/rake_task'
11
+
12
+ Rspec::Core::RakeTask.new(:spec)
13
+
14
+ require 'cucumber/rake/task'
15
+
16
+ namespace :cucumber do
17
+ Cucumber::Rake::Task.new(:ok, 'Run features that should pass') do |t|
18
+ t.fork = true # You may get faster startup if you set this to false
19
+ t.profile = 'default'
20
+ end
21
+
22
+ Cucumber::Rake::Task.new(:wip, 'Run features that are being worked on') do |t|
23
+ t.fork = true # You may get faster startup if you set this to false
24
+ t.profile = 'wip'
25
+ end
26
+
27
+ Cucumber::Rake::Task.new(:rerun, 'Record failing features and run only them if any exist') do |t|
28
+ t.fork = true # You may get faster startup if you set this to false
29
+ t.profile = 'rerun'
30
+ end
31
+
32
+ desc 'Run all features'
33
+ task :all => [:ok, :wip]
34
+ end
35
+ desc 'Alias for cucumber:ok'
36
+ task :cucumber => 'cucumber:ok'
37
+
38
+ task :default => :cucumber
@@ -0,0 +1,85 @@
1
+ class Admin::UsersController < Noodall::Admin::BaseController
2
+ include SortableTable::App::Controllers::ApplicationController
3
+ sortable_attributes :name, :email, :role
4
+
5
+ # GET /users
6
+ # GET /users.xml
7
+ def index
8
+ @users = User.paginate :page => params[:page], :per_page => 20, :order => sort_order(:default => 'asc')
9
+
10
+ respond_to do |format|
11
+ format.html # index.html.erb
12
+ format.xml { render :xml => @users }
13
+ end
14
+ end
15
+
16
+ # GET /users/new
17
+ # GET /users/new.xml
18
+ def new
19
+ @user = User.new
20
+ render :action => 'show'
21
+ end
22
+
23
+ # GET /users/1/edit
24
+ def show
25
+ @user = User.find(params[:id])
26
+ end
27
+
28
+ # POST /users
29
+ # POST /users.xml
30
+ def create
31
+ @user = User.new(params[:user]) do |user|
32
+ # No need for email confirmation
33
+ user.email_confirmed = true
34
+ # Because mass assignment is protected
35
+ user.role = params[:user][:role]
36
+ end
37
+ respond_to do |format|
38
+ if @user.save
39
+ flash[:notice] = 'User was successfully created.'
40
+ format.html { redirect_to(admin_users_url) }
41
+ format.xml { render :xml => @user, :status => :created, :location => @user }
42
+ else
43
+ format.html { render :action => "show" }
44
+ format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
45
+ end
46
+ end
47
+ end
48
+
49
+ # PUT /users/1
50
+ # PUT /users/1.xml
51
+ def update
52
+ @user = User.find(params[:id])
53
+
54
+ # Remove password params if blank so devise does not validate them
55
+ if params[:user][:password].blank?
56
+ params[:user].delete(:password)
57
+ params[:user].delete(:password_confirmation)
58
+ end
59
+
60
+ respond_to do |format|
61
+ if @user.update_attributes(params[:user])
62
+ flash[:notice] = 'User was successfully updated.'
63
+ format.html { redirect_to(admin_users_url) }
64
+ format.xml { head :ok }
65
+ else
66
+ format.html { render :action => "show" }
67
+ format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
68
+ end
69
+ end
70
+ end
71
+
72
+ # DELETE /users/1
73
+ # DELETE /users/1.xml
74
+ def destroy
75
+ @user = User.find(params[:id])
76
+ @user.destroy
77
+ flash[:notice] = 'User was successfully deleted.'
78
+
79
+ respond_to do |format|
80
+ format.html { redirect_to(admin_users_url) }
81
+ format.xml { head :ok }
82
+ end
83
+ end
84
+
85
+ end
@@ -0,0 +1,3 @@
1
+ module Admin::UsersHelper
2
+ include SortableTable::App::Helpers::ApplicationHelper
3
+ end
@@ -0,0 +1,21 @@
1
+ class User
2
+ include MongoMapper::Document
3
+ # Include default devise modules. Others available are:
4
+ # :token_authenticatable, :confirmable, :lockable and :timeoutable
5
+ devise :database_authenticatable,
6
+ :recoverable, :rememberable, :trackable, :validatable
7
+
8
+ include Canable::Cans
9
+ key :name, String
10
+ key :groups, Array
11
+
12
+ timestamps!
13
+
14
+ def full_name
15
+ name || email
16
+ end
17
+
18
+ def admin?
19
+ groups.include?('admin')
20
+ end
21
+ end
@@ -0,0 +1,39 @@
1
+ <h1>Listing Users</h1>
2
+
3
+ <ul class="choices">
4
+ <li><%= link_to 'Create New User', new_admin_user_path %></li>
5
+ </ul>
6
+
7
+ <a class="tooltip" href="/cms_help.pdf">&nbsp;</a>
8
+ <%= will_paginate(@users, :previous_label => 'Previous', :next_label => 'Next') %>
9
+ <div id="content-table">
10
+ <table class="content">
11
+ <thead>
12
+ <tr>
13
+ <%= sortable_table_header :name => "Name", :sort => "title" %>
14
+ <%= sortable_table_header :name => "Email", :sort => "email" %>
15
+ <%= sortable_table_header :name => "Role", :sort => "role" %>
16
+ <th>Delete</th>
17
+ </tr>
18
+ </thead>
19
+ <tbody>
20
+ <% for user in @users -%>
21
+ <tr>
22
+ <td><%= link_to user.name, [:admin, user], :class => 'edit', :title => 'Edit this user' %></td>
23
+ <td><%= user.email %></td>
24
+ <td><%= user.groups %></td>
25
+ <td><%= link_to 'Delete', [:admin, user], :confirm => 'Are you sure?', :method => :delete, :class => 'delete', :title => 'Delete this user' %></td>
26
+ </tr>
27
+ <% end %>
28
+ </tbody>
29
+ <tfoot>
30
+ <tr>
31
+ <%= sortable_table_header :name => "Name", :sort => "title" %>
32
+ <%= sortable_table_header :name => "Email", :sort => "email" %>
33
+ <%= sortable_table_header :name => "Role", :sort => "role" %>
34
+ <th>Delete</th>
35
+ </tr>
36
+ </tfoot>
37
+ </table>
38
+
39
+ <%= will_paginate(@users, :previous_label => 'Previous', :next_label => 'Next') %>