Открыть боковую панель
nt_test121
nt_project_9da4a5yt9x4b
Коммиты
59b6564e
Коммит
59b6564e
создал
Окт 15, 2015
по автору
Valery Sizov
Просмотр файлов
address comments
владелец
dc9100d1
Изменения
3
Скрыть пробелы
Построчно
Рядом
app/models/project_services/teamcity_service.rb
Просмотр файла @
59b6564e
...
...
@@ -45,7 +45,7 @@ def compose_service_hook
end
def
reset_password
if
prop_updated?
(
:teamcity_url
)
&&
!
p
rop_updated?
(
:password
)
if
prop_updated?
(
:teamcity_url
)
&&
!
p
assword_touched?
self
.
password
=
nil
end
end
...
...
app/models/service.rb
Просмотр файла @
59b6564e
...
...
@@ -125,8 +125,9 @@ def #{arg}=(value)
# ActiveRecord does not provide a mechanism to track changes in serialized keys.
# This is why we need to perform extra query to do it mannually.
def
prop_updated?
(
prop_name
)
return
false
if
send
(
"
#{
prop_name
}
_was"
).
nil?
send
(
"
#{
prop_name
}
_was"
)
!=
send
(
prop_name
)
value_was
=
send
(
"
#{
prop_name
}
_was"
)
return
false
if
value_was
.
nil?
value_was
!=
send
(
prop_name
)
end
def
async_execute
(
data
)
...
...
spec/models/project_services/teamcity_service_spec.rb
Просмотр файла @
59b6564e
...
...
@@ -41,18 +41,19 @@
)
end
it
"reset password if url changed"
do
it
"reset password if url
is
changed"
do
@teamcity_service
.
teamcity_url
=
'http://gitlab1.com'
@teamcity_service
.
save
expect
(
@teamcity_service
.
password
).
to
be_nil
end
it
"does not reset password if username changed"
do
it
"does not reset password if username
is
changed"
do
@teamcity_service
.
username
=
"some_name"
@teamcity_service
.
save
expect
(
@teamcity_service
.
password
).
to
eq
(
"password"
)
end
it
"does not reset password if new url is set together with password"
do
@teamcity_service
.
teamcity_url
=
'http://gitlab_edited.com'
@teamcity_service
.
password
=
'123'
...
...
@@ -60,5 +61,41 @@
expect
(
@teamcity_service
.
password
).
to
eq
(
"123"
)
expect
(
@teamcity_service
.
teamcity_url
).
to
eq
(
"http://gitlab_edited.com"
)
end
it
"does not reset password if new url is set together with password, even if it's the same password"
do
@teamcity_service
.
teamcity_url
=
'http://gitlab_edited.com'
@teamcity_service
.
password
=
'password'
@teamcity_service
.
save
expect
(
@teamcity_service
.
password
).
to
eq
(
"password"
)
expect
(
@teamcity_service
.
teamcity_url
).
to
eq
(
"http://gitlab_edited.com"
)
end
context
"when no password was set before"
do
before
do
@teamcity_service
=
TeamcityService
.
create
(
project:
create
(
:project
),
properties:
{
teamcity_url:
'http://gitlab.com'
,
username:
'mic'
}
)
end
it
"saves password if new url is set together with password"
do
@teamcity_service
.
teamcity_url
=
'http://gitlab_edited.com'
@teamcity_service
.
password
=
'password'
@teamcity_service
.
save
expect
(
@teamcity_service
.
password
).
to
eq
(
"password"
)
expect
(
@teamcity_service
.
teamcity_url
).
to
eq
(
"http://gitlab_edited.com"
)
end
end
it
"resets password if url is changed, even if setter called multiple times"
do
@teamcity_service
.
teamcity_url
=
'http://gitlab1.com'
@teamcity_service
.
teamcity_url
=
'http://gitlab1.com'
@teamcity_service
.
save
expect
(
@teamcity_service
.
password
).
to
be_nil
end
end
end
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать