unsakini 0.0.3.1 → 0.0.4.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +37 -6
- data/angular/angular-cli.json +5 -3
- data/angular/npm-debug.log +54 -0
- data/angular/package.json +4 -1
- data/angular/src/app/app.component.html +1 -4
- data/angular/src/app/app.module.ts +8 -7
- data/angular/src/app/app.routes.module.ts +12 -2
- data/angular/src/app/confirm-account/confirm-account.component.ts +27 -0
- data/angular/src/app/confirm-account/confirm-account.html +41 -0
- data/angular/src/app/confirm-account/confirm-account.module.ts +24 -0
- data/angular/src/app/confirm-account/confirm-account.scss +3 -0
- data/angular/src/app/confirm-account/confirm-account.service.ts +27 -0
- data/angular/src/app/confirm-account/index.ts +3 -0
- data/angular/src/app/index.ts +2 -0
- data/angular/src/app/login/index.ts +3 -0
- data/angular/src/app/login/login.component.ts +40 -0
- data/angular/src/app/login/login.html +43 -0
- data/angular/src/app/login/login.module.ts +27 -0
- data/angular/src/app/login/login.service.ts +48 -0
- data/angular/src/app/registration/index.ts +3 -0
- data/angular/src/app/registration/registration.component.html +70 -12
- data/angular/src/app/registration/registration.component.spec.ts +8 -11
- data/angular/src/app/registration/registration.component.ts +10 -8
- data/angular/src/app/registration/registration.module.ts +23 -0
- data/angular/src/app/registration/registration.service.ts +46 -0
- data/angular/src/app/registration/registration.services.spec.ts +71 -0
- data/angular/src/app/services/auth-http/auth.http.service.ts +35 -0
- data/angular/src/app/services/auth-http/index.ts +1 -0
- data/angular/src/app/services/http/http.service.spec.ts +205 -0
- data/angular/src/app/services/http/http.service.ts +40 -0
- data/angular/src/app/services/http/index.ts +1 -0
- data/angular/src/app/services/index.ts +3 -0
- data/angular/src/app/services/services.module.ts +33 -0
- data/angular/src/assets/global.scss +3 -0
- data/angular/src/environments/custom.ts +4 -0
- data/angular/src/environments/environment.prod.ts +2 -1
- data/angular/src/environments/environment.ts +2 -1
- data/angular/src/index.html +1 -1
- data/app/controllers/application_controller.rb +2 -2
- data/app/controllers/concerns/unsakini/board_owner_controller_concern.rb +42 -0
- data/app/controllers/concerns/unsakini/comment_owner_controller_concern.rb +36 -0
- data/app/controllers/concerns/unsakini/logged_in_controller_concern.rb +23 -0
- data/app/controllers/concerns/unsakini/post_owner_controller_concern.rb +38 -0
- data/app/controllers/concerns/unsakini/serializer_controller_concern.rb +13 -0
- data/app/controllers/unsakini/base_controller.rb +6 -0
- data/app/controllers/unsakini/boards_controller.rb +76 -0
- data/app/controllers/unsakini/comments_controller.rb +54 -0
- data/app/controllers/unsakini/posts_controller.rb +61 -0
- data/app/controllers/unsakini/share_board_controller.rb +122 -0
- data/app/controllers/unsakini/user_token_controller.rb +17 -0
- data/app/controllers/unsakini/users_controller.rb +69 -0
- data/app/controllers/unsakini/web_controller.rb +27 -0
- data/app/mailers/unsakini/user_mailer.rb +13 -0
- data/app/models/concerns/unsakini/encryptable_model_concern.rb +97 -0
- data/app/models/unsakini/application_record.rb +7 -0
- data/app/models/unsakini/board.rb +16 -0
- data/app/models/unsakini/comment.rb +12 -0
- data/app/models/unsakini/post.rb +15 -0
- data/app/models/unsakini/user.rb +43 -0
- data/app/models/unsakini/user_board.rb +84 -0
- data/app/models/unsakini.rb +5 -0
- data/app/serializers/unsakini/board_serializer.rb +7 -0
- data/app/serializers/{comment_serializer.rb → unsakini/comment_serializer.rb} +6 -3
- data/app/serializers/unsakini/post_serializer.rb +26 -0
- data/app/serializers/unsakini/user_board_serializer.rb +14 -0
- data/app/serializers/{user_serializer.rb → unsakini/user_serializer.rb} +5 -2
- data/app/views/unsakini/user_mailer/confirm_account.html.erb +3 -0
- data/app/views/unsakini/web/index.html.erb +343 -0
- data/config/routes.rb +10 -10
- data/db/migrate/20161116114222_create_unsakini_boards.rb +10 -0
- data/db/migrate/{20161116200034_create_user_boards.rb → 20161116200034_create_unsakini_user_boards.rb} +3 -2
- data/db/migrate/{20161118031023_create_posts.rb → 20161118031023_create_unsakini_posts.rb} +2 -2
- data/db/migrate/{20161118100454_create_comments.rb → 20161118100454_create_unsakini_comments.rb} +2 -2
- data/db/migrate/20161126145352_create_unsakini_users.rb +15 -0
- data/lib/generators/unsakini/config/config_generator.rb +3 -1
- data/lib/generators/unsakini/dependencies/USAGE +5 -0
- data/lib/generators/unsakini/dependencies/dependencies_generator.rb +19 -0
- data/lib/tasks/unsakini_tasks.rake +6 -37
- data/lib/unsakini/engine.rb +6 -0
- data/lib/unsakini/version.rb +1 -1
- data/public/css/all.css +1204 -0
- data/public/css/all.css.map +7 -0
- data/public/css/bootstrap.css +5622 -0
- data/public/css/bootstrap.css.map +7 -0
- data/public/css/custom.css +15 -0
- data/public/favicons/android-chrome-144x144.png +0 -0
- data/public/favicons/android-chrome-192x192.png +0 -0
- data/public/favicons/android-chrome-36x36.png +0 -0
- data/public/favicons/android-chrome-48x48.png +0 -0
- data/public/favicons/android-chrome-72x72.png +0 -0
- data/public/favicons/android-chrome-96x96.png +0 -0
- data/public/favicons/apple-touch-icon-114x114.png +0 -0
- data/public/favicons/apple-touch-icon-120x120.png +0 -0
- data/public/favicons/apple-touch-icon-144x144.png +0 -0
- data/public/favicons/apple-touch-icon-152x152.png +0 -0
- data/public/favicons/apple-touch-icon-180x180.png +0 -0
- data/public/favicons/apple-touch-icon-57x57.png +0 -0
- data/public/favicons/apple-touch-icon-60x60.png +0 -0
- data/public/favicons/apple-touch-icon-72x72.png +0 -0
- data/public/favicons/apple-touch-icon-76x76.png +0 -0
- data/public/favicons/apple-touch-icon-precomposed.png +0 -0
- data/public/favicons/apple-touch-icon.png +0 -0
- data/public/favicons/favicon-16x16.png +0 -0
- data/public/favicons/favicon-194x194.png +0 -0
- data/public/favicons/favicon-32x32.png +0 -0
- data/public/favicons/favicon-96x96.png +0 -0
- data/public/favicons/favicon.ico +0 -0
- data/public/favicons/mstile-144x144.png +0 -0
- data/public/favicons/mstile-150x150.png +0 -0
- data/public/favicons/mstile-310x150.png +0 -0
- data/public/favicons/mstile-310x310.png +0 -0
- data/public/favicons/mstile-70x70.png +0 -0
- data/public/fonts/bootstrap/glyphicons-halflings-regular.eot +0 -0
- data/public/fonts/bootstrap/glyphicons-halflings-regular.svg +288 -0
- data/public/fonts/bootstrap/glyphicons-halflings-regular.ttf +0 -0
- data/public/fonts/bootstrap/glyphicons-halflings-regular.woff +0 -0
- data/public/fonts/bootstrap/glyphicons-halflings-regular.woff2 +0 -0
- data/public/fonts/font-awesome-4.3.0/css/font-awesome.css +1801 -0
- data/public/fonts/font-awesome-4.3.0/css/font-awesome.min.css +4 -0
- data/public/fonts/font-awesome-4.3.0/fonts/FontAwesome.otf +0 -0
- data/public/fonts/font-awesome-4.3.0/fonts/fontawesome-webfont.eot +0 -0
- data/public/fonts/font-awesome-4.3.0/fonts/fontawesome-webfont.svg +565 -0
- data/public/fonts/font-awesome-4.3.0/fonts/fontawesome-webfont.ttf +0 -0
- data/public/fonts/font-awesome-4.3.0/fonts/fontawesome-webfont.woff +0 -0
- data/public/fonts/font-awesome-4.3.0/fonts/fontawesome-webfont.woff2 +0 -0
- data/public/images/graph-01.svg +425 -0
- data/public/images/graph-02.svg +435 -0
- data/public/images/graph-03.svg +576 -0
- data/public/images/graph-04.svg +70 -0
- data/public/images/img-01.png +0 -0
- data/public/images/img-decor-01.jpg +0 -0
- data/public/images/img-decor-02.jpg +0 -0
- data/public/images/img-decor-03.jpg +0 -0
- data/public/images/img-social-placeholder-01.png +0 -0
- data/public/images/logo-cb.png +0 -0
- data/public/images/logo-codrops.png +0 -0
- data/public/images/logo-pixel.png +0 -0
- data/public/images/logo-smashing.png +0 -0
- data/public/images/logo-tnw.png +0 -0
- data/public/images/logo-w.png +0 -0
- data/public/images/unsakini.svg +56 -0
- data/public/images/user-01.jpg +0 -0
- data/public/images/user-02.jpg +0 -0
- data/public/images/user-03.jpg +0 -0
- data/public/js/bootstrap.js +2306 -0
- data/public/js/jquery-1.11.2.min.js +4 -0
- data/public/js/jquery.main.js +603 -0
- data/public/manifest.json +41 -0
- data/public/unsakini/app/448c34a56d699c29117adc64c43affeb.woff2 +0 -0
- data/public/unsakini/app/89889688147bd7575d6327160d64e760.svg +288 -0
- data/public/unsakini/app/assets/global.scss +3 -0
- data/public/unsakini/app/e18bbf611f2a2e43afc071aa2f4e1512.ttf +0 -0
- data/public/unsakini/app/f4769f9bdb7466be65088239c12046d1.eot +0 -0
- data/public/unsakini/app/fa2772327f55d8198301fdb8bcfc8158.woff +0 -0
- data/{angular/dist → public/unsakini/app}/favicon.ico +0 -0
- data/public/unsakini/app/index.html +14 -0
- data/public/unsakini/app/inline.d41d8cd98f00b204e980.bundle.js +2 -0
- data/public/unsakini/app/inline.d41d8cd98f00b204e980.bundle.map +1 -0
- data/public/unsakini/app/main.54f49c65d3d20650a5d5.bundle.js +2152 -0
- data/public/unsakini/app/main.54f49c65d3d20650a5d5.bundle.js.gz +0 -0
- data/public/unsakini/app/main.54f49c65d3d20650a5d5.bundle.map +1 -0
- data/public/unsakini/app/styles.58e065928ed8ebd0b582.bundle.js +2 -0
- data/public/unsakini/app/styles.58e065928ed8ebd0b582.bundle.map +1 -0
- data/public/unsakini/app/styles.5dac0e986fce6f8738b300cb558b56a0.bundle.css +8 -0
- data/spec/concerns/models/encryptable_concern.rb +3 -2
- data/spec/controllers/{web_base_controller_spec.rb → web_controller_spec.rb} +5 -4
- data/spec/dummy/config/application.rb +3 -1
- data/spec/dummy/config/environments/development.rb +2 -0
- data/spec/dummy/config/initializers/knock.rb +59 -0
- data/spec/dummy/db/schema.rb +16 -14
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/factories/boards.rb +1 -1
- data/spec/factories/comments.rb +1 -1
- data/spec/factories/posts.rb +1 -1
- data/spec/factories/user_boards.rb +1 -1
- data/spec/factories/users.rb +1 -1
- data/spec/models/board_spec.rb +2 -2
- data/spec/models/comment_spec.rb +2 -2
- data/spec/models/post_spec.rb +2 -2
- data/spec/models/user_board_spec.rb +19 -19
- data/spec/models/user_spec.rb +1 -1
- data/spec/requests/{api/boards/api_boards_crud_spec.rb → boards/boards_crud_spec.rb} +26 -26
- data/spec/requests/{api/boards/api_boards_pagination_spec.rb → boards/boards_pagination_spec.rb} +7 -7
- data/spec/requests/{api/boards/api_private_board_spec.rb → boards/private_board_spec.rb} +26 -26
- data/spec/requests/{api/boards/api_shared_board_spec.rb → boards/shared_board_spec.rb} +9 -9
- data/spec/requests/{api/boards/api_sharing_board_spec.rb → boards/sharing_board_spec.rb} +13 -13
- data/spec/requests/{api/comments/api_comments_pagination_spec.rb → comments/comments_pagination_spec.rb} +3 -3
- data/spec/requests/{api/comments/api_comments_private_board_spec.rb → comments/comments_private_board_spec.rb} +20 -20
- data/spec/requests/{api/comments/api_comments_shared_board_spec.rb → comments/comments_shared_board_spec.rb} +17 -17
- data/spec/requests/{api/posts/api_posts_pagination_spec.rb → posts/posts_pagination_spec.rb} +3 -3
- data/spec/requests/{api/posts/api_posts_private_board_spec.rb → posts/posts_private_board_spec.rb} +22 -22
- data/spec/requests/{api/posts/api_posts_shared_board_spec.rb → posts/posts_shared_board_spec.rb} +24 -24
- data/spec/requests/user/user_create_spec.rb +104 -0
- data/spec/requests/{api/api_users_spec.rb → user/user_search_spec.rb} +9 -9
- data/spec/schema/jwt.json +9 -0
- data/spec/schema/validation_message.json +4 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/support/auth_helper.rb +0 -2
- metadata +204 -199
- data/angular/dist/index.html +0 -14
- data/angular/dist/inline.bundle.js +0 -139
- data/angular/dist/inline.map +0 -1
- data/angular/dist/main.bundle.js +0 -64689
- data/angular/dist/main.map +0 -1
- data/angular/dist/styles.bundle.js +0 -364
- data/angular/dist/styles.map +0 -1
- data/angular/src/styles.css +0 -1
- data/app/controllers/api/boards_controller.rb +0 -73
- data/app/controllers/api/comments_controller.rb +0 -51
- data/app/controllers/api/posts_controller.rb +0 -58
- data/app/controllers/api/share_board_controller.rb +0 -118
- data/app/controllers/api/users_controller.rb +0 -27
- data/app/controllers/concerns/board_owner_controller_concern.rb +0 -38
- data/app/controllers/concerns/comment_owner_controller_concern.rb +0 -33
- data/app/controllers/concerns/logged_in_controller_concern.rb +0 -21
- data/app/controllers/concerns/post_owner_controller_concern.rb +0 -36
- data/app/controllers/concerns/serializer_controller_concern.rb +0 -11
- data/app/controllers/user_token_controller.rb +0 -2
- data/app/controllers/web_base_controller.rb +0 -15
- data/app/models/application_record.rb +0 -5
- data/app/models/board.rb +0 -14
- data/app/models/comment.rb +0 -9
- data/app/models/concerns/encryptable_model_concern.rb +0 -96
- data/app/models/post.rb +0 -12
- data/app/models/user.rb +0 -6
- data/app/models/user_board.rb +0 -82
- data/app/serializers/board_serializer.rb +0 -5
- data/app/serializers/post_serializer.rb +0 -23
- data/app/serializers/user_board_serializer.rb +0 -11
- data/app/views/web_base/index.html +0 -16
- data/db/migrate/20161116114222_create_boards.rb +0 -9
- data/db/migrate/20161118221508_add_encrypted_password_to_user_board.rb +0 -5
- data/db/migrate/20161122211105_create_users.rb +0 -12
- data/db/migrate/20161124102633_add_is_shared_to_boards.rb +0 -5
- data/lib/generators/unsakini/angular/USAGE +0 -8
- data/lib/generators/unsakini/angular/angular_generator.rb +0 -7
- data/spec/dummy/config/initializers/assets.rb +0 -11
- data/spec/dummy/config/initializers/cookies_serializer.rb +0 -5
- data/spec/dummy/config/initializers/session_store.rb +0 -3
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20161124210219_create_boards.unsakini_engine.rb +0 -10
- data/spec/dummy/db/migrate/20161124210220_create_user_boards.unsakini_engine.rb +0 -12
- data/spec/dummy/db/migrate/20161124210221_create_posts.unsakini_engine.rb +0 -13
- data/spec/dummy/db/migrate/20161124210222_create_comments.unsakini_engine.rb +0 -12
- data/spec/dummy/db/migrate/20161124210223_add_encrypted_password_to_user_board.unsakini_engine.rb +0 -6
- data/spec/dummy/db/migrate/20161124210224_create_users.unsakini_engine.rb +0 -13
- data/spec/dummy/db/migrate/20161124210225_add_is_shared_to_boards.unsakini_engine.rb +0 -6
- data/spec/dummy/public/app/favicon.ico +0 -0
- data/spec/dummy/public/app/index.html +0 -14
- data/spec/dummy/public/app/inline.bundle.js +0 -139
- data/spec/dummy/public/app/inline.map +0 -1
- data/spec/dummy/public/app/main.bundle.js +0 -64689
- data/spec/dummy/public/app/main.map +0 -1
- data/spec/dummy/public/app/styles.bundle.js +0 -364
- data/spec/dummy/public/app/styles.map +0 -1
- data/spec/dummy/tmp/unsakini-ng2/LICENSE +0 -21
- data/spec/dummy/tmp/unsakini-ng2/README.md +0 -1
- data/spec/dummy/tmp/unsakini-ng2/angular-cli.json +0 -59
- data/spec/dummy/tmp/unsakini-ng2/e2e/app.e2e-spec.ts +0 -14
- data/spec/dummy/tmp/unsakini-ng2/e2e/app.po.ts +0 -11
- data/spec/dummy/tmp/unsakini-ng2/e2e/signup.e2e-spec.ts +0 -28
- data/spec/dummy/tmp/unsakini-ng2/e2e/signup.po.ts +0 -31
- data/spec/dummy/tmp/unsakini-ng2/e2e/tsconfig.json +0 -16
- data/spec/dummy/tmp/unsakini-ng2/karma.conf.js +0 -45
- data/spec/dummy/tmp/unsakini-ng2/package.json +0 -49
- data/spec/dummy/tmp/unsakini-ng2/protractor.conf.js +0 -32
- data/spec/dummy/tmp/unsakini-ng2/src/app/app.component.css +0 -0
- data/spec/dummy/tmp/unsakini-ng2/src/app/app.component.html +0 -4
- data/spec/dummy/tmp/unsakini-ng2/src/app/app.component.spec.ts +0 -47
- data/spec/dummy/tmp/unsakini-ng2/src/app/app.component.ts +0 -10
- data/spec/dummy/tmp/unsakini-ng2/src/app/app.module.ts +0 -29
- data/spec/dummy/tmp/unsakini-ng2/src/app/app.routes.module.ts +0 -29
- data/spec/dummy/tmp/unsakini-ng2/src/app/index.ts +0 -2
- data/spec/dummy/tmp/unsakini-ng2/src/app/registration/registration.component.css +0 -0
- data/spec/dummy/tmp/unsakini-ng2/src/app/registration/registration.component.html +0 -14
- data/spec/dummy/tmp/unsakini-ng2/src/app/registration/registration.component.spec.ts +0 -157
- data/spec/dummy/tmp/unsakini-ng2/src/app/registration/registration.component.ts +0 -42
- data/spec/dummy/tmp/unsakini-ng2/src/environments/environment.prod.ts +0 -3
- data/spec/dummy/tmp/unsakini-ng2/src/environments/environment.ts +0 -8
- data/spec/dummy/tmp/unsakini-ng2/src/favicon.ico +0 -0
- data/spec/dummy/tmp/unsakini-ng2/src/index.html +0 -14
- data/spec/dummy/tmp/unsakini-ng2/src/main.ts +0 -12
- data/spec/dummy/tmp/unsakini-ng2/src/polyfills.ts +0 -19
- data/spec/dummy/tmp/unsakini-ng2/src/styles.css +0 -1
- data/spec/dummy/tmp/unsakini-ng2/src/test.ts +0 -31
- data/spec/dummy/tmp/unsakini-ng2/src/tsconfig.json +0 -18
- data/spec/dummy/tmp/unsakini-ng2/src/typings.d.ts +0 -2
- data/spec/dummy/tmp/unsakini-ng2/tslint.json +0 -114
- data/spec/dummy/tmp/unsakini-ng2/typings.json +0 -4
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
|
-
RSpec.describe "
|
3
|
+
RSpec.describe "Unsakini::Board::Post::Comments", type: :request do
|
4
4
|
|
5
5
|
before(:all) do
|
6
6
|
user_has_shared_board_with_posts_scenario
|
@@ -19,12 +19,12 @@ RSpec.describe "Api::Board::Post::Comments", type: :request do
|
|
19
19
|
context "Comments on my post" do
|
20
20
|
|
21
21
|
it "returns http unauthorized" do
|
22
|
-
get
|
22
|
+
get unsakini_board_post_comments_path(@board, @post)
|
23
23
|
expect(response).to have_http_status(:unauthorized)
|
24
24
|
end
|
25
25
|
|
26
26
|
it "returns http unauthorized" do
|
27
|
-
put
|
27
|
+
put unsakini_board_post_comment_path(@board, @post, @comment), params: valid_attributes, as: :json
|
28
28
|
expect(response).to have_http_status(:unauthorized)
|
29
29
|
end
|
30
30
|
|
@@ -32,7 +32,7 @@ RSpec.describe "Api::Board::Post::Comments", type: :request do
|
|
32
32
|
describe "Get all comments on my post" do
|
33
33
|
describe "As a post owner" do
|
34
34
|
it "returns all comments" do
|
35
|
-
get
|
35
|
+
get unsakini_board_post_comments_path(@board, @post), headers: auth_headers(@user)
|
36
36
|
expect(response).to have_http_status(:ok)
|
37
37
|
expect(body_to_json('0')).to match_json_schema(:comment)
|
38
38
|
expect(body_to_json.count).to eq @post.comments.count
|
@@ -41,12 +41,12 @@ RSpec.describe "Api::Board::Post::Comments", type: :request do
|
|
41
41
|
|
42
42
|
describe "As another user" do
|
43
43
|
it "returns http forbidden" do
|
44
|
-
get
|
44
|
+
get unsakini_board_post_comments_path(@board, @post), headers: auth_headers(@user_2)
|
45
45
|
expect(response).to have_http_status(:forbidden)
|
46
46
|
end
|
47
47
|
|
48
48
|
it "returns http forbidden" do
|
49
|
-
get
|
49
|
+
get unsakini_board_post_comments_path(@shared_board, @post), headers: auth_headers(@user_2)
|
50
50
|
expect(response).to have_http_status(:forbidden)
|
51
51
|
end
|
52
52
|
end
|
@@ -58,13 +58,13 @@ RSpec.describe "Api::Board::Post::Comments", type: :request do
|
|
58
58
|
describe "As post owner" do
|
59
59
|
|
60
60
|
it "returns http unauthorized" do
|
61
|
-
post
|
61
|
+
post unsakini_board_post_comments_path(@board, @post), as: :json, params: valid_attributes
|
62
62
|
expect(response).to have_http_status(:unauthorized)
|
63
63
|
end
|
64
64
|
|
65
65
|
it "returns http unprocessable_entity" do
|
66
66
|
post(
|
67
|
-
|
67
|
+
unsakini_board_post_comments_path(@board, @post),
|
68
68
|
headers: auth_headers(@user),
|
69
69
|
params: invalid_attributes,
|
70
70
|
as: :json
|
@@ -76,7 +76,7 @@ RSpec.describe "Api::Board::Post::Comments", type: :request do
|
|
76
76
|
it "creates a new comment" do
|
77
77
|
comment_count = @post.comments.count
|
78
78
|
post(
|
79
|
-
|
79
|
+
unsakini_board_post_comments_path(@board, @post),
|
80
80
|
headers: auth_headers(@user),
|
81
81
|
params: valid_attributes,
|
82
82
|
as: :json
|
@@ -85,7 +85,7 @@ RSpec.describe "Api::Board::Post::Comments", type: :request do
|
|
85
85
|
expect(response.body).to match_json_schema(:comment)
|
86
86
|
expect(body_to_json('id')).to eq @post.comments.last.id
|
87
87
|
expect(body_to_json('user/id')).to eq @user.id
|
88
|
-
expect(Comment.find_by_id(body_to_json('id'))).to eq @post.comments.last
|
88
|
+
expect(Unsakini::Comment.find_by_id(body_to_json('id'))).to eq @post.comments.last
|
89
89
|
expect(@post.comments.count).to eq(comment_count+1)
|
90
90
|
end
|
91
91
|
end
|
@@ -93,13 +93,13 @@ RSpec.describe "Api::Board::Post::Comments", type: :request do
|
|
93
93
|
describe "As another user" do
|
94
94
|
|
95
95
|
it "returns http unauthorized" do
|
96
|
-
post
|
96
|
+
post unsakini_board_post_comments_path(@board, @post), as: :json, params: valid_attributes
|
97
97
|
expect(response).to have_http_status(:unauthorized)
|
98
98
|
end
|
99
99
|
|
100
100
|
it "returns http forbidden" do
|
101
101
|
post(
|
102
|
-
|
102
|
+
unsakini_board_post_comments_path(@board, @post),
|
103
103
|
headers: auth_headers(@user_2),
|
104
104
|
params: valid_attributes,
|
105
105
|
as: :json
|
@@ -117,7 +117,7 @@ RSpec.describe "Api::Board::Post::Comments", type: :request do
|
|
117
117
|
|
118
118
|
it "updates my comment if user is me" do
|
119
119
|
put(
|
120
|
-
|
120
|
+
unsakini_board_post_comment_path(@board, @post, @comment),
|
121
121
|
params: valid_attributes,
|
122
122
|
headers: auth_headers(@user),
|
123
123
|
as: :json
|
@@ -133,7 +133,7 @@ RSpec.describe "Api::Board::Post::Comments", type: :request do
|
|
133
133
|
|
134
134
|
it "returns http forbidden if not comment owner" do
|
135
135
|
put(
|
136
|
-
|
136
|
+
unsakini_board_post_comment_path(@board, @post, @comment),
|
137
137
|
params: valid_attributes,
|
138
138
|
headers: auth_headers(@user_2),
|
139
139
|
as: :json
|
@@ -152,12 +152,12 @@ RSpec.describe "Api::Board::Post::Comments", type: :request do
|
|
152
152
|
it "Deletes my comment if user is me" do
|
153
153
|
prev_comment_count = @post.comments.count
|
154
154
|
delete(
|
155
|
-
|
155
|
+
unsakini_board_post_comment_path(@board, @post, @comment),
|
156
156
|
headers: auth_headers(@user),
|
157
157
|
)
|
158
158
|
expect(response).to have_http_status(:ok)
|
159
159
|
expect(@post.comments.count).to eq(prev_comment_count-1)
|
160
|
-
expect(Comment.find_by_id(@comment.id)).to be_nil
|
160
|
+
expect(Unsakini::Comment.find_by_id(@comment.id)).to be_nil
|
161
161
|
end
|
162
162
|
|
163
163
|
end
|
@@ -167,23 +167,23 @@ RSpec.describe "Api::Board::Post::Comments", type: :request do
|
|
167
167
|
it "returns http forbidden if not comment owner" do
|
168
168
|
prev_comment_count = @post.comments.count
|
169
169
|
delete(
|
170
|
-
|
170
|
+
unsakini_board_post_comment_path(@board, @post, @comment),
|
171
171
|
headers: auth_headers(@user_2),
|
172
172
|
)
|
173
173
|
expect(response).to have_http_status(:forbidden)
|
174
174
|
expect(@post.comments.count).to eq(prev_comment_count)
|
175
|
-
expect(Comment.find_by_id(@comment.id)).not_to be_nil
|
175
|
+
expect(Unsakini::Comment.find_by_id(@comment.id)).not_to be_nil
|
176
176
|
end
|
177
177
|
|
178
178
|
it "Deletes my comment if user is me" do
|
179
179
|
prev_comment_count = @post.comments.count
|
180
180
|
delete(
|
181
|
-
|
181
|
+
unsakini_board_post_comment_path(@board, @post, @comment),
|
182
182
|
headers: auth_headers(@user),
|
183
183
|
)
|
184
184
|
expect(response).to have_http_status(:ok)
|
185
185
|
expect(@post.comments.count).to eq(prev_comment_count-1)
|
186
|
-
expect(Comment.find_by_id(@comment.id)).to be_nil
|
186
|
+
expect(Unsakini::Comment.find_by_id(@comment.id)).to be_nil
|
187
187
|
end
|
188
188
|
|
189
189
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
|
-
RSpec.describe "
|
3
|
+
RSpec.describe "Unsakini::Board::Post::Comments", type: :request do
|
4
4
|
|
5
5
|
before(:all) do
|
6
6
|
user_has_shared_board_with_posts_scenario
|
@@ -23,7 +23,7 @@ RSpec.describe "Api::Board::Post::Comments", type: :request do
|
|
23
23
|
describe "As a post owner" do
|
24
24
|
|
25
25
|
it "returns all comments" do
|
26
|
-
get
|
26
|
+
get unsakini_board_post_comments_path(@shared_board, @shared_post), headers: auth_headers(@user)
|
27
27
|
expect(response).to have_http_status(:ok)
|
28
28
|
expect(body_to_json('0')).to match_json_schema(:comment)
|
29
29
|
expect(body_to_json.count).to eq @shared_post.comments.count
|
@@ -33,7 +33,7 @@ RSpec.describe "Api::Board::Post::Comments", type: :request do
|
|
33
33
|
|
34
34
|
describe "As another user" do
|
35
35
|
it "returns all comments" do
|
36
|
-
get
|
36
|
+
get unsakini_board_post_comments_path(@shared_board, @shared_post), headers: auth_headers(@user_2)
|
37
37
|
expect(response).to have_http_status(:ok)
|
38
38
|
expect(body_to_json('0')).to match_json_schema(:comment)
|
39
39
|
expect(body_to_json.count).to eq @shared_post.comments.count
|
@@ -48,7 +48,7 @@ RSpec.describe "Api::Board::Post::Comments", type: :request do
|
|
48
48
|
|
49
49
|
it "returns http unprocessable_entity" do
|
50
50
|
post(
|
51
|
-
|
51
|
+
unsakini_board_post_comments_path(@shared_board, @shared_post),
|
52
52
|
headers: auth_headers(@user),
|
53
53
|
params: invalid_attributes,
|
54
54
|
as: :json
|
@@ -60,7 +60,7 @@ RSpec.describe "Api::Board::Post::Comments", type: :request do
|
|
60
60
|
it "creates a new comment" do
|
61
61
|
comment_count = @shared_post.comments.count
|
62
62
|
post(
|
63
|
-
|
63
|
+
unsakini_board_post_comments_path(@shared_board, @shared_post),
|
64
64
|
headers: auth_headers(@user),
|
65
65
|
params: valid_attributes,
|
66
66
|
as: :json
|
@@ -69,7 +69,7 @@ RSpec.describe "Api::Board::Post::Comments", type: :request do
|
|
69
69
|
expect(response.body).to match_json_schema(:comment)
|
70
70
|
expect(body_to_json('content')).to eq valid_attributes[:content]
|
71
71
|
expect(body_to_json('user/id')).to eq @user.id
|
72
|
-
expect(Comment.find_by_id(body_to_json('id'))).to eq @shared_post.comments.last
|
72
|
+
expect(Unsakini::Comment.find_by_id(body_to_json('id'))).to eq @shared_post.comments.last
|
73
73
|
expect(@shared_post.comments.count).to eq(comment_count+1)
|
74
74
|
end
|
75
75
|
|
@@ -79,7 +79,7 @@ RSpec.describe "Api::Board::Post::Comments", type: :request do
|
|
79
79
|
|
80
80
|
it "returns http unprocessable_entity" do
|
81
81
|
post(
|
82
|
-
|
82
|
+
unsakini_board_post_comments_path(@shared_board, @shared_post),
|
83
83
|
headers: auth_headers(@user_2),
|
84
84
|
params: invalid_attributes,
|
85
85
|
as: :json
|
@@ -91,7 +91,7 @@ RSpec.describe "Api::Board::Post::Comments", type: :request do
|
|
91
91
|
it "creates a new comment" do
|
92
92
|
comment_count = @shared_post.comments.count
|
93
93
|
post(
|
94
|
-
|
94
|
+
unsakini_board_post_comments_path(@shared_board, @shared_post),
|
95
95
|
headers: auth_headers(@user_2),
|
96
96
|
params: valid_attributes,
|
97
97
|
as: :json
|
@@ -100,7 +100,7 @@ RSpec.describe "Api::Board::Post::Comments", type: :request do
|
|
100
100
|
expect(response.body).to match_json_schema(:comment)
|
101
101
|
expect(body_to_json('content')).to eq valid_attributes[:content]
|
102
102
|
expect(body_to_json('user/id')).to eq @user_2.id
|
103
|
-
expect(Comment.find_by_id(body_to_json('id'))).to eq @shared_post.comments.last
|
103
|
+
expect(Unsakini::Comment.find_by_id(body_to_json('id'))).to eq @shared_post.comments.last
|
104
104
|
expect(@shared_post.comments.count).to eq(comment_count+1)
|
105
105
|
end
|
106
106
|
|
@@ -113,7 +113,7 @@ RSpec.describe "Api::Board::Post::Comments", type: :request do
|
|
113
113
|
context "As comment owner" do
|
114
114
|
it "updates my comment if user is me" do
|
115
115
|
put(
|
116
|
-
|
116
|
+
unsakini_board_post_comment_path(@shared_board, @shared_post, @shared_comment),
|
117
117
|
params: valid_attributes,
|
118
118
|
headers: auth_headers(@user),
|
119
119
|
as: :json
|
@@ -128,7 +128,7 @@ RSpec.describe "Api::Board::Post::Comments", type: :request do
|
|
128
128
|
|
129
129
|
it "returns http forbidden if not comment owner" do
|
130
130
|
put(
|
131
|
-
|
131
|
+
unsakini_board_post_comment_path(@shared_board, @shared_post, @shared_comment),
|
132
132
|
params: valid_attributes,
|
133
133
|
headers: auth_headers(@user_2),
|
134
134
|
as: :json
|
@@ -145,12 +145,12 @@ RSpec.describe "Api::Board::Post::Comments", type: :request do
|
|
145
145
|
it "Deletes my comment if user is me" do
|
146
146
|
prev_comment_count = @shared_post.comments.count
|
147
147
|
delete(
|
148
|
-
|
148
|
+
unsakini_board_post_comment_path(@shared_board, @shared_post, @shared_comment),
|
149
149
|
headers: auth_headers(@user),
|
150
150
|
)
|
151
151
|
expect(response).to have_http_status(:ok)
|
152
152
|
expect(@shared_post.comments.count).to eq(prev_comment_count-1)
|
153
|
-
expect(Comment.find_by_id(@shared_comment.id)).to be_nil
|
153
|
+
expect(Unsakini::Comment.find_by_id(@shared_comment.id)).to be_nil
|
154
154
|
end
|
155
155
|
|
156
156
|
end
|
@@ -160,23 +160,23 @@ RSpec.describe "Api::Board::Post::Comments", type: :request do
|
|
160
160
|
it "returns http forbidden if not comment owner" do
|
161
161
|
prev_comment_count = @shared_post.comments.count
|
162
162
|
delete(
|
163
|
-
|
163
|
+
unsakini_board_post_comment_path(@shared_board, @shared_post, @shared_comment),
|
164
164
|
headers: auth_headers(@user_2),
|
165
165
|
)
|
166
166
|
expect(response).to have_http_status(:forbidden)
|
167
167
|
expect(@shared_post.comments.count).to eq(prev_comment_count)
|
168
|
-
expect(Comment.find_by_id(@shared_comment.id)).not_to be_nil
|
168
|
+
expect(Unsakini::Comment.find_by_id(@shared_comment.id)).not_to be_nil
|
169
169
|
end
|
170
170
|
|
171
171
|
it "Deletes my comment if user is me" do
|
172
172
|
prev_comment_count = @shared_post.comments.count
|
173
173
|
delete(
|
174
|
-
|
174
|
+
unsakini_board_post_comment_path(@shared_board, @shared_post, @shared_comment),
|
175
175
|
headers: auth_headers(@user),
|
176
176
|
)
|
177
177
|
expect(response).to have_http_status(:ok)
|
178
178
|
expect(@shared_post.comments.count).to eq(prev_comment_count-1)
|
179
|
-
expect(Comment.find_by_id(@shared_comment.id)).to be_nil
|
179
|
+
expect(Unsakini::Comment.find_by_id(@shared_comment.id)).to be_nil
|
180
180
|
end
|
181
181
|
|
182
182
|
end
|
data/spec/requests/{api/posts/api_posts_pagination_spec.rb → posts/posts_pagination_spec.rb}
RENAMED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
3
|
# test scope is @user is owner of the board and owner of the post/s
|
4
|
-
RSpec.describe "
|
4
|
+
RSpec.describe "Usakini::Board::Posts", type: :request do
|
5
5
|
|
6
6
|
before(:each) do
|
7
7
|
user_has_many_posts_scenario
|
@@ -14,7 +14,7 @@ RSpec.describe "Api::Board::Posts", type: :request do
|
|
14
14
|
describe "Get Posts" do
|
15
15
|
|
16
16
|
it "return posts" do
|
17
|
-
get
|
17
|
+
get unsakini_board_posts_path(@board), headers: auth_headers(@user), params: {page: 1}
|
18
18
|
expect(response).to have_http_status(:ok)
|
19
19
|
expect(body_to_json.count).to eq num_per_page
|
20
20
|
expect(body_to_json('0')).to match_json_schema(:post)
|
@@ -22,7 +22,7 @@ RSpec.describe "Api::Board::Posts", type: :request do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
it "return last page" do
|
25
|
-
get
|
25
|
+
get unsakini_board_posts_path(@board), headers: auth_headers(@user), params: {page: 2}
|
26
26
|
expect(response).to have_http_status(:ok)
|
27
27
|
expect(body_to_json.count).to eq @num_posts - num_per_page
|
28
28
|
expect(body_to_json('0')).to match_json_schema(:post)
|
data/spec/requests/{api/posts/api_posts_private_board_spec.rb → posts/posts_private_board_spec.rb}
RENAMED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
3
|
# test scope is @user is owner of the board and owner of the post/s
|
4
|
-
RSpec.describe "
|
4
|
+
RSpec.describe "Unsakini::Board::Posts", type: :request do
|
5
5
|
|
6
6
|
before(:each) do
|
7
7
|
user_has_shared_board_scenario
|
@@ -22,15 +22,15 @@ RSpec.describe "Api::Board::Posts", type: :request do
|
|
22
22
|
describe "Get All Posts" do
|
23
23
|
|
24
24
|
it "return http unauthorized" do
|
25
|
-
get
|
25
|
+
get unsakini_board_posts_path(@board)
|
26
26
|
expect(response).to have_http_status(:unauthorized)
|
27
27
|
end
|
28
28
|
it "return http forbidden" do
|
29
|
-
get
|
29
|
+
get unsakini_board_posts_path(@board), headers: auth_headers(@user_2)
|
30
30
|
expect(response).to have_http_status(:forbidden)
|
31
31
|
end
|
32
32
|
it "return post" do
|
33
|
-
get
|
33
|
+
get unsakini_board_posts_path(@board), headers: auth_headers(@user)
|
34
34
|
expect(response).to have_http_status(:ok)
|
35
35
|
expect(body_to_json('0')).to match_json_schema(:post)
|
36
36
|
expect(response.body).to be_json_eql(serialize(@board.posts.all))
|
@@ -39,15 +39,15 @@ RSpec.describe "Api::Board::Posts", type: :request do
|
|
39
39
|
|
40
40
|
describe "Get Single Post" do
|
41
41
|
it "return http unauthorized" do
|
42
|
-
get
|
42
|
+
get unsakini_board_post_path(@board, @post)
|
43
43
|
expect(response).to have_http_status(:unauthorized)
|
44
44
|
end
|
45
45
|
it "return http forbidden" do
|
46
|
-
get
|
46
|
+
get unsakini_board_post_path(@board, @post), headers: auth_headers(@user_2)
|
47
47
|
expect(response).to have_http_status(:forbidden)
|
48
48
|
end
|
49
49
|
it "return post" do
|
50
|
-
get
|
50
|
+
get unsakini_board_post_path(@board, @post), headers: auth_headers(@user)
|
51
51
|
expect(response).to have_http_status(:ok)
|
52
52
|
expect(response.body).to match_json_schema(:post)
|
53
53
|
expect(response.body).to be_json_eql(serialize(@post))
|
@@ -56,26 +56,26 @@ RSpec.describe "Api::Board::Posts", type: :request do
|
|
56
56
|
|
57
57
|
describe "Create Post" do
|
58
58
|
it "return http unauthorized" do
|
59
|
-
post
|
59
|
+
post unsakini_board_posts_path(@board), as: :json
|
60
60
|
expect(response).to have_http_status(:unauthorized)
|
61
61
|
end
|
62
62
|
it "return http forbidden when not owner" do
|
63
|
-
post
|
63
|
+
post unsakini_board_posts_path(@board), headers: auth_headers(@user_2), params: valid_attributes, as: :json
|
64
64
|
expect(response).to have_http_status(:forbidden)
|
65
65
|
end
|
66
66
|
it "return http unprocessable_entity when invalid title" do
|
67
|
-
post
|
67
|
+
post unsakini_board_posts_path(@board), headers: auth_headers(@user), params: invalid_title_attribute, as: :json
|
68
68
|
expect(response).to have_http_status(:unprocessable_entity)
|
69
69
|
# todo: assert errors
|
70
70
|
end
|
71
71
|
it "return http unprocessable_entity when invalid content" do
|
72
|
-
post
|
72
|
+
post unsakini_board_posts_path(@board), headers: auth_headers(@user), params: invalid_content_attribute, as: :json
|
73
73
|
expect(response).to have_http_status(:unprocessable_entity)
|
74
74
|
# todo: assert errors
|
75
75
|
end
|
76
76
|
it "successfully creates a post" do
|
77
77
|
board_posts_count = @board.posts.count
|
78
|
-
post
|
78
|
+
post unsakini_board_posts_path(@board), headers: auth_headers(@user), params: valid_attributes, as: :json
|
79
79
|
expect(response).to have_http_status(:created)
|
80
80
|
expect(response.body).to match_json_schema(:post)
|
81
81
|
expect(response.body).to be_json_eql(serialize(@board.posts.last))
|
@@ -86,25 +86,25 @@ RSpec.describe "Api::Board::Posts", type: :request do
|
|
86
86
|
describe "Update Post" do
|
87
87
|
|
88
88
|
it "return http unauthorized" do
|
89
|
-
put
|
89
|
+
put unsakini_board_post_path(@board, @post), as: :json
|
90
90
|
expect(response).to have_http_status(:unauthorized)
|
91
91
|
end
|
92
92
|
it "return http forbidden when not owner" do
|
93
|
-
put
|
93
|
+
put unsakini_board_post_path(@board, @post), headers: auth_headers(@user_2), params: valid_attributes, as: :json
|
94
94
|
expect(response).to have_http_status(:forbidden)
|
95
95
|
end
|
96
96
|
it "return http unprocessable_entity when invalid title" do
|
97
|
-
put
|
97
|
+
put unsakini_board_post_path(@board, @post), headers: auth_headers(@user), params: invalid_title_attribute, as: :json
|
98
98
|
expect(response).to have_http_status(:unprocessable_entity)
|
99
99
|
# todo: assert errors
|
100
100
|
end
|
101
101
|
it "return http unprocessable_entity when invalid content" do
|
102
|
-
put
|
102
|
+
put unsakini_board_post_path(@board, @post), headers: auth_headers(@user), params: invalid_content_attribute, as: :json
|
103
103
|
expect(response).to have_http_status(:unprocessable_entity)
|
104
104
|
# todo: assert errors
|
105
105
|
end
|
106
106
|
it "updates my post belonging to my board" do
|
107
|
-
put
|
107
|
+
put unsakini_board_post_path(@board, @post), headers: auth_headers(@user), params: valid_attributes, as: :json
|
108
108
|
expect(response).to have_http_status(:ok)
|
109
109
|
expect(response.body).to match_json_schema(:post)
|
110
110
|
expect(body_to_json('title')).to eq(valid_attributes[:title])
|
@@ -114,21 +114,21 @@ RSpec.describe "Api::Board::Posts", type: :request do
|
|
114
114
|
|
115
115
|
describe "Delete Post" do
|
116
116
|
it "return http unauthorized" do
|
117
|
-
delete
|
117
|
+
delete unsakini_board_post_path(@board, @post)
|
118
118
|
expect(response).to have_http_status(:unauthorized)
|
119
119
|
end
|
120
120
|
it "return http forbidden if not owner" do
|
121
|
-
delete
|
121
|
+
delete unsakini_board_post_path(@board, @post), headers: auth_headers(@user_2)
|
122
122
|
expect(response).to have_http_status(:forbidden)
|
123
123
|
end
|
124
124
|
it "removes my post" do
|
125
125
|
post_id = @post.id
|
126
126
|
board_posts_count = @board.posts.count
|
127
|
-
delete
|
127
|
+
delete unsakini_board_post_path(@board, @post), headers: auth_headers(@user)
|
128
128
|
expect(response).to have_http_status(:ok)
|
129
129
|
expect(@board.posts.count).to eq(board_posts_count-1)
|
130
|
-
expect(Post.find_by_id(post_id)).to be_nil
|
131
|
-
expect(Comment.where(post_id: post_id)).to be_empty
|
130
|
+
expect(Unsakini::Post.find_by_id(post_id)).to be_nil
|
131
|
+
expect(Unsakini::Comment.where(post_id: post_id)).to be_empty
|
132
132
|
end
|
133
133
|
end
|
134
134
|
end
|
data/spec/requests/{api/posts/api_posts_shared_board_spec.rb → posts/posts_shared_board_spec.rb}
RENAMED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
3
|
# test scope is @user is owner of the board and owner of the post/s
|
4
|
-
RSpec.describe "
|
4
|
+
RSpec.describe "Unsakini::Board::Posts", type: :request do
|
5
5
|
|
6
6
|
before(:each) do
|
7
7
|
user_has_shared_board_scenario
|
@@ -21,17 +21,17 @@ RSpec.describe "Api::Board::Posts", type: :request do
|
|
21
21
|
|
22
22
|
describe "Get all posts" do
|
23
23
|
it "return http unauthorized" do
|
24
|
-
get
|
24
|
+
get unsakini_board_posts_path(@shared_board)
|
25
25
|
expect(response).to have_http_status(:unauthorized)
|
26
26
|
end
|
27
27
|
it "returns all posts for first user" do
|
28
|
-
get
|
28
|
+
get unsakini_board_posts_path(@shared_board), headers: auth_headers(@user)
|
29
29
|
expect(response).to have_http_status(:ok)
|
30
30
|
expect(body_to_json('0')).to match_json_schema(:post)
|
31
31
|
expect(response.body).to be_json_eql(serialize(@shared_board.posts.all))
|
32
32
|
end
|
33
33
|
it "returns all posts for second user" do
|
34
|
-
get
|
34
|
+
get unsakini_board_posts_path(@shared_board), headers: auth_headers(@user_2)
|
35
35
|
expect(response).to have_http_status(:ok)
|
36
36
|
expect(body_to_json('0')).to match_json_schema(:post)
|
37
37
|
expect(response.body).to be_json_eql(serialize(@shared_board.posts.all))
|
@@ -40,17 +40,17 @@ RSpec.describe "Api::Board::Posts", type: :request do
|
|
40
40
|
|
41
41
|
describe "Get single post" do
|
42
42
|
it "return http unauthorized" do
|
43
|
-
get
|
43
|
+
get unsakini_board_post_path(@shared_board, @shared_post)
|
44
44
|
expect(response).to have_http_status(:unauthorized)
|
45
45
|
end
|
46
46
|
it "renders post resource to first user" do
|
47
|
-
get
|
47
|
+
get unsakini_board_post_path(@shared_board, @shared_post), headers: auth_headers(@user)
|
48
48
|
expect(response).to have_http_status(:ok)
|
49
49
|
expect(response.body).to match_json_schema(:post)
|
50
50
|
expect(response.body).to be_json_eql(serialize(@shared_post))
|
51
51
|
end
|
52
52
|
it "renders post resource to 2nd user" do
|
53
|
-
get
|
53
|
+
get unsakini_board_post_path(@shared_board, @shared_post), headers: auth_headers(@user_2)
|
54
54
|
expect(response).to have_http_status(:ok)
|
55
55
|
expect(response.body).to match_json_schema(:post)
|
56
56
|
expect(response.body).to be_json_eql(serialize(@shared_post))
|
@@ -61,24 +61,24 @@ RSpec.describe "Api::Board::Posts", type: :request do
|
|
61
61
|
describe "Create post" do
|
62
62
|
|
63
63
|
it "return http unauthorized" do
|
64
|
-
post
|
64
|
+
post unsakini_board_posts_path(@shared_board), as: :json
|
65
65
|
expect(response).to have_http_status(:unauthorized)
|
66
66
|
end
|
67
67
|
|
68
68
|
context "Board owner" do
|
69
69
|
it "return http unprocessable_entity when invalid title" do
|
70
|
-
post
|
70
|
+
post unsakini_board_posts_path(@shared_board), headers: auth_headers(@user), params: invalid_title_attribute, as: :json
|
71
71
|
expect(response).to have_http_status(:unprocessable_entity)
|
72
72
|
# todo: assert errors
|
73
73
|
end
|
74
74
|
it "return http unprocessable_entity when invalid content" do
|
75
|
-
post
|
75
|
+
post unsakini_board_posts_path(@shared_board), headers: auth_headers(@user), params: invalid_content_attribute, as: :json
|
76
76
|
expect(response).to have_http_status(:unprocessable_entity)
|
77
77
|
# todo: assert errors
|
78
78
|
end
|
79
79
|
it "successfully creates a post" do
|
80
80
|
board_posts_count = @shared_board.posts.count
|
81
|
-
post
|
81
|
+
post unsakini_board_posts_path(@shared_board), headers: auth_headers(@user), params: valid_attributes, as: :json
|
82
82
|
expect(response).to have_http_status(:created)
|
83
83
|
expect(response.body).to match_json_schema(:post)
|
84
84
|
expect(response.body).to be_json_eql(serialize(@shared_board.posts.last))
|
@@ -88,18 +88,18 @@ RSpec.describe "Api::Board::Posts", type: :request do
|
|
88
88
|
|
89
89
|
context "Board shared user" do
|
90
90
|
it "return http unprocessable_entity when invalid title" do
|
91
|
-
post
|
91
|
+
post unsakini_board_posts_path(@shared_board), headers: auth_headers(@user_2), params: invalid_title_attribute, as: :json
|
92
92
|
expect(response).to have_http_status(:unprocessable_entity)
|
93
93
|
# todo: assert errors
|
94
94
|
end
|
95
95
|
it "return http unprocessable_entity when invalid content" do
|
96
|
-
post
|
96
|
+
post unsakini_board_posts_path(@shared_board), headers: auth_headers(@user_2), params: invalid_content_attribute, as: :json
|
97
97
|
expect(response).to have_http_status(:unprocessable_entity)
|
98
98
|
# todo: assert errors
|
99
99
|
end
|
100
100
|
it "successfully creates a post" do
|
101
101
|
board_posts_count = @shared_board.posts.count
|
102
|
-
post
|
102
|
+
post unsakini_board_posts_path(@shared_board), headers: auth_headers(@user_2), params: valid_attributes, as: :json
|
103
103
|
expect(response).to have_http_status(:created)
|
104
104
|
expect(response.body).to match_json_schema(:post)
|
105
105
|
expect(response.body).to be_json_eql(serialize(@shared_board.posts.last))
|
@@ -113,23 +113,23 @@ RSpec.describe "Api::Board::Posts", type: :request do
|
|
113
113
|
|
114
114
|
# owner of the post in the board should be able to update it
|
115
115
|
it "return http unauthorized" do
|
116
|
-
put
|
116
|
+
put unsakini_board_post_path(@shared_board, @shared_post), as: :json
|
117
117
|
expect(response).to have_http_status(:unauthorized)
|
118
118
|
end
|
119
119
|
|
120
120
|
context "Post owner" do
|
121
121
|
it "return http unprocessable_entity when invalid title" do
|
122
|
-
put
|
122
|
+
put unsakini_board_post_path(@shared_board, @shared_post), headers: auth_headers(@user), params: invalid_title_attribute, as: :json
|
123
123
|
expect(response).to have_http_status(:unprocessable_entity)
|
124
124
|
# todo: assert errors
|
125
125
|
end
|
126
126
|
it "return http unprocessable_entity when invalid content" do
|
127
|
-
put
|
127
|
+
put unsakini_board_post_path(@shared_board, @shared_post), headers: auth_headers(@user), params: invalid_content_attribute, as: :json
|
128
128
|
expect(response).to have_http_status(:unprocessable_entity)
|
129
129
|
# todo: assert errors
|
130
130
|
end
|
131
131
|
it "updates my post belonging to my board" do
|
132
|
-
put
|
132
|
+
put unsakini_board_post_path(@shared_board, @shared_post), headers: auth_headers(@user), params: valid_attributes, as: :json
|
133
133
|
expect(response).to have_http_status(:ok)
|
134
134
|
expect(response.body).to match_json_schema(:post)
|
135
135
|
@shared_post.reload
|
@@ -142,7 +142,7 @@ RSpec.describe "Api::Board::Posts", type: :request do
|
|
142
142
|
# while the shared user should not
|
143
143
|
context "Shared user" do
|
144
144
|
it "cannot update the post" do
|
145
|
-
put
|
145
|
+
put unsakini_board_post_path(@shared_board, @shared_post), headers: auth_headers(@user_2), params: valid_attributes, as: :json
|
146
146
|
expect(response).to have_http_status(:forbidden)
|
147
147
|
@shared_post.reload
|
148
148
|
expect(@shared_post.title).to_not eq(valid_attributes[:title])
|
@@ -154,27 +154,27 @@ RSpec.describe "Api::Board::Posts", type: :request do
|
|
154
154
|
describe "Delete my post" do
|
155
155
|
|
156
156
|
it "return http unauthorized" do
|
157
|
-
delete
|
157
|
+
delete unsakini_board_post_path(@shared_board, @shared_post)
|
158
158
|
expect(response).to have_http_status(:unauthorized)
|
159
159
|
end
|
160
160
|
|
161
161
|
describe "Post owner" do
|
162
162
|
it "deletes own post" do
|
163
163
|
board_posts_count = @shared_board.posts.count
|
164
|
-
delete
|
164
|
+
delete unsakini_board_post_path(@shared_board, @shared_post), headers: auth_headers(@user)
|
165
165
|
expect(response).to have_http_status(:ok)
|
166
166
|
expect(@shared_board.posts.count).to eq(board_posts_count-1)
|
167
|
-
expect(Post.find_by_id(@shared_post.id)).to be_nil
|
167
|
+
expect(Unsakini::Post.find_by_id(@shared_post.id)).to be_nil
|
168
168
|
end
|
169
169
|
end
|
170
170
|
|
171
171
|
describe "Shared user" do
|
172
172
|
it "return http forbidden" do
|
173
173
|
board_posts_count = @shared_board.posts.count
|
174
|
-
delete
|
174
|
+
delete unsakini_board_post_path(@shared_board, @shared_post), headers: auth_headers(@user_2)
|
175
175
|
expect(response).to have_http_status(:forbidden)
|
176
176
|
expect(board_posts_count).to eq(@shared_board.posts.count)
|
177
|
-
expect(Post.find_by_id(@shared_post.id)).not_to be_nil
|
177
|
+
expect(Unsakini::Post.find_by_id(@shared_post.id)).not_to be_nil
|
178
178
|
end
|
179
179
|
end
|
180
180
|
|