Skip to content

Commit

Permalink
fix(user): correct user login and user set role names
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickocoffeyo committed Jun 6, 2018
1 parent 549b721 commit 8a7f982
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/actions/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function* userLogIn({ username, password }) {
*/
export function* userLogOut() {
yield put({
type: USER_LOG_OUT
type: `${USER_LOG_OUT}_SUCCESS`
});
}

Expand All @@ -57,7 +57,7 @@ export function* userLogOut() {
*/
export function* userSetRole(role) {
yield put({
type: USER_SET_ROLE,
type: `${USER_SET_ROLE}_SUCCESS`,
payload: {
role
}
Expand Down
4 changes: 2 additions & 2 deletions src/actions/user.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('actions->user', () => {
testSaga(userLogOut)
.next()
.put({
type: USER_LOG_OUT
type: `${USER_LOG_OUT}_SUCCESS`
})
.next()
.isDone();
Expand All @@ -69,7 +69,7 @@ describe('actions->user', () => {
testSaga(userSetRole, USER_ROLE_EDITOR)
.next()
.put({
type: USER_SET_ROLE,
type: `${USER_SET_ROLE}_SUCCESS`,
payload: {
role: USER_ROLE_EDITOR
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/App/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ const App = () => (
redirectTo="/dashboard"
component={Login}
/>
<PrivateRoute exact path="/logout" redirectTo="/" component={Logout} />
<PrivateRoute
exact
path="/dashboard"
redirectTo="/login"
component={Dashboard}
/>
<PrivateRoute exact path="/logout" redirectTo="/" component={Logout} />
</Switch>
</Router>
</Fragment>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Logout/Logout.container.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ const mapDispatchToProps = dispatch => ({
dispatch
});

const mapState = () => ({});
const mapState = ({ user }) => ({ user });

export default connect(mapState, mapDispatchToProps)(Logout);
4 changes: 2 additions & 2 deletions src/reducers/__snapshots__/user.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Object {
}
`;

exports[`reducers->user Should handle USER_LOG_OUT 1`] = `
exports[`reducers->user Should handle USER_LOG_OUT_SUCCESS 1`] = `
Object {
"authentication": Object {
"accessToken": null,
Expand All @@ -68,7 +68,7 @@ Object {
}
`;

exports[`reducers->user Should handle USER_SET_ROLE 1`] = `
exports[`reducers->user Should handle USER_SET_ROLE_SUCCESS 1`] = `
Object {
"authentication": Object {
"accessToken": null,
Expand Down
6 changes: 3 additions & 3 deletions src/reducers/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ export default function user(state = defaultState, action) {
/**
* Reducer that handles user logout actions.
*/
case USER_LOG_OUT: {
return { ...defaultState };
case `${USER_LOG_OUT}_SUCCESS`: {
return defaultState;
}

/**
* Reducer that handles setting a user's role.
*/
case USER_SET_ROLE: {
case `${USER_SET_ROLE}_SUCCESS`: {
const { role } = action.payload;
return { ...state, authentication: { ...state.authentication, role } };
}
Expand Down
8 changes: 4 additions & 4 deletions src/reducers/user.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,18 @@ describe('reducers->user', () => {
).toMatchSnapshot();
});

it(`Should handle ${USER_LOG_OUT}`, () => {
it(`Should handle ${USER_LOG_OUT}_SUCCESS`, () => {
expect(
reducer(undefined, {
type: USER_LOG_OUT
type: `${USER_LOG_OUT}_SUCCESS`
})
).toMatchSnapshot();
});

it(`Should handle ${USER_SET_ROLE}`, () => {
it(`Should handle ${USER_SET_ROLE}_SUCCESS`, () => {
expect(
reducer(undefined, {
type: USER_SET_ROLE,
type: `${USER_SET_ROLE}_SUCCESS`,
payload: {
role: USER_ROLE_EDITOR
}
Expand Down

0 comments on commit 8a7f982

Please sign in to comment.