reviewable 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +23 -0
- data/app/assets/javascripts/reviewable/application.js +13 -0
- data/app/assets/stylesheets/reviewable/application.css +15 -0
- data/app/controllers/reviewable/questions_controller.rb +58 -0
- data/app/controllers/reviewable/reviewable_controller.rb +5 -0
- data/app/controllers/reviewable/reviews_controller.rb +58 -0
- data/app/helpers/reviewable/application_helper.rb +4 -0
- data/app/models/reviewable/question.rb +37 -0
- data/app/models/reviewable/review.rb +24 -0
- data/app/views/layouts/reviewable/application.html.erb +14 -0
- data/app/views/reviewable/questions/_form.html.erb +28 -0
- data/app/views/reviewable/questions/_question.html.erb +10 -0
- data/app/views/reviewable/questions/_question.json.jbuilder +10 -0
- data/app/views/reviewable/questions/edit.html.erb +3 -0
- data/app/views/reviewable/questions/index.html.erb +21 -0
- data/app/views/reviewable/questions/index.json.jbuilder +5 -0
- data/app/views/reviewable/questions/new.html.erb +3 -0
- data/config/routes.rb +3 -0
- data/db/migrate/20141013142401_enable_uuid_ossp_extension.rb +7 -0
- data/db/migrate/20141013142552_create_reviewable_reviews.rb +15 -0
- data/db/migrate/20141013145632_create_reviewable_questions.rb +15 -0
- data/lib/reviewable.rb +4 -0
- data/lib/reviewable/acts_as_reviewable.rb +25 -0
- data/lib/reviewable/engine.rb +22 -0
- data/lib/reviewable/version.rb +3 -0
- data/lib/tasks/reviewable_tasks.rake +4 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/models/product.rb +4 -0
- data/spec/dummy/app/models/user.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +23 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +85 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +78 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/assets.rb +8 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20141013173317_create_products.rb +9 -0
- data/spec/dummy/db/migrate/20141013174327_create_users.rb +9 -0
- data/spec/dummy/db/schema.rb +56 -0
- data/spec/dummy/log/development.log +256 -0
- data/spec/dummy/log/test.log +41431 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/dummy/tmp/capybara/capybara-201410141638119443873212.html +24 -0
- data/spec/dummy/tmp/capybara/capybara-201410141807209663577120.html +34 -0
- data/spec/dummy/tmp/capybara/capybara-201410141808528516645046.html +34 -0
- data/spec/dummy/tmp/capybara/capybara-201410141809478831156886.html +34 -0
- data/spec/dummy/tmp/capybara/capybara-201410141811022811314427.html +34 -0
- data/spec/dummy/tmp/capybara/capybara-201410141813201391325985.html +34 -0
- data/spec/dummy/tmp/capybara/capybara-201410141855296114330585.html +86 -0
- data/spec/dummy/tmp/capybara/capybara-201410141857326053813040.html +34 -0
- data/spec/dummy/tmp/capybara/capybara-201410141857482438637842.html +35 -0
- data/spec/dummy/tmp/capybara/capybara-201410141858304336368395.html +35 -0
- data/spec/dummy/tmp/capybara/capybara-20141014185925908498887.html +86 -0
- data/spec/dummy/tmp/capybara/capybara-201410141904184954015862.html +35 -0
- data/spec/dummy/tmp/capybara/capybara-201410141905062396116920.html +46 -0
- data/spec/dummy/tmp/capybara/capybara-201410141905261123020644.html +46 -0
- data/spec/factories/product.rb +7 -0
- data/spec/factories/question.rb +25 -0
- data/spec/factories/review.rb +22 -0
- data/spec/factories/user.rb +7 -0
- data/spec/features/questions/question_create_spec.rb +43 -0
- data/spec/features/questions/question_delete_spec.rb +30 -0
- data/spec/features/questions/question_edit_spec.rb +106 -0
- data/spec/features/questions/question_index_spec.rb +23 -0
- data/spec/models/acts_as_reviewable_spec.rb +12 -0
- data/spec/models/reviewable/question_spec.rb +27 -0
- data/spec/models/reviewable/review_spec.rb +61 -0
- data/spec/rails_helper.rb +60 -0
- data/spec/spec_helper.rb +78 -0
- metadata +263 -0
@@ -0,0 +1,34 @@
|
|
1
|
+
<!DOCTYPE html><html><head>
|
2
|
+
<title>Dummy</title>
|
3
|
+
<link data-turbolinks-track="true" href="/assets/application.css" media="all" rel="stylesheet">
|
4
|
+
<script data-turbolinks-track="true" src="/assets/application.js"></script>
|
5
|
+
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
|
9
|
+
<h2>Questions</h2>
|
10
|
+
|
11
|
+
<table class="table table-striped">
|
12
|
+
<thead>
|
13
|
+
<tr>
|
14
|
+
<th>Question text</th>
|
15
|
+
<th>Question type</th>
|
16
|
+
<th>Enabled</th>
|
17
|
+
<th>Updated at</th>
|
18
|
+
<th></th>
|
19
|
+
</tr>
|
20
|
+
</thead>
|
21
|
+
|
22
|
+
<tbody>
|
23
|
+
|
24
|
+
</tbody>
|
25
|
+
</table>
|
26
|
+
|
27
|
+
<br>
|
28
|
+
|
29
|
+
<a href="/reviewable/questions/new">New Question</a>
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
</body></html>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<!DOCTYPE html><html><head>
|
2
|
+
<title>Dummy</title>
|
3
|
+
<link data-turbolinks-track="true" href="/assets/application.css" media="all" rel="stylesheet">
|
4
|
+
<script data-turbolinks-track="true" src="/assets/application.js"></script>
|
5
|
+
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
|
9
|
+
<h2>Questions</h2>
|
10
|
+
|
11
|
+
|
12
|
+
#<ActiveRecord::Relation []>
|
13
|
+
|
14
|
+
<table class="table table-striped">
|
15
|
+
<thead>
|
16
|
+
<tr>
|
17
|
+
<th>Question text</th>
|
18
|
+
<th>Question type</th>
|
19
|
+
<th>Enabled</th>
|
20
|
+
<th>Updated at</th>
|
21
|
+
<th></th>
|
22
|
+
</tr>
|
23
|
+
</thead>
|
24
|
+
|
25
|
+
<tbody></tbody>
|
26
|
+
</table>
|
27
|
+
|
28
|
+
<br>
|
29
|
+
|
30
|
+
<a href="/reviewable/questions/new">New Question</a>
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
</body></html>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<!DOCTYPE html><html><head>
|
2
|
+
<title>Dummy</title>
|
3
|
+
<link data-turbolinks-track="true" href="/assets/application.css" media="all" rel="stylesheet">
|
4
|
+
<script data-turbolinks-track="true" src="/assets/application.js"></script>
|
5
|
+
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
|
9
|
+
<h2>Questions</h2>
|
10
|
+
|
11
|
+
|
12
|
+
#<ActiveRecord::Relation []>
|
13
|
+
|
14
|
+
<table class="table table-striped">
|
15
|
+
<thead>
|
16
|
+
<tr>
|
17
|
+
<th>Question text</th>
|
18
|
+
<th>Question type</th>
|
19
|
+
<th>Enabled</th>
|
20
|
+
<th>Updated at</th>
|
21
|
+
<th></th>
|
22
|
+
</tr>
|
23
|
+
</thead>
|
24
|
+
|
25
|
+
<tbody></tbody>
|
26
|
+
</table>
|
27
|
+
|
28
|
+
<br>
|
29
|
+
|
30
|
+
<a href="/reviewable/questions/new">New Question</a>
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
</body></html>
|
@@ -0,0 +1,86 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<link data-turbolinks-track="true" href="/assets/application.css" media="all" rel="stylesheet" />
|
6
|
+
<script data-turbolinks-track="true" src="/assets/application.js"></script>
|
7
|
+
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<h2>Questions</h2>
|
12
|
+
|
13
|
+
<table class='table table-striped'>
|
14
|
+
<thead>
|
15
|
+
<tr>
|
16
|
+
<th>Question text</th>
|
17
|
+
<th>Question type</th>
|
18
|
+
<th>Enabled</th>
|
19
|
+
<th>Updated at</th>
|
20
|
+
<th></th>
|
21
|
+
</tr>
|
22
|
+
</thead>
|
23
|
+
|
24
|
+
<tbody>
|
25
|
+
#<ActiveRecord::Relation [#<Reviewable::Question id: 1229, question_text: "question_1", question_type: "select", slug: "slug_1", answer_options_string: "", answer_min: nil, answer_max: nil, enabled: nil, created_at: "2014-10-14 16:59:25", updated_at: "2014-10-14 16:59:25">, #<Reviewable::Question id: 1230, question_text: "question_2", question_type: "select", slug: "slug_2", answer_options_string: "", answer_min: nil, answer_max: nil, enabled: nil, created_at: "2014-10-14 16:59:25", updated_at: "2014-10-14 16:59:25">, #<Reviewable::Question id: 1231, question_text: "question_3", question_type: "string", slug: "slug_3", answer_options_string: "", answer_min: nil, answer_max: nil, enabled: nil, created_at: "2014-10-14 16:59:25", updated_at: "2014-10-14 16:59:25">, #<Reviewable::Question id: 1232, question_text: "question_4", question_type: "select", slug: "slug_4", answer_options_string: "", answer_min: nil, answer_max: nil, enabled: nil, created_at: "2014-10-14 16:59:25", updated_at: "2014-10-14 16:59:25">, #<Reviewable::Question id: 1233, question_text: "question_5", question_type: "text", slug: "slug_5", answer_options_string: "", answer_min: nil, answer_max: nil, enabled: nil, created_at: "2014-10-14 16:59:25", updated_at: "2014-10-14 16:59:25">]>
|
26
|
+
<tr>
|
27
|
+
<td>question_1</td>
|
28
|
+
<td>select</td>
|
29
|
+
<td></td>
|
30
|
+
<td>2014-10-14 16:59:25 UTC</td>
|
31
|
+
<td>
|
32
|
+
<a href="/reviewable/questions/1229/edit">Edit</a> |
|
33
|
+
<a data-confirm="Are you sure?" data-method="delete" href="/reviewable/questions/1229" rel="nofollow">Destroy</a>
|
34
|
+
</td>
|
35
|
+
</tr>
|
36
|
+
<tr>
|
37
|
+
<td>question_2</td>
|
38
|
+
<td>select</td>
|
39
|
+
<td></td>
|
40
|
+
<td>2014-10-14 16:59:25 UTC</td>
|
41
|
+
<td>
|
42
|
+
<a href="/reviewable/questions/1230/edit">Edit</a> |
|
43
|
+
<a data-confirm="Are you sure?" data-method="delete" href="/reviewable/questions/1230" rel="nofollow">Destroy</a>
|
44
|
+
</td>
|
45
|
+
</tr>
|
46
|
+
<tr>
|
47
|
+
<td>question_3</td>
|
48
|
+
<td>string</td>
|
49
|
+
<td></td>
|
50
|
+
<td>2014-10-14 16:59:25 UTC</td>
|
51
|
+
<td>
|
52
|
+
<a href="/reviewable/questions/1231/edit">Edit</a> |
|
53
|
+
<a data-confirm="Are you sure?" data-method="delete" href="/reviewable/questions/1231" rel="nofollow">Destroy</a>
|
54
|
+
</td>
|
55
|
+
</tr>
|
56
|
+
<tr>
|
57
|
+
<td>question_4</td>
|
58
|
+
<td>select</td>
|
59
|
+
<td></td>
|
60
|
+
<td>2014-10-14 16:59:25 UTC</td>
|
61
|
+
<td>
|
62
|
+
<a href="/reviewable/questions/1232/edit">Edit</a> |
|
63
|
+
<a data-confirm="Are you sure?" data-method="delete" href="/reviewable/questions/1232" rel="nofollow">Destroy</a>
|
64
|
+
</td>
|
65
|
+
</tr>
|
66
|
+
<tr>
|
67
|
+
<td>question_5</td>
|
68
|
+
<td>text</td>
|
69
|
+
<td></td>
|
70
|
+
<td>2014-10-14 16:59:25 UTC</td>
|
71
|
+
<td>
|
72
|
+
<a href="/reviewable/questions/1233/edit">Edit</a> |
|
73
|
+
<a data-confirm="Are you sure?" data-method="delete" href="/reviewable/questions/1233" rel="nofollow">Destroy</a>
|
74
|
+
</td>
|
75
|
+
</tr>
|
76
|
+
|
77
|
+
</tbody>
|
78
|
+
</table>
|
79
|
+
|
80
|
+
<br>
|
81
|
+
|
82
|
+
<a href="/reviewable/questions/new">New Question</a>
|
83
|
+
|
84
|
+
|
85
|
+
</body>
|
86
|
+
</html>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<!DOCTYPE html><html><head>
|
2
|
+
<title>Dummy</title>
|
3
|
+
<link data-turbolinks-track="true" href="/assets/application.css" media="all" rel="stylesheet">
|
4
|
+
<script data-turbolinks-track="true" src="/assets/application.js"></script>
|
5
|
+
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
|
9
|
+
<h2>Questions</h2>
|
10
|
+
|
11
|
+
|
12
|
+
#<ActiveRecord::Relation []>
|
13
|
+
|
14
|
+
<table class="table table-striped">
|
15
|
+
<thead>
|
16
|
+
<tr>
|
17
|
+
<th>Question text</th>
|
18
|
+
<th>Question type</th>
|
19
|
+
<th>Enabled</th>
|
20
|
+
<th>Updated at</th>
|
21
|
+
<th></th>
|
22
|
+
</tr>
|
23
|
+
</thead>
|
24
|
+
|
25
|
+
<tbody></tbody>
|
26
|
+
</table>
|
27
|
+
|
28
|
+
<br>
|
29
|
+
|
30
|
+
<a href="/reviewable/questions/new">New Question</a>
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
</body></html>
|
@@ -0,0 +1,46 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<link data-turbolinks-track="true" href="/assets/application.css" media="all" rel="stylesheet" />
|
6
|
+
<script data-turbolinks-track="true" src="/assets/application.js"></script>
|
7
|
+
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<h2>Questions</h2>
|
12
|
+
|
13
|
+
<table class='table table-striped'>
|
14
|
+
<thead>
|
15
|
+
<tr>
|
16
|
+
<th>Question text</th>
|
17
|
+
<th>Question type</th>
|
18
|
+
<th>Enabled</th>
|
19
|
+
<th>Updated at</th>
|
20
|
+
<th></th>
|
21
|
+
</tr>
|
22
|
+
</thead>
|
23
|
+
|
24
|
+
<tbody>
|
25
|
+
#<ActiveRecord::Relation [#<Reviewable::Question id: 1293, question_text: "question_1", question_type: "string", slug: "slug_1", answer_options_string: "", answer_min: nil, answer_max: nil, enabled: nil, created_at: "2014-10-14 17:05:06", updated_at: "2014-10-14 17:05:06">]>
|
26
|
+
<tr>
|
27
|
+
<td>question_1</td>
|
28
|
+
<td>string</td>
|
29
|
+
<td></td>
|
30
|
+
<td>2014-10-14 17:05:06 UTC</td>
|
31
|
+
<td>
|
32
|
+
<a href="/reviewable/questions/1293/edit">Edit</a> |
|
33
|
+
<a data-confirm="Are you sure?" data-method="delete" href="/reviewable/questions/1293" rel="nofollow">Destroy</a>
|
34
|
+
</td>
|
35
|
+
</tr>
|
36
|
+
|
37
|
+
</tbody>
|
38
|
+
</table>
|
39
|
+
|
40
|
+
<br>
|
41
|
+
|
42
|
+
<a href="/reviewable/questions/new">New Question</a>
|
43
|
+
|
44
|
+
|
45
|
+
</body>
|
46
|
+
</html>
|
@@ -0,0 +1,46 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<link data-turbolinks-track="true" href="/assets/application.css" media="all" rel="stylesheet" />
|
6
|
+
<script data-turbolinks-track="true" src="/assets/application.js"></script>
|
7
|
+
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<h2>Questions</h2>
|
12
|
+
|
13
|
+
<table class='table table-striped'>
|
14
|
+
<thead>
|
15
|
+
<tr>
|
16
|
+
<th>Question text</th>
|
17
|
+
<th>Question type</th>
|
18
|
+
<th>Enabled</th>
|
19
|
+
<th>Updated at</th>
|
20
|
+
<th></th>
|
21
|
+
</tr>
|
22
|
+
</thead>
|
23
|
+
|
24
|
+
<tbody>
|
25
|
+
#<ActiveRecord::Relation [#<Reviewable::Question id: 1323, question_text: "question_1", question_type: "select", slug: "slug_1", answer_options_string: "", answer_min: nil, answer_max: nil, enabled: nil, created_at: "2014-10-14 17:05:26", updated_at: "2014-10-14 17:05:26">]>
|
26
|
+
<tr>
|
27
|
+
<td>question_1</td>
|
28
|
+
<td>select</td>
|
29
|
+
<td></td>
|
30
|
+
<td>2014-10-14 17:05:26 UTC</td>
|
31
|
+
<td>
|
32
|
+
<a href="/reviewable/questions/1323/edit">Edit</a> |
|
33
|
+
<a data-confirm="Are you sure?" data-method="delete" href="/reviewable/questions/1323" rel="nofollow">Destroy</a>
|
34
|
+
</td>
|
35
|
+
</tr>
|
36
|
+
|
37
|
+
</tbody>
|
38
|
+
</table>
|
39
|
+
|
40
|
+
<br>
|
41
|
+
|
42
|
+
<a href="/reviewable/questions/new">New Question</a>
|
43
|
+
|
44
|
+
|
45
|
+
</body>
|
46
|
+
</html>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Read about factories at https://github.com/thoughtbot/factory_girl
|
2
|
+
|
3
|
+
FactoryGirl.define do
|
4
|
+
factory :question, :class => 'Reviewable::Question' do
|
5
|
+
sequence(:question_text) {|n| "question_#{n}"}
|
6
|
+
question_type { Reviewable::Question::TYPES.sample }
|
7
|
+
sequence(:slug) {|n| "slug_#{n}"}
|
8
|
+
# t.string :question_text
|
9
|
+
# t.string :question_type
|
10
|
+
# t.string :slug
|
11
|
+
# t.string :answer_options_string, array: true
|
12
|
+
# t.integer :answer_min
|
13
|
+
# t.integer :answer_max
|
14
|
+
# t.boolean :enabled
|
15
|
+
# enabled true
|
16
|
+
|
17
|
+
trait :enabled do
|
18
|
+
enabled true
|
19
|
+
end
|
20
|
+
|
21
|
+
trait :disabled do
|
22
|
+
enabled false
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Read about factories at https://github.com/thoughtbot/factory_girl
|
2
|
+
|
3
|
+
FactoryGirl.define do
|
4
|
+
factory :review, :class => 'Reviewable::Review' do
|
5
|
+
association :reviewable_object, factory: :product
|
6
|
+
association :reviewer, factory: :user
|
7
|
+
|
8
|
+
|
9
|
+
# t.references :reviewable_object, :polymorphic => true
|
10
|
+
# t.references :reviewer, :polymorphic => true
|
11
|
+
# t.uuid :uuid, default: 'uuid_generate_v4()'
|
12
|
+
# t.json :results
|
13
|
+
|
14
|
+
trait :submitted do
|
15
|
+
submitted_at {Time.now}
|
16
|
+
end
|
17
|
+
|
18
|
+
trait :unsubmitted do
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
|
4
|
+
# Feature: Question create
|
5
|
+
# As an admin
|
6
|
+
# I want to create a new question
|
7
|
+
# So it appears on reviews
|
8
|
+
feature 'Question create' do
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
# Scenario: Admin can create questions
|
13
|
+
# Given I am signed in
|
14
|
+
# When I fill in a question form
|
15
|
+
# And I click Create
|
16
|
+
# Then a new question gets created
|
17
|
+
scenario "admin create questions" do
|
18
|
+
visit new_question_path
|
19
|
+
fill_in 'question_question_text', with: 'who are you?'
|
20
|
+
select 'string', from: 'question_question_type'
|
21
|
+
fill_in 'question_slug', with: 'who-are-you'
|
22
|
+
check 'question_enabled'
|
23
|
+
expect {
|
24
|
+
click_button 'Create'
|
25
|
+
}.to change{Reviewable::Question.count}.by(1)
|
26
|
+
expect(current_path).to eq questions_path
|
27
|
+
end
|
28
|
+
|
29
|
+
# Scenario: Admin cannot create invalid questions
|
30
|
+
# Given I am signed in
|
31
|
+
# When I dont fill in a question form
|
32
|
+
# And I click Create
|
33
|
+
# Then a new question is not created
|
34
|
+
# And I see validation errors
|
35
|
+
scenario "admin create questions" do
|
36
|
+
visit new_question_path
|
37
|
+
expect {
|
38
|
+
click_button 'Create'
|
39
|
+
}.not_to change{Reviewable::Question.count}
|
40
|
+
expect(page).to have_content "can't be blank"
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
|
4
|
+
# Feature: question delete
|
5
|
+
# As a user
|
6
|
+
# I want to delete a question
|
7
|
+
# So it doesnt appear in reviews
|
8
|
+
feature 'question delete' do
|
9
|
+
|
10
|
+
|
11
|
+
# Scenario: Admin can delete a question
|
12
|
+
# Given I am signed in
|
13
|
+
# When I delete a question
|
14
|
+
# Then I should see a question deleted message
|
15
|
+
scenario 'admin can delete questions' do
|
16
|
+
question = create(:question)
|
17
|
+
visit questions_path
|
18
|
+
expect{
|
19
|
+
click_link 'Destroy'
|
20
|
+
}.to change{Reviewable::Question.count}.by(-1)
|
21
|
+
|
22
|
+
expect(current_path).to eq questions_path
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
|