diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb
index 87c02c73..f431d867 100644
--- a/app/controllers/posts_controller.rb
+++ b/app/controllers/posts_controller.rb
@@ -39,8 +39,9 @@ class PostsController < ApplicationController
def update
post = Post.find(params[:id])
- if current_user.role == :user && current_user.id != post.user_id
+ if current_user.role == 'user' && current_user.id != post.user_id
render json: I18n.t('errors.unauthorized'), status: :unauthorized
+ return
end
post.post_status_id = params[:post][:post_status_id]
diff --git a/app/javascript/components/Board/PostListItem.tsx b/app/javascript/components/Board/PostListItem.tsx
index 5abc6103..d2bed224 100644
--- a/app/javascript/components/Board/PostListItem.tsx
+++ b/app/javascript/components/Board/PostListItem.tsx
@@ -1,5 +1,7 @@
import * as React from 'react';
+import PostStatusLabel from '../shared/PostStatusLabel';
+
import IPostStatus from '../../interfaces/IPostStatus';
interface Props {
@@ -26,15 +28,7 @@ const PostListItem = ({ id, title, description, postStatus}: Props) => (
0 comments
- {
- postStatus ?
-
- :
- null
- }
+ { postStatus ? : null }
diff --git a/app/javascript/components/Board/PostStatusListItem.tsx b/app/javascript/components/Board/PostStatusListItem.tsx
index d60365ff..e793cec6 100644
--- a/app/javascript/components/Board/PostStatusListItem.tsx
+++ b/app/javascript/components/Board/PostStatusListItem.tsx
@@ -1,5 +1,7 @@
import * as React from 'react';
+import PostStatusLabel from '../shared/PostStatusLabel';
+
interface Props {
name: string;
color: string;
@@ -19,8 +21,7 @@ const PostStatusListItem = ({
{
diff --git a/app/javascript/components/Post/PostP.tsx b/app/javascript/components/Post/PostP.tsx
index 3df02d54..36ffd661 100644
--- a/app/javascript/components/Post/PostP.tsx
+++ b/app/javascript/components/Post/PostP.tsx
@@ -4,6 +4,7 @@ import IPost from '../../interfaces/IPost';
import IPostStatus from '../../interfaces/IPostStatus';
import PostStatusSelect from './PostStatusSelect';
+import PostStatusLabel from '../shared/PostStatusLabel';
interface Props {
postId: number;
@@ -39,9 +40,9 @@ class PostP extends React.Component
{
return (
-
{post.title}
+
{post.title}
{
- isPowerUser ?
+ isPowerUser && post ?
{
}
/>
:
- LLL
+ postStatus.id === post.postStatusId)}
+ />
}
{post.description}
diff --git a/app/javascript/components/Post/PostStatusSelect.tsx b/app/javascript/components/Post/PostStatusSelect.tsx
index 9270cf50..f18085ae 100644
--- a/app/javascript/components/Post/PostStatusSelect.tsx
+++ b/app/javascript/components/Post/PostStatusSelect.tsx
@@ -18,7 +18,7 @@ const PostStatusSelect = ({
handleChange,
}: Props) => (
);
diff --git a/app/javascript/components/shared/PostStatusLabel.tsx b/app/javascript/components/shared/PostStatusLabel.tsx
new file mode 100644
index 00000000..ddbe3f9c
--- /dev/null
+++ b/app/javascript/components/shared/PostStatusLabel.tsx
@@ -0,0 +1,16 @@
+import * as React from 'react';
+
+import IPostStatus from '../../interfaces/IPostStatus';
+
+const PostStatusLabel = ({
+ id,
+ name,
+ color,
+}: IPostStatus) => (
+
+);
+
+export default PostStatusLabel;
\ No newline at end of file
diff --git a/app/javascript/containers/Post.tsx b/app/javascript/containers/Post.tsx
index 3c1e6028..9c129bef 100644
--- a/app/javascript/containers/Post.tsx
+++ b/app/javascript/containers/Post.tsx
@@ -17,6 +17,8 @@ const mapDispatchToProps = (dispatch) => ({
},
changePostStatus(postId: number, newPostStatusId: number, authenticityToken: string) {
+ if (isNaN(newPostStatusId)) newPostStatusId = null;
+
dispatch(changePostStatus(postId, newPostStatusId, authenticityToken));
},
});
diff --git a/app/javascript/stylesheets/application.scss b/app/javascript/stylesheets/application.scss
index df8a3c01..e4f0a69b 100644
--- a/app/javascript/stylesheets/application.scss
+++ b/app/javascript/stylesheets/application.scss
@@ -9,4 +9,14 @@
.gravatar {
border-radius: 16px;
+}
+
+.dot {
+ width: 16px;
+ height: 16px;
+ border-radius: 100%;
+
+ margin-top: auto;
+ margin-bottom: auto;
+ margin-right: 4px;
}
\ No newline at end of file
diff --git a/app/javascript/stylesheets/components/Board.scss b/app/javascript/stylesheets/components/Board.scss
index a7633d77..a6be7ec9 100644
--- a/app/javascript/stylesheets/components/Board.scss
+++ b/app/javascript/stylesheets/components/Board.scss
@@ -199,16 +199,6 @@
}
}
-.dot {
- width: 16px;
- height: 16px;
- border-radius: 100%;
-
- margin-top: auto;
- margin-bottom: auto;
- margin-right: 4px;
-}
-
.infoText {
display: block;
text-align: center;
diff --git a/app/javascript/stylesheets/components/Roadmap.scss b/app/javascript/stylesheets/components/Roadmap.scss
index a1cbd07a..3aa222f7 100644
--- a/app/javascript/stylesheets/components/Roadmap.scss
+++ b/app/javascript/stylesheets/components/Roadmap.scss
@@ -34,12 +34,6 @@
border-bottom-width: 1px;
margin-bottom: 8px;
}
-
- .dot {
- width: 16px;
- height: 16px;
- border-radius: 100%;
- }
.infoText {
text-align: center;
@@ -47,7 +41,6 @@
}
.columnTitle {
- margin: 0 8px;
font-weight: 700;
}
diff --git a/spec/routing/post_routing_spec.rb b/spec/routing/post_routing_spec.rb
index 13da956b..14427426 100644
--- a/spec/routing/post_routing_spec.rb
+++ b/spec/routing/post_routing_spec.rb
@@ -8,10 +8,14 @@ RSpec.describe 'posts routing', :aggregate_failures, type: :routing do
expect(post: '/posts').to route_to(
controller: 'posts', action: 'create'
)
+ expect(get: '/posts/1').to route_to(
+ controller: 'posts', action: 'show', id: '1'
+ )
+ expect(patch: '/posts/1').to route_to(
+ controller: 'posts', action: 'update', id: '1'
+ )
- expect(get: '/posts/1').not_to be_routable
expect(get: '/posts/1/edit').not_to be_routable
- expect(patch: '/posts/1').not_to be_routable
expect(delete: '/posts/1').not_to be_routable
end
end
\ No newline at end of file