schemer_rails 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.
Files changed (106) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +30 -0
  4. data/app/assets/javascripts/schemer/application.js +15 -0
  5. data/app/assets/stylesheets/schemer/application.css +15 -0
  6. data/app/controllers/schemer/application_controller.rb +4 -0
  7. data/app/controllers/schemer/surveys_controller.rb +62 -0
  8. data/app/helpers/schemer/application_helper.rb +4 -0
  9. data/app/models/schemer/answer.rb +9 -0
  10. data/app/models/schemer/concerns/surveyor.rb +33 -0
  11. data/app/models/schemer/option.rb +7 -0
  12. data/app/models/schemer/question.rb +11 -0
  13. data/app/models/schemer/survey.rb +11 -0
  14. data/app/models/schemer/surveyor.rb +9 -0
  15. data/app/serializers/schemer/option_serializer.rb +5 -0
  16. data/app/serializers/schemer/question_serializer.rb +12 -0
  17. data/app/serializers/schemer/survey_serializer.rb +11 -0
  18. data/app/views/layouts/schemer/application.html.erb +14 -0
  19. data/app/views/schemer/surveys/_form.html.erb +42 -0
  20. data/app/views/schemer/surveys/_option_fields.html.erb +11 -0
  21. data/app/views/schemer/surveys/_question_fields.html.erb +19 -0
  22. data/app/views/schemer/surveys/edit.html.erb +6 -0
  23. data/app/views/schemer/surveys/index.html.erb +31 -0
  24. data/app/views/schemer/surveys/new.html.erb +5 -0
  25. data/app/views/schemer/surveys/show.html.erb +27 -0
  26. data/config/routes.rb +4 -0
  27. data/db/migrate/20140922114934_create_schemer_surveys.rb +12 -0
  28. data/db/migrate/20140924092329_create_schemer_questions.rb +10 -0
  29. data/db/migrate/20140924100930_create_schemer_options.rb +10 -0
  30. data/db/migrate/20140924113459_create_schemer_surveyors.rb +10 -0
  31. data/db/migrate/20140925070034_create_schemer_answers.rb +11 -0
  32. data/lib/schemer.rb +6 -0
  33. data/lib/schemer/acts_as_surveyor.rb +51 -0
  34. data/lib/schemer/engine.rb +18 -0
  35. data/lib/schemer/version.rb +3 -0
  36. data/lib/tasks/schemer_tasks.rake +4 -0
  37. data/spec/controllers/schemer/surveys_controller_spec.rb +162 -0
  38. data/spec/dummy/README.rdoc +28 -0
  39. data/spec/dummy/Rakefile +6 -0
  40. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  41. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  42. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  43. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  44. data/spec/dummy/app/models/user.rb +4 -0
  45. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  46. data/spec/dummy/bin/bundle +3 -0
  47. data/spec/dummy/bin/rails +4 -0
  48. data/spec/dummy/bin/rake +4 -0
  49. data/spec/dummy/config.ru +4 -0
  50. data/spec/dummy/config/application.rb +29 -0
  51. data/spec/dummy/config/boot.rb +5 -0
  52. data/spec/dummy/config/database.yml +21 -0
  53. data/spec/dummy/config/environment.rb +5 -0
  54. data/spec/dummy/config/environments/development.rb +37 -0
  55. data/spec/dummy/config/environments/production.rb +78 -0
  56. data/spec/dummy/config/environments/test.rb +39 -0
  57. data/spec/dummy/config/initializers/assets.rb +8 -0
  58. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  59. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  60. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  61. data/spec/dummy/config/initializers/inflections.rb +16 -0
  62. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  63. data/spec/dummy/config/initializers/session_store.rb +3 -0
  64. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  65. data/spec/dummy/config/locales/en.yml +23 -0
  66. data/spec/dummy/config/routes.rb +4 -0
  67. data/spec/dummy/config/secrets.yml +22 -0
  68. data/spec/dummy/db/migrate/20140924120804_create_users.rb +10 -0
  69. data/spec/dummy/db/schema.rb +65 -0
  70. data/spec/dummy/log/development.log +6651 -0
  71. data/spec/dummy/log/test.log +5257 -0
  72. data/spec/dummy/public/404.html +67 -0
  73. data/spec/dummy/public/422.html +67 -0
  74. data/spec/dummy/public/500.html +66 -0
  75. data/spec/dummy/public/favicon.ico +0 -0
  76. data/spec/dummy/spec/factories/users.rb +8 -0
  77. data/spec/dummy/spec/models/user_spec.rb +53 -0
  78. data/spec/dummy/spec/spec_helper.rb +40 -0
  79. data/spec/dummy/tmp/cache/assets/development/sprockets/00b35f525e37a6602da315f4d5e665dc +0 -0
  80. data/spec/dummy/tmp/cache/assets/development/sprockets/0f1b7dae5a45908f12d8a85ec2dea265 +0 -0
  81. data/spec/dummy/tmp/cache/assets/development/sprockets/1cae3a1cfbf20f6d3388e4f0df72e604 +0 -0
  82. data/spec/dummy/tmp/cache/assets/development/sprockets/67ec2eedb1bf19ebac485395204d5ec8 +0 -0
  83. data/spec/dummy/tmp/cache/assets/development/sprockets/6f4031d9ad6e5d190cebb22f3914014d +0 -0
  84. data/spec/dummy/tmp/cache/assets/development/sprockets/771fe04d90b165a3212f1f502e6cee9c +0 -0
  85. data/spec/dummy/tmp/cache/assets/development/sprockets/90f32837697f85e5ab9eb8f474b24ce7 +0 -0
  86. data/spec/dummy/tmp/cache/assets/development/sprockets/b05e2fa6f1b28a61b4327f446cb75a8c +0 -0
  87. data/spec/dummy/tmp/cache/assets/development/sprockets/b711b2b6c927435f89e55ef8cbfd6f16 +0 -0
  88. data/spec/dummy/tmp/cache/assets/development/sprockets/bf73041cb847de60775d7af6a47b0b7b +0 -0
  89. data/spec/dummy/tmp/cache/assets/development/sprockets/c63d712d76a93f6ce39982306770d356 +0 -0
  90. data/spec/dummy/tmp/cache/assets/development/sprockets/cffa59ac01b389e4255c64638fc2885b +0 -0
  91. data/spec/dummy/tmp/cache/assets/development/sprockets/e5ae4857694c81f01b2035047707ab71 +0 -0
  92. data/spec/dummy/tmp/cache/assets/development/sprockets/ed548c7d884e98d8f26294a43e53d139 +0 -0
  93. data/spec/dummy/tmp/cache/assets/development/sprockets/f0e8def7b8807216809294cc60790679 +0 -0
  94. data/spec/factories/schemer_answers.rb +9 -0
  95. data/spec/factories/schemer_options.rb +8 -0
  96. data/spec/factories/schemer_questions.rb +8 -0
  97. data/spec/factories/schemer_surveyors.rb +7 -0
  98. data/spec/factories/schemer_surveys.rb +10 -0
  99. data/spec/models/schemer/answer_spec.rb +11 -0
  100. data/spec/models/schemer/option_spec.rb +9 -0
  101. data/spec/models/schemer/question_spec.rb +11 -0
  102. data/spec/models/schemer/survey_spec.rb +42 -0
  103. data/spec/models/schemer/surveyor_spec.rb +45 -0
  104. data/spec/routing/schemer/surveys_routing_spec.rb +39 -0
  105. data/spec/spec_helper.rb +40 -0
  106. metadata +387 -0
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/404.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/422.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The change you wanted was rejected.</h1>
62
+ <p>Maybe you tried to change something you didn't have access to.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/500.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>We're sorry, but something went wrong.</h1>
62
+ </div>
63
+ <p>If you are the application owner check the logs for more information.</p>
64
+ </div>
65
+ </body>
66
+ </html>
File without changes
@@ -0,0 +1,8 @@
1
+ # Read about factories at https://github.com/thoughtbot/factory_girl
2
+
3
+ FactoryGirl.define do
4
+ factory :user do
5
+ name "MyString"
6
+ email "MyString"
7
+ end
8
+ end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe User do
4
+
5
+ let(:user) { FactoryGirl.create(:user) }
6
+ let(:user_2) { FactoryGirl.create(:user) }
7
+
8
+ let(:options) { [
9
+ { title: "a1"},
10
+ { title: "a2"},
11
+ { title: "a3"},
12
+ { title: "a4"}
13
+ ]
14
+ }
15
+
16
+ let(:questions) { [
17
+ { title: "q1", options_attributes: options },
18
+ { title: "q2", options_attributes: options },
19
+ { title: "q3", options_attributes: options }
20
+ ]
21
+ }
22
+
23
+ let(:survey_params) { {
24
+ title: "test",
25
+ description: "test",
26
+ questions_attributes: questions
27
+ } }
28
+
29
+ # it "should be succesful" do
30
+ # survey = Survey.create(survey_params)
31
+ # expect(survey).to be_present
32
+ # expect(survey.questions.size).to eq(3)
33
+ # expect(survey.questions[0].options.size).to eq(4)
34
+ # end
35
+
36
+ context "should create a survey" do
37
+ it "succesfully" do
38
+ incomplete_survey = ::Schemer::Survey.create(survey_params)
39
+ survey = ::Schemer::Survey.create(survey_params)
40
+ another_survey = ::Schemer::Survey.create(survey_params)
41
+
42
+ surveyor = user.feedbacks.create(survey: survey)
43
+ other_surveyor = user_2.feedbacks.create(survey: incomplete_survey)
44
+
45
+ option = surveyor.survey.questions[0].options[0]
46
+ answer = surveyor.answers.create(option: option, question: option.question)
47
+ expect(answer).to be_present
48
+
49
+ expect(user.list_incomplete_surveys.size).to eq(2)
50
+
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,40 @@
1
+ ENV['RAILS_ENV'] ||= 'test'
2
+
3
+ require File.expand_path("../../config/environment.rb", __FILE__)
4
+ require 'rspec/rails'
5
+ require 'rspec/autorun'
6
+ require 'factory_girl_rails'
7
+ require 'pry'
8
+ require 'shoulda-matchers'
9
+ require 'schemer'
10
+
11
+ Rails.backtrace_cleaner.remove_silencers!
12
+
13
+ # Load support files
14
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
15
+
16
+ RSpec.configure do |config|
17
+ config.mock_with :rspec
18
+ config.use_transactional_fixtures = true
19
+ config.infer_base_class_for_anonymous_controllers = false
20
+ config.infer_spec_type_from_file_location!
21
+ config.order = "random"
22
+
23
+ require 'database_cleaner'
24
+
25
+ config.before(:suite) do
26
+ DatabaseCleaner.strategy = :transaction
27
+ DatabaseCleaner.clean_with(:truncation)
28
+ end
29
+
30
+ config.before(:each) do |example|
31
+ DatabaseCleaner.start
32
+ end
33
+
34
+ config.after(:each) do |example|
35
+ DatabaseCleaner.clean
36
+ end
37
+
38
+ config.include Rails.application.routes.url_helpers
39
+ config.include Schemer::Engine.routes.url_helpers
40
+ end
@@ -0,0 +1,9 @@
1
+ # Read about factories at https://github.com/thoughtbot/factory_girl
2
+
3
+ FactoryGirl.define do
4
+ factory :schemer_answer, :class => 'Answer' do
5
+ surveyor_id 1
6
+ question_id 1
7
+ option_id 1
8
+ end
9
+ end
@@ -0,0 +1,8 @@
1
+ # Read about factories at https://github.com/thoughtbot/factory_girl
2
+
3
+ FactoryGirl.define do
4
+ factory :schemer_option, :class => 'Option' do
5
+ title "MyText"
6
+ question_id 1
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # Read about factories at https://github.com/thoughtbot/factory_girl
2
+
3
+ FactoryGirl.define do
4
+ factory :schemer_question, :class => 'Questions' do
5
+ title "MyText"
6
+ survey_id 1
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ # Read about factories at https://github.com/thoughtbot/factory_girl
2
+
3
+ FactoryGirl.define do
4
+ factory :schemer_surveyor, :class => 'Surveyor' do
5
+ survey_id 1
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ # Read about factories at https://github.com/thoughtbot/factory_girl
2
+
3
+ FactoryGirl.define do
4
+ factory :schemer_survey, :class => 'Survey' do
5
+ title "MyString"
6
+ description "MyText"
7
+ is_started false
8
+ is_complete false
9
+ end
10
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ module Schemer
4
+ describe Answer do
5
+ context "associations" do
6
+ it { should belong_to :surveyor }
7
+ it { should belong_to :question }
8
+ it { should belong_to :option }
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ module Schemer
4
+ describe Option do
5
+ context "associations" do
6
+ it { should belong_to :question }
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ module Schemer
4
+ describe Question do
5
+ context "associations" do
6
+ it { should belong_to :survey }
7
+ it { should have_many :options }
8
+ it { should have_one :answer }
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+
3
+ module Schemer
4
+ describe Survey do
5
+
6
+ context "associations" do
7
+ it { should have_many :questions }
8
+ end
9
+
10
+ context "creating survey with questions" do
11
+
12
+ let(:options) { [
13
+ { title: "a1"},
14
+ { title: "a2"},
15
+ { title: "a3"},
16
+ { title: "a4"}
17
+ ]
18
+ }
19
+
20
+ let(:questions) { [
21
+ { title: "q1", options_attributes: options },
22
+ { title: "q2", options_attributes: options },
23
+ { title: "q3", options_attributes: options }
24
+ ]
25
+ }
26
+
27
+ let(:survey_params) { {
28
+ title: "test",
29
+ description: "test",
30
+ questions_attributes: questions
31
+ } }
32
+
33
+ it "should be succesful" do
34
+ survey = Survey.create(survey_params)
35
+ expect(survey).to be_present
36
+ expect(survey.questions.size).to eq(3)
37
+ expect(survey.questions[0].options.size).to eq(4)
38
+ end
39
+ end
40
+
41
+ end
42
+ end