dougui_users 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +39 -0
- data/app/assets/javascripts/dougui_users/application.js +9 -0
- data/app/assets/stylesheets/dougui_users/application.css +7 -0
- data/app/assets/stylesheets/scaffold.css +56 -0
- data/app/controllers/dougui_users/application_controller.rb +27 -0
- data/app/controllers/dougui_users/user_activates_controller.rb +13 -0
- data/app/controllers/dougui_users/user_reset_passwords_controller.rb +41 -0
- data/app/controllers/dougui_users/user_sessions_controller.rb +34 -0
- data/app/controllers/dougui_users/users_controller.rb +51 -0
- data/app/helpers/dougui_users/user_mailer_helper.rb +13 -0
- data/app/mailers/dougui_users/user_mailer.rb +15 -0
- data/app/models/dougui_users/user.rb +16 -0
- data/app/models/dougui_users/user_session.rb +11 -0
- data/app/models/user_session.rb +2 -0
- data/app/views/dougui_users/user_mailer/activation.html.erb +1 -0
- data/app/views/dougui_users/user_mailer/reset_password.html.erb +1 -0
- data/app/views/dougui_users/user_reset_passwords/edit.html.erb +16 -0
- data/app/views/dougui_users/user_reset_passwords/new.html.erb +11 -0
- data/app/views/dougui_users/user_sessions/new.html.erb +22 -0
- data/app/views/dougui_users/users/edit.html.erb +16 -0
- data/app/views/dougui_users/users/new.html.erb +25 -0
- data/app/views/layouts/dougui_users/application.html.erb +12 -0
- data/config/cucumber.yml +8 -0
- data/config/locales/en.yml +5 -0
- data/config/locales/fr.yml +50 -0
- data/config/routes.rb +13 -0
- data/db/migrate/20110916144049_create_dougui_users_users.rb +20 -0
- data/features/step_definitions/custom_web_steps.rb +3 -0
- data/features/step_definitions/email_steps.rb +206 -0
- data/features/step_definitions/user_steps.rb +90 -0
- data/features/step_definitions/web_steps.rb +211 -0
- data/features/support/env.rb +88 -0
- data/features/support/paths.rb +49 -0
- data/features/support/selectors.rb +39 -0
- data/features/user.feature +86 -0
- data/features/user_activates.feature +13 -0
- data/features/user_reset_passwords.feature +56 -0
- data/features/user_session.feature +35 -0
- data/lib/dougui_users/engine.rb +5 -0
- data/lib/dougui_users/version.rb +3 -0
- data/lib/dougui_users.rb +7 -0
- data/lib/tasks/cucumber.rake +65 -0
- data/lib/tasks/dougui_users_tasks.rake +4 -0
- data/spec/controllers/dougui_users/user_activates_controller_spec.rb +32 -0
- data/spec/controllers/dougui_users/user_reset_passwords_controller_spec.rb +59 -0
- data/spec/controllers/dougui_users/user_sessions_controller_spec.rb +57 -0
- data/spec/controllers/dougui_users/users_controller_spec.rb +98 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +9 -0
- data/spec/dummy/app/assets/stylesheets/application.css +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config/application.rb +45 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +30 -0
- data/spec/dummy/config/environments/production.rb +60 -0
- data/spec/dummy/config/environments/test.rb +42 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/locales/fr.yml +269 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/schema.rb +28 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +1340 -0
- data/spec/dummy/log/test.log +15056 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/tmp/cache/assets/D0B/620/sprockets%2F5fe8057c4691686098ead34f79e79e8f +0 -0
- data/spec/factories/dougui_users/user_factory.rb +9 -0
- data/spec/models/dougui_users/user_spec.rb +30 -0
- data/spec/spec_helper.rb +65 -0
- metadata +326 -0
@@ -0,0 +1,86 @@
|
|
1
|
+
Feature: User
|
2
|
+
In order to manage my account
|
3
|
+
As a visitor
|
4
|
+
I want to manage my account
|
5
|
+
|
6
|
+
@autotest
|
7
|
+
Scenario Outline: Create a new account
|
8
|
+
Given I have no users
|
9
|
+
And I am on the new user page
|
10
|
+
|
11
|
+
When I fill in the following:
|
12
|
+
| Pseudo | <pseudo> |
|
13
|
+
| Adresse de courriel | <email> |
|
14
|
+
| Mot de passe | <password> |
|
15
|
+
| Mot de passe (confirmation) | <password_confirmation> |
|
16
|
+
And I press "S'inscrire"
|
17
|
+
|
18
|
+
Then I should see "<message>"
|
19
|
+
And I should have <nb_users> user
|
20
|
+
|
21
|
+
Examples:
|
22
|
+
| pseudo | email | password | password_confirmation | message | nb_users |
|
23
|
+
| dougui | guirec.corbel@gmail.com | test1234 | test1234 | Vous avez été enregistré. Un courriel de confirmation vous a été envoyé. Vous devez confirmer votre inscription pour continuer. | 1 |
|
24
|
+
| | guirec.corbel@gmail.com | test1234 | test1234 | est trop court (au moins 3 caractères) | 0 |
|
25
|
+
| dougui | guirec.corbel | test1234 | test1234 | ne semble pas être une adresse de courriel | 0 |
|
26
|
+
| dougui | guirec.corbel@gmail.com | test1234 | test123 | ne concorde pas avec la confirmation | 0 |
|
27
|
+
|
28
|
+
|
29
|
+
@mailer
|
30
|
+
Scenario: Send an email when a new user is created
|
31
|
+
Given no emails have been sent
|
32
|
+
And I have no users
|
33
|
+
And I am on the new user page
|
34
|
+
|
35
|
+
When I create a user
|
36
|
+
|
37
|
+
Then I should receive an email
|
38
|
+
And I should see a link for dougui's activate page in the email body
|
39
|
+
And I should see "Activation de votre compte" in the email subject
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
Scenario Outline: Update an account
|
44
|
+
Given I am a logged user with this following:
|
45
|
+
| active | true |
|
46
|
+
| username | <pseudo_old> |
|
47
|
+
| email | <email_old> |
|
48
|
+
And I am on dougui's edit page
|
49
|
+
|
50
|
+
When I fill in the following:
|
51
|
+
| Pseudo | <pseudo_new> |
|
52
|
+
| Adresse de courriel | <email_new> |
|
53
|
+
And I press "Valider"
|
54
|
+
|
55
|
+
Then I should have <nb_users> user with this following:
|
56
|
+
| username | <pseudo_new> |
|
57
|
+
| email | <email_new> |
|
58
|
+
And I should see "<message>"
|
59
|
+
|
60
|
+
Examples:
|
61
|
+
| pseudo_old | email_old | pseudo_new | email_new | nb_users | message |
|
62
|
+
| dougui | guirec.corbel@gmail.com | dougui1 | guirec.corbel1@gmail.com | 1 | Votre compte a été modifié |
|
63
|
+
| dougui | guirec.corbel@gmail.com | dougui | guirec.corbel | 0 | ne semble pas être une adresse de courriel |
|
64
|
+
| dougui | guirec.corbel@gmail.com | | guirec.corbel@gmail.com | 0 | est trop court (au moins 3 caractères) |
|
65
|
+
|
66
|
+
|
67
|
+
Scenario: Follow the link to reset password
|
68
|
+
Given I am a logged user with username "dougui"
|
69
|
+
|
70
|
+
When I go to dougui's edit page
|
71
|
+
And I follow "Modifier le mot de passe"
|
72
|
+
|
73
|
+
Then I should be on dougui's reset password page
|
74
|
+
|
75
|
+
|
76
|
+
Scenario: Destroy an account
|
77
|
+
Given I am a logged user
|
78
|
+
|
79
|
+
When I go to the home page
|
80
|
+
And I follow "Supprimer mon compte"
|
81
|
+
|
82
|
+
|
83
|
+
Then I should have no user
|
84
|
+
And I should be on the home page
|
85
|
+
And I should see "Votre compte a été supprimé"
|
86
|
+
And I should see "S'inscrire"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Feature: User
|
2
|
+
In order to verify the activation processus
|
3
|
+
As a visitor
|
4
|
+
I want to activate my account
|
5
|
+
|
6
|
+
Scenario: Activate my account
|
7
|
+
Given I have a user with this following:
|
8
|
+
| username | dougui |
|
9
|
+
| active | false |
|
10
|
+
When I go to dougui's activate page
|
11
|
+
Then I should have a user with this following:
|
12
|
+
| username | dougui |
|
13
|
+
| active | true |
|
@@ -0,0 +1,56 @@
|
|
1
|
+
Feature: User
|
2
|
+
In order to verify the processus for reseting a password
|
3
|
+
As a visitor
|
4
|
+
I want to reset my password
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given I have a user with this following:
|
8
|
+
| email | guirec.corbel@gmail.com |
|
9
|
+
| username | dougui |
|
10
|
+
|
11
|
+
|
12
|
+
Scenario Outline: I fill the form for reset my password
|
13
|
+
Given I am on the new user reset password page
|
14
|
+
|
15
|
+
When I fill in the following:
|
16
|
+
| Adresse de courriel | <email_filled> |
|
17
|
+
And I press "Valider"
|
18
|
+
|
19
|
+
Then I should see "<message>"
|
20
|
+
|
21
|
+
Examples:
|
22
|
+
| email_filled | message |
|
23
|
+
| guirec.corbel@gmail.com | Un courriel de confirmation vous a été envoyé. Vous devez suivre les étapes indquées pour continuer |
|
24
|
+
| bliblablou@gmail.com | Cette adresse de courriel n'est pas enregistrée. |
|
25
|
+
|
26
|
+
|
27
|
+
@mailer
|
28
|
+
Scenario: I receive an email when I want to reset my password
|
29
|
+
Given I am on the new user reset password page
|
30
|
+
|
31
|
+
When I fill in the following:
|
32
|
+
| Adresse de courriel | guirec.corbel@gmail.com |
|
33
|
+
And I press "Valider"
|
34
|
+
|
35
|
+
Then I should receive an email
|
36
|
+
And I should see a link for dougui's reset password page in the email body
|
37
|
+
And I should see "Activation de votre compte" in the email subject
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
Scenario Outline: I update the password
|
42
|
+
Given I am a logged user with this following:
|
43
|
+
| active | true |
|
44
|
+
Given I am on dougui's reset password page
|
45
|
+
|
46
|
+
When I fill in the following:
|
47
|
+
| Mot de passe | <password> |
|
48
|
+
| Mot de passe (confirmation) | <password> |
|
49
|
+
And I press "Valider"
|
50
|
+
|
51
|
+
And I should see "<message>"
|
52
|
+
|
53
|
+
Examples:
|
54
|
+
| password | message |
|
55
|
+
| test123 | Votre mot de passe a été modifié |
|
56
|
+
| | est trop court (au moins 4 caractères)|
|
@@ -0,0 +1,35 @@
|
|
1
|
+
Feature: User
|
2
|
+
In order to control the connection system
|
3
|
+
As a valid user
|
4
|
+
I want to connect and disconnect a user
|
5
|
+
|
6
|
+
Scenario Outline: Login a valid user
|
7
|
+
Given I have a user with this following:
|
8
|
+
| username | dougui |
|
9
|
+
| password | test |
|
10
|
+
| password_confirmation | test |
|
11
|
+
| active | <active> |
|
12
|
+
And I am on the login page
|
13
|
+
|
14
|
+
When I fill in the following:
|
15
|
+
| Pseudo | <username_filled> |
|
16
|
+
| Mot de passe | <password_filled> |
|
17
|
+
And I press "Se connecter"
|
18
|
+
|
19
|
+
And I should see "<message>"
|
20
|
+
|
21
|
+
Examples:
|
22
|
+
| username_filled | password_filled | active | message |
|
23
|
+
| dougui | test | true | |
|
24
|
+
| dougui1 | test | true | n'est pas valide |
|
25
|
+
| dougui | test | false | Votre compte n'est pas actif |
|
26
|
+
| | test | true | doit être rempli(e) |
|
27
|
+
| dougui | | true | doit être rempli(e) |
|
28
|
+
|
29
|
+
Scenario: Disconnect a user connected
|
30
|
+
Given I am a logged user
|
31
|
+
And I follow "Se déconnecter"
|
32
|
+
|
33
|
+
Then I should be on the home page
|
34
|
+
|
35
|
+
And I should see "Se connecter"
|
data/lib/dougui_users.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
|
2
|
+
# It is recommended to regenerate this file in the future when you upgrade to a
|
3
|
+
# newer version of cucumber-rails. Consider adding your own code to a new file
|
4
|
+
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
5
|
+
# files.
|
6
|
+
|
7
|
+
|
8
|
+
unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
|
9
|
+
|
10
|
+
vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
|
11
|
+
$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
|
12
|
+
|
13
|
+
begin
|
14
|
+
require 'cucumber/rake/task'
|
15
|
+
|
16
|
+
namespace :cucumber do
|
17
|
+
Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t|
|
18
|
+
t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
|
19
|
+
t.fork = true # You may get faster startup if you set this to false
|
20
|
+
t.profile = 'default'
|
21
|
+
end
|
22
|
+
|
23
|
+
Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t|
|
24
|
+
t.binary = vendored_cucumber_bin
|
25
|
+
t.fork = true # You may get faster startup if you set this to false
|
26
|
+
t.profile = 'wip'
|
27
|
+
end
|
28
|
+
|
29
|
+
Cucumber::Rake::Task.new({:rerun => 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t|
|
30
|
+
t.binary = vendored_cucumber_bin
|
31
|
+
t.fork = true # You may get faster startup if you set this to false
|
32
|
+
t.profile = 'rerun'
|
33
|
+
end
|
34
|
+
|
35
|
+
desc 'Run all features'
|
36
|
+
task :all => [:ok, :wip]
|
37
|
+
|
38
|
+
task :statsetup do
|
39
|
+
require 'rails/code_statistics'
|
40
|
+
::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features')
|
41
|
+
::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?('features')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
desc 'Alias for cucumber:ok'
|
45
|
+
task :cucumber => 'cucumber:ok'
|
46
|
+
|
47
|
+
task :default => :cucumber
|
48
|
+
|
49
|
+
task :features => :cucumber do
|
50
|
+
STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
|
51
|
+
end
|
52
|
+
|
53
|
+
# In case we don't have ActiveRecord, append a no-op task that we can depend upon.
|
54
|
+
task 'db:test:prepare' do
|
55
|
+
end
|
56
|
+
|
57
|
+
task :stats => 'cucumber:statsetup'
|
58
|
+
rescue LoadError
|
59
|
+
desc 'cucumber rake task not available (cucumber not installed)'
|
60
|
+
task :cucumber do
|
61
|
+
abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module DouguiUsers
|
4
|
+
describe UserActivatesController do
|
5
|
+
before do
|
6
|
+
#Rails.application.routes.draw do
|
7
|
+
# :controller not valid when inside a namespace,
|
8
|
+
# so use a constraint that'll match the same path
|
9
|
+
# match ':controller(/:action(/:id(.:format)))', :controller => /\/[^\/]+/
|
10
|
+
#end
|
11
|
+
end
|
12
|
+
|
13
|
+
after do
|
14
|
+
# Reload the routes so the rest of the app's specs still pass
|
15
|
+
#Rails.application.reload_routes!
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
before (:each) do
|
21
|
+
User.destroy_all
|
22
|
+
@user = FactoryGirl.create(:user)
|
23
|
+
end
|
24
|
+
subject {response}
|
25
|
+
|
26
|
+
describe "GET 'edit'" do
|
27
|
+
before (:each) {get :edit, {:id => @user.perishable_token, :use_route => :dougui_users}}
|
28
|
+
it {should redirect_to login_path}
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
#encoding=utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
module DouguiUsers
|
5
|
+
describe DouguiUsers::UserResetPasswordsController do
|
6
|
+
setup :activate_authlogic
|
7
|
+
|
8
|
+
before (:each) do
|
9
|
+
User.destroy_all
|
10
|
+
@user = FactoryGirl.create(:user)
|
11
|
+
@user_attributes = FactoryGirl.attributes_for(:user)
|
12
|
+
@user.save
|
13
|
+
end
|
14
|
+
subject {response}
|
15
|
+
|
16
|
+
describe "GET 'new'" do
|
17
|
+
before (:each) {get :new, :use_route => :dougui_users}
|
18
|
+
it {should be_success}
|
19
|
+
it {should render_template("user_reset_passwords/new")}
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "PUT 'create'" do
|
23
|
+
context "with valid arguments" do
|
24
|
+
before (:each) {post :create, :user => @user.attributes, :use_route => :dougui_users}
|
25
|
+
it {should redirect_to login_path}
|
26
|
+
end
|
27
|
+
|
28
|
+
context "with invalid arguments" do
|
29
|
+
before (:each) {post :create, :user => {}, :use_route => :dougui_users}
|
30
|
+
it {should be_success}
|
31
|
+
it {should render_template("/")}
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "GET 'edit'" do
|
37
|
+
context "when logged" do
|
38
|
+
|
39
|
+
before (:each) do
|
40
|
+
@user.active = true
|
41
|
+
@user.save
|
42
|
+
UserSession.create(@user)
|
43
|
+
get :edit, :id => @user.perishable_token, :use_route => :dougui_users
|
44
|
+
end
|
45
|
+
|
46
|
+
context "with valid id" do
|
47
|
+
it {should be_success}
|
48
|
+
it {should render_template("user_reset_passwords/edit")}
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context "when unlogged" do
|
53
|
+
before (:each) {get :edit, :id => @user.perishable_token, :use_route => :dougui_users}
|
54
|
+
should_not_access
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
#encoding=utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
module DouguiUsers
|
5
|
+
describe DouguiUsers::UserSessionsController do
|
6
|
+
setup :activate_authlogic
|
7
|
+
|
8
|
+
before (:each) do
|
9
|
+
User.destroy_all
|
10
|
+
@user = FactoryGirl.create(:user)
|
11
|
+
@user.active = true
|
12
|
+
@user.save
|
13
|
+
@user_attributes = FactoryGirl.attributes_for(:user)
|
14
|
+
|
15
|
+
@attributes = {"username"=>@user.username, "password"=>@user.password}
|
16
|
+
end
|
17
|
+
subject {response}
|
18
|
+
|
19
|
+
describe "GET 'new'" do
|
20
|
+
before (:each) {get :new, :use_route => :dougui_users}
|
21
|
+
it {should be_success}
|
22
|
+
it {should render_template("dougui_users/user_sessions/new")}
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "PUT 'create'" do
|
26
|
+
context "with valid arguments" do
|
27
|
+
before (:each) { post :create, :user_session => @attributes, :use_route => :dougui_users}
|
28
|
+
it {should redirect_to root_path}
|
29
|
+
end
|
30
|
+
|
31
|
+
context "with invalid arguments" do
|
32
|
+
before (:each) {post :create, :user_session => {}, :use_route => :dougui_users}
|
33
|
+
it {should be_success}
|
34
|
+
it {should render_template("dougui_users/user_sessions/new")}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "DELETE 'destroy'" do
|
39
|
+
context "when logged" do
|
40
|
+
before (:each) do
|
41
|
+
@user.active = true
|
42
|
+
@user.save
|
43
|
+
UserSession.create(@user)
|
44
|
+
delete :destroy, :use_route => :dougui_users
|
45
|
+
end
|
46
|
+
it {should redirect_to root_path}
|
47
|
+
end
|
48
|
+
|
49
|
+
context "when unlogged" do
|
50
|
+
before (:each) do
|
51
|
+
delete :destroy, :use_route => :dougui_users
|
52
|
+
end
|
53
|
+
should_not_access
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module DouguiUsers
|
4
|
+
describe UsersController do
|
5
|
+
setup :activate_authlogic
|
6
|
+
|
7
|
+
before (:each) do
|
8
|
+
User.destroy_all
|
9
|
+
@user = FactoryGirl.build(:user)
|
10
|
+
@user_attributes = FactoryGirl.attributes_for(:user)
|
11
|
+
end
|
12
|
+
subject {response}
|
13
|
+
|
14
|
+
describe "GET 'new'" do
|
15
|
+
before (:each) {get :new, :use_route => :dougui_users}
|
16
|
+
it {should be_success}
|
17
|
+
it {should render_template("dougui_users/users/new")}
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "PUT 'create'" do
|
21
|
+
context "with valid arguments" do
|
22
|
+
before (:each) {post :create, :user => @user_attributes, :use_route => :dougui_users}
|
23
|
+
it {should redirect_to login_path}
|
24
|
+
end
|
25
|
+
|
26
|
+
context "with invalid arguments" do
|
27
|
+
before (:each) {post :create, :user => {}, :use_route => :dougui_users}
|
28
|
+
it {should be_success}
|
29
|
+
it {should render_template("dougui_users/")}
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "GET 'edit'" do
|
35
|
+
context "when logged" do
|
36
|
+
before (:each) do
|
37
|
+
@user.active = true
|
38
|
+
@user.save
|
39
|
+
UserSession.create(@user)
|
40
|
+
put :edit, :user => @user_attributes, :id => @user.id, :use_route => :dougui_users
|
41
|
+
end
|
42
|
+
it {should be_success}
|
43
|
+
it {should render_template("dougui_users/users/edit")}
|
44
|
+
end
|
45
|
+
|
46
|
+
context "when unlogged" do
|
47
|
+
before (:each) {put :edit, :user => @user_attributes, :id => @user.id, :use_route => :dougui_users}
|
48
|
+
should_not_access
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "PUT 'update'" do
|
53
|
+
context "when logged" do
|
54
|
+
before (:each) do
|
55
|
+
@user.active = true
|
56
|
+
@user.save
|
57
|
+
UserSession.create(@user)
|
58
|
+
end
|
59
|
+
|
60
|
+
context "with valid arguments" do
|
61
|
+
before (:each) {put :update, :user => @user_attributes, :id => @user.id, :use_route => :dougui_users }
|
62
|
+
it {should redirect_to root_path}
|
63
|
+
end
|
64
|
+
|
65
|
+
context "with invalid arguments" do
|
66
|
+
before (:each) do
|
67
|
+
@user_attributes[:username] = nil
|
68
|
+
put :update, :user => @user_attributes, :id => @user.id, :use_route => :dougui_users
|
69
|
+
end
|
70
|
+
it {should be_success}
|
71
|
+
it {should render_template("dougui_users/users/edit")}
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context "when unlogged" do
|
76
|
+
before (:each) { put :update, :user => @user_attributes, :id => @user.id, :use_route => :dougui_users }
|
77
|
+
should_not_access
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "DELETE 'destroy'" do
|
82
|
+
context "when logged" do
|
83
|
+
before (:each) do
|
84
|
+
@user.active = true
|
85
|
+
@user.save
|
86
|
+
UserSession.create(@user)
|
87
|
+
delete :destroy, :id => @user.id, :use_route => :dougui_users
|
88
|
+
end
|
89
|
+
it {should redirect_to root_path}
|
90
|
+
end
|
91
|
+
|
92
|
+
context "when unlogged" do
|
93
|
+
before (:each) { delete :destroy, :id => @user.id, :use_route => :dougui_users }
|
94
|
+
should_not_access
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
data/spec/dummy/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
+
|
5
|
+
require File.expand_path('../config/application', __FILE__)
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|
@@ -0,0 +1,9 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into including all the files listed below.
|
2
|
+
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
3
|
+
// be included in the compiled file accessible from http://example.com/assets/application.js
|
4
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
5
|
+
// the compiled file.
|
6
|
+
//
|
7
|
+
//= require jquery
|
8
|
+
//= require jquery_ujs
|
9
|
+
//= require_tree .
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll automatically include all the stylesheets available in this directory
|
3
|
+
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
|
4
|
+
* the top of the compiled file, but it's generally better to create a new file per style scope.
|
5
|
+
*= require_self
|
6
|
+
*= require_tree .
|
7
|
+
*/
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
Bundler.require
|
6
|
+
require "dougui_users"
|
7
|
+
|
8
|
+
module Dummy
|
9
|
+
class Application < Rails::Application
|
10
|
+
# Settings in config/environments/* take precedence over those specified here.
|
11
|
+
# Application configuration should go into files in config/initializers
|
12
|
+
# -- all .rb files in that directory are automatically loaded.
|
13
|
+
|
14
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
15
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
16
|
+
|
17
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
18
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
19
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
20
|
+
|
21
|
+
# Activate observers that should always be running.
|
22
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
23
|
+
|
24
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
25
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
26
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
27
|
+
|
28
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
29
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
30
|
+
config.i18n.default_locale = :fr
|
31
|
+
|
32
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
33
|
+
config.encoding = "utf-8"
|
34
|
+
|
35
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
36
|
+
config.filter_parameters += [:password]
|
37
|
+
|
38
|
+
# Enable the asset pipeline
|
39
|
+
config.assets.enabled = true
|
40
|
+
|
41
|
+
# Version of your assets, change this if you want to expire all your assets
|
42
|
+
config.assets.version = '1.0'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# SQLite version 3.x
|
2
|
+
# gem install sqlite3
|
3
|
+
#
|
4
|
+
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
+
# gem 'sqlite3'
|
6
|
+
development:
|
7
|
+
adapter: sqlite3
|
8
|
+
database: db/development.sqlite3
|
9
|
+
pool: 5
|
10
|
+
timeout: 5000
|
11
|
+
|
12
|
+
# Warning: The database defined as "test" will be erased and
|
13
|
+
# re-generated from your development database when you run "rake".
|
14
|
+
# Do not set this db to the same as development or production.
|
15
|
+
test:
|
16
|
+
adapter: sqlite3
|
17
|
+
database: db/test.sqlite3
|
18
|
+
pool: 5
|
19
|
+
timeout: 5000
|
20
|
+
|
21
|
+
production:
|
22
|
+
adapter: sqlite3
|
23
|
+
database: db/production.sqlite3
|
24
|
+
pool: 5
|
25
|
+
timeout: 5000
|