Skip to content

Commit ef54833

Browse files
committed
Ensure instructions edits set updated timestamp
1 parent 189970c commit ef54833

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

src/actions/projects.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const updateProjectSource = createAction(
2121
export const updateProjectInstructions = createAction(
2222
'UPDATE_PROJECT_INSTRUCTIONS',
2323
(projectKey, newValue) => ({projectKey, newValue}),
24+
(_projectKey, _newValue, timestamp = Date.now()) => ({timestamp}),
2425
);
2526

2627
export const toggleLibrary = createAction(

src/reducers/projects.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ export default function reduceProjects(stateIn, action) {
119119
return state.setIn(
120120
[action.payload.projectKey, 'instructions'],
121121
action.payload.newValue,
122+
).setIn(
123+
[action.payload.projectKey, 'updatedAt'],
124+
action.meta.timestamp,
122125
);
123126

124127
case 'PROJECT_CREATED':

test/unit/reducers/projects.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,16 @@ test('updateProjectSource', reducerTest(
6666
),
6767
));
6868

69-
tap(initProjects({1: false}), projects =>
70-
test('updateProjectInstructions', reducerTest(
71-
reducer,
72-
projects,
73-
partial(updateProjectInstructions, '1', '# Instructions\n\nHello.'),
74-
projects.update('1', projectIn =>
75-
projectIn.set('instructions', '# Instructions\n\nHello.'),
69+
test('updateProjectInstructions', reducerTest(
70+
reducer,
71+
initProjects({[projectKey]: false}),
72+
partial(updateProjectInstructions, projectKey, '# Instructions', now),
73+
initProjects({[projectKey]: true}).
74+
update(
75+
projectKey,
76+
editedProject => editedProject.set('instructions', '# Instructions'),
7677
),
77-
)),
78-
);
78+
));
7979

8080
test('changeCurrentProject', (t) => {
8181
t.test('from modified to pristine', reducerTest(

0 commit comments

Comments
 (0)