lib/card/auth/setup.rb in card-1.97.0 vs lib/card/auth/setup.rb in card-1.97.0.1

- old
+ new

@@ -19,20 +19,36 @@ # @param mode [true/false] simulate setup need if true def simulate_setup_need! mode=true @simulating_setup_need = mode end + # for testing setup + def hide_accounts! mode=true + Card.cache.delete(SETUP_COMPLETED_KEY) if mode + @hidden_accounts = mode && (account_ids - [WagnBotID, AnonymousID]) + end + + def account_ids + as_bot do + Card.search right_id: AccountID, + not: { left_id: ["in", WagnBotID, AnonymousID] }, + return: :id + end + end + def instant_account_activation simulate_setup_need! yield ensure simulate_setup_need! false end private def account_count - as_bot { Card.count_by_wql right: Card[:account].name } + wql = { right_id: AccountID } + wql[:not] = { id: ["in"].concat(@hidden_accounts) } if @hidden_accounts + as_bot { Card.count_by_wql wql } end end end end