File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change 1
1
class ExpoPushToken < ActiveRecord ::Base
2
2
belongs_to :user
3
3
4
- validates_presence_of :token
5
- validates_uniqueness_of :token
6
- validates_presence_of :user
4
+ validates :token , presence : true , uniqueness : { scope : :user }
5
+ validates :user , presence : true
7
6
end
8
7
Original file line number Diff line number Diff line change @@ -34,6 +34,19 @@ class ExpoPushTokensTest < Redmine::ApiTest::Base
34
34
end
35
35
end
36
36
37
+ test 'should not create same token twice' do
38
+ assert_difference "ExpoPushToken.count" do
39
+ post "/expo_push_tokens.json" ,
40
+ params : @payload ,
41
+ headers : { "CONTENT_TYPE" => 'application/json' } . merge ( @creds )
42
+ assert_response 201
43
+ post "/expo_push_tokens.json" ,
44
+ params : @payload ,
45
+ headers : { "CONTENT_TYPE" => 'application/json' } . merge ( @creds )
46
+ assert_response 422
47
+ end
48
+ end
49
+
37
50
test 'should require token' do
38
51
assert_no_difference "ExpoPushToken.count" do
39
52
post "/expo_push_tokens.json" ,
@@ -79,7 +92,7 @@ class ExpoPushTokensTest < Redmine::ApiTest::Base
79
92
assert_difference "ExpoPushToken.count" , -1 do
80
93
delete "/expo_push_tokens" , params : { user_id : @jsmith . id }
81
94
end
82
- assert_redirected_to "/users/#{ @jsmith . id } "
95
+ assert_redirected_to "/users/#{ @jsmith . id } /edit "
83
96
84
97
assert_raise ActiveRecord ::RecordNotFound do
85
98
@t2 . reload
You can’t perform that action at this time.
0 commit comments