Skip to content

Commit f3fe918

Browse files
committed
Remove the default kind from Push
1 parent a313b70 commit f3fe918

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

app/models/push.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
require "addressable/uri"
44

55
class Push < ApplicationRecord
6-
enum :kind, [:text, :file, :url], default: :text, validate: true
6+
enum :kind, [:text, :file, :url], validate: true
77

88
validate :check_enabled_push_kinds
99
validates :url_token, presence: true, uniqueness: true

test/unit/password_unit_test.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
class PasswordUnitTest < Minitest::Test
66
def test_save
7-
password = Push.create(payload: "asdf")
7+
password = Push.create(kind: "text", payload: "asdf")
88
password.check_limits
99
assert password.save
1010
end
1111

1212
def test_kind_validation
13-
password = Push.create(payload: "asdf")
13+
password = Push.create(kind: "text", payload: "asdf")
1414
password.valid?
1515
assert password.errors[:kind].none?
1616

@@ -28,19 +28,19 @@ def test_kind_validation
2828
end
2929

3030
def test_expired_check
31-
password = Push.create(payload: "asdf")
31+
password = Push.create(kind: "text", payload: "asdf")
3232
password.check_limits
3333
assert_not password.expired?
3434

35-
password = Push.create(payload: "asdf", created_at: 100.weeks.ago, updated_at: 100.weeks.ago)
35+
password = Push.create(kind: "text", payload: "asdf", created_at: 100.weeks.ago, updated_at: 100.weeks.ago)
3636
assert password
3737

3838
password.check_limits
3939
assert password.expired?
4040
end
4141

4242
def test_defaults
43-
push = Push.create(created_at: 3.days.ago, updated_at: 3.days.ago, payload: "asdf")
43+
push = Push.create(kind: "text", created_at: 3.days.ago, updated_at: 3.days.ago, payload: "asdf")
4444

4545
assert push.expire_after_days == Settings.pw.expire_after_days_default
4646
assert push.expire_after_views == Settings.pw.expire_after_views_default
@@ -51,7 +51,7 @@ def test_defaults
5151

5252
def test_days_expiration
5353
# 3 days left
54-
push = Push.create(created_at: 3.days.ago, updated_at: 3.days.ago,
54+
push = Push.create(kind: "text", created_at: 3.days.ago, updated_at: 3.days.ago,
5555
payload: "asdf", expire_after_days: 6)
5656
push.check_limits
5757

@@ -60,7 +60,7 @@ def test_days_expiration
6060
assert_not push.expired
6161

6262
# already expired
63-
push = Push.create(created_at: 3.days.ago, updated_at: 3.days.ago,
63+
push = Push.create(kind: "text", created_at: 3.days.ago, updated_at: 3.days.ago,
6464
payload: "asdf", expire_after_days: 1)
6565
push.check_limits
6666

@@ -69,7 +69,7 @@ def test_days_expiration
6969
assert push.expired
7070

7171
# Old expired push
72-
push = Push.create(created_at: 100.days.ago, updated_at: 100.days.ago,
72+
push = Push.create(kind: "text", created_at: 100.days.ago, updated_at: 100.days.ago,
7373
payload: "asdf", expire_after_days: 1)
7474
push.check_limits
7575

@@ -78,7 +78,7 @@ def test_days_expiration
7878
assert push.expired
7979

8080
# Today 1 day password
81-
push = Push.create(payload: "asdf", expire_after_days: 1)
81+
push = Push.create(kind: "text", payload: "asdf", expire_after_days: 1)
8282
push.check_limits
8383

8484
assert push.days_old.zero?
@@ -88,14 +88,14 @@ def test_days_expiration
8888

8989
def test_views_expiration
9090
# No views
91-
push = Push.create(payload: "asdf", expire_after_views: 1)
91+
push = Push.create(kind: "text", payload: "asdf", expire_after_views: 1)
9292
push.check_limits
9393

9494
assert push.views_remaining == 1
9595
assert_not push.expired
9696

9797
# 1 View should expire
98-
push = Push.create(payload: "asdf", expire_after_views: 1)
98+
push = Push.create(kind: "text", payload: "asdf", expire_after_views: 1)
9999
push.check_limits
100100

101101
assert push.views_remaining == 1

0 commit comments

Comments
 (0)