survey_says 0.0.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.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +65 -0
- data/Rakefile +39 -0
- data/app/assets/images/survey_says/sprites.png +0 -0
- data/app/assets/javascripts/bootstrap.js.coffee +21 -0
- data/app/assets/javascripts/survey_says/answer_form.js +42 -0
- data/app/assets/javascripts/survey_says.js +2 -0
- data/app/assets/stylesheets/survey_says/bootstrap.css +356 -0
- data/app/assets/stylesheets/survey_says/general.css.erb +138 -0
- data/app/assets/stylesheets/survey_says/sprite.css.erb +1 -0
- data/app/assets/stylesheets/survey_says.css +1 -0
- data/app/controllers/survey_admin/answers_controller.rb +64 -0
- data/app/controllers/survey_admin/base_controller.rb +15 -0
- data/app/controllers/survey_admin/questionnaires_controller.rb +44 -0
- data/app/controllers/survey_admin/questions_controller.rb +61 -0
- data/app/controllers/survey_admin/survey_properties_controller.rb +50 -0
- data/app/helpers/survey_admin/answers_helper.rb +2 -0
- data/app/helpers/survey_admin/questionnaires_helper.rb +2 -0
- data/app/helpers/survey_admin/questions_helper.rb +2 -0
- data/app/helpers/survey_admin/survey_properties_helper.rb +2 -0
- data/app/models/answer.rb +21 -0
- data/app/models/question.rb +11 -0
- data/app/models/questionnaire.rb +3 -0
- data/app/models/score.rb +12 -0
- data/app/models/survey_image.rb +29 -0
- data/app/models/survey_property.rb +5 -0
- data/app/models/user_answer.rb +6 -0
- data/app/views/layouts/survey_admin.html.erb +39 -0
- data/app/views/survey_admin/answers/_form.html.erb +49 -0
- data/app/views/survey_admin/answers/_score.html.erb +13 -0
- data/app/views/survey_admin/answers/_survey_image.html.erb +10 -0
- data/app/views/survey_admin/answers/edit.html.erb +12 -0
- data/app/views/survey_admin/answers/index.html.erb +61 -0
- data/app/views/survey_admin/answers/new.html.erb +8 -0
- data/app/views/survey_admin/answers/show.html.erb +38 -0
- data/app/views/survey_admin/questionnaires/_form.html.erb +8 -0
- data/app/views/survey_admin/questionnaires/edit.html.erb +11 -0
- data/app/views/survey_admin/questionnaires/index.html.erb +18 -0
- data/app/views/survey_admin/questionnaires/new.html.erb +8 -0
- data/app/views/survey_admin/questionnaires/show.html.erb +17 -0
- data/app/views/survey_admin/questions/_answer.html.erb +13 -0
- data/app/views/survey_admin/questions/_form.html.erb +52 -0
- data/app/views/survey_admin/questions/edit.html.erb +11 -0
- data/app/views/survey_admin/questions/index.html.erb +30 -0
- data/app/views/survey_admin/questions/new.html.erb +10 -0
- data/app/views/survey_admin/questions/show.html.erb +29 -0
- data/app/views/survey_admin/survey_properties/_form.html.erb +8 -0
- data/app/views/survey_admin/survey_properties/edit.html.erb +11 -0
- data/app/views/survey_admin/survey_properties/index.html.erb +19 -0
- data/app/views/survey_admin/survey_properties/new.html.erb +8 -0
- data/app/views/survey_admin/survey_properties/show.html.erb +12 -0
- data/config/routes.rb +17 -0
- data/db/development.sqlite3 +0 -0
- data/db/migrate/20111208181247_create_questions.rb +11 -0
- data/db/migrate/20111208181414_create_answers.rb +14 -0
- data/db/migrate/20111208181429_create_survey_properties.rb +9 -0
- data/db/migrate/20111208181449_create_scores.rb +15 -0
- data/db/migrate/20111211175518_create_user_answers.rb +12 -0
- data/db/migrate/20111211175604_create_questionnaires.rb +8 -0
- data/db/migrate/20111211180011_add_questionaire_id_to_questions.rb +7 -0
- data/db/migrate/20111213185612_create_survey_images.rb +15 -0
- data/lib/generators/survey_models_generator.rb +32 -0
- data/lib/generators/survey_says_generator.rb +60 -0
- data/lib/survey_says/acts_as_survey_says.rb +59 -0
- data/lib/survey_says/core_ext.rb +0 -0
- data/lib/survey_says/engine.rb +4 -0
- data/lib/survey_says/version.rb +3 -0
- data/lib/survey_says.rb +7 -0
- data/lib/tasks/survey_says_tasks.rake +4 -0
- data/test/acts_as_survey_test.rb +87 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +12 -0
- data/test/dummy/app/assets/stylesheets/application.css +10 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/helpers/error_messages_helper.rb +23 -0
- data/test/dummy/app/helpers/layout_helper.rb +22 -0
- data/test/dummy/app/views/layouts/application.html.erb +19 -0
- data/test/dummy/config/application.rb +45 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +39 -0
- data/test/dummy/config/environments/production.rb +69 -0
- data/test/dummy/config/environments/test.rb +48 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +10 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +58 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20111010112000_create_users.rb +7 -0
- data/test/dummy/db/schema.rb +82 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +11108 -0
- data/test/dummy/log/test.log +12731 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +26 -0
- data/test/dummy/public/assets/products/1/large/image01.jpg +0 -0
- data/test/dummy/public/assets/products/1/mini/image01.jpg +0 -0
- data/test/dummy/public/assets/products/1/original/image01.jpg +0 -0
- data/test/dummy/public/assets/products/1/product/image01.jpg +0 -0
- data/test/dummy/public/assets/products/1/small/image01.jpg +0 -0
- data/test/dummy/public/assets/products/2/large/delete.png +0 -0
- data/test/dummy/public/assets/products/2/mini/delete.png +0 -0
- data/test/dummy/public/assets/products/2/original/delete.png +0 -0
- data/test/dummy/public/assets/products/2/product/delete.png +0 -0
- data/test/dummy/public/assets/products/2/small/delete.png +0 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/public/stylesheets/application.css +83 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/tmp/cache/assets/BF8/2D0/sprockets%2F061365584f62ff829333e404d3566614 +0 -0
- data/test/dummy/tmp/cache/assets/C17/0E0/sprockets%2F976726a8626e66694980f590bc387807 +0 -0
- data/test/dummy/tmp/cache/assets/C4B/B20/sprockets%2F75e3756ba610340b7d9e0501e2738815 +0 -0
- data/test/dummy/tmp/cache/assets/C74/4F0/sprockets%2F2b3933c1c8b63193cbf460019680641c +0 -0
- data/test/dummy/tmp/cache/assets/C8B/250/sprockets%2F1a17d2874364d2e99677211577ccbd29 +0 -0
- data/test/dummy/tmp/cache/assets/CBA/690/sprockets%2F4b4be759f94f48654023ccf82558c202 +0 -0
- data/test/dummy/tmp/cache/assets/CD1/FA0/sprockets%2F887d02a66c0be114c4d845e0e31b5046 +0 -0
- data/test/dummy/tmp/cache/assets/CDE/2F0/sprockets%2F01f7a04861b8d5c6ff5259b931b513a8 +0 -0
- data/test/dummy/tmp/cache/assets/CDE/990/sprockets%2Fd076ad241795a6dce56456d661c3c540 +0 -0
- data/test/dummy/tmp/cache/assets/CE8/960/sprockets%2F055e1879b589151f8c914fd4d2faa451 +0 -0
- data/test/dummy/tmp/cache/assets/CEA/E30/sprockets%2F3b6e44c89e8821a8ade264ba89536306 +0 -0
- data/test/dummy/tmp/cache/assets/CFB/EC0/sprockets%2F7b68fde8e3e0b2496451649499a339fd +0 -0
- data/test/dummy/tmp/cache/assets/D0A/650/sprockets%2F3892c73640ba239ad055eb70adc7d376 +0 -0
- data/test/dummy/tmp/cache/assets/D1A/400/sprockets%2F3db3e35d06c8ee7eea759a5561609176 +0 -0
- data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/D35/7F0/sprockets%2Fb0bf073fb61c9ab736703d17e7223d7c +0 -0
- data/test/dummy/tmp/cache/assets/D39/260/sprockets%2F1c93edd8921f9c9dd8f9b391a8576996 +0 -0
- data/test/dummy/tmp/cache/assets/D44/8F0/sprockets%2Fd4882ae3d2b7e5c4a792a962b96d0c53 +0 -0
- data/test/dummy/tmp/cache/assets/D45/380/sprockets%2Fdcec95a29ee086a4283091e0671cee84 +0 -0
- data/test/dummy/tmp/cache/assets/D4F/990/sprockets%2F448cea593d65f06453fd58c813be85ec +0 -0
- data/test/dummy/tmp/cache/assets/D54/ED0/sprockets%2F71c9fa01091d432b131da3bb73faf3d4 +0 -0
- data/test/dummy/tmp/cache/assets/D5C/B80/sprockets%2F25fb254ba6af4c046abe0d457470b6b4 +0 -0
- data/test/dummy/tmp/cache/assets/D5F/B70/sprockets%2F7df07cffaafc819374564f89a9779d33 +0 -0
- data/test/dummy/tmp/cache/assets/D6A/A80/sprockets%2F65d4f0c9709bb65e6f0d20c4d33f6bd0 +0 -0
- data/test/dummy/tmp/cache/assets/D7D/470/sprockets%2Fc4f8c42e5a8d6a013a72e1e4dee99879 +0 -0
- data/test/dummy/tmp/cache/assets/D84/210/sprockets%2Fabd0103ccec2b428ac62c94e4c40b384 +0 -0
- data/test/dummy/tmp/cache/assets/D90/570/sprockets%2Fc28a3557e8dc87e9666afd75e7a578fa +0 -0
- data/test/dummy/tmp/cache/assets/D9F/AA0/sprockets%2F5faefd4c3b0d325d6046fc76bc634f93 +0 -0
- data/test/dummy/tmp/cache/assets/DA9/CA0/sprockets%2F65298b70d60c89a7fc08cea4dee62f2d +0 -0
- data/test/dummy/tmp/cache/assets/DE4/230/sprockets%2F2edbb30dab2c30af6660456f54aca6cb +0 -0
- data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/E06/600/sprockets%2Fe4ef2dbc6691ad7f906b8cbca636e45d +0 -0
- data/test/dummy/tmp/cache/assets/E23/5C0/sprockets%2Ffdb40ef1a5e8bbeda0c5732a545cc8f3 +0 -0
- data/test/dummy/tmp/cache/assets/E36/A40/sprockets%2Fbb57cff6dedd610b280b8fbfd9285b5f +0 -0
- data/test/factories/answers.rb +6 -0
- data/test/factories/questionnaires.rb +3 -0
- data/test/factories/questions.rb +12 -0
- data/test/factories/scores.rb +5 -0
- data/test/factories/survey_images.rb +9 -0
- data/test/factories/survey_properties.rb +3 -0
- data/test/factories/user_answers.rb +4 -0
- data/test/factories/users.rb +3 -0
- data/test/fixtures/answers.yml +13 -0
- data/test/fixtures/questionnaires.yml +7 -0
- data/test/fixtures/questions.yml +11 -0
- data/test/fixtures/scores.yml +11 -0
- data/test/fixtures/survey_images.yml +19 -0
- data/test/fixtures/survey_properties.yml +7 -0
- data/test/fixtures/user_answers.yml +9 -0
- data/test/functional/survey_admin/answers_controller_test.rb +71 -0
- data/test/functional/survey_admin/questionnaires_controller_test.rb +52 -0
- data/test/functional/survey_admin/questions_controller_test.rb +61 -0
- data/test/functional/survey_admin/survey_properties_controller_test.rb +59 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/survey_says_test.rb +7 -0
- data/test/test_helper.rb +16 -0
- data/test/unit/answer_test.rb +12 -0
- data/test/unit/question_test.rb +7 -0
- data/test/unit/questionaire_test.rb +7 -0
- data/test/unit/score_test.rb +7 -0
- data/test/unit/survey_image_test.rb +7 -0
- data/test/unit/survey_property_test.rb +7 -0
- data/test/unit/user_answer_test.rb +7 -0
- metadata +420 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/404.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/422.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/500.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
23
|
+
<p>We've been notified about this issue and we'll take a look at it shortly.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
File without changes
|
@@ -0,0 +1,83 @@
|
|
1
|
+
html, body {
|
2
|
+
background-color: #4B7399;
|
3
|
+
font-family: Verdana, Helvetica, Arial;
|
4
|
+
font-size: 14px;
|
5
|
+
}
|
6
|
+
|
7
|
+
a img {
|
8
|
+
border: none;
|
9
|
+
}
|
10
|
+
|
11
|
+
a {
|
12
|
+
color: #0000FF;
|
13
|
+
}
|
14
|
+
|
15
|
+
.clear {
|
16
|
+
clear: both;
|
17
|
+
height: 0;
|
18
|
+
overflow: hidden;
|
19
|
+
}
|
20
|
+
|
21
|
+
#container {
|
22
|
+
width: 75%;
|
23
|
+
margin: 0 auto;
|
24
|
+
background-color: #FFF;
|
25
|
+
padding: 20px 40px;
|
26
|
+
border: solid 1px black;
|
27
|
+
margin-top: 20px;
|
28
|
+
}
|
29
|
+
|
30
|
+
#flash_notice, #flash_error, #flash_alert {
|
31
|
+
padding: 5px 8px;
|
32
|
+
margin: 10px 0;
|
33
|
+
}
|
34
|
+
|
35
|
+
#flash_notice {
|
36
|
+
background-color: #CFC;
|
37
|
+
border: solid 1px #6C6;
|
38
|
+
}
|
39
|
+
|
40
|
+
#flash_error, #flash_alert {
|
41
|
+
background-color: #FCC;
|
42
|
+
border: solid 1px #C66;
|
43
|
+
}
|
44
|
+
|
45
|
+
.error_messages {
|
46
|
+
width: 400px;
|
47
|
+
border: 2px solid #CF0000;
|
48
|
+
padding: 0px;
|
49
|
+
padding-bottom: 12px;
|
50
|
+
margin-bottom: 20px;
|
51
|
+
background-color: #f0f0f0;
|
52
|
+
font-size: 12px;
|
53
|
+
}
|
54
|
+
|
55
|
+
.error_messages h2 {
|
56
|
+
text-align: left;
|
57
|
+
font-weight: bold;
|
58
|
+
padding: 5px 10px;
|
59
|
+
font-size: 12px;
|
60
|
+
margin: 0;
|
61
|
+
background-color: #c00;
|
62
|
+
color: #fff;
|
63
|
+
}
|
64
|
+
|
65
|
+
.error_messages p {
|
66
|
+
margin: 8px 10px;
|
67
|
+
}
|
68
|
+
|
69
|
+
.error_messages ul {
|
70
|
+
margin: 0;
|
71
|
+
}
|
72
|
+
|
73
|
+
.field_with_errors {
|
74
|
+
display: inline;
|
75
|
+
}
|
76
|
+
|
77
|
+
form .field, form .actions {
|
78
|
+
margin: 10px 0;
|
79
|
+
}
|
80
|
+
|
81
|
+
form label {
|
82
|
+
display: block;
|
83
|
+
}
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Factory.define :question do |s|
|
2
|
+
s.details 'John'
|
3
|
+
s.active true
|
4
|
+
s.position 1
|
5
|
+
end
|
6
|
+
|
7
|
+
Factory.define :question_with_questionnaire, :parent => :question do |s|
|
8
|
+
s.questionnaire { |c| c.association(:questionnaire) }
|
9
|
+
s.details 'John with questionaire'
|
10
|
+
s.active true
|
11
|
+
s.position 2
|
12
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
2
|
+
|
3
|
+
one:
|
4
|
+
imageable_id: 1
|
5
|
+
imageable_type: MyString
|
6
|
+
position: 1
|
7
|
+
photo_file_name: MyString
|
8
|
+
photo_content_type: MyString
|
9
|
+
photo_file_size: 1
|
10
|
+
caption: MyString
|
11
|
+
|
12
|
+
two:
|
13
|
+
imageable_id: 1
|
14
|
+
imageable_type: MyString
|
15
|
+
position: 1
|
16
|
+
photo_file_name: MyString
|
17
|
+
photo_content_type: MyString
|
18
|
+
photo_file_size: 1
|
19
|
+
caption: MyString
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class SurveyAdmin::AnswersControllerTest < ActionController::TestCase
|
4
|
+
def test_index
|
5
|
+
@question = Factory(:question)
|
6
|
+
@answer = Factory(:answer, :question => @question)
|
7
|
+
get :index, :question_id => @question.id
|
8
|
+
assert_template 'index'
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_show
|
12
|
+
@question = Factory(:question)
|
13
|
+
@answer = Factory(:answer, :question => @question)
|
14
|
+
get :show, :id => @answer.id, :question_id => @question.id
|
15
|
+
assert_template 'show'
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_new
|
19
|
+
@question = Factory(:question)
|
20
|
+
@answer = Factory(:answer, :question => @question)
|
21
|
+
get :new, :question_id => @question.id
|
22
|
+
assert_template 'new'
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_create_invalid
|
26
|
+
@question = Factory(:question)
|
27
|
+
@answer = Factory(:answer, :question => @question)
|
28
|
+
Answer.any_instance.stubs(:valid?).returns(false)
|
29
|
+
post :create, :question_id => @question.id
|
30
|
+
assert_template 'new'
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_create_valid
|
34
|
+
@question = Factory(:question)
|
35
|
+
@answer = Factory(:answer, :question => @question)
|
36
|
+
Answer.any_instance.stubs(:valid?).returns(true)
|
37
|
+
post :create, :question_id => @question.id
|
38
|
+
assert_redirected_to survey_admin_question_answer_url(assigns(:answer).question ,assigns(:answer))
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_edit
|
42
|
+
@question = Factory(:question)
|
43
|
+
@answer = Factory(:answer, :question => @question)
|
44
|
+
get :edit, :id => @answer.id, :question_id => @question.id
|
45
|
+
assert_template 'edit'
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_update_invalid
|
49
|
+
@question = Factory(:question)
|
50
|
+
@answer = Factory(:answer, :question => @question)
|
51
|
+
Answer.any_instance.stubs(:valid?).returns(false)
|
52
|
+
put :update, :id => @answer.id, :question_id => @question.id
|
53
|
+
assert_template 'edit'
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_update_valid
|
57
|
+
@question = Factory(:question)
|
58
|
+
@answer = Factory(:answer, :question => @question)
|
59
|
+
Answer.any_instance.stubs(:valid?).returns(true)
|
60
|
+
put :update, :id => @answer.id, :question_id => @question.id
|
61
|
+
assert_redirected_to survey_admin_question_answer_url(assigns(:answer).question,assigns(:answer))
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_destroy
|
65
|
+
@question = Factory(:question)
|
66
|
+
answer = Factory(:answer, :question => @question)
|
67
|
+
delete :destroy, :id => answer, :question_id => @question.id
|
68
|
+
assert_redirected_to survey_admin_question_answers_url(@question)
|
69
|
+
assert !Answer.find(answer.id).active
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class SurveyAdmin::QuestionnairesControllerTest < ActionController::TestCase
|
4
|
+
def test_index
|
5
|
+
questionnaire = Factory(:questionnaire)
|
6
|
+
get :index
|
7
|
+
assert_template 'index'
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_show
|
11
|
+
questionnaire = Factory(:questionnaire)
|
12
|
+
get :show, :id => questionnaire.id
|
13
|
+
assert_template 'show'
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_new
|
17
|
+
get :new
|
18
|
+
assert_template 'new'
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_create_invalid
|
22
|
+
Questionnaire.any_instance.stubs(:valid?).returns(false)
|
23
|
+
post :create
|
24
|
+
assert_template 'new'
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_create_valid
|
28
|
+
Questionnaire.any_instance.stubs(:valid?).returns(true)
|
29
|
+
post :create, :questionnaire => { :name => 'Johnny!'}
|
30
|
+
assert_redirected_to survey_admin_questionnaire_url(assigns(:questionnaire))
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_edit
|
34
|
+
questionnaire = Factory(:questionnaire)
|
35
|
+
get :edit, :id => questionnaire.id
|
36
|
+
assert_template 'edit'
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_update_invalid
|
40
|
+
questionnaire = Factory(:questionnaire)
|
41
|
+
Questionnaire.any_instance.stubs(:valid?).returns(false)
|
42
|
+
put :update, :id => questionnaire.id
|
43
|
+
assert_template 'edit'
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_update_valid
|
47
|
+
questionnaire = Factory(:questionnaire)
|
48
|
+
Questionnaire.any_instance.stubs(:valid?).returns(true)
|
49
|
+
put :update, :id => questionnaire.id
|
50
|
+
assert_redirected_to survey_admin_questionnaire_url(assigns(:questionnaire))
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class SurveyAdmin::QuestionsControllerTest < ActionController::TestCase
|
4
|
+
#fixtures :questions
|
5
|
+
|
6
|
+
def test_index
|
7
|
+
get :index
|
8
|
+
assert_template 'index'
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_show
|
12
|
+
question = Factory(:question)
|
13
|
+
get :show, :id => question.id
|
14
|
+
assert_template 'show'
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_new
|
18
|
+
get :new
|
19
|
+
assert_template 'new'
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_create_invalid
|
23
|
+
Question.any_instance.stubs(:valid?).returns(false)
|
24
|
+
post :create
|
25
|
+
assert_template 'new'
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_create_valid
|
29
|
+
Question.any_instance.stubs(:valid?).returns(true)
|
30
|
+
post :create
|
31
|
+
assert_redirected_to survey_admin_question_answers_url(assigns(:question))
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_edit
|
35
|
+
question = Factory(:question)
|
36
|
+
get :edit, :id => question.id
|
37
|
+
assert_template 'edit'
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_update_invalid
|
41
|
+
question = Factory(:question)
|
42
|
+
Question.any_instance.stubs(:valid?).returns(false)
|
43
|
+
put :update, :id => question.id
|
44
|
+
assert_template 'edit'
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_update_valid
|
48
|
+
question = Factory(:question)
|
49
|
+
Question.any_instance.stubs(:valid?).returns(true)
|
50
|
+
put :update, :id => question.id
|
51
|
+
assert_redirected_to survey_admin_question_answers_url(assigns(:question))
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_destroy
|
55
|
+
question = Factory(:question)
|
56
|
+
delete :destroy, :id => question.id
|
57
|
+
assert_redirected_to survey_admin_questions_url
|
58
|
+
assert Question.exists?(question.id)
|
59
|
+
assert !Question.find(question.id).active
|
60
|
+
end
|
61
|
+
end
|