@@ -5,6 +5,7 @@ const request = require( "supertest" );
55const nock = require ( "nock" ) ;
66const fs = require ( "fs" ) ;
77const config = require ( "../../../config" ) ;
8+ const testHelper = require ( "../../../lib/test_helper" ) ;
89
910const fixtures = JSON . parse ( fs . readFileSync ( "schema/fixtures.js" ) ) ;
1011
@@ -247,6 +248,55 @@ describe( "Users", ( ) => {
247248 . expect ( 200 , done ) ;
248249 } ) ;
249250
251+ it ( "returns monthly supporter = true even if user does not prefer to show the monthly badge" , async function ( ) {
252+ const userPG = {
253+ id : 2025101011 ,
254+ created_at : "2025-10-10 00:00:00" ,
255+ updated_at : "2025-10-10 00:00:00" ,
256+ last_active : "2025-10-10" ,
257+ login : "20251011_monthly_supporter" ,
258+ name : "Monthly Supporter" ,
259+ site_id : 1 ,
260+ donorbox_plan_status : "active" ,
261+ donorbox_plan_type : "monthly"
262+ } ;
263+ const userES = {
264+ id : 2025101011 ,
265+ login : "20251011_monthly_supporter" ,
266+ suspended : false
267+ } ;
268+ const preferencePG = {
269+ id : 2025101013 ,
270+ name : "prefers_monthly_supporter_badge" ,
271+ owner_id : 2025101011 ,
272+ owner_type : "User" ,
273+ value : "f"
274+ } ;
275+ const userPGIds = await testHelper . insertJSObjectsIntoPostgresTable ( "users" , [ userPG ] ) ;
276+ const preferencePGIds = await testHelper . insertJSObjectsIntoPostgresTable ( "preferences" , [ preferencePG ] ) ;
277+ const userESIds = await testHelper . insertJSObjectsIntoESIndex ( "users" , [ userES ] ) ;
278+ const cleanUp = async ( ) => {
279+ await testHelper . deleteIdsFromPostgresTable ( "users" , userPGIds ) ;
280+ await testHelper . deleteIdsFromPostgresTable ( "preferences" , preferencePGIds ) ;
281+ await testHelper . deleteIdsFromESIndex ( "users" , userESIds ) ;
282+ } ;
283+
284+ const token = jwt . sign ( { user_id : 2025101011 } ,
285+ config . jwtSecret || "secret" ,
286+ { algorithm : "HS512" } ) ;
287+ try {
288+ await request ( this . app ) . get ( "/v1/users/me" ) . set ( "Authorization" , token )
289+ . expect ( res => {
290+ expect ( res . body . total_results ) . to . eq ( 1 ) ;
291+ expect ( res . body . results [ 0 ] . monthly_supporter ) . to . eq ( true ) ;
292+ } )
293+ . expect ( "Content-Type" , / j s o n / )
294+ . expect ( 200 ) ;
295+ } finally {
296+ await cleanUp ( ) ;
297+ }
298+ } ) ;
299+
250300 _ . each ( [
251301 "confirmation_sent_at" ,
252302 "confirmed_at" ,
0 commit comments