curupira 0.1.4 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +131 -117
- data/app/controllers/curupira/authorized_controller.rb +1 -1
- data/app/controllers/curupira/passwords_controller.rb +1 -1
- data/app/controllers/curupira/sessions_controller.rb +1 -1
- data/curupira.gemspec +7 -7
- data/lib/curupira/version.rb +1 -1
- data/spec/controllers/controller_spec.rb +3 -2
- data/spec/controllers/groups_controller_spec.rb +16 -16
- data/spec/controllers/passwords_controller_spec.rb +20 -20
- data/spec/controllers/permissions_controller_spec.rb +1 -1
- data/spec/controllers/roles_controller_spec.rb +16 -16
- data/spec/controllers/sessions_controller_spec.rb +8 -8
- data/spec/controllers/users_controller_spec.rb +16 -16
- data/spec/dummy/app/views/base/index.html.erb +0 -0
- data/spec/rails_helper.rb +2 -2
- metadata +79 -35
@@ -28,24 +28,24 @@ describe Curupira::PasswordsController do
|
|
28
28
|
let!(:user) { FactoryGirl.create :user, reset_password_token: 123456 }
|
29
29
|
|
30
30
|
it "should get new" do
|
31
|
-
get :edit, id: user.reset_password_token
|
31
|
+
get :edit, params: { id: user.reset_password_token }
|
32
32
|
expect(response).to be_success
|
33
33
|
end
|
34
34
|
|
35
35
|
it "returns user" do
|
36
|
-
get :edit, id: user.reset_password_token
|
36
|
+
get :edit, params: { id: user.reset_password_token }
|
37
37
|
expect(assigns(:user)).to eql user
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
41
|
context "when token does not exists" do
|
42
42
|
it "redirect to new_session_path" do
|
43
|
-
get :edit, id: "no token"
|
43
|
+
get :edit, params: { id: "no token" }
|
44
44
|
expect(response).to redirect_to :new_session
|
45
45
|
end
|
46
46
|
|
47
47
|
it "sends flash alert" do
|
48
|
-
get :edit, id: "no token"
|
48
|
+
get :edit, params: { id: "no token" }
|
49
49
|
expect(flash[:alert]).to eql "Token para resetar senha expirado ou inválido"
|
50
50
|
end
|
51
51
|
end
|
@@ -54,7 +54,7 @@ describe Curupira::PasswordsController do
|
|
54
54
|
it "redirects to root path" do
|
55
55
|
login_user(FactoryGirl.create :user)
|
56
56
|
|
57
|
-
get :edit, id: "any token here"
|
57
|
+
get :edit, params: { id: "any token here" }
|
58
58
|
expect(response).to redirect_to root_path
|
59
59
|
expect(flash[:alert]).to eql "Você já está logado"
|
60
60
|
end
|
@@ -67,42 +67,42 @@ describe Curupira::PasswordsController do
|
|
67
67
|
|
68
68
|
it "delivers password reset instructions" do
|
69
69
|
expect {
|
70
|
-
post :create, user: { email: user.email }
|
70
|
+
post :create, params: { user: { email: user.email } }
|
71
71
|
}.to change { ActionMailer::Base.deliveries.size }.by(1)
|
72
72
|
end
|
73
73
|
|
74
74
|
it "creates reset password token" do
|
75
75
|
expect(user.reload.reset_password_token).to be_nil
|
76
76
|
|
77
|
-
post :create, user: { email: user.email }
|
77
|
+
post :create, params: { user: { email: user.email } }
|
78
78
|
|
79
79
|
expect(user.reload.reset_password_token).to_not be_nil
|
80
80
|
end
|
81
81
|
|
82
82
|
it "redirects to new_session_path" do
|
83
|
-
post :create, user: { email: user.email }
|
83
|
+
post :create, params: { user: { email: user.email } }
|
84
84
|
expect(response).to redirect_to new_session_path
|
85
85
|
end
|
86
86
|
|
87
87
|
it "sends flash notice" do
|
88
|
-
post :create, user: { email: user.email }
|
88
|
+
post :create, params: { user: { email: user.email } }
|
89
89
|
expect(flash[:notice]).to eql "Verifique seu email para receber instruções de recuperação de senha"
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
93
|
context "email does not exists" do
|
94
94
|
it "assigns user with wrong email" do
|
95
|
-
post :create, user: { email: "wrong@email.com" }
|
95
|
+
post :create, params: { user: { email: "wrong@email.com" } }
|
96
96
|
expect(assigns[:user].email).to eql "wrong@email.com"
|
97
97
|
end
|
98
98
|
|
99
99
|
it "renders new" do
|
100
|
-
post :create, user: { email: "wrong@email.com" }
|
100
|
+
post :create, params: { user: { email: "wrong@email.com" } }
|
101
101
|
expect(response).to render_template :new
|
102
102
|
end
|
103
103
|
|
104
104
|
it "sends flash alert" do
|
105
|
-
post :create, user: { email: "wrong@email.com" }
|
105
|
+
post :create, params: { user: { email: "wrong@email.com" } }
|
106
106
|
expect(flash[:alert]).to eql "Email não encontrado"
|
107
107
|
end
|
108
108
|
end
|
@@ -111,7 +111,7 @@ describe Curupira::PasswordsController do
|
|
111
111
|
it "redirects to root path" do
|
112
112
|
login_user(FactoryGirl.create :user)
|
113
113
|
|
114
|
-
post :create, id: "any token here"
|
114
|
+
post :create, params: { id: "any token here" }
|
115
115
|
expect(response).to redirect_to root_path
|
116
116
|
expect(flash[:alert]).to eql "Você já está logado"
|
117
117
|
end
|
@@ -124,36 +124,36 @@ describe Curupira::PasswordsController do
|
|
124
124
|
let!(:user) { FactoryGirl.create :user, reset_password_token: 123456 }
|
125
125
|
|
126
126
|
it "redirects to new_session_path" do
|
127
|
-
put :update, id: user.reset_password_token, user: { password: "123456" }
|
127
|
+
put :update, params: { id: user.reset_password_token, user: { password: "123456" } }
|
128
128
|
expect(response).to redirect_to new_session_path
|
129
129
|
end
|
130
130
|
|
131
131
|
it "updates users password" do
|
132
132
|
expect {
|
133
|
-
put :update, id: user.reset_password_token, user: { password: "123456" }
|
133
|
+
put :update, params: { id: user.reset_password_token, user: { password: "123456" } }
|
134
134
|
}.to change { user.reload.crypted_password }
|
135
135
|
end
|
136
136
|
|
137
137
|
it "delivers reseted password email notification" do
|
138
138
|
expect {
|
139
|
-
put :update, id: user.reset_password_token, user: { password: "123456" }
|
139
|
+
put :update, params: { id: user.reset_password_token, user: { password: "123456" } }
|
140
140
|
}.to change { ActionMailer::Base.deliveries.size }.by(1)
|
141
141
|
end
|
142
142
|
|
143
143
|
it "sends flash notice" do
|
144
|
-
put :update, id: user.reset_password_token, user: { password: "123456" }
|
144
|
+
put :update, params: { id: user.reset_password_token, user: { password: "123456" } }
|
145
145
|
expect(flash[:notice]).to eql "Senha atualizada com sucesso. Entre com sua nova senha"
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
149
149
|
context "when token does not exists" do
|
150
150
|
it "redirect to new_session_path" do
|
151
|
-
put :update, id: "i dont exist"
|
151
|
+
put :update, params: { id: "i dont exist" }
|
152
152
|
expect(response).to redirect_to :new_session
|
153
153
|
end
|
154
154
|
|
155
155
|
it "sends flash alert" do
|
156
|
-
put :update, id: "i dont exist"
|
156
|
+
put :update, params: { id: "i dont exist" }
|
157
157
|
expect(flash[:alert]).to eql "Token para resetar senha expirado ou inválido"
|
158
158
|
end
|
159
159
|
end
|
@@ -162,7 +162,7 @@ describe Curupira::PasswordsController do
|
|
162
162
|
it "redirects to root path" do
|
163
163
|
login_user(FactoryGirl.create :user)
|
164
164
|
|
165
|
-
put :update, id: "any token here"
|
165
|
+
put :update, params: { id: "any token here" }
|
166
166
|
expect(response).to redirect_to root_path
|
167
167
|
expect(flash[:alert]).to eql "Você já está logado"
|
168
168
|
end
|
@@ -25,7 +25,7 @@ describe Curupira::PermissionsController do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
before do
|
28
|
-
patch :create, user_id: user, group_user_id: group_user, group_user: params
|
28
|
+
patch :create, params: { user_id: user, group_user_id: group_user, group_user: params }
|
29
29
|
end
|
30
30
|
|
31
31
|
it "sets flash message" do
|
@@ -24,12 +24,12 @@ describe Curupira::RolesController do
|
|
24
24
|
let!(:role) { FactoryGirl.create(:role) }
|
25
25
|
|
26
26
|
it "should get show" do
|
27
|
-
get :show, id: role
|
27
|
+
get :show, params: { id: role }
|
28
28
|
expect(response).to be_success
|
29
29
|
end
|
30
30
|
|
31
31
|
it "returns role" do
|
32
|
-
get :show, id: user
|
32
|
+
get :show, params: { id: user }
|
33
33
|
expect(assigns(:role)).to eql role
|
34
34
|
end
|
35
35
|
end
|
@@ -37,7 +37,7 @@ describe Curupira::RolesController do
|
|
37
37
|
context "when user does not exist" do
|
38
38
|
it "renders 404" do
|
39
39
|
expect {
|
40
|
-
get :show, id: "wrong id"
|
40
|
+
get :show, params: { id: "wrong id" }
|
41
41
|
}.to raise_error ActiveRecord::RecordNotFound
|
42
42
|
end
|
43
43
|
end
|
@@ -60,12 +60,12 @@ describe Curupira::RolesController do
|
|
60
60
|
let!(:role) { FactoryGirl.create(:role) }
|
61
61
|
|
62
62
|
it "should get edit" do
|
63
|
-
get :edit, id: role
|
63
|
+
get :edit, params: { id: role }
|
64
64
|
expect(response).to be_success
|
65
65
|
end
|
66
66
|
|
67
67
|
it "returns role" do
|
68
|
-
get :edit, id: role
|
68
|
+
get :edit, params: { id: role }
|
69
69
|
expect(assigns(:role)).to eql role
|
70
70
|
end
|
71
71
|
end
|
@@ -73,7 +73,7 @@ describe Curupira::RolesController do
|
|
73
73
|
context "when user does not exist" do
|
74
74
|
it "renders 404" do
|
75
75
|
expect {
|
76
|
-
get :edit, id: "wrong id"
|
76
|
+
get :edit, params: { id: "wrong id" }
|
77
77
|
}.to raise_error ActiveRecord::RecordNotFound
|
78
78
|
end
|
79
79
|
end
|
@@ -94,18 +94,18 @@ describe Curupira::RolesController do
|
|
94
94
|
end
|
95
95
|
|
96
96
|
it "should redirect to new user" do
|
97
|
-
post :create, role: params
|
97
|
+
post :create, params: { role: params }
|
98
98
|
expect(flash[:notice]).to eql "Perfil criado com sucesso"
|
99
99
|
end
|
100
100
|
|
101
101
|
it "should redirect to new role" do
|
102
|
-
post :create, role: params
|
102
|
+
post :create, params: { role: params }
|
103
103
|
expect(response).to redirect_to assigns(:role)
|
104
104
|
end
|
105
105
|
|
106
106
|
it "creates role" do
|
107
107
|
expect {
|
108
|
-
post :create, role: params
|
108
|
+
post :create, params: { role: params }
|
109
109
|
}.to change { Role.count }.by(1)
|
110
110
|
|
111
111
|
expect(assigns[:role].name).to eql "Minha Role"
|
@@ -118,12 +118,12 @@ describe Curupira::RolesController do
|
|
118
118
|
|
119
119
|
it "does not create user" do
|
120
120
|
expect {
|
121
|
-
post :create, role: params
|
121
|
+
post :create, params: { role: params }
|
122
122
|
}.to change { Role.count }.by(0)
|
123
123
|
end
|
124
124
|
|
125
125
|
it "should render new" do
|
126
|
-
post :create, role: params
|
126
|
+
post :create, params: { role: params }
|
127
127
|
expect(response).to render_template :new
|
128
128
|
end
|
129
129
|
end
|
@@ -136,17 +136,17 @@ describe Curupira::RolesController do
|
|
136
136
|
let(:params) { FactoryGirl.build(:role, name: 'Outra role').attributes }
|
137
137
|
|
138
138
|
it "sets flash message" do
|
139
|
-
put :update, id: role, role: params
|
139
|
+
put :update, params: { id: role, role: params }
|
140
140
|
expect(flash[:notice]).to eql "Perfil atualizado com sucesso"
|
141
141
|
end
|
142
142
|
|
143
143
|
it "redirects to user" do
|
144
|
-
put :update, id: role, role: params
|
144
|
+
put :update, params: { id: role, role: params }
|
145
145
|
expect(response).to redirect_to assigns(:role)
|
146
146
|
end
|
147
147
|
|
148
148
|
it "updates role" do
|
149
|
-
put :update, id: role, role: params
|
149
|
+
put :update, params: { id: role, role: params }
|
150
150
|
expect(assigns(:role).name).to eql "Outra role"
|
151
151
|
end
|
152
152
|
end
|
@@ -155,12 +155,12 @@ describe Curupira::RolesController do
|
|
155
155
|
let(:params) { FactoryGirl.build(:role, name: '').attributes }
|
156
156
|
|
157
157
|
it "does not create role" do
|
158
|
-
put :update, id: role, role: params
|
158
|
+
put :update, params: { id: role, role: params }
|
159
159
|
expect(assigns(:role).reload.name).to eql role.name
|
160
160
|
end
|
161
161
|
|
162
162
|
it "should render edit" do
|
163
|
-
put :update, id: role, role: params
|
163
|
+
put :update, params: { id: role, role: params }
|
164
164
|
expect(response).to render_template :edit
|
165
165
|
end
|
166
166
|
end
|
@@ -29,7 +29,7 @@ describe Curupira::SessionsController do
|
|
29
29
|
context "when credentials are valid" do
|
30
30
|
context "with email" do
|
31
31
|
it "create session" do
|
32
|
-
post :create, user: { username: user.email, password: 123456 }
|
32
|
+
post :create, params: { user: { username: user.email, password: 123456 } }
|
33
33
|
|
34
34
|
expect(User.find(session[:user_id])).to eql user
|
35
35
|
end
|
@@ -37,20 +37,20 @@ describe Curupira::SessionsController do
|
|
37
37
|
|
38
38
|
context "with username" do
|
39
39
|
it "create session" do
|
40
|
-
post :create, user: { username: user.username, password: 123456 }
|
40
|
+
post :create, params: { user: { username: user.username, password: 123456 } }
|
41
41
|
|
42
42
|
expect(User.find(session[:user_id])).to eql user
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
it "redirects to root path" do
|
47
|
-
post :create, user: { username: user.email, password: 123456 }
|
47
|
+
post :create, params: { user: { username: user.email, password: 123456 } }
|
48
48
|
|
49
49
|
expect(response).to redirect_to root_path
|
50
50
|
end
|
51
51
|
|
52
52
|
it "renders flash notice" do
|
53
|
-
post :create, user: { username: user.email, password: 123456 }
|
53
|
+
post :create, params: { user: { username: user.email, password: 123456 } }
|
54
54
|
|
55
55
|
expect(flash[:notice]).to eql "Bem vindo!"
|
56
56
|
end
|
@@ -59,7 +59,7 @@ describe Curupira::SessionsController do
|
|
59
59
|
it "redirects to root path" do
|
60
60
|
login_user(FactoryGirl.create :user)
|
61
61
|
|
62
|
-
post :create, user: { username: user.email, password: 123456 }
|
62
|
+
post :create, params: { user: { username: user.email, password: 123456 } }
|
63
63
|
expect(response).to redirect_to root_path
|
64
64
|
expect(flash[:alert]).to eql "Você já está logado"
|
65
65
|
end
|
@@ -68,19 +68,19 @@ describe Curupira::SessionsController do
|
|
68
68
|
|
69
69
|
context "when credentials are invalid" do
|
70
70
|
it "renders flash alert" do
|
71
|
-
post :create, user: { username: user.email, password: "wrong pass" }
|
71
|
+
post :create, params: { user: { username: user.email, password: "wrong pass" } }
|
72
72
|
|
73
73
|
expect(flash[:alert]).to eql "Login ou senha inválidos"
|
74
74
|
end
|
75
75
|
|
76
76
|
it "renders new" do
|
77
|
-
post :create, user: { username: user.email, password: "wrong pass" }
|
77
|
+
post :create, params: { user: { username: user.email, password: "wrong pass" } }
|
78
78
|
|
79
79
|
expect(response).to render_template :new
|
80
80
|
end
|
81
81
|
|
82
82
|
it "returns new user" do
|
83
|
-
post :create, user: { username: user.email, password: "wrong pass" }
|
83
|
+
post :create, params: { user: { username: user.email, password: "wrong pass" } }
|
84
84
|
|
85
85
|
expect(assigns[:user]).to be_new_record
|
86
86
|
expect(assigns[:user].username).to eql user.email
|
@@ -24,12 +24,12 @@ describe Curupira::UsersController do
|
|
24
24
|
describe "GET show" do
|
25
25
|
context "when user exists" do
|
26
26
|
it "should get show" do
|
27
|
-
get :show, id: user
|
27
|
+
get :show, params: { id: user }
|
28
28
|
expect(response).to be_success
|
29
29
|
end
|
30
30
|
|
31
31
|
it "returns user" do
|
32
|
-
get :show, id: user
|
32
|
+
get :show, params: { id: user }
|
33
33
|
expect(assigns(:user)).to eql user
|
34
34
|
end
|
35
35
|
end
|
@@ -37,7 +37,7 @@ describe Curupira::UsersController do
|
|
37
37
|
context "when user does not exist" do
|
38
38
|
it "renders 404" do
|
39
39
|
expect {
|
40
|
-
get :show, id: "wrong id"
|
40
|
+
get :show, params: { id: "wrong id" }
|
41
41
|
}.to raise_error ActiveRecord::RecordNotFound
|
42
42
|
end
|
43
43
|
end
|
@@ -58,12 +58,12 @@ describe Curupira::UsersController do
|
|
58
58
|
describe "GET edit" do
|
59
59
|
context "when user exists" do
|
60
60
|
it "should get edit" do
|
61
|
-
get :edit, id: user
|
61
|
+
get :edit, params: { id: user }
|
62
62
|
expect(response).to be_success
|
63
63
|
end
|
64
64
|
|
65
65
|
it "returns user" do
|
66
|
-
get :edit, id: user
|
66
|
+
get :edit, params: { id: user }
|
67
67
|
expect(assigns(:user)).to eql user
|
68
68
|
end
|
69
69
|
end
|
@@ -71,7 +71,7 @@ describe Curupira::UsersController do
|
|
71
71
|
context "when user does not exist" do
|
72
72
|
it "renders 404" do
|
73
73
|
expect {
|
74
|
-
get :edit, id: "wrong id"
|
74
|
+
get :edit, params: { id: "wrong id" }
|
75
75
|
}.to raise_error ActiveRecord::RecordNotFound
|
76
76
|
end
|
77
77
|
end
|
@@ -88,18 +88,18 @@ describe Curupira::UsersController do
|
|
88
88
|
group_users_attributes: { "0": { group_id: group.id, role_group_users_attributes: { "0": { role_id: role.id } } } } } }
|
89
89
|
|
90
90
|
it "should redirect to new user" do
|
91
|
-
post :create, user: params
|
91
|
+
post :create, params: { user: params }
|
92
92
|
expect(flash[:notice]).to eql "Usuário criado com sucesso"
|
93
93
|
end
|
94
94
|
|
95
95
|
it "should redirect to new user" do
|
96
|
-
post :create, user: params
|
96
|
+
post :create, params: { user: params }
|
97
97
|
expect(response).to redirect_to assigns(:user)
|
98
98
|
end
|
99
99
|
|
100
100
|
it "creates user" do
|
101
101
|
expect {
|
102
|
-
post :create, user: params
|
102
|
+
post :create, params: { user: params }
|
103
103
|
}.to change { User.count }.by(1)
|
104
104
|
|
105
105
|
expect(assigns[:user].email).to eql "new_email@mail.com"
|
@@ -117,12 +117,12 @@ describe Curupira::UsersController do
|
|
117
117
|
|
118
118
|
it "does not create user" do
|
119
119
|
expect {
|
120
|
-
post :create, user: params
|
120
|
+
post :create, params: { user: params }
|
121
121
|
}.to change { User.count }.by(0)
|
122
122
|
end
|
123
123
|
|
124
124
|
it "should render new" do
|
125
|
-
post :create, user: params
|
125
|
+
post :create, params: { user: params }
|
126
126
|
expect(response).to render_template :new
|
127
127
|
end
|
128
128
|
end
|
@@ -140,19 +140,19 @@ describe Curupira::UsersController do
|
|
140
140
|
group_users_attributes: { "0": { id: group.id, _destroy: true } } } }
|
141
141
|
|
142
142
|
it "sets flash message" do
|
143
|
-
put :update, id: user, user: params
|
143
|
+
put :update, params: { id: user, user: params }
|
144
144
|
expect(flash[:notice]).to eql "Usuário atualizado com sucesso"
|
145
145
|
end
|
146
146
|
|
147
147
|
it "redirects to user" do
|
148
|
-
put :update, id: user, user: params
|
148
|
+
put :update, params: { id: user, user: params }
|
149
149
|
expect(response).to redirect_to assigns(:user)
|
150
150
|
end
|
151
151
|
|
152
152
|
it "updates user" do
|
153
153
|
expect(user.groups).to_not be_empty
|
154
154
|
|
155
|
-
put :update, id: user, user: params
|
155
|
+
put :update, params: { id: user, user: params }
|
156
156
|
expect(assigns(:user).email).to eql "new_email@mail.com"
|
157
157
|
expect(assigns(:user).username).to eql "new_username"
|
158
158
|
expect(assigns(:user).name).to eql "New Name"
|
@@ -167,14 +167,14 @@ describe Curupira::UsersController do
|
|
167
167
|
password: 12345678 } }
|
168
168
|
|
169
169
|
it "does not create user" do
|
170
|
-
put :update, id: user, user: params
|
170
|
+
put :update, params: { id: user, user: params }
|
171
171
|
expect(assigns(:user).reload.email).to eql user.email
|
172
172
|
expect(assigns(:user).reload.username).to eql user.username
|
173
173
|
expect(assigns(:user).reload.name).to eql user.name
|
174
174
|
end
|
175
175
|
|
176
176
|
it "should render edit" do
|
177
|
-
put :update, id: user, user: params
|
177
|
+
put :update, params: { id: user, user: params }
|
178
178
|
expect(response).to render_template :edit
|
179
179
|
end
|
180
180
|
end
|