Replace hardcoded user id with a reference to the relevant user fixture
This makes it easier to figure out what the 1 refers to.
This commit is contained in:
parent
7725cd59b4
commit
2e9baaa50a
1 changed files with 13 additions and 13 deletions
|
@ -92,10 +92,10 @@ class UserPreferenceControllerTest < ActionController::TestCase
|
||||||
put :update
|
put :update
|
||||||
end
|
end
|
||||||
assert_response :unauthorized, "should be authenticated"
|
assert_response :unauthorized, "should be authenticated"
|
||||||
assert_equal "value", UserPreference.find([1, "key"]).v
|
assert_equal "value", UserPreference.find([users(:normal_user).id, "key"]).v
|
||||||
assert_equal "some_value", UserPreference.find([1, "some_key"]).v
|
assert_equal "some_value", UserPreference.find([users(:normal_user).id, "some_key"]).v
|
||||||
assert_raises ActiveRecord::RecordNotFound do
|
assert_raises ActiveRecord::RecordNotFound do
|
||||||
UserPreference.find([1, "new_key"])
|
UserPreference.find([users(:normal_user).id, "new_key"])
|
||||||
end
|
end
|
||||||
|
|
||||||
# authenticate as a user with preferences
|
# authenticate as a user with preferences
|
||||||
|
@ -109,10 +109,10 @@ class UserPreferenceControllerTest < ActionController::TestCase
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal "text/plain", @response.content_type
|
assert_equal "text/plain", @response.content_type
|
||||||
assert_equal "", @response.body
|
assert_equal "", @response.body
|
||||||
assert_equal "new_value", UserPreference.find([1, "key"]).v
|
assert_equal "new_value", UserPreference.find([users(:normal_user).id, "key"]).v
|
||||||
assert_equal "value", UserPreference.find([1, "new_key"]).v
|
assert_equal "value", UserPreference.find([users(:normal_user).id, "new_key"]).v
|
||||||
assert_raises ActiveRecord::RecordNotFound do
|
assert_raises ActiveRecord::RecordNotFound do
|
||||||
UserPreference.find([1, "some_key"])
|
UserPreference.find([users(:normal_user).id, "some_key"])
|
||||||
end
|
end
|
||||||
|
|
||||||
# try a put with duplicate keys
|
# try a put with duplicate keys
|
||||||
|
@ -123,7 +123,7 @@ class UserPreferenceControllerTest < ActionController::TestCase
|
||||||
assert_response :bad_request
|
assert_response :bad_request
|
||||||
assert_equal "text/plain", @response.content_type
|
assert_equal "text/plain", @response.content_type
|
||||||
assert_equal "Duplicate preferences with key key", @response.body
|
assert_equal "Duplicate preferences with key key", @response.body
|
||||||
assert_equal "new_value", UserPreference.find([1, "key"]).v
|
assert_equal "new_value", UserPreference.find([users(:normal_user).id, "key"]).v
|
||||||
|
|
||||||
# try a put with invalid content
|
# try a put with invalid content
|
||||||
assert_no_difference "UserPreference.count" do
|
assert_no_difference "UserPreference.count" do
|
||||||
|
@ -143,7 +143,7 @@ class UserPreferenceControllerTest < ActionController::TestCase
|
||||||
end
|
end
|
||||||
assert_response :unauthorized, "should be authenticated"
|
assert_response :unauthorized, "should be authenticated"
|
||||||
assert_raises ActiveRecord::RecordNotFound do
|
assert_raises ActiveRecord::RecordNotFound do
|
||||||
UserPreference.find([1, "new_key"])
|
UserPreference.find([users(:normal_user).id, "new_key"])
|
||||||
end
|
end
|
||||||
|
|
||||||
# authenticate as a user with preferences
|
# authenticate as a user with preferences
|
||||||
|
@ -157,7 +157,7 @@ class UserPreferenceControllerTest < ActionController::TestCase
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal "text/plain", @response.content_type
|
assert_equal "text/plain", @response.content_type
|
||||||
assert_equal "", @response.body
|
assert_equal "", @response.body
|
||||||
assert_equal "new_value", UserPreference.find([1, "new_key"]).v
|
assert_equal "new_value", UserPreference.find([users(:normal_user).id, "new_key"]).v
|
||||||
|
|
||||||
# try changing the value of a preference
|
# try changing the value of a preference
|
||||||
assert_no_difference "UserPreference.count" do
|
assert_no_difference "UserPreference.count" do
|
||||||
|
@ -167,7 +167,7 @@ class UserPreferenceControllerTest < ActionController::TestCase
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal "text/plain", @response.content_type
|
assert_equal "text/plain", @response.content_type
|
||||||
assert_equal "", @response.body
|
assert_equal "", @response.body
|
||||||
assert_equal "newer_value", UserPreference.find([1, "new_key"]).v
|
assert_equal "newer_value", UserPreference.find([users(:normal_user).id, "new_key"]).v
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -178,7 +178,7 @@ class UserPreferenceControllerTest < ActionController::TestCase
|
||||||
delete :delete_one, :preference_key => "key"
|
delete :delete_one, :preference_key => "key"
|
||||||
end
|
end
|
||||||
assert_response :unauthorized, "should be authenticated"
|
assert_response :unauthorized, "should be authenticated"
|
||||||
assert_equal "value", UserPreference.find([1, "key"]).v
|
assert_equal "value", UserPreference.find([users(:normal_user).id, "key"]).v
|
||||||
|
|
||||||
# authenticate as a user with preferences
|
# authenticate as a user with preferences
|
||||||
basic_authorization("test@openstreetmap.org", "test")
|
basic_authorization("test@openstreetmap.org", "test")
|
||||||
|
@ -191,7 +191,7 @@ class UserPreferenceControllerTest < ActionController::TestCase
|
||||||
assert_equal "text/plain", @response.content_type
|
assert_equal "text/plain", @response.content_type
|
||||||
assert_equal "", @response.body
|
assert_equal "", @response.body
|
||||||
assert_raises ActiveRecord::RecordNotFound do
|
assert_raises ActiveRecord::RecordNotFound do
|
||||||
UserPreference.find([1, "key"])
|
UserPreference.find([users(:normal_user).id, "key"])
|
||||||
end
|
end
|
||||||
|
|
||||||
# try the delete again for the same key
|
# try the delete again for the same key
|
||||||
|
@ -200,7 +200,7 @@ class UserPreferenceControllerTest < ActionController::TestCase
|
||||||
end
|
end
|
||||||
assert_response :not_found
|
assert_response :not_found
|
||||||
assert_raises ActiveRecord::RecordNotFound do
|
assert_raises ActiveRecord::RecordNotFound do
|
||||||
UserPreference.find([1, "key"])
|
UserPreference.find([users(:normal_user).id, "key"])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue