unsakini 0.0.3 → 0.0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +6 -7
- data/angular/README.md +31 -1
- data/angular/dist/inline.map +1 -1
- data/angular/dist/main.bundle.js +64 -110
- data/angular/dist/main.map +1 -1
- data/angular/dist/styles.map +1 -1
- data/angular/package.json +2 -1
- data/app/controllers/api/comments_controller.rb +1 -1
- data/app/controllers/api/posts_controller.rb +1 -1
- data/lib/unsakini/version.rb +1 -1
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/public/app/inline.map +1 -1
- data/spec/dummy/public/app/main.bundle.js +64 -110
- data/spec/dummy/public/app/main.map +1 -1
- data/spec/dummy/public/app/styles.map +1 -1
- data/spec/requests/api/boards/api_boards_pagination_spec.rb +16 -0
- data/spec/requests/api/comments/api_comments_pagination_spec.rb +31 -0
- data/spec/requests/api/comments/api_comments_private_board_spec.rb +197 -0
- data/spec/requests/api/comments/{api_comments_spec.rb → api_comments_shared_board_spec.rb} +0 -180
- data/spec/requests/api/posts/api_posts_pagination_spec.rb +34 -0
- data/spec/requests/api/posts/api_posts_private_board_spec.rb +136 -0
- data/spec/requests/api/posts/{api_posts_spec.rb → api_posts_shared_board_spec.rb} +0 -116
- data/spec/support/scenario_helper.rb +34 -2
- metadata +13 -6
- data/angular/LICENSE +0 -21
@@ -0,0 +1,136 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
# test scope is @user is owner of the board and owner of the post/s
|
4
|
+
RSpec.describe "Api::Board::Posts", type: :request do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
user_has_shared_board_scenario
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:valid_attributes) {
|
11
|
+
{title: Faker::Name.title, content: Faker::Hacker.say_something_smart}
|
12
|
+
}
|
13
|
+
let(:invalid_title_attribute) {
|
14
|
+
{title: "", content: Faker::Hacker.say_something_smart}
|
15
|
+
}
|
16
|
+
let(:invalid_content_attribute) {
|
17
|
+
{title: Faker::Name.title, content: ""}
|
18
|
+
}
|
19
|
+
|
20
|
+
context "Privat Board Posts" do
|
21
|
+
|
22
|
+
describe "Get All Posts" do
|
23
|
+
|
24
|
+
it "return http unauthorized" do
|
25
|
+
get api_board_posts_path(@board)
|
26
|
+
expect(response).to have_http_status(:unauthorized)
|
27
|
+
end
|
28
|
+
it "return http forbidden" do
|
29
|
+
get api_board_posts_path(@board), headers: auth_headers(@user_2)
|
30
|
+
expect(response).to have_http_status(:forbidden)
|
31
|
+
end
|
32
|
+
it "return post" do
|
33
|
+
get api_board_posts_path(@board), headers: auth_headers(@user)
|
34
|
+
expect(response).to have_http_status(:ok)
|
35
|
+
expect(body_to_json('0')).to match_json_schema(:post)
|
36
|
+
expect(response.body).to be_json_eql(serialize(@board.posts.all))
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "Get Single Post" do
|
41
|
+
it "return http unauthorized" do
|
42
|
+
get api_board_post_path(@board, @post)
|
43
|
+
expect(response).to have_http_status(:unauthorized)
|
44
|
+
end
|
45
|
+
it "return http forbidden" do
|
46
|
+
get api_board_post_path(@board, @post), headers: auth_headers(@user_2)
|
47
|
+
expect(response).to have_http_status(:forbidden)
|
48
|
+
end
|
49
|
+
it "return post" do
|
50
|
+
get api_board_post_path(@board, @post), headers: auth_headers(@user)
|
51
|
+
expect(response).to have_http_status(:ok)
|
52
|
+
expect(response.body).to match_json_schema(:post)
|
53
|
+
expect(response.body).to be_json_eql(serialize(@post))
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "Create Post" do
|
58
|
+
it "return http unauthorized" do
|
59
|
+
post api_board_posts_path(@board), as: :json
|
60
|
+
expect(response).to have_http_status(:unauthorized)
|
61
|
+
end
|
62
|
+
it "return http forbidden when not owner" do
|
63
|
+
post api_board_posts_path(@board), headers: auth_headers(@user_2), params: valid_attributes, as: :json
|
64
|
+
expect(response).to have_http_status(:forbidden)
|
65
|
+
end
|
66
|
+
it "return http unprocessable_entity when invalid title" do
|
67
|
+
post api_board_posts_path(@board), headers: auth_headers(@user), params: invalid_title_attribute, as: :json
|
68
|
+
expect(response).to have_http_status(:unprocessable_entity)
|
69
|
+
# todo: assert errors
|
70
|
+
end
|
71
|
+
it "return http unprocessable_entity when invalid content" do
|
72
|
+
post api_board_posts_path(@board), headers: auth_headers(@user), params: invalid_content_attribute, as: :json
|
73
|
+
expect(response).to have_http_status(:unprocessable_entity)
|
74
|
+
# todo: assert errors
|
75
|
+
end
|
76
|
+
it "successfully creates a post" do
|
77
|
+
board_posts_count = @board.posts.count
|
78
|
+
post api_board_posts_path(@board), headers: auth_headers(@user), params: valid_attributes, as: :json
|
79
|
+
expect(response).to have_http_status(:created)
|
80
|
+
expect(response.body).to match_json_schema(:post)
|
81
|
+
expect(response.body).to be_json_eql(serialize(@board.posts.last))
|
82
|
+
expect(@board.posts.count).to eq(board_posts_count+1)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "Update Post" do
|
87
|
+
|
88
|
+
it "return http unauthorized" do
|
89
|
+
put api_board_post_path(@board, @post), as: :json
|
90
|
+
expect(response).to have_http_status(:unauthorized)
|
91
|
+
end
|
92
|
+
it "return http forbidden when not owner" do
|
93
|
+
put api_board_post_path(@board, @post), headers: auth_headers(@user_2), params: valid_attributes, as: :json
|
94
|
+
expect(response).to have_http_status(:forbidden)
|
95
|
+
end
|
96
|
+
it "return http unprocessable_entity when invalid title" do
|
97
|
+
put api_board_post_path(@board, @post), headers: auth_headers(@user), params: invalid_title_attribute, as: :json
|
98
|
+
expect(response).to have_http_status(:unprocessable_entity)
|
99
|
+
# todo: assert errors
|
100
|
+
end
|
101
|
+
it "return http unprocessable_entity when invalid content" do
|
102
|
+
put api_board_post_path(@board, @post), headers: auth_headers(@user), params: invalid_content_attribute, as: :json
|
103
|
+
expect(response).to have_http_status(:unprocessable_entity)
|
104
|
+
# todo: assert errors
|
105
|
+
end
|
106
|
+
it "updates my post belonging to my board" do
|
107
|
+
put api_board_post_path(@board, @post), headers: auth_headers(@user), params: valid_attributes, as: :json
|
108
|
+
expect(response).to have_http_status(:ok)
|
109
|
+
expect(response.body).to match_json_schema(:post)
|
110
|
+
expect(body_to_json('title')).to eq(valid_attributes[:title])
|
111
|
+
expect(body_to_json('content')).to eq(valid_attributes[:content])
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe "Delete Post" do
|
116
|
+
it "return http unauthorized" do
|
117
|
+
delete api_board_post_path(@board, @post)
|
118
|
+
expect(response).to have_http_status(:unauthorized)
|
119
|
+
end
|
120
|
+
it "return http forbidden if not owner" do
|
121
|
+
delete api_board_post_path(@board, @post), headers: auth_headers(@user_2)
|
122
|
+
expect(response).to have_http_status(:forbidden)
|
123
|
+
end
|
124
|
+
it "removes my post" do
|
125
|
+
post_id = @post.id
|
126
|
+
board_posts_count = @board.posts.count
|
127
|
+
delete api_board_post_path(@board, @post), headers: auth_headers(@user)
|
128
|
+
expect(response).to have_http_status(:ok)
|
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
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
@@ -17,122 +17,6 @@ RSpec.describe "Api::Board::Posts", type: :request do
|
|
17
17
|
{title: Faker::Name.title, content: ""}
|
18
18
|
}
|
19
19
|
|
20
|
-
context "Privat Board Posts" do
|
21
|
-
|
22
|
-
describe "Get All Posts" do
|
23
|
-
|
24
|
-
it "return http unauthorized" do
|
25
|
-
get api_board_posts_path(@board)
|
26
|
-
expect(response).to have_http_status(:unauthorized)
|
27
|
-
end
|
28
|
-
it "return http forbidden" do
|
29
|
-
get api_board_posts_path(@board), headers: auth_headers(@user_2)
|
30
|
-
expect(response).to have_http_status(:forbidden)
|
31
|
-
end
|
32
|
-
it "return post" do
|
33
|
-
get api_board_posts_path(@board), headers: auth_headers(@user)
|
34
|
-
expect(response).to have_http_status(:ok)
|
35
|
-
expect(body_to_json('0')).to match_json_schema(:post)
|
36
|
-
expect(response.body).to be_json_eql(serialize(@board.posts.all))
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe "Get Single Post" do
|
41
|
-
it "return http unauthorized" do
|
42
|
-
get api_board_post_path(@board, @post)
|
43
|
-
expect(response).to have_http_status(:unauthorized)
|
44
|
-
end
|
45
|
-
it "return http forbidden" do
|
46
|
-
get api_board_post_path(@board, @post), headers: auth_headers(@user_2)
|
47
|
-
expect(response).to have_http_status(:forbidden)
|
48
|
-
end
|
49
|
-
it "return post" do
|
50
|
-
get api_board_post_path(@board, @post), headers: auth_headers(@user)
|
51
|
-
expect(response).to have_http_status(:ok)
|
52
|
-
expect(response.body).to match_json_schema(:post)
|
53
|
-
expect(response.body).to be_json_eql(serialize(@post))
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
describe "Create Post" do
|
58
|
-
it "return http unauthorized" do
|
59
|
-
post api_board_posts_path(@board), as: :json
|
60
|
-
expect(response).to have_http_status(:unauthorized)
|
61
|
-
end
|
62
|
-
it "return http forbidden when not owner" do
|
63
|
-
post api_board_posts_path(@board), headers: auth_headers(@user_2), params: valid_attributes, as: :json
|
64
|
-
expect(response).to have_http_status(:forbidden)
|
65
|
-
end
|
66
|
-
it "return http unprocessable_entity when invalid title" do
|
67
|
-
post api_board_posts_path(@board), headers: auth_headers(@user), params: invalid_title_attribute, as: :json
|
68
|
-
expect(response).to have_http_status(:unprocessable_entity)
|
69
|
-
# todo: assert errors
|
70
|
-
end
|
71
|
-
it "return http unprocessable_entity when invalid content" do
|
72
|
-
post api_board_posts_path(@board), headers: auth_headers(@user), params: invalid_content_attribute, as: :json
|
73
|
-
expect(response).to have_http_status(:unprocessable_entity)
|
74
|
-
# todo: assert errors
|
75
|
-
end
|
76
|
-
it "successfully creates a post" do
|
77
|
-
board_posts_count = @board.posts.count
|
78
|
-
post api_board_posts_path(@board), headers: auth_headers(@user), params: valid_attributes, as: :json
|
79
|
-
expect(response).to have_http_status(:created)
|
80
|
-
expect(response.body).to match_json_schema(:post)
|
81
|
-
expect(response.body).to be_json_eql(serialize(@board.posts.last))
|
82
|
-
expect(@board.posts.count).to eq(board_posts_count+1)
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
describe "Update Post" do
|
87
|
-
|
88
|
-
it "return http unauthorized" do
|
89
|
-
put api_board_post_path(@board, @post), as: :json
|
90
|
-
expect(response).to have_http_status(:unauthorized)
|
91
|
-
end
|
92
|
-
it "return http forbidden when not owner" do
|
93
|
-
put api_board_post_path(@board, @post), headers: auth_headers(@user_2), params: valid_attributes, as: :json
|
94
|
-
expect(response).to have_http_status(:forbidden)
|
95
|
-
end
|
96
|
-
it "return http unprocessable_entity when invalid title" do
|
97
|
-
put api_board_post_path(@board, @post), headers: auth_headers(@user), params: invalid_title_attribute, as: :json
|
98
|
-
expect(response).to have_http_status(:unprocessable_entity)
|
99
|
-
# todo: assert errors
|
100
|
-
end
|
101
|
-
it "return http unprocessable_entity when invalid content" do
|
102
|
-
put api_board_post_path(@board, @post), headers: auth_headers(@user), params: invalid_content_attribute, as: :json
|
103
|
-
expect(response).to have_http_status(:unprocessable_entity)
|
104
|
-
# todo: assert errors
|
105
|
-
end
|
106
|
-
it "updates my post belonging to my board" do
|
107
|
-
put api_board_post_path(@board, @post), headers: auth_headers(@user), params: valid_attributes, as: :json
|
108
|
-
expect(response).to have_http_status(:ok)
|
109
|
-
expect(response.body).to match_json_schema(:post)
|
110
|
-
expect(body_to_json('title')).to eq(valid_attributes[:title])
|
111
|
-
expect(body_to_json('content')).to eq(valid_attributes[:content])
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
describe "Delete Post" do
|
116
|
-
it "return http unauthorized" do
|
117
|
-
delete api_board_post_path(@board, @post)
|
118
|
-
expect(response).to have_http_status(:unauthorized)
|
119
|
-
end
|
120
|
-
it "return http forbidden if not owner" do
|
121
|
-
delete api_board_post_path(@board, @post), headers: auth_headers(@user_2)
|
122
|
-
expect(response).to have_http_status(:forbidden)
|
123
|
-
end
|
124
|
-
it "removes my post" do
|
125
|
-
post_id = @post.id
|
126
|
-
board_posts_count = @board.posts.count
|
127
|
-
delete api_board_post_path(@board, @post), headers: auth_headers(@user)
|
128
|
-
expect(response).to have_http_status(:ok)
|
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
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
20
|
context "Shared Board Posts" do
|
137
21
|
|
138
22
|
describe "Get all posts" do
|
@@ -130,8 +130,8 @@ module BoardSpecHelper
|
|
130
130
|
def boards_pagination_scenario
|
131
131
|
|
132
132
|
@user = create(:user)
|
133
|
-
@num_boards =
|
134
|
-
@num_my_shared_boards =
|
133
|
+
@num_boards = 15
|
134
|
+
@num_my_shared_boards = 17
|
135
135
|
|
136
136
|
@num_boards.times do
|
137
137
|
board = create(:board)
|
@@ -159,8 +159,40 @@ module BoardSpecHelper
|
|
159
159
|
|
160
160
|
end
|
161
161
|
|
162
|
+
def user_has_many_posts_scenario
|
163
|
+
user_has_board_scenario
|
164
|
+
@num_posts = 35
|
165
|
+
|
166
|
+
@num_posts.times do
|
167
|
+
|
168
|
+
create(:post, {
|
169
|
+
user_id: @user.id,
|
170
|
+
board_id: @board.id
|
171
|
+
})
|
172
|
+
end
|
173
|
+
|
174
|
+
@num_posts = @board.posts.count
|
175
|
+
end
|
176
|
+
|
177
|
+
def post_has_many_comments_scenario
|
178
|
+
user_has_board_scenario
|
179
|
+
@num_comments = 35
|
180
|
+
|
181
|
+
@num_comments.times do
|
182
|
+
|
183
|
+
create(:comment, {
|
184
|
+
user_id: @user.id,
|
185
|
+
post_id: @post.id
|
186
|
+
})
|
187
|
+
end
|
188
|
+
|
189
|
+
@num_comments = @post.comments.count
|
190
|
+
end
|
191
|
+
|
162
192
|
end
|
163
193
|
|
194
|
+
|
195
|
+
# include to spec env
|
164
196
|
RSpec.configure do |config|
|
165
197
|
config.include BoardSpecHelper
|
166
198
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unsakini
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.3
|
4
|
+
version: 0.0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adones Pitogo
|
@@ -252,7 +252,6 @@ files:
|
|
252
252
|
- MIT-LICENSE
|
253
253
|
- README.md
|
254
254
|
- Rakefile
|
255
|
-
- angular/LICENSE
|
256
255
|
- angular/README.md
|
257
256
|
- angular/angular-cli.json
|
258
257
|
- angular/dist/favicon.ico
|
@@ -453,8 +452,12 @@ files:
|
|
453
452
|
- spec/requests/api/boards/api_private_board_spec.rb
|
454
453
|
- spec/requests/api/boards/api_shared_board_spec.rb
|
455
454
|
- spec/requests/api/boards/api_sharing_board_spec.rb
|
456
|
-
- spec/requests/api/comments/
|
457
|
-
- spec/requests/api/
|
455
|
+
- spec/requests/api/comments/api_comments_pagination_spec.rb
|
456
|
+
- spec/requests/api/comments/api_comments_private_board_spec.rb
|
457
|
+
- spec/requests/api/comments/api_comments_shared_board_spec.rb
|
458
|
+
- spec/requests/api/posts/api_posts_pagination_spec.rb
|
459
|
+
- spec/requests/api/posts/api_posts_private_board_spec.rb
|
460
|
+
- spec/requests/api/posts/api_posts_shared_board_spec.rb
|
458
461
|
- spec/schema/board.json
|
459
462
|
- spec/schema/comment.json
|
460
463
|
- spec/schema/post.json
|
@@ -607,13 +610,17 @@ test_files:
|
|
607
610
|
- spec/controllers/web_base_controller_spec.rb
|
608
611
|
- spec/rails_helper.rb
|
609
612
|
- spec/requests/api/api_users_spec.rb
|
610
|
-
- spec/requests/api/comments/
|
613
|
+
- spec/requests/api/comments/api_comments_pagination_spec.rb
|
614
|
+
- spec/requests/api/comments/api_comments_shared_board_spec.rb
|
615
|
+
- spec/requests/api/comments/api_comments_private_board_spec.rb
|
611
616
|
- spec/requests/api/boards/api_sharing_board_spec.rb
|
612
617
|
- spec/requests/api/boards/api_boards_crud_spec.rb
|
613
618
|
- spec/requests/api/boards/api_shared_board_spec.rb
|
614
619
|
- spec/requests/api/boards/api_private_board_spec.rb
|
615
620
|
- spec/requests/api/boards/api_boards_pagination_spec.rb
|
616
|
-
- spec/requests/api/posts/
|
621
|
+
- spec/requests/api/posts/api_posts_pagination_spec.rb
|
622
|
+
- spec/requests/api/posts/api_posts_shared_board_spec.rb
|
623
|
+
- spec/requests/api/posts/api_posts_private_board_spec.rb
|
617
624
|
- spec/models/comment_spec.rb
|
618
625
|
- spec/models/user_board_spec.rb
|
619
626
|
- spec/models/board_spec.rb
|
data/angular/LICENSE
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2016 unsakini
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|