spud_core 0.8.13 → 0.8.15
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +62 -0
- data/Rakefile +2 -14
- data/app/assets/javascripts/spud/admin/application.js +47 -18
- data/app/controllers/spud/admin/application_controller.rb +0 -2
- data/app/controllers/spud/application_controller.rb +19 -6
- data/app/controllers/spud/password_resets_controller.rb +37 -37
- data/app/controllers/spud/setup_controller.rb +2 -6
- data/app/helpers/spud/admin/application_helper.rb +22 -23
- data/app/views/layouts/spud/admin/detail.html.erb +3 -3
- data/app/views/spud/admin/dashboard/index.html.erb +1 -1
- data/lib/spud_core/configuration.rb +1 -0
- data/lib/spud_core/engine.rb +2 -2
- data/lib/spud_core/version.rb +1 -1
- data/spec/controllers/spud/admin/application_controller_spec.rb +49 -0
- data/spec/controllers/spud/admin/dashbord_controller_spec.rb +60 -0
- data/spec/controllers/spud/admin/users_controller_spec.rb +194 -0
- data/spec/controllers/spud/application_controller_spec.rb +49 -0
- data/spec/controllers/spud/password_reset_controller_spec.rb +93 -0
- data/spec/controllers/spud/setup_controller_spec.rb +56 -0
- data/spec/controllers/spud/sitemap_controllers_spec.rb +20 -0
- data/spec/controllers/spud/user_sessions_controller_spec.rb +53 -0
- data/spec/controllers/spud/users_controller_spec.rb +69 -0
- data/{test → spec}/dummy/README.rdoc +0 -0
- data/{test → spec}/dummy/Rakefile +0 -0
- data/{test → spec}/dummy/app/assets/javascripts/application.js +0 -0
- data/{test → spec}/dummy/app/assets/stylesheets/application.css +0 -0
- data/{test → spec}/dummy/app/controllers/application_controller.rb +0 -0
- data/{test → spec}/dummy/app/helpers/application_helper.rb +0 -0
- data/{test → spec}/dummy/app/views/layouts/application.html.erb +0 -0
- data/{test → spec}/dummy/config.ru +0 -0
- data/{test → spec}/dummy/config/application.rb +2 -0
- data/{test → spec}/dummy/config/boot.rb +0 -0
- data/{test → spec}/dummy/config/database.yml +0 -0
- data/{test → spec}/dummy/config/environment.rb +0 -0
- data/{test → spec}/dummy/config/environments/development.rb +0 -0
- data/{test → spec}/dummy/config/environments/production.rb +0 -0
- data/{test → spec}/dummy/config/environments/test.rb +0 -0
- data/{test → spec}/dummy/config/initializers/backtrace_silencers.rb +0 -0
- data/{test → spec}/dummy/config/initializers/inflections.rb +0 -0
- data/{test → spec}/dummy/config/initializers/mime_types.rb +0 -0
- data/{test → spec}/dummy/config/initializers/secret_token.rb +0 -0
- data/{test → spec}/dummy/config/initializers/session_store.rb +0 -0
- data/{test → spec}/dummy/config/initializers/wrap_parameters.rb +0 -0
- data/{test → spec}/dummy/config/locales/en.yml +0 -0
- data/{test → spec}/dummy/config/routes.rb +0 -0
- data/{test → spec}/dummy/db/schema.rb +11 -1
- data/spec/dummy/log/development.log +39 -0
- data/spec/dummy/log/test.log +54295 -0
- data/{test → spec}/dummy/public/404.html +0 -0
- data/{test → spec}/dummy/public/422.html +0 -0
- data/{test → spec}/dummy/public/500.html +0 -0
- data/{test → spec}/dummy/public/favicon.ico +0 -0
- data/{test → spec}/dummy/script/rails +0 -0
- data/spec/helpers/spud/admin/application_helper_spec.rb +150 -0
- data/spec/models/spud_user_spec.rb +27 -0
- data/spec/spec_helper.rb +40 -0
- data/spec/support/authlogic_helper.rb +2 -0
- metadata +220 -114
- data/README.rdoc +0 -3
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +0 -46
- data/test/dummy/log/test.log +0 -17677
- data/test/fixtures/spud_user_settings.yml +0 -11
- data/test/functional/spud/password_resets_controller_test.rb +0 -7
- data/test/unit/helpers/spud/password_resets_helper_test.rb +0 -4
- data/test/unit/spud_user_settings_test.rb +0 -7
@@ -5,11 +5,11 @@
|
|
5
5
|
</span>
|
6
6
|
<h2>
|
7
7
|
<%if @page_thumbnail%>
|
8
|
-
<span class="thumb_wrapper"><%=image_tag(@page_thumbnail)%></span>
|
8
|
+
<span class="thumb_wrapper"><%=image_tag(@page_thumbnail,:hidpi_src => asset_path(@page_thumbnail.gsub(/\.png/,"@2x.png")))%></span>
|
9
9
|
<%end%>
|
10
10
|
<%=@page_name%>
|
11
11
|
</h2>
|
12
|
-
|
12
|
+
|
13
13
|
<div id="details">
|
14
14
|
<%if content_for?(:detail_nav)%>
|
15
15
|
<div id="detail_nav_wrapper">
|
@@ -28,4 +28,4 @@
|
|
28
28
|
</div>
|
29
29
|
</div>
|
30
30
|
<%end%>
|
31
|
-
<%= render :template => 'layouts/spud/admin/application' %>
|
31
|
+
<%= render :template => 'layouts/spud/admin/application' %>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<%@admin_applications.each do |admin_application|%>
|
4
4
|
|
5
5
|
<div class="admin_application" id="application_name_<%=admin_application[:name]%>"><a href="<%=admin_application[:url]%>">
|
6
|
-
<div class="image_wrapper"><%=image_tag(admin_application[:thumbnail],:
|
6
|
+
<div class="image_wrapper"><%=image_tag(admin_application[:thumbnail],:hidpi_src=>hidpi_asset(admin_application[:thumbnail]))%></div>
|
7
7
|
<span class="application_name"><%=admin_application[:name]%></span>
|
8
8
|
</a>
|
9
9
|
</div>
|
data/lib/spud_core/engine.rb
CHANGED
@@ -11,8 +11,8 @@ require 'will_paginate'
|
|
11
11
|
module Spud
|
12
12
|
module Core
|
13
13
|
class Engine < ::Rails::Engine
|
14
|
-
require
|
15
|
-
require
|
14
|
+
require "#{root}/lib/spud_core/belongs_to_app"
|
15
|
+
require "#{root}/lib/spud_core/searchable"
|
16
16
|
|
17
17
|
def self.require_model(model_name)
|
18
18
|
require "#{root}/app/models/#{model_name}"
|
data/lib/spud_core/version.rb
CHANGED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spud::Admin::ApplicationController do
|
4
|
+
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
activate_authlogic
|
8
|
+
@user = FactoryGirl.create(:spud_user)
|
9
|
+
@session = SpudUserSession.create(@user)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe :require_admin_user do
|
13
|
+
controller(Spud::Admin::ApplicationController) do
|
14
|
+
def index
|
15
|
+
render :nothing => true
|
16
|
+
end
|
17
|
+
end
|
18
|
+
it "should respond successfully if the current user is a super admin" do
|
19
|
+
@user.update_attribute(:super_admin, true)
|
20
|
+
get :index
|
21
|
+
|
22
|
+
response.should be_success
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should respond successfully if the current user has admin permissions" do
|
26
|
+
@user.spud_admin_permissions.create(:name => "pages", :access => true)
|
27
|
+
get :index
|
28
|
+
|
29
|
+
response.should be_success
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should redirect to the login if the current user is not logged in" do
|
33
|
+
@session.destroy
|
34
|
+
get :index
|
35
|
+
|
36
|
+
response.should redirect_to(new_spud_user_session_url)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should redirect to the root for a user without administrative priviledges" do
|
40
|
+
@user.super_admin = false
|
41
|
+
@user.spud_admin_permissions = []
|
42
|
+
@user.save
|
43
|
+
get :index
|
44
|
+
|
45
|
+
response.should redirect_to(root_url)
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spud::Admin::DashboardController do
|
4
|
+
before(:all) do
|
5
|
+
Spud::Core.configure do |config|
|
6
|
+
config.admin_applications = [
|
7
|
+
{name: "Blog", thumbnail: "/url/to/image", url: "/url/to/app", order: 0},
|
8
|
+
{name: "Settings", thumbnail: "/url/to/image", url: "/url/to/app", order: 0},
|
9
|
+
{name: "Pages", thumbnail: "/url/to/image", url: "/url/to/app", order: 0},
|
10
|
+
]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
before(:each) do
|
15
|
+
activate_authlogic
|
16
|
+
@user = FactoryGirl.create(:spud_user)
|
17
|
+
SpudUserSession.create(@user)
|
18
|
+
end
|
19
|
+
|
20
|
+
describe :index do
|
21
|
+
it "should display applications the current user has access to given that the current user is not a super admin" do
|
22
|
+
@user.super_admin = false
|
23
|
+
@user.spud_admin_permissions.build(FactoryGirl.attributes_for(:spud_admin_permission, :name => "Blog", :access => true))
|
24
|
+
@user.spud_admin_permissions.build(FactoryGirl.attributes_for(:spud_admin_permission, :name => "Pages", :access => true))
|
25
|
+
@user.save
|
26
|
+
get :index
|
27
|
+
|
28
|
+
assigns(:admin_applications).collect{|app| app[:name] }.should =~ @user.spud_admin_permissions.collect{|permission| permission.name }
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should not display applications the current user does not have access to given that the current user is not a super admin" do
|
32
|
+
@user.super_admin = false
|
33
|
+
@user.spud_admin_permissions.build(FactoryGirl.attributes_for(:spud_admin_permission, :name => "Blog", :access => true))
|
34
|
+
@user.spud_admin_permissions.build(FactoryGirl.attributes_for(:spud_admin_permission, :name => "Pages", :access => true))
|
35
|
+
@user.save
|
36
|
+
get :index
|
37
|
+
|
38
|
+
assigns(:admin_applications).collect{|app| app[:name] }.should_not include(:settings)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should display all the applications despite the users permissions given the current user is a super admin" do
|
42
|
+
@user.super_admin = true
|
43
|
+
@user.spud_admin_permissions.build(FactoryGirl.attributes_for(:spud_admin_permission, :name => "Blog", :access => true))
|
44
|
+
@user.save
|
45
|
+
get :index
|
46
|
+
|
47
|
+
assigns(:admin_applications).collect{|app| app[:name] }.should =~ Spud::Core.admin_applications.collect{|app| app[:name] }
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should display applications in order of user preference if available" do
|
51
|
+
@user.super_admin = true
|
52
|
+
@user.save
|
53
|
+
@user.spud_user_settings.create(:key => "app_order",:value => "Pages,Settings")
|
54
|
+
get :index
|
55
|
+
|
56
|
+
assigns(:admin_applications).collect{|app| app[:name] }.should =~ ["Pages","Settings","Blog"]
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,194 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spud::Admin::UsersController do
|
4
|
+
before(:each) do
|
5
|
+
activate_authlogic
|
6
|
+
@user = SpudUserSession.create(FactoryGirl.build(:spud_user, :super_admin => true))
|
7
|
+
end
|
8
|
+
|
9
|
+
describe :index do
|
10
|
+
it "should return an array of users" do
|
11
|
+
2.times {|x| FactoryGirl.create(:spud_user) }
|
12
|
+
get :index
|
13
|
+
|
14
|
+
assigns(:users).count.should be > 1
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should not return any users if there are no users" do
|
18
|
+
get :index
|
19
|
+
|
20
|
+
assigns(:users).count.should == 1 # the currently logged in user is the only user
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should not allow access to users with NO permissions" do
|
24
|
+
SpudUserSession.create(FactoryGirl.build(:spud_user, :super_admin => false))
|
25
|
+
get :index
|
26
|
+
|
27
|
+
response.should redirect_to(root_url)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should allow access to users with the correct permissions" do
|
31
|
+
u = FactoryGirl.create(:spud_user, :super_admin => false)
|
32
|
+
u.spud_admin_permissions << FactoryGirl.build(:spud_admin_permission, :name => "Users", :access => true)
|
33
|
+
SpudUserSession.create(u)
|
34
|
+
get :index
|
35
|
+
|
36
|
+
response.should be_success
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should not allow access to users without permission and redirect to root_url if the user has no permissions" do
|
40
|
+
u = FactoryGirl.create(:spud_user, :super_admin => false)
|
41
|
+
u.spud_admin_permissions << []
|
42
|
+
SpudUserSession.create(u)
|
43
|
+
get :index
|
44
|
+
|
45
|
+
response.should redirect_to(root_url)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should not allow access to users without permission and redirect to root_url if the users has no other admin modules" do
|
49
|
+
u = FactoryGirl.create(:spud_user, :super_admin => false)
|
50
|
+
u.spud_admin_permissions << [
|
51
|
+
FactoryGirl.build(:spud_admin_permission, :name => "Users", :access => false)
|
52
|
+
]
|
53
|
+
SpudUserSession.create(u)
|
54
|
+
get :index
|
55
|
+
|
56
|
+
response.should redirect_to(root_url)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should not allow access to users without permission and redirect to admin_root if the users has other admin modules" do
|
60
|
+
u = FactoryGirl.create(:spud_user, :super_admin => false)
|
61
|
+
u.spud_admin_permissions << [
|
62
|
+
FactoryGirl.build(:spud_admin_permission, :name => "Users", :access => false),
|
63
|
+
FactoryGirl.build(:spud_admin_permission, :name => "App2", :access => true)
|
64
|
+
]
|
65
|
+
SpudUserSession.create(u)
|
66
|
+
get :index
|
67
|
+
|
68
|
+
response.should redirect_to(spud_admin_root_url)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe :show do
|
73
|
+
it "should respond successfully" do
|
74
|
+
user = FactoryGirl.create(:spud_user)
|
75
|
+
get :show, :id => user.id
|
76
|
+
|
77
|
+
response.should be_success
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should show the user" do
|
81
|
+
user = FactoryGirl.create(:spud_user)
|
82
|
+
get :show, :id => user.id
|
83
|
+
|
84
|
+
assigns(:user).id.should == user.id
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe :new do
|
89
|
+
it "should respond successfully" do
|
90
|
+
get :new, :format => :js
|
91
|
+
|
92
|
+
response.should be_success
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should build a user object for the form" do
|
96
|
+
get :new, :format => :js
|
97
|
+
|
98
|
+
assigns(:user).should_not be_blank
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe :create do
|
103
|
+
context "HTML format" do
|
104
|
+
it "should create a new user with a valid form submission" do
|
105
|
+
lambda {
|
106
|
+
post :create, :spud_user => FactoryGirl.attributes_for(:spud_user)
|
107
|
+
}.should change(SpudUser, :count).by(1)
|
108
|
+
response.should be_redirect
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should not create a user with an invalid form entry" do
|
112
|
+
lambda {
|
113
|
+
post :create, :spud_user => FactoryGirl.attributes_for(:spud_user, :email => nil)
|
114
|
+
}.should_not change(SpudUser, :count)
|
115
|
+
flash[:error].should_not be_blank
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
context "JS format" do
|
120
|
+
it "should create a new user with a valid form submission" do
|
121
|
+
lambda {
|
122
|
+
post :create, :spud_user => FactoryGirl.attributes_for(:spud_user), :format => :js
|
123
|
+
}.should change(SpudUser, :count).by(1)
|
124
|
+
response.should be_success
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should not create a user with an invalid form entry" do
|
128
|
+
lambda {
|
129
|
+
post :create, :spud_user => FactoryGirl.attributes_for(:spud_user, :email => nil), :format => :js
|
130
|
+
}.should_not change(SpudUser, :count)
|
131
|
+
response.should_not be_success
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
describe :edit do
|
138
|
+
context "HTML format" do
|
139
|
+
it "should load the correct user for the edit form" do
|
140
|
+
user = FactoryGirl.create(:spud_user)
|
141
|
+
get :edit, :id => user.id
|
142
|
+
|
143
|
+
assigns(:user).id.should == user.id
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
context "JS format" do
|
148
|
+
it "should load the correct user for the edit form" do
|
149
|
+
user = FactoryGirl.create(:spud_user)
|
150
|
+
get :edit, :id => user.id, :format => :js
|
151
|
+
|
152
|
+
assigns(:user).id.should == user.id
|
153
|
+
end
|
154
|
+
|
155
|
+
end
|
156
|
+
|
157
|
+
end
|
158
|
+
|
159
|
+
describe :update do
|
160
|
+
it "should update the email when the first name attribute is changed" do
|
161
|
+
user = FactoryGirl.create(:spud_user)
|
162
|
+
new_name = "Adam"
|
163
|
+
lambda {
|
164
|
+
put :update, :id => user.id, :spud_user => user.attributes.merge!(:first_name => new_name)
|
165
|
+
user.reload
|
166
|
+
}.should change(user, :first_name).to(new_name)
|
167
|
+
end
|
168
|
+
|
169
|
+
it "should redirect to the admin users after a successful update" do
|
170
|
+
user = FactoryGirl.create(:spud_user)
|
171
|
+
put :update, :id => user.id, :spud_user => user.attributes.merge!(:first_name => "Adam")
|
172
|
+
|
173
|
+
response.should redirect_to(spud_admin_users_url)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
describe :destroy do
|
178
|
+
it "should destroy the user" do
|
179
|
+
user = FactoryGirl.create(:spud_user)
|
180
|
+
lambda {
|
181
|
+
delete :destroy, :id => user.id
|
182
|
+
}.should change(SpudUser, :count).by(-1)
|
183
|
+
response.should be_redirect
|
184
|
+
end
|
185
|
+
|
186
|
+
it "should destroy the user with the wrong id" do
|
187
|
+
user = FactoryGirl.create(:spud_user)
|
188
|
+
lambda {
|
189
|
+
delete :destroy, :id => "23532"
|
190
|
+
}.should_not change(SpudUser, :count)
|
191
|
+
response.should be_redirect
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spud::ApplicationController do
|
4
|
+
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
activate_authlogic
|
8
|
+
@user = FactoryGirl.create(:spud_user)
|
9
|
+
@session = SpudUserSession.create(@user)
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
describe :current_site_name do
|
15
|
+
controller(Spud::ApplicationController) do
|
16
|
+
def index
|
17
|
+
render :nothing => true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
it "should return config site name if multisite is disabled" do
|
21
|
+
Spud::Core.configure do |config|
|
22
|
+
config.site_name = "Test Site"
|
23
|
+
end
|
24
|
+
@controller.current_site_name.should == 'Test Site'
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should return config site name if multisite is enabled but multisite name is blank" do
|
28
|
+
Spud::Core.configure do |config|
|
29
|
+
config.site_name = "Test Site"
|
30
|
+
config.multisite_mode_enabled = true
|
31
|
+
end
|
32
|
+
@controller.current_site_name.should == 'Test Site'
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should return multisite name if multisite is enabled" do
|
36
|
+
Spud::Core.configure do |config|
|
37
|
+
config.site_name = "Test Site"
|
38
|
+
config.multisite_mode_enabled = true
|
39
|
+
config.multisite_config += [{:hosts => ["test.host"],:site_name =>"Site B"}]
|
40
|
+
end
|
41
|
+
|
42
|
+
# puts request.host_with_port
|
43
|
+
# helper.request = {:host_with_port => "example.com"}
|
44
|
+
@controller.request = request
|
45
|
+
@controller.current_site_name.should == 'Site B'
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spud::PasswordResetsController do
|
4
|
+
let(:user) { FactoryGirl.build(:spud_user, :id => 1) }
|
5
|
+
|
6
|
+
context :get do
|
7
|
+
describe :new do
|
8
|
+
it "should return success" do
|
9
|
+
get :new
|
10
|
+
response.should be_success
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe :edit do
|
15
|
+
context "with a valid id" do
|
16
|
+
before(:all) do
|
17
|
+
SpudUser.stubs(:find_using_perishable_token).returns(user)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should render the edit form" do
|
21
|
+
get :edit, :id => 1
|
22
|
+
response.should be_success
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "with an invalid id" do
|
27
|
+
before(:all) do
|
28
|
+
SpudUser.stubs(:find_using_perishable_token).returns(nil)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should redirect to the login form" do
|
32
|
+
get :edit, :id => user.id
|
33
|
+
response.should redirect_to(new_spud_user_session_url)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context :post do
|
40
|
+
|
41
|
+
describe :create do
|
42
|
+
context "with a valid user email address submitted" do
|
43
|
+
before(:each) do
|
44
|
+
user.perishable_token = "jfdlsafhbkvabuadfbds"
|
45
|
+
SpudUser.stubs(:find_by_email).returns(user)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should trigger the password notificiation" do
|
49
|
+
Spud::CoreMailer.expects(:forgot_password_notification).returns(stub(:deliver))
|
50
|
+
post :create, :email => user.email
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should redirect to the login form" do
|
54
|
+
post :create, :email => user.email
|
55
|
+
response.should redirect_to(new_spud_user_session_url)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context "with an invalid user email address submitted" do
|
60
|
+
before(:each) do
|
61
|
+
SpudUser.stubs(:find_by_email).returns(nil)
|
62
|
+
end
|
63
|
+
it "should re-render the password reset form" do
|
64
|
+
post :create, :email => "invalid@email.com"
|
65
|
+
response.should render_template("new")
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe :update do
|
71
|
+
let(:valid_data) { {:id => user.id, :spud_user => {:password => "password", :password_confirmation => "password"}}}
|
72
|
+
let(:invalid_data) { {:id => user.id, :spud_user => {:password => "password", :password_confirmation => "drowssap"}}}
|
73
|
+
|
74
|
+
before(:each) do
|
75
|
+
SpudUser.stubs(:find_using_perishable_token).returns(user)
|
76
|
+
end
|
77
|
+
|
78
|
+
context "with valid password entry" do
|
79
|
+
it "should save and redirect to the login form" do
|
80
|
+
post :update, valid_data
|
81
|
+
response.should redirect_to(new_spud_user_session_url)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context "with an invalid password entry" do
|
86
|
+
it "should re-render the password form" do
|
87
|
+
post :update, invalid_data
|
88
|
+
response.should render_template("edit")
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|