File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,21 +14,13 @@ class Account < ApplicationRecord
1414
1515 after_create :create_default_shop!
1616
17- def personal_account_for? ( shopkeeper )
18- personal? && owner? ( shopkeeper )
19- end
20-
2117 def admin? ( shopkeeper )
2218 accounts_shopkeeper = AccountsShopkeeper . find_by ( account : self , shopkeeper : shopkeeper )
2319 return false if accounts_shopkeeper . blank?
2420
2521 accounts_shopkeeper . admin?
2622 end
2723
28- def owner? ( user )
29- owner_id == user . id
30- end
31-
3224 private
3325
3426 def create_default_shop!
Original file line number Diff line number Diff line change @@ -12,9 +12,6 @@ class AccountsInvitation < ApplicationRecord
1212
1313 before_create :set_token
1414
15- scope :active , -> { where ( created_at : EXPIRES_IN . ago ..) }
16- scope :expired , -> { where ( created_at : ...EXPIRES_IN . ago ) }
17-
1815 def expired?
1916 created_at < EXPIRES_IN . ago
2017 end
Original file line number Diff line number Diff line change @@ -25,9 +25,6 @@ class Shopkeeper < ApplicationRecord
2525 presence : true ,
2626 inclusion : { in : %w[ ios android ] }
2727
28- scope :android , -> { where ( current_platform : "android" ) }
29- scope :ios , -> { where ( current_platform : "ios" ) }
30-
3128 # override devise method to include additional info as opts hash
3229 def send_confirmation_instructions ( opts = { } )
3330 generate_confirmation_token! unless @raw_confirmation_token
Original file line number Diff line number Diff line change @@ -43,27 +43,6 @@ def setup
4343 assert_not_includes Account . team , personal_account
4444 end
4545
46- test "personal_account_for? returns true for owner's personal account" do
47- account = Account . create! ( name : "Personal" , owner : @shopkeeper , personal : true )
48- assert account . personal_account_for? ( @shopkeeper )
49- end
50-
51- test "personal_account_for? returns false for team account" do
52- account = Account . create! ( name : "Team" , owner : @shopkeeper , personal : false )
53- assert_not account . personal_account_for? ( @shopkeeper )
54- end
55-
56- test "owner? returns true for account owner" do
57- account = Account . create! ( name : "Test Account" , owner : @shopkeeper )
58- assert account . owner? ( @shopkeeper )
59- end
60-
61- test "owner? returns false for non-owner" do
62- other_shopkeeper = shopkeepers ( :two )
63- account = Account . create! ( name : "Test Account" , owner : @shopkeeper )
64- assert_not account . owner? ( other_shopkeeper )
65- end
66-
6746 test "admin? returns true when shopkeeper is admin" do
6847 account = Account . create! ( name : "Test Account" , owner : @shopkeeper )
6948 AccountsShopkeeper . create! (
Original file line number Diff line number Diff line change @@ -299,27 +299,6 @@ def setup
299299 end
300300 end
301301
302- test "active scope returns non-expired invitations" do
303- active_invitation = AccountsInvitation . create! (
304- account : @account ,
305- name : "Active User" ,
306- email : "active_scope@example.com" ,
307- junior_member : true
308- )
309-
310- expired_invitation = AccountsInvitation . create! (
311- account : @account ,
312- name : "Expired User" ,
313- email : "expired_scope@example.com" ,
314- junior_member : true
315- )
316- expired_invitation . update_column ( :created_at , ( AccountsInvitation ::EXPIRES_IN + 1 . minute ) . ago )
317-
318- active_invitations = AccountsInvitation . active
319- assert_includes active_invitations , active_invitation
320- assert_not_includes active_invitations , expired_invitation
321- end
322-
323302 test "resend_invite touches created_at and sends invite" do
324303 invitation = AccountsInvitation . create! (
325304 account : @account ,
Original file line number Diff line number Diff line change @@ -66,20 +66,6 @@ class ShopkeeperTest < ActiveSupport::TestCase
6666 assert shopkeeper . valid?
6767 end
6868
69- test "android scope returns android shopkeepers" do
70- shopkeeper = shopkeepers ( :one )
71- shopkeeper . update! ( current_platform : "android" )
72-
73- assert_includes Shopkeeper . android , shopkeeper
74- end
75-
76- test "ios scope returns ios shopkeepers" do
77- shopkeeper = shopkeepers ( :one )
78- shopkeeper . update! ( current_platform : "ios" )
79-
80- assert_includes Shopkeeper . ios , shopkeeper
81- end
82-
8369 test "should have many shops through accounts" do
8470 shopkeeper = shopkeepers ( :one )
8571 shopkeeper . create_default_account
You can’t perform that action at this time.
0 commit comments