forked from bofh/fetsite
AutoCommit Don Jul 30 00:03:02 CEST 2015
This commit is contained in:
3
app/assets/javascripts/survey/answers.js.coffee
Normal file
3
app/assets/javascripts/survey/answers.js.coffee
Normal file
@@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
||||
3
app/assets/javascripts/survey/choices.js.coffee
Normal file
3
app/assets/javascripts/survey/choices.js.coffee
Normal file
@@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
||||
3
app/assets/javascripts/survey/questions.js.coffee
Normal file
3
app/assets/javascripts/survey/questions.js.coffee
Normal file
@@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
||||
3
app/assets/stylesheets/survey/answers.css.scss
Normal file
3
app/assets/stylesheets/survey/answers.css.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the Survey::answers controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
3
app/assets/stylesheets/survey/choices.css.scss
Normal file
3
app/assets/stylesheets/survey/choices.css.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the Survey::choices controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
3
app/assets/stylesheets/survey/questions.css.scss
Normal file
3
app/assets/stylesheets/survey/questions.css.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the Survey::questions controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
83
app/controllers/survey/answers_controller.rb
Normal file
83
app/controllers/survey/answers_controller.rb
Normal file
@@ -0,0 +1,83 @@
|
||||
class Survey::AnswersController < ApplicationController
|
||||
# GET /survey/answers
|
||||
# GET /survey/answers.json
|
||||
def index
|
||||
@survey_answers = Survey::Answer.all
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @survey_answers }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /survey/answers/1
|
||||
# GET /survey/answers/1.json
|
||||
def show
|
||||
@survey_answer = Survey::Answer.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.json { render json: @survey_answer }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /survey/answers/new
|
||||
# GET /survey/answers/new.json
|
||||
def new
|
||||
@survey_answer = Survey::Answer.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.json { render json: @survey_answer }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /survey/answers/1/edit
|
||||
def edit
|
||||
@survey_answer = Survey::Answer.find(params[:id])
|
||||
end
|
||||
|
||||
# POST /survey/answers
|
||||
# POST /survey/answers.json
|
||||
def create
|
||||
@survey_answer = Survey::Answer.new(params[:survey_answer])
|
||||
|
||||
respond_to do |format|
|
||||
if @survey_answer.save
|
||||
format.html { redirect_to @survey_answer, notice: 'Answer was successfully created.' }
|
||||
format.json { render json: @survey_answer, status: :created, location: @survey_answer }
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
format.json { render json: @survey_answer.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PUT /survey/answers/1
|
||||
# PUT /survey/answers/1.json
|
||||
def update
|
||||
@survey_answer = Survey::Answer.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @survey_answer.update_attributes(params[:survey_answer])
|
||||
format.html { redirect_to @survey_answer, notice: 'Answer was successfully updated.' }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.html { render action: "edit" }
|
||||
format.json { render json: @survey_answer.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /survey/answers/1
|
||||
# DELETE /survey/answers/1.json
|
||||
def destroy
|
||||
@survey_answer = Survey::Answer.find(params[:id])
|
||||
@survey_answer.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to survey_answers_url }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
end
|
||||
83
app/controllers/survey/choices_controller.rb
Normal file
83
app/controllers/survey/choices_controller.rb
Normal file
@@ -0,0 +1,83 @@
|
||||
class Survey::ChoicesController < ApplicationController
|
||||
# GET /survey/choices
|
||||
# GET /survey/choices.json
|
||||
def index
|
||||
@survey_choices = Survey::Choice.all
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @survey_choices }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /survey/choices/1
|
||||
# GET /survey/choices/1.json
|
||||
def show
|
||||
@survey_choice = Survey::Choice.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.json { render json: @survey_choice }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /survey/choices/new
|
||||
# GET /survey/choices/new.json
|
||||
def new
|
||||
@survey_choice = Survey::Choice.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.json { render json: @survey_choice }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /survey/choices/1/edit
|
||||
def edit
|
||||
@survey_choice = Survey::Choice.find(params[:id])
|
||||
end
|
||||
|
||||
# POST /survey/choices
|
||||
# POST /survey/choices.json
|
||||
def create
|
||||
@survey_choice = Survey::Choice.new(params[:survey_choice])
|
||||
|
||||
respond_to do |format|
|
||||
if @survey_choice.save
|
||||
format.html { redirect_to @survey_choice, notice: 'Choice was successfully created.' }
|
||||
format.json { render json: @survey_choice, status: :created, location: @survey_choice }
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
format.json { render json: @survey_choice.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PUT /survey/choices/1
|
||||
# PUT /survey/choices/1.json
|
||||
def update
|
||||
@survey_choice = Survey::Choice.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @survey_choice.update_attributes(params[:survey_choice])
|
||||
format.html { redirect_to @survey_choice, notice: 'Choice was successfully updated.' }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.html { render action: "edit" }
|
||||
format.json { render json: @survey_choice.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /survey/choices/1
|
||||
# DELETE /survey/choices/1.json
|
||||
def destroy
|
||||
@survey_choice = Survey::Choice.find(params[:id])
|
||||
@survey_choice.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to survey_choices_url }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
end
|
||||
85
app/controllers/survey/questions_controller.rb
Normal file
85
app/controllers/survey/questions_controller.rb
Normal file
@@ -0,0 +1,85 @@
|
||||
class Survey::QuestionsController < ApplicationController
|
||||
# GET /survey/questions
|
||||
# GET /survey/questions.json
|
||||
def index
|
||||
@survey_questions = Survey::Question.all
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @survey_questions }
|
||||
end
|
||||
end
|
||||
def answer
|
||||
render :show
|
||||
end
|
||||
# GET /survey/questions/1
|
||||
# GET /survey/questions/1.json
|
||||
def show
|
||||
@survey_question = Survey::Question.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.json { render json: @survey_question }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /survey/questions/new
|
||||
# GET /survey/questions/new.json
|
||||
def new
|
||||
@survey_question = Survey::Question.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.json { render json: @survey_question }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /survey/questions/1/edit
|
||||
def edit
|
||||
@survey_question = Survey::Question.find(params[:id])
|
||||
end
|
||||
|
||||
# POST /survey/questions
|
||||
# POST /survey/questions.json
|
||||
def create
|
||||
@survey_question = Survey::Question.new(params[:survey_question])
|
||||
|
||||
respond_to do |format|
|
||||
if @survey_question.save
|
||||
format.html { redirect_to @survey_question, notice: 'Question was successfully created.' }
|
||||
format.json { render json: @survey_question, status: :created, location: @survey_question }
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
format.json { render json: @survey_question.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PUT /survey/questions/1
|
||||
# PUT /survey/questions/1.json
|
||||
def update
|
||||
@survey_question = Survey::Question.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @survey_question.update_attributes(params[:survey_question])
|
||||
format.html { redirect_to @survey_question, notice: 'Question was successfully updated.' }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.html { render action: "edit" }
|
||||
format.json { render json: @survey_question.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /survey/questions/1
|
||||
# DELETE /survey/questions/1.json
|
||||
def destroy
|
||||
@survey_question = Survey::Question.find(params[:id])
|
||||
@survey_question.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to survey_questions_url }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
end
|
||||
2
app/helpers/survey/answers_helper.rb
Normal file
2
app/helpers/survey/answers_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module Survey::AnswersHelper
|
||||
end
|
||||
2
app/helpers/survey/choices_helper.rb
Normal file
2
app/helpers/survey/choices_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module Survey::ChoicesHelper
|
||||
end
|
||||
2
app/helpers/survey/questions_helper.rb
Normal file
2
app/helpers/survey/questions_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module Survey::QuestionsHelper
|
||||
end
|
||||
5
app/models/survey.rb
Normal file
5
app/models/survey.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
module Survey
|
||||
def self.table_name_prefix
|
||||
'survey_'
|
||||
end
|
||||
end
|
||||
5
app/models/survey/answer.rb
Normal file
5
app/models/survey/answer.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class Survey::Answer < ActiveRecord::Base
|
||||
belongs_to :choice, class_name: 'Survey::Choice'
|
||||
belongs_to :user
|
||||
# attr_accessible :title, :body
|
||||
end
|
||||
5
app/models/survey/choice.rb
Normal file
5
app/models/survey/choice.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class Survey::Choice < ActiveRecord::Base
|
||||
belongs_to :question, class_name: 'Survey::Question'
|
||||
attr_accessible :picture, :sort, :text
|
||||
has_many :answers, class_name: 'Survey::Answer'
|
||||
end
|
||||
16
app/models/survey/question.rb
Normal file
16
app/models/survey/question.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
class Survey::Question < ActiveRecord::Base
|
||||
attr_accessible :text, :title, :typ, :choice_ids
|
||||
belongs_to :parent, polymorphic: true
|
||||
has_many :choices
|
||||
has_many :answers, through: :choices
|
||||
def add_yesno_choices
|
||||
c=Survey::Choice.new(title: "Ja")
|
||||
c.save
|
||||
this.choices << c
|
||||
c=Survey::Choice.new(title: "Nein")
|
||||
c.save
|
||||
this.choices << c
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
10
app/views/survey/answers/_form.html.erb
Normal file
10
app/views/survey/answers/_form.html.erb
Normal file
@@ -0,0 +1,10 @@
|
||||
<%= semantic_form_for @answer do |f| %>
|
||||
<%= f.inputs do %>
|
||||
<%= f.input :choice %>
|
||||
<%= f.input :user %>
|
||||
<% end %>
|
||||
|
||||
<%= f.actions do %>
|
||||
<%= f.action :submit, :as => :input %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
6
app/views/survey/answers/edit.html.erb
Normal file
6
app/views/survey/answers/edit.html.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<h1>Editing survey_answer</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Show', @survey_answer %> |
|
||||
<%= link_to 'Back', survey_answers_path %>
|
||||
25
app/views/survey/answers/index.html.erb
Normal file
25
app/views/survey/answers/index.html.erb
Normal file
@@ -0,0 +1,25 @@
|
||||
<h1>Listing survey_answers</h1>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Choice</th>
|
||||
<th>User</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
<% @survey_answers.each do |survey_answer| %>
|
||||
<tr>
|
||||
<td><%= survey_answer.choice %></td>
|
||||
<td><%= survey_answer.user %></td>
|
||||
<td><%= link_to 'Show', survey_answer %></td>
|
||||
<td><%= link_to 'Edit', edit_survey_answer_path(survey_answer) %></td>
|
||||
<td><%= link_to 'Destroy', survey_answer, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
|
||||
<%= link_to 'New Answer', new_survey_answer_path %>
|
||||
5
app/views/survey/answers/new.html.erb
Normal file
5
app/views/survey/answers/new.html.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
<h1>New survey_answer</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Back', survey_answers_path %>
|
||||
15
app/views/survey/answers/show.html.erb
Normal file
15
app/views/survey/answers/show.html.erb
Normal file
@@ -0,0 +1,15 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<p>
|
||||
<b>Choice:</b>
|
||||
<%= @survey_answer.choice %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>User:</b>
|
||||
<%= @survey_answer.user %>
|
||||
</p>
|
||||
|
||||
|
||||
<%= link_to 'Edit', edit_survey_answer_path(@survey_answer) %> |
|
||||
<%= link_to 'Back', survey_answers_path %>
|
||||
12
app/views/survey/choices/_form.html.erb
Normal file
12
app/views/survey/choices/_form.html.erb
Normal file
@@ -0,0 +1,12 @@
|
||||
<%= semantic_form_for @choice do |f| %>
|
||||
<%= f.inputs do %>
|
||||
<%= f.input :text %>
|
||||
<%= f.input :question %>
|
||||
<%= f.input :sort %>
|
||||
<%= f.input :picture %>
|
||||
<% end %>
|
||||
|
||||
<%= f.actions do %>
|
||||
<%= f.action :submit, :as => :input %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
6
app/views/survey/choices/edit.html.erb
Normal file
6
app/views/survey/choices/edit.html.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<h1>Editing survey_choice</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Show', @survey_choice %> |
|
||||
<%= link_to 'Back', survey_choices_path %>
|
||||
29
app/views/survey/choices/index.html.erb
Normal file
29
app/views/survey/choices/index.html.erb
Normal file
@@ -0,0 +1,29 @@
|
||||
<h1>Listing survey_choices</h1>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Text</th>
|
||||
<th>Question</th>
|
||||
<th>Sort</th>
|
||||
<th>Picture</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
<% @survey_choices.each do |survey_choice| %>
|
||||
<tr>
|
||||
<td><%= survey_choice.text %></td>
|
||||
<td><%= survey_choice.question %></td>
|
||||
<td><%= survey_choice.sort %></td>
|
||||
<td><%= survey_choice.picture %></td>
|
||||
<td><%= link_to 'Show', survey_choice %></td>
|
||||
<td><%= link_to 'Edit', edit_survey_choice_path(survey_choice) %></td>
|
||||
<td><%= link_to 'Destroy', survey_choice, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
|
||||
<%= link_to 'New Choice', new_survey_choice_path %>
|
||||
5
app/views/survey/choices/new.html.erb
Normal file
5
app/views/survey/choices/new.html.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
<h1>New survey_choice</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Back', survey_choices_path %>
|
||||
25
app/views/survey/choices/show.html.erb
Normal file
25
app/views/survey/choices/show.html.erb
Normal file
@@ -0,0 +1,25 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<p>
|
||||
<b>Text:</b>
|
||||
<%= @survey_choice.text %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Question:</b>
|
||||
<%= @survey_choice.question %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Sort:</b>
|
||||
<%= @survey_choice.sort %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Picture:</b>
|
||||
<%= @survey_choice.picture %>
|
||||
</p>
|
||||
|
||||
|
||||
<%= link_to 'Edit', edit_survey_choice_path(@survey_choice) %> |
|
||||
<%= link_to 'Back', survey_choices_path %>
|
||||
13
app/views/survey/questions/_form.html.erb
Normal file
13
app/views/survey/questions/_form.html.erb
Normal file
@@ -0,0 +1,13 @@
|
||||
<%= semantic_form_for @survey_question do |f| %>
|
||||
<%= f.inputs do %>
|
||||
<%= f.input :title %>
|
||||
<%= f.input :text %>
|
||||
|
||||
|
||||
<%= f.input :typ %>
|
||||
<% end %>
|
||||
|
||||
<%= f.actions do %>
|
||||
<%= f.action :submit, :as => :input %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
2
app/views/survey/questions/_question.html.erb
Normal file
2
app/views/survey/questions/_question.html.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
<b><%= question.title%></b>
|
||||
<%= form_for %>
|
||||
6
app/views/survey/questions/edit.html.erb
Normal file
6
app/views/survey/questions/edit.html.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<h1>Editing survey_question</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Show', @survey_question %> |
|
||||
<%= link_to 'Back', survey_questions_path %>
|
||||
27
app/views/survey/questions/index.html.erb
Normal file
27
app/views/survey/questions/index.html.erb
Normal file
@@ -0,0 +1,27 @@
|
||||
<h1>Listing survey_questions</h1>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Title</th>
|
||||
<th>Text</th>
|
||||
<th>Typ</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
<% @survey_questions.each do |survey_question| %>
|
||||
<tr>
|
||||
<td><%= survey_question.title %></td>
|
||||
<td><%= survey_question.text %></td>
|
||||
<td><%= survey_question.typ %></td>
|
||||
<td><%= link_to 'Show', survey_question %></td>
|
||||
<td><%= link_to 'Edit', edit_survey_question_path(survey_question) %></td>
|
||||
<td><%= link_to 'Destroy', survey_question, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
|
||||
<%= link_to 'New Question', new_survey_question_path %>
|
||||
5
app/views/survey/questions/new.html.erb
Normal file
5
app/views/survey/questions/new.html.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
<h1>New survey_question</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Back', survey_questions_path %>
|
||||
21
app/views/survey/questions/show.html.erb
Normal file
21
app/views/survey/questions/show.html.erb
Normal file
@@ -0,0 +1,21 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<p>
|
||||
<b>Title:</b>
|
||||
<%= @survey_question.title %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Text:</b>
|
||||
<%= @survey_question.text %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Typ:</b>
|
||||
<%= @survey_question.typ %>
|
||||
</p>
|
||||
|
||||
<%= render @survey_question %>
|
||||
|
||||
<%= link_to 'Edit', edit_survey_question_path(@survey_question) %> |
|
||||
<%= link_to 'Back', survey_questions_path %>
|
||||
@@ -1,5 +1,23 @@
|
||||
|
||||
Fetsite::Application.routes.draw do
|
||||
namespace :survey do
|
||||
resources :answers
|
||||
end
|
||||
|
||||
|
||||
namespace :survey do
|
||||
resources :choices
|
||||
end
|
||||
|
||||
|
||||
namespace :survey do
|
||||
resources :questions do
|
||||
member do
|
||||
:answer
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
themes_for_rails
|
||||
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
|
||||
resources :home, :only=>[:index] do
|
||||
|
||||
12
db/migrate/20150729210826_create_survey_questions.rb
Normal file
12
db/migrate/20150729210826_create_survey_questions.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class CreateSurveyQuestions < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :survey_questions do |t|
|
||||
t.string :title
|
||||
t.text :text
|
||||
t.integer :typ
|
||||
t.string :parent_type
|
||||
t.integer :parent_id
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
13
db/migrate/20150729211328_create_survey_choices.rb
Normal file
13
db/migrate/20150729211328_create_survey_choices.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class CreateSurveyChoices < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :survey_choices do |t|
|
||||
t.string :text
|
||||
t.references :question
|
||||
t.integer :sort
|
||||
t.string :picture
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
add_index :survey_choices, :question_id
|
||||
end
|
||||
end
|
||||
12
db/migrate/20150729211914_create_survey_answers.rb
Normal file
12
db/migrate/20150729211914_create_survey_answers.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class CreateSurveyAnswers < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :survey_answers do |t|
|
||||
t.references :choice
|
||||
t.references :user
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
add_index :survey_answers, :choice_id
|
||||
add_index :survey_answers, :user_id
|
||||
end
|
||||
end
|
||||
159
spec/controllers/survey/answers_controller_spec.rb
Normal file
159
spec/controllers/survey/answers_controller_spec.rb
Normal file
@@ -0,0 +1,159 @@
|
||||
require 'rails_helper'
|
||||
|
||||
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
||||
# It demonstrates how one might use RSpec to specify the controller code that
|
||||
# was generated by Rails when you ran the scaffold generator.
|
||||
#
|
||||
# It assumes that the implementation code is generated by the rails scaffold
|
||||
# generator. If you are using any extension libraries to generate different
|
||||
# controller code, this generated spec may or may not pass.
|
||||
#
|
||||
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
||||
# of tools you can use to make these specs even more expressive, but we're
|
||||
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
||||
#
|
||||
# Compared to earlier versions of this generator, there is very limited use of
|
||||
# stubs and message expectations in this spec. Stubs are only used when there
|
||||
# is no simpler way to get a handle on the object needed for the example.
|
||||
# Message expectations are only used when there is no simpler way to specify
|
||||
# that an instance is receiving a specific message.
|
||||
|
||||
RSpec.describe Survey::AnswersController, :type => :controller do
|
||||
|
||||
# This should return the minimal set of attributes required to create a valid
|
||||
# Survey::Answer. As you add validations to Survey::Answer, be sure to
|
||||
# adjust the attributes here as well.
|
||||
let(:valid_attributes) {
|
||||
skip("Add a hash of attributes valid for your model")
|
||||
}
|
||||
|
||||
let(:invalid_attributes) {
|
||||
skip("Add a hash of attributes invalid for your model")
|
||||
}
|
||||
|
||||
# This should return the minimal set of values that should be in the session
|
||||
# in order to pass any filters (e.g. authentication) defined in
|
||||
# Survey::AnswersController. Be sure to keep this updated too.
|
||||
let(:valid_session) { {} }
|
||||
|
||||
describe "GET #index" do
|
||||
it "assigns all survey_answers as @survey_answers" do
|
||||
answer = Survey::Answer.create! valid_attributes
|
||||
get :index, {}, valid_session
|
||||
expect(assigns(:survey_answers)).to eq([answer])
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #show" do
|
||||
it "assigns the requested survey_answer as @survey_answer" do
|
||||
answer = Survey::Answer.create! valid_attributes
|
||||
get :show, {:id => answer.to_param}, valid_session
|
||||
expect(assigns(:survey_answer)).to eq(answer)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #new" do
|
||||
it "assigns a new survey_answer as @survey_answer" do
|
||||
get :new, {}, valid_session
|
||||
expect(assigns(:survey_answer)).to be_a_new(Survey::Answer)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #edit" do
|
||||
it "assigns the requested survey_answer as @survey_answer" do
|
||||
answer = Survey::Answer.create! valid_attributes
|
||||
get :edit, {:id => answer.to_param}, valid_session
|
||||
expect(assigns(:survey_answer)).to eq(answer)
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST #create" do
|
||||
context "with valid params" do
|
||||
it "creates a new Survey::Answer" do
|
||||
expect {
|
||||
post :create, {:survey_answer => valid_attributes}, valid_session
|
||||
}.to change(Survey::Answer, :count).by(1)
|
||||
end
|
||||
|
||||
it "assigns a newly created survey_answer as @survey_answer" do
|
||||
post :create, {:survey_answer => valid_attributes}, valid_session
|
||||
expect(assigns(:survey_answer)).to be_a(Survey::Answer)
|
||||
expect(assigns(:survey_answer)).to be_persisted
|
||||
end
|
||||
|
||||
it "redirects to the created survey_answer" do
|
||||
post :create, {:survey_answer => valid_attributes}, valid_session
|
||||
expect(response).to redirect_to(Survey::Answer.last)
|
||||
end
|
||||
end
|
||||
|
||||
context "with invalid params" do
|
||||
it "assigns a newly created but unsaved survey_answer as @survey_answer" do
|
||||
post :create, {:survey_answer => invalid_attributes}, valid_session
|
||||
expect(assigns(:survey_answer)).to be_a_new(Survey::Answer)
|
||||
end
|
||||
|
||||
it "re-renders the 'new' template" do
|
||||
post :create, {:survey_answer => invalid_attributes}, valid_session
|
||||
expect(response).to render_template("new")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "PUT #update" do
|
||||
context "with valid params" do
|
||||
let(:new_attributes) {
|
||||
skip("Add a hash of attributes valid for your model")
|
||||
}
|
||||
|
||||
it "updates the requested survey_answer" do
|
||||
answer = Survey::Answer.create! valid_attributes
|
||||
put :update, {:id => answer.to_param, :survey_answer => new_attributes}, valid_session
|
||||
answer.reload
|
||||
skip("Add assertions for updated state")
|
||||
end
|
||||
|
||||
it "assigns the requested survey_answer as @survey_answer" do
|
||||
answer = Survey::Answer.create! valid_attributes
|
||||
put :update, {:id => answer.to_param, :survey_answer => valid_attributes}, valid_session
|
||||
expect(assigns(:survey_answer)).to eq(answer)
|
||||
end
|
||||
|
||||
it "redirects to the survey_answer" do
|
||||
answer = Survey::Answer.create! valid_attributes
|
||||
put :update, {:id => answer.to_param, :survey_answer => valid_attributes}, valid_session
|
||||
expect(response).to redirect_to(answer)
|
||||
end
|
||||
end
|
||||
|
||||
context "with invalid params" do
|
||||
it "assigns the survey_answer as @survey_answer" do
|
||||
answer = Survey::Answer.create! valid_attributes
|
||||
put :update, {:id => answer.to_param, :survey_answer => invalid_attributes}, valid_session
|
||||
expect(assigns(:survey_answer)).to eq(answer)
|
||||
end
|
||||
|
||||
it "re-renders the 'edit' template" do
|
||||
answer = Survey::Answer.create! valid_attributes
|
||||
put :update, {:id => answer.to_param, :survey_answer => invalid_attributes}, valid_session
|
||||
expect(response).to render_template("edit")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "DELETE #destroy" do
|
||||
it "destroys the requested survey_answer" do
|
||||
answer = Survey::Answer.create! valid_attributes
|
||||
expect {
|
||||
delete :destroy, {:id => answer.to_param}, valid_session
|
||||
}.to change(Survey::Answer, :count).by(-1)
|
||||
end
|
||||
|
||||
it "redirects to the survey_answers list" do
|
||||
answer = Survey::Answer.create! valid_attributes
|
||||
delete :destroy, {:id => answer.to_param}, valid_session
|
||||
expect(response).to redirect_to(survey_answers_url)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
159
spec/controllers/survey/choices_controller_spec.rb
Normal file
159
spec/controllers/survey/choices_controller_spec.rb
Normal file
@@ -0,0 +1,159 @@
|
||||
require 'rails_helper'
|
||||
|
||||
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
||||
# It demonstrates how one might use RSpec to specify the controller code that
|
||||
# was generated by Rails when you ran the scaffold generator.
|
||||
#
|
||||
# It assumes that the implementation code is generated by the rails scaffold
|
||||
# generator. If you are using any extension libraries to generate different
|
||||
# controller code, this generated spec may or may not pass.
|
||||
#
|
||||
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
||||
# of tools you can use to make these specs even more expressive, but we're
|
||||
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
||||
#
|
||||
# Compared to earlier versions of this generator, there is very limited use of
|
||||
# stubs and message expectations in this spec. Stubs are only used when there
|
||||
# is no simpler way to get a handle on the object needed for the example.
|
||||
# Message expectations are only used when there is no simpler way to specify
|
||||
# that an instance is receiving a specific message.
|
||||
|
||||
RSpec.describe Survey::ChoicesController, :type => :controller do
|
||||
|
||||
# This should return the minimal set of attributes required to create a valid
|
||||
# Survey::Choice. As you add validations to Survey::Choice, be sure to
|
||||
# adjust the attributes here as well.
|
||||
let(:valid_attributes) {
|
||||
skip("Add a hash of attributes valid for your model")
|
||||
}
|
||||
|
||||
let(:invalid_attributes) {
|
||||
skip("Add a hash of attributes invalid for your model")
|
||||
}
|
||||
|
||||
# This should return the minimal set of values that should be in the session
|
||||
# in order to pass any filters (e.g. authentication) defined in
|
||||
# Survey::ChoicesController. Be sure to keep this updated too.
|
||||
let(:valid_session) { {} }
|
||||
|
||||
describe "GET #index" do
|
||||
it "assigns all survey_choices as @survey_choices" do
|
||||
choice = Survey::Choice.create! valid_attributes
|
||||
get :index, {}, valid_session
|
||||
expect(assigns(:survey_choices)).to eq([choice])
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #show" do
|
||||
it "assigns the requested survey_choice as @survey_choice" do
|
||||
choice = Survey::Choice.create! valid_attributes
|
||||
get :show, {:id => choice.to_param}, valid_session
|
||||
expect(assigns(:survey_choice)).to eq(choice)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #new" do
|
||||
it "assigns a new survey_choice as @survey_choice" do
|
||||
get :new, {}, valid_session
|
||||
expect(assigns(:survey_choice)).to be_a_new(Survey::Choice)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #edit" do
|
||||
it "assigns the requested survey_choice as @survey_choice" do
|
||||
choice = Survey::Choice.create! valid_attributes
|
||||
get :edit, {:id => choice.to_param}, valid_session
|
||||
expect(assigns(:survey_choice)).to eq(choice)
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST #create" do
|
||||
context "with valid params" do
|
||||
it "creates a new Survey::Choice" do
|
||||
expect {
|
||||
post :create, {:survey_choice => valid_attributes}, valid_session
|
||||
}.to change(Survey::Choice, :count).by(1)
|
||||
end
|
||||
|
||||
it "assigns a newly created survey_choice as @survey_choice" do
|
||||
post :create, {:survey_choice => valid_attributes}, valid_session
|
||||
expect(assigns(:survey_choice)).to be_a(Survey::Choice)
|
||||
expect(assigns(:survey_choice)).to be_persisted
|
||||
end
|
||||
|
||||
it "redirects to the created survey_choice" do
|
||||
post :create, {:survey_choice => valid_attributes}, valid_session
|
||||
expect(response).to redirect_to(Survey::Choice.last)
|
||||
end
|
||||
end
|
||||
|
||||
context "with invalid params" do
|
||||
it "assigns a newly created but unsaved survey_choice as @survey_choice" do
|
||||
post :create, {:survey_choice => invalid_attributes}, valid_session
|
||||
expect(assigns(:survey_choice)).to be_a_new(Survey::Choice)
|
||||
end
|
||||
|
||||
it "re-renders the 'new' template" do
|
||||
post :create, {:survey_choice => invalid_attributes}, valid_session
|
||||
expect(response).to render_template("new")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "PUT #update" do
|
||||
context "with valid params" do
|
||||
let(:new_attributes) {
|
||||
skip("Add a hash of attributes valid for your model")
|
||||
}
|
||||
|
||||
it "updates the requested survey_choice" do
|
||||
choice = Survey::Choice.create! valid_attributes
|
||||
put :update, {:id => choice.to_param, :survey_choice => new_attributes}, valid_session
|
||||
choice.reload
|
||||
skip("Add assertions for updated state")
|
||||
end
|
||||
|
||||
it "assigns the requested survey_choice as @survey_choice" do
|
||||
choice = Survey::Choice.create! valid_attributes
|
||||
put :update, {:id => choice.to_param, :survey_choice => valid_attributes}, valid_session
|
||||
expect(assigns(:survey_choice)).to eq(choice)
|
||||
end
|
||||
|
||||
it "redirects to the survey_choice" do
|
||||
choice = Survey::Choice.create! valid_attributes
|
||||
put :update, {:id => choice.to_param, :survey_choice => valid_attributes}, valid_session
|
||||
expect(response).to redirect_to(choice)
|
||||
end
|
||||
end
|
||||
|
||||
context "with invalid params" do
|
||||
it "assigns the survey_choice as @survey_choice" do
|
||||
choice = Survey::Choice.create! valid_attributes
|
||||
put :update, {:id => choice.to_param, :survey_choice => invalid_attributes}, valid_session
|
||||
expect(assigns(:survey_choice)).to eq(choice)
|
||||
end
|
||||
|
||||
it "re-renders the 'edit' template" do
|
||||
choice = Survey::Choice.create! valid_attributes
|
||||
put :update, {:id => choice.to_param, :survey_choice => invalid_attributes}, valid_session
|
||||
expect(response).to render_template("edit")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "DELETE #destroy" do
|
||||
it "destroys the requested survey_choice" do
|
||||
choice = Survey::Choice.create! valid_attributes
|
||||
expect {
|
||||
delete :destroy, {:id => choice.to_param}, valid_session
|
||||
}.to change(Survey::Choice, :count).by(-1)
|
||||
end
|
||||
|
||||
it "redirects to the survey_choices list" do
|
||||
choice = Survey::Choice.create! valid_attributes
|
||||
delete :destroy, {:id => choice.to_param}, valid_session
|
||||
expect(response).to redirect_to(survey_choices_url)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
159
spec/controllers/survey/questions_controller_spec.rb
Normal file
159
spec/controllers/survey/questions_controller_spec.rb
Normal file
@@ -0,0 +1,159 @@
|
||||
require 'rails_helper'
|
||||
|
||||
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
||||
# It demonstrates how one might use RSpec to specify the controller code that
|
||||
# was generated by Rails when you ran the scaffold generator.
|
||||
#
|
||||
# It assumes that the implementation code is generated by the rails scaffold
|
||||
# generator. If you are using any extension libraries to generate different
|
||||
# controller code, this generated spec may or may not pass.
|
||||
#
|
||||
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
||||
# of tools you can use to make these specs even more expressive, but we're
|
||||
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
||||
#
|
||||
# Compared to earlier versions of this generator, there is very limited use of
|
||||
# stubs and message expectations in this spec. Stubs are only used when there
|
||||
# is no simpler way to get a handle on the object needed for the example.
|
||||
# Message expectations are only used when there is no simpler way to specify
|
||||
# that an instance is receiving a specific message.
|
||||
|
||||
RSpec.describe Survey::QuestionsController, :type => :controller do
|
||||
|
||||
# This should return the minimal set of attributes required to create a valid
|
||||
# Survey::Question. As you add validations to Survey::Question, be sure to
|
||||
# adjust the attributes here as well.
|
||||
let(:valid_attributes) {
|
||||
skip("Add a hash of attributes valid for your model")
|
||||
}
|
||||
|
||||
let(:invalid_attributes) {
|
||||
skip("Add a hash of attributes invalid for your model")
|
||||
}
|
||||
|
||||
# This should return the minimal set of values that should be in the session
|
||||
# in order to pass any filters (e.g. authentication) defined in
|
||||
# Survey::QuestionsController. Be sure to keep this updated too.
|
||||
let(:valid_session) { {} }
|
||||
|
||||
describe "GET #index" do
|
||||
it "assigns all survey_questions as @survey_questions" do
|
||||
question = Survey::Question.create! valid_attributes
|
||||
get :index, {}, valid_session
|
||||
expect(assigns(:survey_questions)).to eq([question])
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #show" do
|
||||
it "assigns the requested survey_question as @survey_question" do
|
||||
question = Survey::Question.create! valid_attributes
|
||||
get :show, {:id => question.to_param}, valid_session
|
||||
expect(assigns(:survey_question)).to eq(question)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #new" do
|
||||
it "assigns a new survey_question as @survey_question" do
|
||||
get :new, {}, valid_session
|
||||
expect(assigns(:survey_question)).to be_a_new(Survey::Question)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #edit" do
|
||||
it "assigns the requested survey_question as @survey_question" do
|
||||
question = Survey::Question.create! valid_attributes
|
||||
get :edit, {:id => question.to_param}, valid_session
|
||||
expect(assigns(:survey_question)).to eq(question)
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST #create" do
|
||||
context "with valid params" do
|
||||
it "creates a new Survey::Question" do
|
||||
expect {
|
||||
post :create, {:survey_question => valid_attributes}, valid_session
|
||||
}.to change(Survey::Question, :count).by(1)
|
||||
end
|
||||
|
||||
it "assigns a newly created survey_question as @survey_question" do
|
||||
post :create, {:survey_question => valid_attributes}, valid_session
|
||||
expect(assigns(:survey_question)).to be_a(Survey::Question)
|
||||
expect(assigns(:survey_question)).to be_persisted
|
||||
end
|
||||
|
||||
it "redirects to the created survey_question" do
|
||||
post :create, {:survey_question => valid_attributes}, valid_session
|
||||
expect(response).to redirect_to(Survey::Question.last)
|
||||
end
|
||||
end
|
||||
|
||||
context "with invalid params" do
|
||||
it "assigns a newly created but unsaved survey_question as @survey_question" do
|
||||
post :create, {:survey_question => invalid_attributes}, valid_session
|
||||
expect(assigns(:survey_question)).to be_a_new(Survey::Question)
|
||||
end
|
||||
|
||||
it "re-renders the 'new' template" do
|
||||
post :create, {:survey_question => invalid_attributes}, valid_session
|
||||
expect(response).to render_template("new")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "PUT #update" do
|
||||
context "with valid params" do
|
||||
let(:new_attributes) {
|
||||
skip("Add a hash of attributes valid for your model")
|
||||
}
|
||||
|
||||
it "updates the requested survey_question" do
|
||||
question = Survey::Question.create! valid_attributes
|
||||
put :update, {:id => question.to_param, :survey_question => new_attributes}, valid_session
|
||||
question.reload
|
||||
skip("Add assertions for updated state")
|
||||
end
|
||||
|
||||
it "assigns the requested survey_question as @survey_question" do
|
||||
question = Survey::Question.create! valid_attributes
|
||||
put :update, {:id => question.to_param, :survey_question => valid_attributes}, valid_session
|
||||
expect(assigns(:survey_question)).to eq(question)
|
||||
end
|
||||
|
||||
it "redirects to the survey_question" do
|
||||
question = Survey::Question.create! valid_attributes
|
||||
put :update, {:id => question.to_param, :survey_question => valid_attributes}, valid_session
|
||||
expect(response).to redirect_to(question)
|
||||
end
|
||||
end
|
||||
|
||||
context "with invalid params" do
|
||||
it "assigns the survey_question as @survey_question" do
|
||||
question = Survey::Question.create! valid_attributes
|
||||
put :update, {:id => question.to_param, :survey_question => invalid_attributes}, valid_session
|
||||
expect(assigns(:survey_question)).to eq(question)
|
||||
end
|
||||
|
||||
it "re-renders the 'edit' template" do
|
||||
question = Survey::Question.create! valid_attributes
|
||||
put :update, {:id => question.to_param, :survey_question => invalid_attributes}, valid_session
|
||||
expect(response).to render_template("edit")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "DELETE #destroy" do
|
||||
it "destroys the requested survey_question" do
|
||||
question = Survey::Question.create! valid_attributes
|
||||
expect {
|
||||
delete :destroy, {:id => question.to_param}, valid_session
|
||||
}.to change(Survey::Question, :count).by(-1)
|
||||
end
|
||||
|
||||
it "redirects to the survey_questions list" do
|
||||
question = Survey::Question.create! valid_attributes
|
||||
delete :destroy, {:id => question.to_param}, valid_session
|
||||
expect(response).to redirect_to(survey_questions_url)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
7
spec/factories/survey_answers.rb
Normal file
7
spec/factories/survey_answers.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
FactoryGirl.define do
|
||||
factory :survey_answer, :class => 'Survey::Answer' do
|
||||
choice nil
|
||||
user nil
|
||||
end
|
||||
|
||||
end
|
||||
9
spec/factories/survey_choices.rb
Normal file
9
spec/factories/survey_choices.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
FactoryGirl.define do
|
||||
factory :survey_choice, :class => 'Survey::Choice' do
|
||||
text "MyString"
|
||||
question nil
|
||||
sort 1
|
||||
picture "MyString"
|
||||
end
|
||||
|
||||
end
|
||||
8
spec/factories/survey_questions.rb
Normal file
8
spec/factories/survey_questions.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
FactoryGirl.define do
|
||||
factory :survey_question, :class => 'Survey::Question' do
|
||||
title "MyString"
|
||||
text "MyText"
|
||||
typ 1
|
||||
end
|
||||
|
||||
end
|
||||
15
spec/helpers/survey/answers_helper_spec.rb
Normal file
15
spec/helpers/survey/answers_helper_spec.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
require 'rails_helper'
|
||||
|
||||
# Specs in this file have access to a helper object that includes
|
||||
# the Survey::AnswersHelper. For example:
|
||||
#
|
||||
# describe Survey::AnswersHelper do
|
||||
# describe "string concat" do
|
||||
# it "concats two strings with spaces" do
|
||||
# expect(helper.concat_strings("this","that")).to eq("this that")
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
RSpec.describe Survey::AnswersHelper, :type => :helper do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
15
spec/helpers/survey/choices_helper_spec.rb
Normal file
15
spec/helpers/survey/choices_helper_spec.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
require 'rails_helper'
|
||||
|
||||
# Specs in this file have access to a helper object that includes
|
||||
# the Survey::ChoicesHelper. For example:
|
||||
#
|
||||
# describe Survey::ChoicesHelper do
|
||||
# describe "string concat" do
|
||||
# it "concats two strings with spaces" do
|
||||
# expect(helper.concat_strings("this","that")).to eq("this that")
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
RSpec.describe Survey::ChoicesHelper, :type => :helper do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
15
spec/helpers/survey/questions_helper_spec.rb
Normal file
15
spec/helpers/survey/questions_helper_spec.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
require 'rails_helper'
|
||||
|
||||
# Specs in this file have access to a helper object that includes
|
||||
# the Survey::QuestionsHelper. For example:
|
||||
#
|
||||
# describe Survey::QuestionsHelper do
|
||||
# describe "string concat" do
|
||||
# it "concats two strings with spaces" do
|
||||
# expect(helper.concat_strings("this","that")).to eq("this that")
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
RSpec.describe Survey::QuestionsHelper, :type => :helper do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
5
spec/models/survey/answer_spec.rb
Normal file
5
spec/models/survey/answer_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Survey::Answer, :type => :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
5
spec/models/survey/choice_spec.rb
Normal file
5
spec/models/survey/choice_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Survey::Choice, :type => :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
5
spec/models/survey/question_spec.rb
Normal file
5
spec/models/survey/question_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Survey::Question, :type => :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
10
spec/requests/survey/survey_answers_spec.rb
Normal file
10
spec/requests/survey/survey_answers_spec.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "Survey::Answers", :type => :request do
|
||||
describe "GET /survey_answers" do
|
||||
it "works! (now write some real specs)" do
|
||||
get survey_answers_path
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
||||
10
spec/requests/survey/survey_choices_spec.rb
Normal file
10
spec/requests/survey/survey_choices_spec.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "Survey::Choices", :type => :request do
|
||||
describe "GET /survey_choices" do
|
||||
it "works! (now write some real specs)" do
|
||||
get survey_choices_path
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
||||
10
spec/requests/survey/survey_questions_spec.rb
Normal file
10
spec/requests/survey/survey_questions_spec.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "Survey::Questions", :type => :request do
|
||||
describe "GET /survey_questions" do
|
||||
it "works! (now write some real specs)" do
|
||||
get survey_questions_path
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
||||
35
spec/routing/survey/answers_routing_spec.rb
Normal file
35
spec/routing/survey/answers_routing_spec.rb
Normal file
@@ -0,0 +1,35 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe Survey::AnswersController, :type => :routing do
|
||||
describe "routing" do
|
||||
|
||||
it "routes to #index" do
|
||||
expect(:get => "/survey/answers").to route_to("survey/answers#index")
|
||||
end
|
||||
|
||||
it "routes to #new" do
|
||||
expect(:get => "/survey/answers/new").to route_to("survey/answers#new")
|
||||
end
|
||||
|
||||
it "routes to #show" do
|
||||
expect(:get => "/survey/answers/1").to route_to("survey/answers#show", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #edit" do
|
||||
expect(:get => "/survey/answers/1/edit").to route_to("survey/answers#edit", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #create" do
|
||||
expect(:post => "/survey/answers").to route_to("survey/answers#create")
|
||||
end
|
||||
|
||||
it "routes to #update" do
|
||||
expect(:put => "/survey/answers/1").to route_to("survey/answers#update", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #destroy" do
|
||||
expect(:delete => "/survey/answers/1").to route_to("survey/answers#destroy", :id => "1")
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
35
spec/routing/survey/choices_routing_spec.rb
Normal file
35
spec/routing/survey/choices_routing_spec.rb
Normal file
@@ -0,0 +1,35 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe Survey::ChoicesController, :type => :routing do
|
||||
describe "routing" do
|
||||
|
||||
it "routes to #index" do
|
||||
expect(:get => "/survey/choices").to route_to("survey/choices#index")
|
||||
end
|
||||
|
||||
it "routes to #new" do
|
||||
expect(:get => "/survey/choices/new").to route_to("survey/choices#new")
|
||||
end
|
||||
|
||||
it "routes to #show" do
|
||||
expect(:get => "/survey/choices/1").to route_to("survey/choices#show", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #edit" do
|
||||
expect(:get => "/survey/choices/1/edit").to route_to("survey/choices#edit", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #create" do
|
||||
expect(:post => "/survey/choices").to route_to("survey/choices#create")
|
||||
end
|
||||
|
||||
it "routes to #update" do
|
||||
expect(:put => "/survey/choices/1").to route_to("survey/choices#update", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #destroy" do
|
||||
expect(:delete => "/survey/choices/1").to route_to("survey/choices#destroy", :id => "1")
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
35
spec/routing/survey/questions_routing_spec.rb
Normal file
35
spec/routing/survey/questions_routing_spec.rb
Normal file
@@ -0,0 +1,35 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe Survey::QuestionsController, :type => :routing do
|
||||
describe "routing" do
|
||||
|
||||
it "routes to #index" do
|
||||
expect(:get => "/survey/questions").to route_to("survey/questions#index")
|
||||
end
|
||||
|
||||
it "routes to #new" do
|
||||
expect(:get => "/survey/questions/new").to route_to("survey/questions#new")
|
||||
end
|
||||
|
||||
it "routes to #show" do
|
||||
expect(:get => "/survey/questions/1").to route_to("survey/questions#show", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #edit" do
|
||||
expect(:get => "/survey/questions/1/edit").to route_to("survey/questions#edit", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #create" do
|
||||
expect(:post => "/survey/questions").to route_to("survey/questions#create")
|
||||
end
|
||||
|
||||
it "routes to #update" do
|
||||
expect(:put => "/survey/questions/1").to route_to("survey/questions#update", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #destroy" do
|
||||
expect(:delete => "/survey/questions/1").to route_to("survey/questions#destroy", :id => "1")
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
21
spec/views/survey/answers/edit.html.erb_spec.rb
Normal file
21
spec/views/survey/answers/edit.html.erb_spec.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "survey/answers/edit", :type => :view do
|
||||
before(:each) do
|
||||
@survey_answer = assign(:survey_answer, Survey::Answer.create!(
|
||||
:choice => nil,
|
||||
:user => nil
|
||||
))
|
||||
end
|
||||
|
||||
it "renders the edit survey_answer form" do
|
||||
render
|
||||
|
||||
assert_select "form[action=?][method=?]", survey_answer_path(@survey_answer), "post" do
|
||||
|
||||
assert_select "input#survey_answer_choice[name=?]", "survey_answer[choice]"
|
||||
|
||||
assert_select "input#survey_answer_user[name=?]", "survey_answer[user]"
|
||||
end
|
||||
end
|
||||
end
|
||||
22
spec/views/survey/answers/index.html.erb_spec.rb
Normal file
22
spec/views/survey/answers/index.html.erb_spec.rb
Normal file
@@ -0,0 +1,22 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "survey/answers/index", :type => :view do
|
||||
before(:each) do
|
||||
assign(:survey_answers, [
|
||||
Survey::Answer.create!(
|
||||
:choice => nil,
|
||||
:user => nil
|
||||
),
|
||||
Survey::Answer.create!(
|
||||
:choice => nil,
|
||||
:user => nil
|
||||
)
|
||||
])
|
||||
end
|
||||
|
||||
it "renders a list of survey/answers" do
|
||||
render
|
||||
assert_select "tr>td", :text => nil.to_s, :count => 2
|
||||
assert_select "tr>td", :text => nil.to_s, :count => 2
|
||||
end
|
||||
end
|
||||
21
spec/views/survey/answers/new.html.erb_spec.rb
Normal file
21
spec/views/survey/answers/new.html.erb_spec.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "survey/answers/new", :type => :view do
|
||||
before(:each) do
|
||||
assign(:survey_answer, Survey::Answer.new(
|
||||
:choice => nil,
|
||||
:user => nil
|
||||
))
|
||||
end
|
||||
|
||||
it "renders new survey_answer form" do
|
||||
render
|
||||
|
||||
assert_select "form[action=?][method=?]", survey_answers_path, "post" do
|
||||
|
||||
assert_select "input#survey_answer_choice[name=?]", "survey_answer[choice]"
|
||||
|
||||
assert_select "input#survey_answer_user[name=?]", "survey_answer[user]"
|
||||
end
|
||||
end
|
||||
end
|
||||
16
spec/views/survey/answers/show.html.erb_spec.rb
Normal file
16
spec/views/survey/answers/show.html.erb_spec.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "survey/answers/show", :type => :view do
|
||||
before(:each) do
|
||||
@survey_answer = assign(:survey_answer, Survey::Answer.create!(
|
||||
:choice => nil,
|
||||
:user => nil
|
||||
))
|
||||
end
|
||||
|
||||
it "renders attributes in <p>" do
|
||||
render
|
||||
expect(rendered).to match(//)
|
||||
expect(rendered).to match(//)
|
||||
end
|
||||
end
|
||||
27
spec/views/survey/choices/edit.html.erb_spec.rb
Normal file
27
spec/views/survey/choices/edit.html.erb_spec.rb
Normal file
@@ -0,0 +1,27 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "survey/choices/edit", :type => :view do
|
||||
before(:each) do
|
||||
@survey_choice = assign(:survey_choice, Survey::Choice.create!(
|
||||
:text => "MyString",
|
||||
:question => nil,
|
||||
:sort => 1,
|
||||
:picture => "MyString"
|
||||
))
|
||||
end
|
||||
|
||||
it "renders the edit survey_choice form" do
|
||||
render
|
||||
|
||||
assert_select "form[action=?][method=?]", survey_choice_path(@survey_choice), "post" do
|
||||
|
||||
assert_select "input#survey_choice_text[name=?]", "survey_choice[text]"
|
||||
|
||||
assert_select "input#survey_choice_question[name=?]", "survey_choice[question]"
|
||||
|
||||
assert_select "input#survey_choice_sort[name=?]", "survey_choice[sort]"
|
||||
|
||||
assert_select "input#survey_choice_picture[name=?]", "survey_choice[picture]"
|
||||
end
|
||||
end
|
||||
end
|
||||
28
spec/views/survey/choices/index.html.erb_spec.rb
Normal file
28
spec/views/survey/choices/index.html.erb_spec.rb
Normal file
@@ -0,0 +1,28 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "survey/choices/index", :type => :view do
|
||||
before(:each) do
|
||||
assign(:survey_choices, [
|
||||
Survey::Choice.create!(
|
||||
:text => "Text",
|
||||
:question => nil,
|
||||
:sort => 1,
|
||||
:picture => "Picture"
|
||||
),
|
||||
Survey::Choice.create!(
|
||||
:text => "Text",
|
||||
:question => nil,
|
||||
:sort => 1,
|
||||
:picture => "Picture"
|
||||
)
|
||||
])
|
||||
end
|
||||
|
||||
it "renders a list of survey/choices" do
|
||||
render
|
||||
assert_select "tr>td", :text => "Text".to_s, :count => 2
|
||||
assert_select "tr>td", :text => nil.to_s, :count => 2
|
||||
assert_select "tr>td", :text => 1.to_s, :count => 2
|
||||
assert_select "tr>td", :text => "Picture".to_s, :count => 2
|
||||
end
|
||||
end
|
||||
27
spec/views/survey/choices/new.html.erb_spec.rb
Normal file
27
spec/views/survey/choices/new.html.erb_spec.rb
Normal file
@@ -0,0 +1,27 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "survey/choices/new", :type => :view do
|
||||
before(:each) do
|
||||
assign(:survey_choice, Survey::Choice.new(
|
||||
:text => "MyString",
|
||||
:question => nil,
|
||||
:sort => 1,
|
||||
:picture => "MyString"
|
||||
))
|
||||
end
|
||||
|
||||
it "renders new survey_choice form" do
|
||||
render
|
||||
|
||||
assert_select "form[action=?][method=?]", survey_choices_path, "post" do
|
||||
|
||||
assert_select "input#survey_choice_text[name=?]", "survey_choice[text]"
|
||||
|
||||
assert_select "input#survey_choice_question[name=?]", "survey_choice[question]"
|
||||
|
||||
assert_select "input#survey_choice_sort[name=?]", "survey_choice[sort]"
|
||||
|
||||
assert_select "input#survey_choice_picture[name=?]", "survey_choice[picture]"
|
||||
end
|
||||
end
|
||||
end
|
||||
20
spec/views/survey/choices/show.html.erb_spec.rb
Normal file
20
spec/views/survey/choices/show.html.erb_spec.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "survey/choices/show", :type => :view do
|
||||
before(:each) do
|
||||
@survey_choice = assign(:survey_choice, Survey::Choice.create!(
|
||||
:text => "Text",
|
||||
:question => nil,
|
||||
:sort => 1,
|
||||
:picture => "Picture"
|
||||
))
|
||||
end
|
||||
|
||||
it "renders attributes in <p>" do
|
||||
render
|
||||
expect(rendered).to match(/Text/)
|
||||
expect(rendered).to match(//)
|
||||
expect(rendered).to match(/1/)
|
||||
expect(rendered).to match(/Picture/)
|
||||
end
|
||||
end
|
||||
24
spec/views/survey/questions/edit.html.erb_spec.rb
Normal file
24
spec/views/survey/questions/edit.html.erb_spec.rb
Normal file
@@ -0,0 +1,24 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "survey/questions/edit", :type => :view do
|
||||
before(:each) do
|
||||
@survey_question = assign(:survey_question, Survey::Question.create!(
|
||||
:title => "MyString",
|
||||
:text => "MyText",
|
||||
:typ => 1
|
||||
))
|
||||
end
|
||||
|
||||
it "renders the edit survey_question form" do
|
||||
render
|
||||
|
||||
assert_select "form[action=?][method=?]", survey_question_path(@survey_question), "post" do
|
||||
|
||||
assert_select "input#survey_question_title[name=?]", "survey_question[title]"
|
||||
|
||||
assert_select "textarea#survey_question_text[name=?]", "survey_question[text]"
|
||||
|
||||
assert_select "input#survey_question_typ[name=?]", "survey_question[typ]"
|
||||
end
|
||||
end
|
||||
end
|
||||
25
spec/views/survey/questions/index.html.erb_spec.rb
Normal file
25
spec/views/survey/questions/index.html.erb_spec.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "survey/questions/index", :type => :view do
|
||||
before(:each) do
|
||||
assign(:survey_questions, [
|
||||
Survey::Question.create!(
|
||||
:title => "Title",
|
||||
:text => "MyText",
|
||||
:typ => 1
|
||||
),
|
||||
Survey::Question.create!(
|
||||
:title => "Title",
|
||||
:text => "MyText",
|
||||
:typ => 1
|
||||
)
|
||||
])
|
||||
end
|
||||
|
||||
it "renders a list of survey/questions" do
|
||||
render
|
||||
assert_select "tr>td", :text => "Title".to_s, :count => 2
|
||||
assert_select "tr>td", :text => "MyText".to_s, :count => 2
|
||||
assert_select "tr>td", :text => 1.to_s, :count => 2
|
||||
end
|
||||
end
|
||||
24
spec/views/survey/questions/new.html.erb_spec.rb
Normal file
24
spec/views/survey/questions/new.html.erb_spec.rb
Normal file
@@ -0,0 +1,24 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "survey/questions/new", :type => :view do
|
||||
before(:each) do
|
||||
assign(:survey_question, Survey::Question.new(
|
||||
:title => "MyString",
|
||||
:text => "MyText",
|
||||
:typ => 1
|
||||
))
|
||||
end
|
||||
|
||||
it "renders new survey_question form" do
|
||||
render
|
||||
|
||||
assert_select "form[action=?][method=?]", survey_questions_path, "post" do
|
||||
|
||||
assert_select "input#survey_question_title[name=?]", "survey_question[title]"
|
||||
|
||||
assert_select "textarea#survey_question_text[name=?]", "survey_question[text]"
|
||||
|
||||
assert_select "input#survey_question_typ[name=?]", "survey_question[typ]"
|
||||
end
|
||||
end
|
||||
end
|
||||
18
spec/views/survey/questions/show.html.erb_spec.rb
Normal file
18
spec/views/survey/questions/show.html.erb_spec.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "survey/questions/show", :type => :view do
|
||||
before(:each) do
|
||||
@survey_question = assign(:survey_question, Survey::Question.create!(
|
||||
:title => "Title",
|
||||
:text => "MyText",
|
||||
:typ => 1
|
||||
))
|
||||
end
|
||||
|
||||
it "renders attributes in <p>" do
|
||||
render
|
||||
expect(rendered).to match(/Title/)
|
||||
expect(rendered).to match(/MyText/)
|
||||
expect(rendered).to match(/1/)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user