sforkowany z mirror/soapbox
				
			Fix Soapbox Config
							rodzic
							
								
									77c7f34e4a
								
							
						
					
					
						commit
						b3de700732
					
				
										
											
												Plik diff jest za duży
												Load Diff
											
										
									
								
							|  | @ -1,5 +1,6 @@ | |||
| import { Record } from 'immutable'; | ||||
| 
 | ||||
| import { ADMIN_CONFIG_UPDATE_REQUEST } from 'soapbox/actions/admin'; | ||||
| import { INSTANCE_REMEMBER_SUCCESS } from 'soapbox/actions/instance'; | ||||
| 
 | ||||
| import reducer from '../instance'; | ||||
|  | @ -116,4 +117,23 @@ describe('instance reducer', () => { | |||
|       expect(result.toJS()).toMatchObject(expected); | ||||
|     }); | ||||
|   }); | ||||
| 
 | ||||
|   describe('ADMIN_CONFIG_UPDATE_REQUEST', () => { | ||||
|     const { configs } = require('soapbox/__fixtures__/pleroma-admin-config.json'); | ||||
| 
 | ||||
|     it('imports the configs', () => { | ||||
|       const action = { | ||||
|         type: ADMIN_CONFIG_UPDATE_REQUEST, | ||||
|         configs, | ||||
|       }; | ||||
| 
 | ||||
|       // The normalizer has `registrations: closed` by default
 | ||||
|       const state = reducer(undefined, {}); | ||||
|       expect(state.registrations).toBe(false); | ||||
| 
 | ||||
|       // After importing the configs, registration will be open
 | ||||
|       const result = reducer(state, action); | ||||
|       expect(result.registrations).toBe(true); | ||||
|     }); | ||||
|   }); | ||||
| }); | ||||
|  |  | |||
|  | @ -52,7 +52,7 @@ const getConfigValue = (instanceConfig: ImmutableMap<string, any>, key: string) | |||
|   return v ? v.getIn(['tuple', 1]) : undefined; | ||||
| }; | ||||
| 
 | ||||
| const importConfigs = (state: typeof initialState, configs: ImmutableMap<string, any>) => { | ||||
| const importConfigs = (state: typeof initialState, configs: ImmutableList<any>) => { | ||||
|   // FIXME: This is pretty hacked together. Need to make a cleaner map.
 | ||||
|   const config = ConfigDB.find(configs, ':pleroma', ':instance'); | ||||
|   const simplePolicy = ConfigDB.toSimplePolicy(configs); | ||||
|  | @ -126,7 +126,7 @@ export default function instance(state = initialState, action: AnyAction) { | |||
|     return importNodeinfo(state, ImmutableMap(fromJS(action.nodeinfo))); | ||||
|   case ADMIN_CONFIG_UPDATE_REQUEST: | ||||
|   case ADMIN_CONFIG_UPDATE_SUCCESS: | ||||
|     return importConfigs(state, ImmutableMap(fromJS(action.configs))); | ||||
|     return importConfigs(state, ImmutableList(fromJS(action.configs))); | ||||
|   default: | ||||
|     return state; | ||||
|   } | ||||
|  |  | |||
		Ładowanie…
	
		Reference in New Issue
	
	 Alex Gleason
						Alex Gleason