diff --git a/Gemfile b/Gemfile index d034287e..13637d5b 100644 --- a/Gemfile +++ b/Gemfile @@ -8,7 +8,7 @@ gem 'rails', '~> 5.2.3' # Use postgresql as the database for Active Record gem 'pg', '>= 0.18', '< 2.0' # Use Puma as the app server -gem 'puma', '~> 3.11' +gem 'puma', '~> 3.12' # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0' # Use Uglifier as compressor for JavaScript assets @@ -60,6 +60,7 @@ group :test do gem 'selenium-webdriver' # Easy installation and use of chromedriver to run system tests with Chrome gem 'webdrivers' + gem 'cucumber' gem 'cucumber-rails', require: false # database_cleaner is not required, but highly recommended gem 'database_cleaner' diff --git a/Gemfile.lock b/Gemfile.lock index 1c0f8f1e..69389b0c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -133,13 +133,13 @@ GEM multi_json (1.14.1) multi_test (0.1.2) nio4r (2.5.2) - nokogiri (1.10.5) + nokogiri (1.10.8) mini_portile2 (~> 2.4.0) orm_adapter (0.5.0) pg (1.1.4) public_suffix (4.0.1) - puma (3.12.1) - rack (2.0.7) + puma (3.12.6) + rack (2.2.3) rack-test (1.1.0) rack (>= 1.0, < 3) rails (5.2.3) @@ -243,7 +243,7 @@ GEM selenium-webdriver (>= 3.0, < 4.0) websocket-driver (0.7.1) websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.4) + websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) @@ -255,13 +255,14 @@ DEPENDENCIES byebug capybara (>= 2.15) coffee-rails (~> 4.2) + cucumber cucumber-rails database_cleaner devise jbuilder (~> 2.5) listen (>= 3.0.5, < 3.2) pg (>= 0.18, < 2.0) - puma (~> 3.11) + puma (~> 3.12) rails (~> 5.2.3) rspec-rails sass-rails (~> 5.0) @@ -279,4 +280,4 @@ RUBY VERSION ruby 2.6.3p62 BUNDLED WITH - 1.17.2 + 2.1.4 diff --git a/app/assets/javascripts/faqs.coffee b/app/assets/javascripts/faqs.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/faqs.coffee @@ -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://coffeescript.org/ diff --git a/app/assets/javascripts/faqs_suggestions.coffee b/app/assets/javascripts/faqs_suggestions.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/faqs_suggestions.coffee @@ -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://coffeescript.org/ diff --git a/app/assets/javascripts/topics.coffee b/app/assets/javascripts/topics.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/topics.coffee @@ -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://coffeescript.org/ diff --git a/app/assets/stylesheets/faqs.scss b/app/assets/stylesheets/faqs.scss new file mode 100644 index 00000000..b7e2f4de --- /dev/null +++ b/app/assets/stylesheets/faqs.scss @@ -0,0 +1,187 @@ +// Place all the styles related to the Faqs controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ +/* Sakura.css v1.3.1 + * ================ + * Minimal css theme. + * Project: https://github.com/oxalorg/sakura/ + */ +/* Body */ +html { + font-size: 62.5%; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; } + + body { + font-size: 1.8rem; + line-height: 1.618; + max-width: 38em; + margin: auto; + color: #4a4a4a; + background-color: #f9f9f9; + padding: 13px; } + + @media (max-width: 684px) { + body { + font-size: 1.53rem; } } + + @media (max-width: 382px) { + body { + font-size: 1.35rem; } } + + h1, h2, h3, h4, h5, h6 { + line-height: 1.1; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-weight: 700; + margin-top: 3rem; + margin-bottom: 1.5rem; + overflow-wrap: break-word; + word-wrap: break-word; + -ms-word-break: break-all; + word-break: break-word; } + + h1 { + font-size: 2.35em; } + + h2 { + font-size: 2.00em; } + + h3 { + font-size: 1.75em; } + + h4 { + font-size: 1.5em; } + + h5 { + font-size: 1.25em; } + + h6 { + font-size: 1em; } + + p { + margin-top: 0px; + margin-bottom: 2.5rem; } + + small, sub, sup { + font-size: 75%; } + + hr { + border-color: #1d7484; } + + a { + text-decoration: none; + color: #1d7484; } + a:hover { + color: #982c61; + border-bottom: 2px solid #4a4a4a; } + a:visited { + color: #144f5a; } + + ul { + padding-left: 1.4em; + margin-top: 0px; + margin-bottom: 2.5rem; } + + li { + margin-bottom: 0.4em; } + + blockquote { + margin-left: 0px; + margin-right: 0px; + padding-left: 1em; + padding-top: 0.8em; + padding-bottom: 0.8em; + padding-right: 0.8em; + border-left: 5px solid #1d7484; + margin-bottom: 2.5rem; + background-color: #f1f1f1; } + + blockquote p { + margin-bottom: 0; } + + img, video { + height: auto; + max-width: 100%; + margin-top: 0px; + margin-bottom: 2.5rem; } + + /* Pre and Code */ + pre { + background-color: #f1f1f1; + display: block; + padding: 1em; + overflow-x: auto; + margin-top: 0px; + margin-bottom: 2.5rem; } + + code { + font-size: 0.9em; + padding: 0 0.5em; + background-color: #f1f1f1; + white-space: pre-wrap; } + + pre > code { + padding: 0; + background-color: transparent; + white-space: pre; } + + /* Tables */ + table { + text-align: justify; + width: 100%; + border-collapse: collapse; } + + td, th { + padding: 0.5em; + border-bottom: 1px solid #f1f1f1; } + + /* Buttons, forms and input */ + input, textarea { + border: 1px solid #4a4a4a; } + input:focus, textarea:focus { + border: 1px solid #1d7484; } + + textarea { + width: 100%; } + + .button, button, input[type="submit"], input[type="reset"], input[type="button"] { + display: inline-block; + padding: 5px 10px; + text-align: center; + text-decoration: none; + white-space: nowrap; + background-color: #1d7484; + color: #f9f9f9; + border-radius: 1px; + border: 1px solid #1d7484; + cursor: pointer; + box-sizing: border-box; } + .button[disabled], button[disabled], input[type="submit"][disabled], input[type="reset"][disabled], input[type="button"][disabled] { + cursor: default; + opacity: .5; } + .button:focus:enabled, .button:hover:enabled, button:focus:enabled, button:hover:enabled, input[type="submit"]:focus:enabled, input[type="submit"]:hover:enabled, input[type="reset"]:focus:enabled, input[type="reset"]:hover:enabled, input[type="button"]:focus:enabled, input[type="button"]:hover:enabled { + background-color: #982c61; + border-color: #982c61; + color: #f9f9f9; + outline: 0; } + + textarea, select, input { + color: #4a4a4a; + padding: 6px 10px; + /* The 6px vertically centers text on FF, ignored by Webkit */ + margin-bottom: 10px; + background-color: #f1f1f1; + border: 1px solid #f1f1f1; + border-radius: 4px; + box-shadow: none; + box-sizing: border-box; } + textarea:focus, select:focus, input:focus { + border: 1px solid #1d7484; + outline: 0; } + + input[type="checkbox"]:focus { + outline: 1px dotted #1d7484; } + + label, legend, fieldset { + display: block; + margin-bottom: .5rem; + font-weight: 600; } \ No newline at end of file diff --git a/app/assets/stylesheets/faqs_suggestions.scss b/app/assets/stylesheets/faqs_suggestions.scss new file mode 100644 index 00000000..044b2f0d --- /dev/null +++ b/app/assets/stylesheets/faqs_suggestions.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the FaqsSuggestions controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/scaffolds.scss b/app/assets/stylesheets/scaffolds.scss new file mode 100644 index 00000000..626d42ca --- /dev/null +++ b/app/assets/stylesheets/scaffolds.scss @@ -0,0 +1,184 @@ +/* Sakura.css v1.3.1 + * ================ + * Minimal css theme. + * Project: https://github.com/oxalorg/sakura/ + */ +/* Body */ +html { + font-size: 62.5%; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; } + +body { + font-size: 1.8rem; + line-height: 1.618; + max-width: 38em; + margin: auto; + color: #4a4a4a; + background-color: #f9f9f9; + padding: 13px; } + +@media (max-width: 684px) { + body { + font-size: 1.53rem; } } + +@media (max-width: 382px) { + body { + font-size: 1.35rem; } } + +h1, h2, h3, h4, h5, h6 { + line-height: 1.1; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-weight: 700; + margin-top: 3rem; + margin-bottom: 1.5rem; + overflow-wrap: break-word; + word-wrap: break-word; + -ms-word-break: break-all; + word-break: break-word; } + +h1 { + font-size: 2.35em; } + +h2 { + font-size: 2.00em; } + +h3 { + font-size: 1.75em; } + +h4 { + font-size: 1.5em; } + +h5 { + font-size: 1.25em; } + +h6 { + font-size: 1em; } + +p { + margin-top: 0px; + margin-bottom: 2.5rem; } + +small, sub, sup { + font-size: 75%; } + +hr { + border-color: #1d7484; } + +a { + text-decoration: none; + color: #1d7484; } + a:hover { + color: #982c61; + border-bottom: 2px solid #4a4a4a; } + a:visited { + color: #144f5a; } + +ul { + padding-left: 1.4em; + margin-top: 0px; + margin-bottom: 2.5rem; } + +li { + margin-bottom: 0.4em; } + +blockquote { + margin-left: 0px; + margin-right: 0px; + padding-left: 1em; + padding-top: 0.8em; + padding-bottom: 0.8em; + padding-right: 0.8em; + border-left: 5px solid #1d7484; + margin-bottom: 2.5rem; + background-color: #f1f1f1; } + +blockquote p { + margin-bottom: 0; } + +img, video { + height: auto; + max-width: 100%; + margin-top: 0px; + margin-bottom: 2.5rem; } + +/* Pre and Code */ +pre { + background-color: #f1f1f1; + display: block; + padding: 1em; + overflow-x: auto; + margin-top: 0px; + margin-bottom: 2.5rem; } + +code { + font-size: 0.9em; + padding: 0 0.5em; + background-color: #f1f1f1; + white-space: pre-wrap; } + +pre > code { + padding: 0; + background-color: transparent; + white-space: pre; } + +/* Tables */ +table { + text-align: justify; + width: 100%; + border-collapse: collapse; } + +td, th { + padding: 0.5em; + border-bottom: 1px solid #f1f1f1; } + +/* Buttons, forms and input */ +input, textarea { + border: 1px solid #4a4a4a; } + input:focus, textarea:focus { + border: 1px solid #1d7484; } + +textarea { + width: 100%; } + +.button, button, input[type="submit"], input[type="reset"], input[type="button"] { + display: inline-block; + padding: 5px 10px; + text-align: center; + text-decoration: none; + white-space: nowrap; + background-color: #1d7484; + color: #f9f9f9; + border-radius: 1px; + border: 1px solid #1d7484; + cursor: pointer; + box-sizing: border-box; } + .button[disabled], button[disabled], input[type="submit"][disabled], input[type="reset"][disabled], input[type="button"][disabled] { + cursor: default; + opacity: .5; } + .button:focus:enabled, .button:hover:enabled, button:focus:enabled, button:hover:enabled, input[type="submit"]:focus:enabled, input[type="submit"]:hover:enabled, input[type="reset"]:focus:enabled, input[type="reset"]:hover:enabled, input[type="button"]:focus:enabled, input[type="button"]:hover:enabled { + background-color: #982c61; + border-color: #982c61; + color: #f9f9f9; + outline: 0; } + +textarea, select, input { + color: #4a4a4a; + padding: 6px 10px; + /* The 6px vertically centers text on FF, ignored by Webkit */ + margin-bottom: 10px; + background-color: #f1f1f1; + border: 1px solid #f1f1f1; + border-radius: 4px; + box-shadow: none; + box-sizing: border-box; } + textarea:focus, select:focus, input:focus { + border: 1px solid #1d7484; + outline: 0; } + +input[type="checkbox"]:focus { + outline: 1px dotted #1d7484; } + +label, legend, fieldset { + display: block; + margin-bottom: .5rem; + font-weight: 600; } \ No newline at end of file diff --git a/app/assets/stylesheets/topics.scss b/app/assets/stylesheets/topics.scss new file mode 100644 index 00000000..f234f079 --- /dev/null +++ b/app/assets/stylesheets/topics.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Topics controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/faqs_controller.rb b/app/controllers/faqs_controller.rb new file mode 100644 index 00000000..d2116b21 --- /dev/null +++ b/app/controllers/faqs_controller.rb @@ -0,0 +1,102 @@ +## +# Classe da controller dos FAQS +# Herda de ApplicationController +class FaqsController < ApplicationController + before_action :set_faq, only: [:show, :edit, :update, :destroy] + before_action :must_be_admin, only: [:create, :edit, :update, :destroy] + + + ## + # Retorna todos as FAQ + def index + @faqs = Faq.all + end + + ## + #... + def show + end + + ## + # Cria nova instancia de FAQ + def new + @faq = Faq.new + end + + ## + #... + def edit + end + + ## + # Popula uma instancia de FAQ com um dos tipos do faq_params + # Redireciona para a página da FAQ criada. + def create + @faq = Faq.new(faq_params) + + respond_to do |format| + if @faq.save + format.html { redirect_to @faq, notice: 'Faq was successfully created.' } + format.json { render :show, status: :created, location: @faq } + else + format.html { render :new } + format.json { render json: @faq.errors, status: :unprocessable_entity } + end + end + end + + + ## + # Atualiza uma FAQ pre existente + # Redireciona para a página da FAQ atualizada + def update + respond_to do |format| + if @faq.update(faq_params) + format.html { redirect_to @faq, notice: 'Faq was successfully updated.' } + format.json { render :show, status: :ok, location: @faq } + else + format.html { render :edit } + format.json { render json: @faq.errors, status: :unprocessable_entity } + end + end + end + + + ## + # Apaga uma instancia de FAQ + # Redireciona para a página de faqs + def destroy + @faq.destroy + respond_to do |format| + format.html { redirect_to faqs_url, notice: 'Faq was successfully destroyed.' } + format.json { head :no_content } + end + end + + + private + + ## + # Encontra e seta a FAQ requerida. + # @param [number] id - id da FAQ + def set_faq + @faq = Faq.find(params[:id]) + end + + ## + # Retorna os parametros aceitos pela FAQ + # Podem ser do tipo Question, Answer ou Topic_id + def faq_params + params.require(:faq).permit(:question, :answer, :topic_id) + end + + ## + # Redireciona o usuário para a pagina faqs + # caso não seja admin. Exibe alerta na tela. + def must_be_admin + unless current_user && current_user.role == "administrator" + redirect_to faqs_url, alert: "Rota restrita para administradores" + end + end + +end diff --git a/app/controllers/faqs_suggestions_controller.rb b/app/controllers/faqs_suggestions_controller.rb new file mode 100644 index 00000000..4c83d5e7 --- /dev/null +++ b/app/controllers/faqs_suggestions_controller.rb @@ -0,0 +1,109 @@ +## +# Classe da controller das sugestões de resposta ou pergunta das FAQ +# Herda de ApplicationController +class FaqsSuggestionsController < ApplicationController + before_action :set_faqs_suggestion, only: [:show, :edit, :update, :destroy] + before_action :must_be_admin, only: [:destroy, :index, :accept] + before_action :must_be_authenticated_user, only: [:create, :edit, :update] + + ## + # Retorna todas as faqs_suggestions + def index + @faqs_suggestions = FaqsSuggestion.all + end + + ## + #... + def show + end + + ## + # Cria nova instancia de faqs_suggestion + def new + @faqs_suggestion = FaqsSuggestion.new + end + + ## + #... + def edit + end + + + ## + # Popula uma instancia de faqs_suggestions com um dos tipos de faqs_suggestion_params + # Redireciona para a página da faqs_suggestions criada. + def create + @faqs_suggestion = FaqsSuggestion.new(faqs_suggestion_params) + + respond_to do |format| + if @faqs_suggestion.save + format.html { redirect_to @faqs_suggestion, notice: 'Faqs suggestion was successfully created.' } + format.json { render :show, status: :created, location: @faqs_suggestion } + else + format.html { render :new } + format.json { render json: @faqs_suggestion.errors, status: :unprocessable_entity } + end + end + end + + ## + # Atualiza uma faqs_suggestions pre existente + # Redireciona para a página da faqs_suggestions atualizada + def update + respond_to do |format| + if @faqs_suggestion.update(faqs_suggestion_params) + format.html { redirect_to @faqs_suggestion, notice: 'Faqs suggestion was successfully updated.' } + format.json { render :show, status: :ok, location: @faqs_suggestion } + else + format.html { render :edit } + format.json { render json: @faqs_suggestion.errors, status: :unprocessable_entity } + end + end + end + + ## + # Apaga uma instancia de faqs_suggestion + # Redireciona para a página faqs_suggestions + def destroy + @faqs_suggestion.destroy + respond_to do |format| + format.html { redirect_to faqs_suggestions_url, notice: 'Faqs suggestion was successfully destroyed.' } + format.json { head :no_content } + end + end + + + private + + ## + # Econtra e seta a faqs_suggestion requerida + # @param [number] id - id da faqs_suggestion + def set_faqs_suggestion + @faqs_suggestion = FaqsSuggestion.find(params[:id]) + end + + ## + # Retorna os parametros aceitos pelos métodos de faq_suggestion + # Podem ser do tipo Question, Answer ou Topic_id + def faqs_suggestion_params + params.require(:faqs_suggestion).permit(:question, :answer, :topic_id) + end + + ## + # Redireciona o usuário para a pagina faqs + # caso não seja admin. Exibe alerta na tela + def must_be_admin + unless current_user && current_user.role == "administrator" + redirect_to faqs_url, alert: "Rota restrita para administradores" + end + end + + ## + # Redireciona o usuário para a página faqs + # caso nao seja um usuario autenticado. + def must_be_authenticated_user + unless current_user && current_user.role != "administrator" + redirect_to faqs_url, alert: "Rota restrita para usuários cadastrados" + end + end +end diff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rb new file mode 100644 index 00000000..cf5b6612 --- /dev/null +++ b/app/controllers/topics_controller.rb @@ -0,0 +1,102 @@ +## +# Classe da controller dos tópicos das FAQ +# Herda de ApplicationController +class TopicsController < ApplicationController + ## + # Configura as pre-actions de toda requisicao + # Indica as operacoes disponiveis e trava o acesso para não administradores + before_action :set_topic, only: [:show, :edit, :update, :destroy] + before_action :set_faq, only: [:show, :edit, :update, :destroy] + before_action :must_be_admin, only: [:create, :edit, :update, :destroy] + + ## + # Retorna todos os topics + def index + @topics = Topic.all + end + + ## + #... + def show + end + + ## + # Cria nova instancia de topic + def new + @topic = Topic.new + end + + ## + #... + def edit + end + + ## + # Popula uma instancia de topic com um dos tipos de topic_params + # Redireciona para a página do topic criado + def create + @topic = Topic.new(topic_params) + + respond_to do |format| + if @topic.save + format.html { redirect_to @topic, notice: 'Topic was successfully created.' } + format.json { render :show, status: :created, location: @topic } + else + format.html { render :new } + format.json { render json: @topic.errors, status: :unprocessable_entity } + end + end + end + + ## + # Atualiza um topic pre existente + # Redireciona para a página do topic atualizado + def update + respond_to do |format| + if @topic.update(topic_params) + format.html { redirect_to @topic, notice: 'Topic was successfully updated.' } + format.json { render :show, status: :ok, location: @topic } + else + format.html { render :edit } + format.json { render json: @topic.errors, status: :unprocessable_entity } + end + end + end + + ## + # Apaga uma instancia de topic + # Redireciona para a página de topics + def destroy + @topic.destroy + respond_to do |format| + format.html { redirect_to topics_url, notice: 'Topic was successfully destroyed.' } + format.json { head :no_content } + end + end + + + private + + ## + # Encontra e seta o topic requerida. + # @param [number] id - id do topic + def set_topic + @topic = Topic.find(params[:id]) + end + + ## + # Retorna os parametros aceitos pelo topic + # Podem ser apenas do tipo titulo + def topic_params + params.require(:topic).permit(:titulo) + end + + ## + # Redireciona o usuário para a pagina faqs + # caso não seja admin. Exibe alerta na tela. + def must_be_admin + unless current_user && current_user.role == "administrator" + redirect_to faqs_url, alert: "Rota restrita para administradores" + end + end +end diff --git a/app/doc/ApplicationController.html b/app/doc/ApplicationController.html new file mode 100644 index 00000000..95fd6bbd --- /dev/null +++ b/app/doc/ApplicationController.html @@ -0,0 +1,157 @@ + + + + + + +class ApplicationController - RDoc Documentation + + + + + + + + + + + + + + + + + + +
+

+ class ApplicationController +

+ +
+ +
+ + +
+ + + + + + + + + +
+
+

Protected Instance Methods

+
+ + +
+ +
+ configure_permitted_parameters() + + click to toggle source + +
+ + +
+ + + + + + +
+
# File application_controller.rb, line 8
+def configure_permitted_parameters
+  devise_parameter_sanitizer.permit(:sign_up, keys: %i[full_name role])
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/app/doc/FaqsController.html b/app/doc/FaqsController.html new file mode 100644 index 00000000..21407867 --- /dev/null +++ b/app/doc/FaqsController.html @@ -0,0 +1,389 @@ + + + + + + +class FaqsController - RDoc Documentation + + + + + + + + + + + + + + + + + + +
+

+ class FaqsController +

+ +
+ +

Classe da controller dos FAQS Herda de ApplicationController

+ +
+ + +
+ + + + + + + + + +
+
+

Public Instance Methods

+
+ + +
+ +
+ create() + + click to toggle source + +
+ + +
+ +

Popula uma instancia de FAQ com um dos tipos do faq_params Redireciona para a página da FAQ criada.

+ + + + +
+
# File faqs_controller.rb, line 34
+def create
+  @faq = Faq.new(faq_params)
+
+  respond_to do |format|
+    if @faq.save
+      format.html { redirect_to @faq, notice: 'Faq was successfully created.' }
+      format.json { render :show, status: :created, location: @faq }
+    else
+      format.html { render :new }
+      format.json { render json: @faq.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + + click to toggle source + +
+ + +
+ +

Apaga uma instancia de FAQ Redireciona para faqs_url

+ + + + +
+
# File faqs_controller.rb, line 68
+def destroy
+  @faq.destroy
+  respond_to do |format|
+    format.html { redirect_to faqs_url, notice: 'Faq was successfully destroyed.' }
+    format.json { head :no_content }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ edit() + + click to toggle source + +
+ + +
+ +

+ + + + +
+
# File faqs_controller.rb, line 28
+def edit
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + + click to toggle source + +
+ + +
+ +

Retorna todos as FAQ

+ + + + +
+
# File faqs_controller.rb, line 11
+def index
+  @faqs = Faq.all
+end
+
+ +
+ + + + +
+ + +
+ +
+ new() + + click to toggle source + +
+ + +
+ +

Cria nova instancia de FAQ

+ + + + +
+
# File faqs_controller.rb, line 22
+def new
+  @faq = Faq.new
+end
+
+ +
+ + + + +
+ + +
+ +
+ show() + + click to toggle source + +
+ + +
+ +

+ + + + +
+
# File faqs_controller.rb, line 17
+def show
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + + click to toggle source + +
+ + +
+ +

Atualiza uma FAQ pre existente Redireciona para a página da FAQ atualizada

+ + + + +
+
# File faqs_controller.rb, line 52
+def update
+  respond_to do |format|
+    if @faq.update(faq_params)
+      format.html { redirect_to @faq, notice: 'Faq was successfully updated.' }
+      format.json { render :show, status: :ok, location: @faq }
+    else
+      format.html { render :edit }
+      format.json { render json: @faq.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/app/doc/FaqsSuggestionsController.html b/app/doc/FaqsSuggestionsController.html new file mode 100644 index 00000000..839c923c --- /dev/null +++ b/app/doc/FaqsSuggestionsController.html @@ -0,0 +1,389 @@ + + + + + + +class FaqsSuggestionsController - RDoc Documentation + + + + + + + + + + + + + + + + + + +
+

+ class FaqsSuggestionsController +

+ +
+ +

Classe da controller das sugestões de resposta ou pergunta das FAQ Herda de ApplicationController

+ +
+ + +
+ + + + + + + + + +
+
+

Public Instance Methods

+
+ + +
+ +
+ create() + + click to toggle source + +
+ + +
+ +

Popula uma instancia de faqs_suggestions com um dos tipos de faqs_suggestion_params Redireciona para a página da faqs_suggestions criada.

+ + + + +
+
# File faqs_suggestions_controller.rb, line 35
+def create
+  @faqs_suggestion = FaqsSuggestion.new(faqs_suggestion_params)
+
+  respond_to do |format|
+    if @faqs_suggestion.save
+      format.html { redirect_to @faqs_suggestion, notice: 'Faqs suggestion was successfully created.' }
+      format.json { render :show, status: :created, location: @faqs_suggestion }
+    else
+      format.html { render :new }
+      format.json { render json: @faqs_suggestion.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + + click to toggle source + +
+ + +
+ +

Apaga uma instancia de faqs_suggestion Redireciona para a página faqs_suggestions

+ + + + +
+
# File faqs_suggestions_controller.rb, line 67
+def destroy
+  @faqs_suggestion.destroy
+  respond_to do |format|
+    format.html { redirect_to faqs_suggestions_url, notice: 'Faqs suggestion was successfully destroyed.' }
+    format.json { head :no_content }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ edit() + + click to toggle source + +
+ + +
+ +

+ + + + +
+
# File faqs_suggestions_controller.rb, line 28
+def edit
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + + click to toggle source + +
+ + +
+ +

Retorna todas as faqs_suggestions

+ + + + +
+
# File faqs_suggestions_controller.rb, line 11
+def index
+  @faqs_suggestions = FaqsSuggestion.all
+end
+
+ +
+ + + + +
+ + +
+ +
+ new() + + click to toggle source + +
+ + +
+ +

Cria nova instancia de faqs_suggestion

+ + + + +
+
# File faqs_suggestions_controller.rb, line 22
+def new
+  @faqs_suggestion = FaqsSuggestion.new
+end
+
+ +
+ + + + +
+ + +
+ +
+ show() + + click to toggle source + +
+ + +
+ +

+ + + + +
+
# File faqs_suggestions_controller.rb, line 17
+def show
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + + click to toggle source + +
+ + +
+ +

Atualiza uma faqs_suggestions pre existente Redireciona para a página da faqs_suggestions atualizada

+ + + + +
+
# File faqs_suggestions_controller.rb, line 52
+def update
+  respond_to do |format|
+    if @faqs_suggestion.update(faqs_suggestion_params)
+      format.html { redirect_to @faqs_suggestion, notice: 'Faqs suggestion was successfully updated.' }
+      format.json { render :show, status: :ok, location: @faqs_suggestion }
+    else
+      format.html { render :edit }
+      format.json { render json: @faqs_suggestion.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/app/doc/HomeController.html b/app/doc/HomeController.html new file mode 100644 index 00000000..ecf7a02d --- /dev/null +++ b/app/doc/HomeController.html @@ -0,0 +1,156 @@ + + + + + + +class HomeController - RDoc Documentation + + + + + + + + + + + + + + + + + + +
+

+ class HomeController +

+ +
+ +
+ + +
+ + + + + + + + + +
+
+

Public Instance Methods

+
+ + +
+ +
+ index() + + click to toggle source + +
+ + +
+ + + + + + +
+
# File home_controller.rb, line 2
+def index
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/app/doc/TopicsController.html b/app/doc/TopicsController.html new file mode 100644 index 00000000..d91aa129 --- /dev/null +++ b/app/doc/TopicsController.html @@ -0,0 +1,423 @@ + + + + + + +class TopicsController - RDoc Documentation + + + + + + + + + + + + + + + + + + +
+

+ class TopicsController +

+ +
+ +

Classe da controller dos tópicos das FAQ Herda de ApplicationController

+ +
+ + +
+ + + + + + + + + +
+
+

Public Instance Methods

+
+ + +
+ +
+ create() + + click to toggle source + +
+ + +
+ +

Popula uma instancia de topic com um dos tipos de topic_params Redireciona para a página do topic criado

+ + + + +
+
# File topics_controller.rb, line 37
+def create
+  @topic = Topic.new(topic_params)
+
+  respond_to do |format|
+    if @topic.save
+      format.html { redirect_to @topic, notice: 'Topic was successfully created.' }
+      format.json { render :show, status: :created, location: @topic }
+    else
+      format.html { render :new }
+      format.json { render json: @topic.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + + click to toggle source + +
+ + +
+ +

Apaga uma instancia de topic Redireciona para a página de topics

+ + + + +
+
# File topics_controller.rb, line 69
+def destroy
+  @topic.destroy
+  respond_to do |format|
+    format.html { redirect_to topics_url, notice: 'Topic was successfully destroyed.' }
+    format.json { head :no_content }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ edit() + + click to toggle source + +
+ + +
+ +

+ + + + +
+
# File topics_controller.rb, line 31
+def edit
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + + click to toggle source + +
+ + +
+ +

Retorna todos os topics

+ + + + +
+
# File topics_controller.rb, line 14
+def index
+  @topics = Topic.all
+end
+
+ +
+ + + + +
+ + +
+ +
+ new() + + click to toggle source + +
+ + +
+ +

Cria nova instancia de topic

+ + + + +
+
# File topics_controller.rb, line 25
+def new
+  @topic = Topic.new
+end
+
+ +
+ + + + +
+ + +
+ +
+ set_topic() + + click to toggle source + +
+ + +
+ +

Configura as pre-actions de toda requisicao Indica as operacoes disponiveis e trava o acesso para não administradores

+ + + + +
+
# File topics_controller.rb, line 8
+before_action :set_topic, only: [:show, :edit, :update, :destroy]
+
+
+ +
+ + + + +
+ + +
+ +
+ show() + + click to toggle source + +
+ + +
+ +

+ + + + +
+
# File topics_controller.rb, line 20
+def show
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + + click to toggle source + +
+ + +
+ +

Atualiza um topic pre existente Redireciona para a página do topic atualizado

+ + + + +
+
# File topics_controller.rb, line 54
+def update
+  respond_to do |format|
+    if @topic.update(topic_params)
+      format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }
+      format.json { render :show, status: :ok, location: @topic }
+    else
+      format.html { render :edit }
+      format.json { render json: @topic.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/app/doc/created.rid b/app/doc/created.rid new file mode 100644 index 00000000..fef407f2 --- /dev/null +++ b/app/doc/created.rid @@ -0,0 +1,6 @@ +Fri, 04 Dec 2020 23:36:55 -0300 +./application_controller.rb Thu, 29 Oct 2020 21:39:42 -0300 +./faqs_controller.rb Fri, 04 Dec 2020 23:28:46 -0300 +./faqs_suggestions_controller.rb Fri, 04 Dec 2020 23:33:56 -0300 +./home_controller.rb Thu, 29 Oct 2020 21:39:42 -0300 +./topics_controller.rb Fri, 04 Dec 2020 23:36:46 -0300 diff --git a/app/doc/css/fonts.css b/app/doc/css/fonts.css new file mode 100644 index 00000000..57302b51 --- /dev/null +++ b/app/doc/css/fonts.css @@ -0,0 +1,167 @@ +/* + * Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/), + * with Reserved Font Name "Source". All Rights Reserved. Source is a + * trademark of Adobe Systems Incorporated in the United States and/or other + * countries. + * + * This Font Software is licensed under the SIL Open Font License, Version + * 1.1. + * + * This license is copied below, and is also available with a FAQ at: + * http://scripts.sil.org/OFL + */ + +@font-face { + font-family: "Source Code Pro"; + font-style: normal; + font-weight: 400; + src: local("Source Code Pro"), + local("SourceCodePro-Regular"), + url("../fonts/SourceCodePro-Regular.ttf") format("truetype"); +} + +@font-face { + font-family: "Source Code Pro"; + font-style: normal; + font-weight: 700; + src: local("Source Code Pro Bold"), + local("SourceCodePro-Bold"), + url("../fonts/SourceCodePro-Bold.ttf") format("truetype"); +} + +/* + * Copyright (c) 2010, Łukasz Dziedzic (dziedzic@typoland.com), + * with Reserved Font Name Lato. + * + * This Font Software is licensed under the SIL Open Font License, Version + * 1.1. + * + * This license is copied below, and is also available with a FAQ at: + * http://scripts.sil.org/OFL + */ + +@font-face { + font-family: "Lato"; + font-style: normal; + font-weight: 300; + src: local("Lato Light"), + local("Lato-Light"), + url("../fonts/Lato-Light.ttf") format("truetype"); +} + +@font-face { + font-family: "Lato"; + font-style: italic; + font-weight: 300; + src: local("Lato Light Italic"), + local("Lato-LightItalic"), + url("../fonts/Lato-LightItalic.ttf") format("truetype"); +} + +@font-face { + font-family: "Lato"; + font-style: normal; + font-weight: 700; + src: local("Lato Regular"), + local("Lato-Regular"), + url("../fonts/Lato-Regular.ttf") format("truetype"); +} + +@font-face { + font-family: "Lato"; + font-style: italic; + font-weight: 700; + src: local("Lato Italic"), + local("Lato-Italic"), + url("../fonts/Lato-RegularItalic.ttf") format("truetype"); +} + +/* + * ----------------------------------------------------------- + * SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 + * ----------------------------------------------------------- + * + * PREAMBLE + * The goals of the Open Font License (OFL) are to stimulate worldwide + * development of collaborative font projects, to support the font creation + * efforts of academic and linguistic communities, and to provide a free and + * open framework in which fonts may be shared and improved in partnership + * with others. + * + * The OFL allows the licensed fonts to be used, studied, modified and + * redistributed freely as long as they are not sold by themselves. The + * fonts, including any derivative works, can be bundled, embedded, + * redistributed and/or sold with any software provided that any reserved + * names are not used by derivative works. The fonts and derivatives, + * however, cannot be released under any other type of license. The + * requirement for fonts to remain under this license does not apply + * to any document created using the fonts or their derivatives. + * + * DEFINITIONS + * "Font Software" refers to the set of files released by the Copyright + * Holder(s) under this license and clearly marked as such. This may + * include source files, build scripts and documentation. + * + * "Reserved Font Name" refers to any names specified as such after the + * copyright statement(s). + * + * "Original Version" refers to the collection of Font Software components as + * distributed by the Copyright Holder(s). + * + * "Modified Version" refers to any derivative made by adding to, deleting, + * or substituting -- in part or in whole -- any of the components of the + * Original Version, by changing formats or by porting the Font Software to a + * new environment. + * + * "Author" refers to any designer, engineer, programmer, technical + * writer or other person who contributed to the Font Software. + * + * PERMISSION & CONDITIONS + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of the Font Software, to use, study, copy, merge, embed, modify, + * redistribute, and sell modified and unmodified copies of the Font + * Software, subject to the following conditions: + * + * 1) Neither the Font Software nor any of its individual components, + * in Original or Modified Versions, may be sold by itself. + * + * 2) Original or Modified Versions of the Font Software may be bundled, + * redistributed and/or sold with any software, provided that each copy + * contains the above copyright notice and this license. These can be + * included either as stand-alone text files, human-readable headers or + * in the appropriate machine-readable metadata fields within text or + * binary files as long as those fields can be easily viewed by the user. + * + * 3) No Modified Version of the Font Software may use the Reserved Font + * Name(s) unless explicit written permission is granted by the corresponding + * Copyright Holder. This restriction only applies to the primary font name as + * presented to the users. + * + * 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font + * Software shall not be used to promote, endorse or advertise any + * Modified Version, except to acknowledge the contribution(s) of the + * Copyright Holder(s) and the Author(s) or with their explicit written + * permission. + * + * 5) The Font Software, modified or unmodified, in part or in whole, + * must be distributed entirely under this license, and must not be + * distributed under any other license. The requirement for fonts to + * remain under this license does not apply to any document created + * using the Font Software. + * + * TERMINATION + * This license becomes null and void if any of the above conditions are + * not met. + * + * DISCLAIMER + * THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT + * OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL + * DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM + * OTHER DEALINGS IN THE FONT SOFTWARE. + */ + diff --git a/app/doc/css/rdoc.css b/app/doc/css/rdoc.css new file mode 100644 index 00000000..1bdb6e62 --- /dev/null +++ b/app/doc/css/rdoc.css @@ -0,0 +1,611 @@ +/* + * "Darkfish" Rdoc CSS + * $Id: rdoc.css 54 2009-01-27 01:09:48Z deveiant $ + * + * Author: Michael Granger + * + */ + +/* vim: ft=css et sw=2 ts=2 sts=2 */ +/* Base Green is: #6C8C22 */ + +.hide { display: none !important; } + +* { padding: 0; margin: 0; } + +body { + background: #fafafa; + font-family: Lato, sans-serif; + font-weight: 300; +} + +h1 span, +h2 span, +h3 span, +h4 span, +h5 span, +h6 span { + position: relative; + + display: none; + padding-left: 1em; + line-height: 0; + vertical-align: baseline; + font-size: 10px; +} + +h1 span { top: -1.3em; } +h2 span { top: -1.2em; } +h3 span { top: -1.0em; } +h4 span { top: -0.8em; } +h5 span { top: -0.5em; } +h6 span { top: -0.5em; } + +h1:hover span, +h2:hover span, +h3:hover span, +h4:hover span, +h5:hover span, +h6:hover span { + display: inline; +} + +h1:target, +h2:target, +h3:target, +h4:target, +h5:target, +h6:target { + margin-left: -10px; + border-left: 10px solid #f1edba; +} + +:link, +:visited { + color: #6C8C22; + text-decoration: none; +} + +:link:hover, +:visited:hover { + border-bottom: 1px dotted #6C8C22; +} + +code, +pre { + font-family: "Source Code Pro", Monaco, monospace; +} + +/* @group Generic Classes */ + +.initially-hidden { + display: none; +} + +#search-field { + width: 98%; + background: white; + border: none; + height: 1.5em; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; + text-align: left; +} +#search-field:focus { + background: #f1edba; +} +#search-field:-moz-placeholder, +#search-field::-webkit-input-placeholder { + font-weight: bold; + color: #666; +} + +.missing-docs { + font-size: 120%; + background: white url(images/wrench_orange.png) no-repeat 4px center; + color: #ccc; + line-height: 2em; + border: 1px solid #d00; + opacity: 1; + padding-left: 20px; + text-indent: 24px; + letter-spacing: 3px; + font-weight: bold; + -webkit-border-radius: 5px; + -moz-border-radius: 5px; +} + +.target-section { + border: 2px solid #dcce90; + border-left-width: 8px; + padding: 0 1em; + background: #fff3c2; +} + +/* @end */ + +/* @group Index Page, Standalone file pages */ +.table-of-contents ul { + margin: 1em; + list-style: none; +} + +.table-of-contents ul ul { + margin-top: 0.25em; +} + +.table-of-contents ul :link, +.table-of-contents ul :visited { + font-size: 16px; +} + +.table-of-contents li { + margin-bottom: 0.25em; +} + +.table-of-contents li .toc-toggle { + width: 16px; + height: 16px; + background: url(images/add.png) no-repeat; +} + +.table-of-contents li .toc-toggle.open { + background: url(images/delete.png) no-repeat; +} + +/* @end */ + +/* @group Top-Level Structure */ + +nav { + float: left; + width: 260px; + font-family: Helvetica, sans-serif; + font-size: 14px; +} + +main { + display: block; + margin: 0 2em 5em 260px; + padding-left: 20px; + min-width: 340px; + font-size: 16px; +} + +main h1, +main h2, +main h3, +main h4, +main h5, +main h6 { + font-family: Helvetica, sans-serif; +} + +.table-of-contents main { + margin-left: 2em; +} + +#validator-badges { + clear: both; + margin: 1em 1em 2em; + font-size: smaller; +} + +/* @end */ + +/* @group navigation */ +nav { + margin-bottom: 1em; +} + +nav .nav-section { + margin-top: 2em; + border-top: 2px solid #aaa; + font-size: 90%; + overflow: hidden; +} + +nav h2 { + margin: 0; + padding: 2px 8px 2px 8px; + background-color: #e8e8e8; + color: #555; + font-size: 125%; + text-align: center; +} + +nav h3, +#table-of-contents-navigation { + margin: 0; + padding: 2px 8px 2px 8px; + text-align: right; + background-color: #e8e8e8; + color: #555; +} + +nav ul, +nav dl, +nav p { + padding: 4px 8px 0; + list-style: none; +} + +#project-navigation .nav-section { + margin: 0; + border-top: 0; +} + +#home-section h2 { + text-align: center; +} + +#table-of-contents-navigation { + font-size: 1.2em; + font-weight: bold; + text-align: center; +} + +#search-section { + margin-top: 0; + border-top: 0; +} + +#search-field-wrapper { + border-top: 1px solid #aaa; + border-bottom: 1px solid #aaa; + padding: 3px 8px; + background-color: #e8e8e8; + color: #555; +} + +ul.link-list li { + white-space: nowrap; + line-height: 1.4em; +} + +ul.link-list .type { + font-size: 8px; + text-transform: uppercase; + color: white; + background: #969696; + padding: 2px 4px; + -webkit-border-radius: 5px; +} + +.calls-super { + background: url(images/arrow_up.png) no-repeat right center; +} + +/* @end */ + +/* @group Documentation Section */ +main { + color: #333; +} + +main > h1:first-child, +main > h2:first-child, +main > h3:first-child, +main > h4:first-child, +main > h5:first-child, +main > h6:first-child { + margin-top: 0px; +} + +main sup { + vertical-align: super; + font-size: 0.8em; +} + +/* The heading with the class name */ +main h1[class] { + margin-top: 0; + margin-bottom: 1em; + font-size: 2em; + color: #6C8C22; +} + +main h1 { + margin: 2em 0 0.5em; + font-size: 1.7em; +} + +main h2 { + margin: 2em 0 0.5em; + font-size: 1.5em; +} + +main h3 { + margin: 2em 0 0.5em; + font-size: 1.2em; +} + +main h4 { + margin: 2em 0 0.5em; + font-size: 1.1em; +} + +main h5 { + margin: 2em 0 0.5em; + font-size: 1em; +} + +main h6 { + margin: 2em 0 0.5em; + font-size: 1em; +} + +main p { + margin: 0 0 0.5em; + line-height: 1.4em; +} + +main pre { + margin: 1.2em 0.5em; + padding: 1em; + font-size: 0.8em; +} + +main hr { + margin: 1.5em 1em; + border: 2px solid #ddd; +} + +main blockquote { + margin: 0 2em 1.2em 1.2em; + padding-left: 0.5em; + border-left: 2px solid #ddd; +} + +main ol, +main ul { + margin: 1em 2em; +} + +main li > p { + margin-bottom: 0.5em; +} + +main dl { + margin: 1em 0.5em; +} + +main dt { + margin-bottom: 0.5em; + font-weight: bold; +} + +main dd { + margin: 0 1em 1em 0.5em; +} + +main header h2 { + margin-top: 2em; + border-width: 0; + border-top: 4px solid #bbb; + font-size: 130%; +} + +main header h3 { + margin: 2em 0 1.5em; + border-width: 0; + border-top: 3px solid #bbb; + font-size: 120%; +} + +.documentation-section-title { + position: relative; +} +.documentation-section-title .section-click-top { + position: absolute; + top: 6px; + left: 12px; + font-size: 10px; + color: #9b9877; + visibility: hidden; + padding-left: 0.5px; +} + +.documentation-section-title:hover .section-click-top { + visibility: visible; +} + +.constants-list > dl { + margin: 1em 0 2em; + border: 0; +} + +.constants-list > dl dt { + margin-bottom: 0.75em; + padding-left: 0; + font-family: "Source Code Pro", Monaco, monospace; + font-size: 110%; +} + +.constants-list > dl dt a { + color: inherit; +} + +.constants-list > dl dd { + margin: 0 0 2em 0; + padding: 0; + color: #666; +} + +.documentation-section h2 { + position: relative; +} + +.documentation-section h2 a { + position: absolute; + top: 8px; + right: 10px; + font-size: 12px; + color: #9b9877; + visibility: hidden; +} + +.documentation-section h2:hover a { + visibility: visible; +} + +/* @group Method Details */ + +main .method-source-code { + max-height: 0; + overflow: hidden; + transition-duration: 200ms; + transition-delay: 0ms; + transition-property: all; + transition-timing-function: ease-in-out; +} + +main .method-source-code.active-menu { + max-height: 100vh; +} + +main .method-description .method-calls-super { + color: #333; + font-weight: bold; +} + +main .method-detail { + margin-bottom: 2.5em; + cursor: pointer; +} + +main .method-detail:target { + margin-left: -10px; + border-left: 10px solid #f1edba; +} + +main .method-heading { + position: relative; + font-family: "Source Code Pro", Monaco, monospace; + font-size: 110%; + font-weight: bold; + color: #333; +} +main .method-heading :link, +main .method-heading :visited { + color: inherit; +} +main .method-click-advice { + position: absolute; + top: 2px; + right: 5px; + font-size: 12px; + color: #9b9877; + visibility: hidden; + padding-right: 20px; + line-height: 20px; + background: url(images/zoom.png) no-repeat right top; +} +main .method-heading:hover .method-click-advice { + visibility: visible; +} + +main .method-alias .method-heading { + color: #666; +} + +main .method-description, +main .aliases { + margin-top: 0.75em; + color: #333; +} + +main .aliases { + padding-top: 4px; + font-style: italic; + cursor: default; +} +main .method-description ul { + margin-left: 1.5em; +} + +main #attribute-method-details .method-detail:hover { + background-color: transparent; + cursor: default; +} +main .attribute-access-type { + text-transform: uppercase; + padding: 0 1em; +} +/* @end */ + +/* @end */ + +/* @group Source Code */ + +pre { + margin: 0.5em 0; + border: 1px dashed #999; + padding: 0.5em; + background: #262626; + color: white; + overflow: auto; +} + +.ruby-constant { color: #7fffd4; background: transparent; } +.ruby-keyword { color: #00ffff; background: transparent; } +.ruby-ivar { color: #eedd82; background: transparent; } +.ruby-operator { color: #00ffee; background: transparent; } +.ruby-identifier { color: #ffdead; background: transparent; } +.ruby-node { color: #ffa07a; background: transparent; } +.ruby-comment { color: #dc0000; background: transparent; } +.ruby-regexp { color: #ffa07a; background: transparent; } +.ruby-value { color: #7fffd4; background: transparent; } + +/* @end */ + + +/* @group search results */ +#search-results { + font-family: Lato, sans-serif; + font-weight: 300; +} + +#search-results .search-match { + font-family: Helvetica, sans-serif; + font-weight: normal; +} + +#search-results .search-selected { + background: #e8e8e8; + border-bottom: 1px solid transparent; +} + +#search-results li { + list-style: none; + border-bottom: 1px solid #aaa; + margin-bottom: 0.5em; +} + +#search-results li:last-child { + border-bottom: none; + margin-bottom: 0; +} + +#search-results li p { + padding: 0; + margin: 0.5em; +} + +#search-results .search-namespace { + font-weight: bold; +} + +#search-results li em { + background: yellow; + font-style: normal; +} + +#search-results pre { + margin: 0.5em; + font-family: "Source Code Pro", Monaco, monospace; +} + +/* @end */ + diff --git a/app/doc/fonts/Lato-Light.ttf b/app/doc/fonts/Lato-Light.ttf new file mode 100644 index 00000000..b49dd437 Binary files /dev/null and b/app/doc/fonts/Lato-Light.ttf differ diff --git a/app/doc/fonts/Lato-LightItalic.ttf b/app/doc/fonts/Lato-LightItalic.ttf new file mode 100644 index 00000000..7959fef0 Binary files /dev/null and b/app/doc/fonts/Lato-LightItalic.ttf differ diff --git a/app/doc/fonts/Lato-Regular.ttf b/app/doc/fonts/Lato-Regular.ttf new file mode 100644 index 00000000..839cd589 Binary files /dev/null and b/app/doc/fonts/Lato-Regular.ttf differ diff --git a/app/doc/fonts/Lato-RegularItalic.ttf b/app/doc/fonts/Lato-RegularItalic.ttf new file mode 100644 index 00000000..bababa09 Binary files /dev/null and b/app/doc/fonts/Lato-RegularItalic.ttf differ diff --git a/app/doc/fonts/SourceCodePro-Bold.ttf b/app/doc/fonts/SourceCodePro-Bold.ttf new file mode 100644 index 00000000..61e3090c Binary files /dev/null and b/app/doc/fonts/SourceCodePro-Bold.ttf differ diff --git a/app/doc/fonts/SourceCodePro-Regular.ttf b/app/doc/fonts/SourceCodePro-Regular.ttf new file mode 100644 index 00000000..85686d96 Binary files /dev/null and b/app/doc/fonts/SourceCodePro-Regular.ttf differ diff --git a/app/doc/images/add.png b/app/doc/images/add.png new file mode 100644 index 00000000..6332fefe Binary files /dev/null and b/app/doc/images/add.png differ diff --git a/app/doc/images/arrow_up.png b/app/doc/images/arrow_up.png new file mode 100644 index 00000000..1ebb1932 Binary files /dev/null and b/app/doc/images/arrow_up.png differ diff --git a/app/doc/images/brick.png b/app/doc/images/brick.png new file mode 100644 index 00000000..7851cf34 Binary files /dev/null and b/app/doc/images/brick.png differ diff --git a/app/doc/images/brick_link.png b/app/doc/images/brick_link.png new file mode 100644 index 00000000..9ebf013a Binary files /dev/null and b/app/doc/images/brick_link.png differ diff --git a/app/doc/images/bug.png b/app/doc/images/bug.png new file mode 100644 index 00000000..2d5fb90e Binary files /dev/null and b/app/doc/images/bug.png differ diff --git a/app/doc/images/bullet_black.png b/app/doc/images/bullet_black.png new file mode 100644 index 00000000..57619706 Binary files /dev/null and b/app/doc/images/bullet_black.png differ diff --git a/app/doc/images/bullet_toggle_minus.png b/app/doc/images/bullet_toggle_minus.png new file mode 100644 index 00000000..b47ce55f Binary files /dev/null and b/app/doc/images/bullet_toggle_minus.png differ diff --git a/app/doc/images/bullet_toggle_plus.png b/app/doc/images/bullet_toggle_plus.png new file mode 100644 index 00000000..9ab4a896 Binary files /dev/null and b/app/doc/images/bullet_toggle_plus.png differ diff --git a/app/doc/images/date.png b/app/doc/images/date.png new file mode 100644 index 00000000..783c8335 Binary files /dev/null and b/app/doc/images/date.png differ diff --git a/app/doc/images/delete.png b/app/doc/images/delete.png new file mode 100644 index 00000000..08f24936 Binary files /dev/null and b/app/doc/images/delete.png differ diff --git a/app/doc/images/find.png b/app/doc/images/find.png new file mode 100644 index 00000000..15474796 Binary files /dev/null and b/app/doc/images/find.png differ diff --git a/app/doc/images/loadingAnimation.gif b/app/doc/images/loadingAnimation.gif new file mode 100644 index 00000000..82290f48 Binary files /dev/null and b/app/doc/images/loadingAnimation.gif differ diff --git a/app/doc/images/macFFBgHack.png b/app/doc/images/macFFBgHack.png new file mode 100644 index 00000000..c6473b32 Binary files /dev/null and b/app/doc/images/macFFBgHack.png differ diff --git a/app/doc/images/package.png b/app/doc/images/package.png new file mode 100644 index 00000000..da3c2a2d Binary files /dev/null and b/app/doc/images/package.png differ diff --git a/app/doc/images/page_green.png b/app/doc/images/page_green.png new file mode 100644 index 00000000..de8e003f Binary files /dev/null and b/app/doc/images/page_green.png differ diff --git a/app/doc/images/page_white_text.png b/app/doc/images/page_white_text.png new file mode 100644 index 00000000..813f712f Binary files /dev/null and b/app/doc/images/page_white_text.png differ diff --git a/app/doc/images/page_white_width.png b/app/doc/images/page_white_width.png new file mode 100644 index 00000000..1eb88094 Binary files /dev/null and b/app/doc/images/page_white_width.png differ diff --git a/app/doc/images/plugin.png b/app/doc/images/plugin.png new file mode 100644 index 00000000..6187b15a Binary files /dev/null and b/app/doc/images/plugin.png differ diff --git a/app/doc/images/ruby.png b/app/doc/images/ruby.png new file mode 100644 index 00000000..f763a168 Binary files /dev/null and b/app/doc/images/ruby.png differ diff --git a/app/doc/images/tag_blue.png b/app/doc/images/tag_blue.png new file mode 100644 index 00000000..3f02b5f8 Binary files /dev/null and b/app/doc/images/tag_blue.png differ diff --git a/app/doc/images/tag_green.png b/app/doc/images/tag_green.png new file mode 100644 index 00000000..83ec984b Binary files /dev/null and b/app/doc/images/tag_green.png differ diff --git a/app/doc/images/transparent.png b/app/doc/images/transparent.png new file mode 100644 index 00000000..d665e179 Binary files /dev/null and b/app/doc/images/transparent.png differ diff --git a/app/doc/images/wrench.png b/app/doc/images/wrench.png new file mode 100644 index 00000000..5c8213fe Binary files /dev/null and b/app/doc/images/wrench.png differ diff --git a/app/doc/images/wrench_orange.png b/app/doc/images/wrench_orange.png new file mode 100644 index 00000000..565a9330 Binary files /dev/null and b/app/doc/images/wrench_orange.png differ diff --git a/app/doc/images/zoom.png b/app/doc/images/zoom.png new file mode 100644 index 00000000..908612e3 Binary files /dev/null and b/app/doc/images/zoom.png differ diff --git a/app/doc/index.html b/app/doc/index.html new file mode 100644 index 00000000..ff39dc0a --- /dev/null +++ b/app/doc/index.html @@ -0,0 +1,95 @@ + + + + + + +RDoc Documentation + + + + + + + + + + + + + + + + + + +
+ +

This is the API documentation for RDoc Documentation. + +

+ + + + + diff --git a/app/doc/js/darkfish.js b/app/doc/js/darkfish.js new file mode 100644 index 00000000..111bbf8e --- /dev/null +++ b/app/doc/js/darkfish.js @@ -0,0 +1,84 @@ +/** + * + * Darkfish Page Functions + * $Id: darkfish.js 53 2009-01-07 02:52:03Z deveiant $ + * + * Author: Michael Granger + * + */ + +/* Provide console simulation for firebug-less environments */ +/* +if (!("console" in window) || !("firebug" in console)) { + var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", + "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"]; + + window.console = {}; + for (var i = 0; i < names.length; ++i) + window.console[names[i]] = function() {}; +}; +*/ + + +function showSource( e ) { + var target = e.target; + while (!target.classList.contains('method-detail')) { + target = target.parentNode; + } + if (typeof target !== "undefined" && target !== null) { + target = target.querySelector('.method-source-code'); + } + if (typeof target !== "undefined" && target !== null) { + target.classList.toggle('active-menu') + } +}; + +function hookSourceViews() { + document.querySelectorAll('.method-heading').forEach(function (codeObject) { + codeObject.addEventListener('click', showSource); + }); +}; + +function hookSearch() { + var input = document.querySelector('#search-field'); + var result = document.querySelector('#search-results'); + result.classList.remove("initially-hidden"); + + var search_section = document.querySelector('#search-section'); + search_section.classList.remove("initially-hidden"); + + var search = new Search(search_data, input, result); + + search.renderItem = function(result) { + var li = document.createElement('li'); + var html = ''; + + // TODO add relative path to + + + + + + + + + + + + + + +
+

Table of Contents - RDoc Documentation

+ + + + +

Classes and Modules

+ + +

Methods

+
    + +
  • + #configure_permitted_parameters + — + ApplicationController + +
  • + #create + — + TopicsController + +
  • + #create + — + FaqsSuggestionsController + +
  • + #create + — + FaqsController + +
  • + #destroy + — + FaqsSuggestionsController + +
  • + #destroy + — + TopicsController + +
  • + #destroy + — + FaqsController + +
  • + #edit + — + FaqsSuggestionsController + +
  • + #edit + — + TopicsController + +
  • + #edit + — + FaqsController + +
  • + #index + — + FaqsController + +
  • + #index + — + FaqsSuggestionsController + +
  • + #index + — + TopicsController + +
  • + #index + — + HomeController + +
  • + #new + — + FaqsController + +
  • + #new + — + FaqsSuggestionsController + +
  • + #new + — + TopicsController + +
  • + #set_topic + — + TopicsController + +
  • + #show + — + TopicsController + +
  • + #show + — + FaqsSuggestionsController + +
  • + #show + — + FaqsController + +
  • + #update + — + TopicsController + +
  • + #update + — + FaqsController + +
  • + #update + — + FaqsSuggestionsController + +
+
+ + + + diff --git a/app/helpers/faqs_helper.rb b/app/helpers/faqs_helper.rb new file mode 100644 index 00000000..d36ed486 --- /dev/null +++ b/app/helpers/faqs_helper.rb @@ -0,0 +1,2 @@ +module FaqsHelper +end diff --git a/app/helpers/faqs_suggestions_helper.rb b/app/helpers/faqs_suggestions_helper.rb new file mode 100644 index 00000000..00439a39 --- /dev/null +++ b/app/helpers/faqs_suggestions_helper.rb @@ -0,0 +1,2 @@ +module FaqsSuggestionsHelper +end diff --git a/app/helpers/topics_helper.rb b/app/helpers/topics_helper.rb new file mode 100644 index 00000000..488eed51 --- /dev/null +++ b/app/helpers/topics_helper.rb @@ -0,0 +1,2 @@ +module TopicsHelper +end diff --git a/app/models/faq.rb b/app/models/faq.rb new file mode 100644 index 00000000..31b7ce76 --- /dev/null +++ b/app/models/faq.rb @@ -0,0 +1,3 @@ +class Faq < ApplicationRecord + belongs_to :topic +end diff --git a/app/models/faqs_suggestion.rb b/app/models/faqs_suggestion.rb new file mode 100644 index 00000000..9f9e3ca5 --- /dev/null +++ b/app/models/faqs_suggestion.rb @@ -0,0 +1,3 @@ +class FaqsSuggestion < ApplicationRecord + belongs_to :topic +end diff --git a/app/models/questionTopic.rb b/app/models/questionTopic.rb new file mode 100644 index 00000000..5effd522 --- /dev/null +++ b/app/models/questionTopic.rb @@ -0,0 +1,5 @@ +class QuestionTopic < ApplicationRecord + + validates :title, presence: true + belongs :question, :class_name=>"Question", :foreign_key => "question_id", optional: true +end \ No newline at end of file diff --git a/app/models/suggestion.rb b/app/models/suggestion.rb new file mode 100644 index 00000000..d25f6d32 --- /dev/null +++ b/app/models/suggestion.rb @@ -0,0 +1,6 @@ +class Suggestion < ApplicationRecord + validates :answer, presence: true + validates :title, presence: true + has_one :questionTopic, dependent: :destroy + +end \ No newline at end of file diff --git a/app/models/topic.rb b/app/models/topic.rb new file mode 100644 index 00000000..891f5791 --- /dev/null +++ b/app/models/topic.rb @@ -0,0 +1,5 @@ +class Topic < ApplicationRecord + validates :titulo, presence: true + has_many :Faqs + has_many :FaqsSuggestions +end diff --git a/app/views/faq/index.html.erb b/app/views/faq/index.html.erb new file mode 100644 index 00000000..dd28d809 --- /dev/null +++ b/app/views/faq/index.html.erb @@ -0,0 +1,2 @@ +

FAQS

+

Find me in app/views/faq/index.html.erb

\ No newline at end of file diff --git a/app/views/faqs/_faq.json.jbuilder b/app/views/faqs/_faq.json.jbuilder new file mode 100644 index 00000000..92b1e033 --- /dev/null +++ b/app/views/faqs/_faq.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! faq, :id, :question, :answer, :topic_id, :created_at, :updated_at +json.url faq_url(faq, format: :json) diff --git a/app/views/faqs/_form.html.erb b/app/views/faqs/_form.html.erb new file mode 100644 index 00000000..369cfe99 --- /dev/null +++ b/app/views/faqs/_form.html.erb @@ -0,0 +1,32 @@ +<%= form_with(model: faq, local: true) do |form| %> + <% if faq.errors.any? %> +
+

<%= pluralize(faq.errors.count, "error") %> prohibited this faq from being saved:

+ +
    + <% faq.errors.full_messages.each do |message| %> +
  • <%= message %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= form.label :question %> + <%= form.text_field :question %> +
+ +
+ <%= form.label :answer %> + <%= form.text_field :answer %> +
+ +
+ <%= form.label :topic %>
+ <%= form.collection_select :topic_id, Topic.all, :id, :titulo %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/faqs/edit.html.erb b/app/views/faqs/edit.html.erb new file mode 100644 index 00000000..67f4b280 --- /dev/null +++ b/app/views/faqs/edit.html.erb @@ -0,0 +1,6 @@ +

Editing Faq

+ +<%= render 'form', faq: @faq %> + +<%= link_to 'Show', @faq %> | +<%= link_to 'Back', faqs_path %> diff --git a/app/views/faqs/index.html.erb b/app/views/faqs/index.html.erb new file mode 100644 index 00000000..c5fcc94a --- /dev/null +++ b/app/views/faqs/index.html.erb @@ -0,0 +1,35 @@ +

<%= notice %>

+ +

Faqs

+ + + + + + + + + + + + + <% @faqs.each do |faq| %> + + + + + + + + + <% end %> + +
QuestionAnswerTopic
<%= faq.question %><%= faq.answer %><%= faq.topic.titulo %><%= link_to 'Show', faq %><%= link_to 'Edit', edit_faq_path(faq) %><%= link_to 'Destroy', faq, method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to 'New Faq', new_faq_path %> +
+<%= link_to 'New Faqs Suggestion', new_faqs_suggestion_path %> +
+<%= link_to 'New Topic', new_topic_path %> \ No newline at end of file diff --git a/app/views/faqs/index.json.jbuilder b/app/views/faqs/index.json.jbuilder new file mode 100644 index 00000000..93ff1456 --- /dev/null +++ b/app/views/faqs/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @faqs, partial: "faqs/faq", as: :faq diff --git a/app/views/faqs/new.html.erb b/app/views/faqs/new.html.erb new file mode 100644 index 00000000..740f7396 --- /dev/null +++ b/app/views/faqs/new.html.erb @@ -0,0 +1,5 @@ +

New Faq

+ +<%= render 'form', faq: @faq %> + +<%= link_to 'Back', faqs_path %> diff --git a/app/views/faqs/show.html.erb b/app/views/faqs/show.html.erb new file mode 100644 index 00000000..326a3b9f --- /dev/null +++ b/app/views/faqs/show.html.erb @@ -0,0 +1,19 @@ +

<%= notice %>

+ +

+ Question: + <%= @faq.question %> +

+ +

+ Answer: + <%= @faq.answer %> +

+ +

+ Topic: + <%= @faq.topic.titulo %> +

+ +<%= link_to 'Edit', edit_faq_path(@faq) %> | +<%= link_to 'Back', faqs_path %> diff --git a/app/views/faqs/show.json.jbuilder b/app/views/faqs/show.json.jbuilder new file mode 100644 index 00000000..513d96c5 --- /dev/null +++ b/app/views/faqs/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "faqs/faq", faq: @faq diff --git a/app/views/faqs_suggestions/_faqs_suggestion.json.jbuilder b/app/views/faqs_suggestions/_faqs_suggestion.json.jbuilder new file mode 100644 index 00000000..511f9667 --- /dev/null +++ b/app/views/faqs_suggestions/_faqs_suggestion.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! faqs_suggestion, :id, :question, :answer, :topic_id, :created_at, :updated_at +json.url faqs_suggestion_url(faqs_suggestion, format: :json) diff --git a/app/views/faqs_suggestions/_form.html.erb b/app/views/faqs_suggestions/_form.html.erb new file mode 100644 index 00000000..15ff9fc8 --- /dev/null +++ b/app/views/faqs_suggestions/_form.html.erb @@ -0,0 +1,32 @@ +<%= form_with(model: faqs_suggestion, local: true) do |form| %> + <% if faqs_suggestion.errors.any? %> +
+

<%= pluralize(faqs_suggestion.errors.count, "error") %> prohibited this faqs_suggestion from being saved:

+ +
    + <% faqs_suggestion.errors.full_messages.each do |message| %> +
  • <%= message %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= form.label :question %> + <%= form.text_field :question %> +
+ +
+ <%= form.label :answer %> + <%= form.text_field :answer %> +
+ +
+ <%= form.label :topic %>
+ <%= form.collection_select :topic_id, Topic.all, :id, :titulo %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/faqs_suggestions/edit.html.erb b/app/views/faqs_suggestions/edit.html.erb new file mode 100644 index 00000000..a7eddc82 --- /dev/null +++ b/app/views/faqs_suggestions/edit.html.erb @@ -0,0 +1,6 @@ +

Editing Faqs Suggestion

+ +<%= render 'form', faqs_suggestion: @faqs_suggestion %> + +<%= link_to 'Show', @faqs_suggestion %> | +<%= link_to 'Back', faqs_suggestions_path %> diff --git a/app/views/faqs_suggestions/index.html.erb b/app/views/faqs_suggestions/index.html.erb new file mode 100644 index 00000000..b38eb18e --- /dev/null +++ b/app/views/faqs_suggestions/index.html.erb @@ -0,0 +1,31 @@ +

<%= notice %>

+ +

Faqs Suggestions

+ + + + + + + + + + + + + <% @faqs_suggestions.each do |faqs_suggestion| %> + + + + + + + + + <% end %> + +
QuestionAnswerTopic
<%= faqs_suggestion.question %><%= faqs_suggestion.answer %><%= faqs_suggestion.topic %><%= link_to 'Show', faqs_suggestion %><%= link_to 'Edit', edit_faqs_suggestion_path(faqs_suggestion) %><%= link_to 'Destroy', faqs_suggestion, method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to 'New Faqs Suggestion', new_faqs_suggestion_path %> diff --git a/app/views/faqs_suggestions/index.json.jbuilder b/app/views/faqs_suggestions/index.json.jbuilder new file mode 100644 index 00000000..eff4ac3c --- /dev/null +++ b/app/views/faqs_suggestions/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @faqs_suggestions, partial: "faqs_suggestions/faqs_suggestion", as: :faqs_suggestion diff --git a/app/views/faqs_suggestions/new.html.erb b/app/views/faqs_suggestions/new.html.erb new file mode 100644 index 00000000..83d38920 --- /dev/null +++ b/app/views/faqs_suggestions/new.html.erb @@ -0,0 +1,5 @@ +

New Faqs Suggestion

+ +<%= render 'form', faqs_suggestion: @faqs_suggestion %> + +<%= link_to 'Back', faqs_suggestions_path %> diff --git a/app/views/faqs_suggestions/show.html.erb b/app/views/faqs_suggestions/show.html.erb new file mode 100644 index 00000000..56026069 --- /dev/null +++ b/app/views/faqs_suggestions/show.html.erb @@ -0,0 +1,19 @@ +

<%= notice %>

+ +

+ Question: + <%= @faqs_suggestion.question %> +

+ +

+ Answer: + <%= @faqs_suggestion.answer %> +

+ +

+ Topic: + <%= @faqs_suggestion.topic %> +

+ +<%= link_to 'Edit', edit_faqs_suggestion_path(@faqs_suggestion) %> | +<%= link_to 'Back', faqs_suggestions_path %> diff --git a/app/views/faqs_suggestions/show.json.jbuilder b/app/views/faqs_suggestions/show.json.jbuilder new file mode 100644 index 00000000..62343662 --- /dev/null +++ b/app/views/faqs_suggestions/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "faqs_suggestions/faqs_suggestion", faqs_suggestion: @faqs_suggestion diff --git a/app/views/topics/_form.html.erb b/app/views/topics/_form.html.erb new file mode 100644 index 00000000..ffa3c28b --- /dev/null +++ b/app/views/topics/_form.html.erb @@ -0,0 +1,22 @@ +<%= form_with(model: topic, local: true) do |form| %> + <% if topic.errors.any? %> +
+

<%= pluralize(topic.errors.count, "error") %> prohibited this topic from being saved:

+ +
    + <% topic.errors.full_messages.each do |message| %> +
  • <%= message %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= form.label :titulo %> + <%= form.text_field :titulo %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/topics/_topic.json.jbuilder b/app/views/topics/_topic.json.jbuilder new file mode 100644 index 00000000..203665b3 --- /dev/null +++ b/app/views/topics/_topic.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! topic, :id, :titulo, :created_at, :updated_at +json.url topic_url(topic, format: :json) diff --git a/app/views/topics/edit.html.erb b/app/views/topics/edit.html.erb new file mode 100644 index 00000000..240428b1 --- /dev/null +++ b/app/views/topics/edit.html.erb @@ -0,0 +1,6 @@ +

Editing Topic

+ +<%= render 'form', topic: @topic %> + +<%= link_to 'Show', @topic %> | +<%= link_to 'Back', topics_path %> diff --git a/app/views/topics/index.html.erb b/app/views/topics/index.html.erb new file mode 100644 index 00000000..7a225cfa --- /dev/null +++ b/app/views/topics/index.html.erb @@ -0,0 +1,27 @@ +

<%= notice %>

+ +

Topics

+ + + + + + + + + + + <% @topics.each do |topic| %> + + + + + + + <% end %> + +
Titulo
<%= topic.titulo %><%= link_to 'Show', topic %><%= link_to 'Edit', edit_topic_path(topic) %><%= link_to 'Destroy', topic, method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to 'New Topic', new_topic_path %> diff --git a/app/views/topics/index.json.jbuilder b/app/views/topics/index.json.jbuilder new file mode 100644 index 00000000..70659d01 --- /dev/null +++ b/app/views/topics/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @topics, partial: "topics/topic", as: :topic diff --git a/app/views/topics/new.html.erb b/app/views/topics/new.html.erb new file mode 100644 index 00000000..45903dd2 --- /dev/null +++ b/app/views/topics/new.html.erb @@ -0,0 +1,5 @@ +

New Topic

+ +<%= render 'form', topic: @topic %> + +<%= link_to 'Back', topics_path %> diff --git a/app/views/topics/show.html.erb b/app/views/topics/show.html.erb new file mode 100644 index 00000000..14c7403f --- /dev/null +++ b/app/views/topics/show.html.erb @@ -0,0 +1,9 @@ +

<%= notice %>

+ +

+ Titulo: + <%= @topic.titulo %> +

+ +<%= link_to 'Edit', edit_topic_path(@topic) %> | +<%= link_to 'Back', topics_path %> diff --git a/app/views/topics/show.json.jbuilder b/app/views/topics/show.json.jbuilder new file mode 100644 index 00000000..cc0cfc01 --- /dev/null +++ b/app/views/topics/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "topics/topic", topic: @topic diff --git a/config/database.yml b/config/database.yml index bbc24623..ba7f8db8 100644 --- a/config/database.yml +++ b/config/database.yml @@ -23,7 +23,9 @@ default: &default development: <<: *default - database: secretaria_ppgi_development + database: secretaria_ppgi + username: postgres + password: post123 # The specified database role being used to connect to postgres. # To create additional roles in postgres see `$ createuser --help`. @@ -37,11 +39,11 @@ development: # Connect on a TCP socket. Omitted by default since the client uses a # domain socket that doesn't need configuration. Windows does not have # domain sockets, so uncomment these lines. - #host: localhost + host: localhost # The TCP port the server listens on. Defaults to 5432. # If your server runs on a different port number, change accordingly. - #port: 5432 + port: 5432 # Schema search path. The server defaults to $user,public #schema_search_path: myapp,sharedapp,public @@ -57,7 +59,9 @@ development: # Do not set this db to the same as development or production. test: <<: *default - database: secretaria_ppgi_test + database: secretaria_ppgi + username: postgres + password: post123 # As with config/secrets.yml, you never want to store sensitive information, # like your database password, in your source code. If your source code is @@ -78,8 +82,20 @@ test: # production: # url: <%= ENV['DATABASE_URL'] %> # + + host: localhost + + # The TCP port the server listens on. Defaults to 5432. + # If your server runs on a different port number, change accordingly. + port: 5432 production: <<: *default - database: secretaria_ppgi_production - username: secretaria_ppgi - password: <%= ENV['SECRETARIA_PPGI_DATABASE_PASSWORD'] %> + database: secretaria_ppgi + username: postgres + password: post123 + + host: localhost + + # The TCP port the server listens on. Defaults to 5432. + # If your server runs on a different port number, change accordingly. + port: 5432 diff --git a/config/routes.rb b/config/routes.rb index f33f7f68..4d744770 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,7 +1,11 @@ # frozen_string_literal: true Rails.application.routes.draw do + resources :topics + resources :faqs_suggestions + resources :faqs get 'home/index' + get 'faq/index' devise_for :users # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html root to: 'home#index' diff --git a/db/migrate/20201204223242_create_topics.rb b/db/migrate/20201204223242_create_topics.rb new file mode 100644 index 00000000..d35a1713 --- /dev/null +++ b/db/migrate/20201204223242_create_topics.rb @@ -0,0 +1,9 @@ +class CreateTopics < ActiveRecord::Migration[5.2] + def change + create_table :topics do |t| + t.string :titulo + + t.timestamps + end + end +end diff --git a/db/migrate/20201204223740_create_faqs_suggestions.rb b/db/migrate/20201204223740_create_faqs_suggestions.rb new file mode 100644 index 00000000..c87f82f0 --- /dev/null +++ b/db/migrate/20201204223740_create_faqs_suggestions.rb @@ -0,0 +1,11 @@ +class CreateFaqsSuggestions < ActiveRecord::Migration[5.2] + def change + create_table :faqs_suggestions do |t| + t.string :question + t.string :answer + t.references :topic, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/migrate/20201204223755_create_faqs.rb b/db/migrate/20201204223755_create_faqs.rb new file mode 100644 index 00000000..90a687e8 --- /dev/null +++ b/db/migrate/20201204223755_create_faqs.rb @@ -0,0 +1,11 @@ +class CreateFaqs < ActiveRecord::Migration[5.2] + def change + create_table :faqs do |t| + t.string :question + t.string :answer + t.references :topic, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 96d61d72..6f8a41fc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,11 +10,35 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2019_11_14_163205) do +ActiveRecord::Schema.define(version: 2020_12_04_223755) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" + create_table "faqs", force: :cascade do |t| + t.string "question" + t.string "answer" + t.bigint "topic_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["topic_id"], name: "index_faqs_on_topic_id" + end + + create_table "faqs_suggestions", force: :cascade do |t| + t.string "question" + t.string "answer" + t.bigint "topic_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["topic_id"], name: "index_faqs_suggestions_on_topic_id" + end + + create_table "topics", force: :cascade do |t| + t.string "titulo" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "users", force: :cascade do |t| t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false @@ -30,4 +54,6 @@ t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true end + add_foreign_key "faqs", "topics" + add_foreign_key "faqs_suggestions", "topics" end diff --git a/features/Criar_sugestao_de_pergunta_e_resposta.feature b/features/Criar_sugestao_de_pergunta_e_resposta.feature new file mode 100644 index 00000000..19c0368f --- /dev/null +++ b/features/Criar_sugestao_de_pergunta_e_resposta.feature @@ -0,0 +1,14 @@ +Feature: Criar uma sugestão de pergunta e dar uma sugestão de resposta + Como usuário, + Quero cadastrar uma sugestão para de pergunta e também sugirir uma resposta para a pergunta para que eu possa ajudar no levatamento de perguntas + + + Scenario: + Given Que Usuario esteja logado como email "teste@teste1.com" e "123teste" + And Esteja página inicial e logado + And Clicar no link "FAQS" + When O Clicar no botão "Adicionar Sugestão" + Then O usuário preenche os campos de texto "fieldPergunta" e "fieldResposta" com uma "pergunta" e "resposta" + Then O usuário clica "Salvar Sugestão" + Then será cadastrado uma nova sugestão de pergunta e resposta + diff --git a/features/Criar_sugestao_de_resposta.feature b/features/Criar_sugestao_de_resposta.feature new file mode 100644 index 00000000..e77013df --- /dev/null +++ b/features/Criar_sugestao_de_resposta.feature @@ -0,0 +1,27 @@ + + +Feature: Enviar sugestão de resposta para uma pergunta já cadastrada + Como usuário, + Quero cadastrar uma sugestão de resposta para uma pergunta já cadastrar + Para que eu possa ajudar os administradores do sistema + + Scenario: + Given Que Usuario esteja logado como email "teste@teste1.com" e "123teste" + And Esteja página inicial e logado + And Clicar no link "FAQS" + When Clicar em alguma pergunta + When O Clicar no botão "Adicionar Sugestão" + Then O usuário preenche os campos de texto "fieldResposta" com uma "resposta" + Then O usuário clica "Salvar Sugestão" + Then será cadastrado uma nova sugestão de pergunta e resposta + + + @pending + Scenario: Titulo + Dado Realizacao + Quando Tipo de Usuario + Entao Objetivo + Exemplos: + | Razao | + | Valor 1 | + | Valor 2 | diff --git a/features/edicao_pergunta_resposta.feature b/features/edicao_pergunta_resposta.feature new file mode 100644 index 00000000..8bca3168 --- /dev/null +++ b/features/edicao_pergunta_resposta.feature @@ -0,0 +1,20 @@ +Feature: Editar resposta cadastrada +Como um administrador, para que eu mantenha as perguntas e respostas atualizadas, eu gostaria de editar uma resposta já cadastrada + +Scenario: Usuário administrador edita pergunta ou resposta + Given que um usuário admin está logado + And ele está na tela onde os faqs são exibidos + And a pergunta "como_editar", a resposta "editando" do tópico "editar_cadastro" existem + When o usuário administrador clicar no botão editar para alterar a pergunta "como_editar", a resposta "editando" do tópico "editar_cadastro" + Then deve carregar a tela que edita a pergunta "como_editar", a resposta "editando" do tópico "editar_cadastro" + When preenche o campo titulo, pergunta e resposta com um "titulo", "pergunta" e "resposta" + And clica no botao "Atualizar" + Then a pergunta, resposta e topico sao atualizados + + +Scenario: Usuario que não é adminstrador tenta editar uma pergunta ou resposta + Given que o usuario está logado + And o usuário não é um administrador + And o usuário esta na tela onde os faqs são exibidos + Then o usuario nao pode visualizar o botao "editar" + diff --git a/features/step_definitions/Criar_sugestao_de_pergunta_e_resposta.rb b/features/step_definitions/Criar_sugestao_de_pergunta_e_resposta.rb new file mode 100644 index 00000000..35d82394 --- /dev/null +++ b/features/step_definitions/Criar_sugestao_de_pergunta_e_resposta.rb @@ -0,0 +1,39 @@ +Given("Que Usuario esteja logado como email {string} e {string}")_ do |string, string2| + visit '/users/sign_in' + User.create(full_name: "usuario_teste", email: string, password: string2, role:"estudante", resgistration:"00000000001") + fill_in 'user_email', with: string + fill_in 'user_password', with: string2 + click_on 'Log in' + page.should have_content("Welcome! You have signed up successfully.") + end + + And("Esteja página inicial e logado") do + pending + end + + And("Clicar no link {link_faq}") do + pending + end + + When("O Clicar no botão {button_name}") do |button_name| + pending + end + + Then("O usuário preenche os campos de texto {field1} e {field2} com uma {value1} e {value2}") do |field1, field2, value1,value1| + pending + end + + Then("O usuário clica {button_name}") do |button_name| + pending + end + + Then("será cadastrado uma nova sugestão de pergunta e resposta") do + pending + end + + + + + + + diff --git a/features/step_definitions/Criar_sugestao_de_resposta.rb b/features/step_definitions/Criar_sugestao_de_resposta.rb new file mode 100644 index 00000000..f2f74879 --- /dev/null +++ b/features/step_definitions/Criar_sugestao_de_resposta.rb @@ -0,0 +1,35 @@ +Given("Que Usuario esteja logado como email {string} e com a senha {string}")_ do |string, string2| + visit '/users/sign_in' + User.create(full_name: "usuario_teste", email: string, password: string2, role:"estudante", resgistration:"00000000001") + fill_in 'user_email', with: string + fill_in 'user_password', with: string2 + click_on 'Log in' + page.should have_content("Welcome! You have signed up successfully.") + end + +And("Esteja página inicial e logado") do + pending + end + + And("Clicar no link {link_faq}") do + pending + end + + When("O Clicar no botão {button_name}") do |button_name| + pending + end + + Then("O usuário preenche os campos de texto {field} e {value}") do |field, value| + pending + end + + Then("O usuário clica {button_name}") do |button_name| + pending + end + + Then("será cadastrado uma nova sugestão de pergunta e resposta") do + pending + end + + + diff --git a/features/step_definitions/cadastro_pergunta_resposta.rb b/features/step_definitions/cadastro_pergunta_resposta.rb new file mode 100644 index 00000000..0fad6812 --- /dev/null +++ b/features/step_definitions/cadastro_pergunta_resposta.rb @@ -0,0 +1,37 @@ +#Usuário administrador cadastra nova pergunta e resposta em FAQ +Given("Usuário está logado com {email} e {password}") do |email, password| + pending +end + +And("Usuário se encontra na tela de FAQ") do + pending +end + +When("O usuário clica no botão {button_name}") do |button_name| + pending +end + +Then("O usuário preenche os campos de texto {fieldPergunta} e {fieldResposta} com uma {pergunta} e {resposta}") do |fieldPergunta, fieldResposta, pergunta, resposta| + pending +end + +Then("O usuário clica no botão {button_name}") do |button_name| + pending +end + +Then("É cadastrado um novo par Pergunta e Resposta") do + pending +end + +#Usuário sem privilégios não pode interagir com botão de Adicionar Pergunta e Resposta +Given("Usuário não logado com conta de administrador") do + pending +end + +And("Usuário se encontra na tela de FAQ") do + pending +end + +Then("O botão {button_name} deve estar indispoível") do |button_name| + pending +end \ No newline at end of file diff --git a/features/step_definitions/cadastro_topico_faq.rb b/features/step_definitions/cadastro_topico_faq.rb new file mode 100644 index 00000000..bbacfa89 --- /dev/null +++ b/features/step_definitions/cadastro_topico_faq.rb @@ -0,0 +1,37 @@ +#Usuário administrador cadastra novo tópico para organizar FAQ +Given("Usuário está logado com {email} e {password}") do |email, password| + pending +end + +And("Usuário se encontra na tela de FAQ") do + pending +end + +When("O usuário clica no botão {button_name}") do |button_name| + pending +end + +Then("O usuário preenche o campo de texto {field} com um {value}") do |field, value| + pending +end + +Then("O usuário clica no botão {button_name}") do |button_name| + pending +end + +Then("É cadastrado um novo tópico") do + pending +end + +#Usuário sem privilégios não pode interagir com botão de adicionar Tópico +Given("Usuário não logado com conta de administrador") do + pending +end + +And("Usuário se encontra na tela de FAQ") do + pending +end + +Then("O botão {button_name} deve estar indispoível") do |button_name| + pending +end \ No newline at end of file diff --git a/features/step_definitions/edicao_pergunta_resposta.rb b/features/step_definitions/edicao_pergunta_resposta.rb new file mode 100644 index 00000000..e86e2d8e --- /dev/null +++ b/features/step_definitions/edicao_pergunta_resposta.rb @@ -0,0 +1,47 @@ +Given("que um usuário admin está logado") do + pending # Write code here that turns the phrase above into concrete actions +end + +Given("ele está na tela onde os faqs são exibidos") do + pending # Write code here that turns the phrase above into concrete actions +end + +Given("a pergunta {string}, a resposta {string} do tópico {string} existem") do |string, string2, string3| + pending # Write code here that turns the phrase above into concrete actions +end + +When("o usuário administrador clicar no botão editar para alterar a pergunta {string}, a resposta {string} do tópico {string}") do |string, string2, string3| + pending # Write code here that turns the phrase above into concrete actions +end + +Then("deve carregar a tela que edita a pergunta {string}, a resposta {string} do tópico {string}") do |string, string2, string3| + pending # Write code here that turns the phrase above into concrete actions +end + +When("preenche o campo titulo, pergunta e resposta com um {string}, {string} e {string}") do |string, string2, string3| + pending # Write code here that turns the phrase above into concrete actions +end + +When("clica no botao {string}") do |string| + pending # Write code here that turns the phrase above into concrete actions +end + +Then("a pergunta, resposta e topico sao atualizados") do + pending # Write code here that turns the phrase above into concrete actions +end + +Given("que o usuario está logado") do + pending # Write code here that turns the phrase above into concrete actions +end + +Given("o usuário não é um administrador") do + pending # Write code here that turns the phrase above into concrete actions +end + +Given("o usuário esta na tela onde os faqs são exibidos") do + pending # Write code here that turns the phrase above into concrete actions +end + +Then("o usuario nao pode visualizar o botao {string}") do |string| + pending # Write code here that turns the phrase above into concrete actions +end \ No newline at end of file diff --git a/features/step_definitions/ver_perguntas_por_topico.rb b/features/step_definitions/ver_perguntas_por_topico.rb new file mode 100644 index 00000000..1961c5bd --- /dev/null +++ b/features/step_definitions/ver_perguntas_por_topico.rb @@ -0,0 +1,7 @@ +Given("Que o usuário esta na tela {string}") do |string| + pending # Write code here that turns the phrase above into concrete actions +end + +Then("Ele pode vesualizar a pergunta {string}, a resposta {string} do tópico {string}") do |string, string2, string3| + pending # Write code here that turns the phrase above into concrete actions +end \ No newline at end of file diff --git a/features/support/cadastro_pergunta_resposta_faq.feature b/features/support/cadastro_pergunta_resposta_faq.feature new file mode 100644 index 00000000..03560630 --- /dev/null +++ b/features/support/cadastro_pergunta_resposta_faq.feature @@ -0,0 +1,46 @@ +Feature: Cadastro de Pergunta e Resposta para o FAQ +Como um usuário, para que eu possa ajudar no levantamento de perguntas, eu gostaria de fazer uma sugestão de pergunta e dar uma sugestão de resposta + +Scenario: Usuário administrador cadastra nova pergunta e resposta em FAQ + Given Usuário está logado com "admin@cucumber.com" e "admin123" + And Usuário se encontra na tela de FAQ + When O usuário clica no botão "Adicionar Pergunta e Resposta" + Then O usuário preenche os campos de texto "fieldPergunta" e "fieldResposta" com uma "pergunta" e "resposta" + Then O usuário clica no botão "Salvar" + Then É cadastrado um novo par Pergunta e Resposta + +Scenario: Usuário administrador cadastra nova pergunta e resposta em FAQ + Given Usuário está logado com "admin@cucumber.com" e "admin123" + And Usuário se encontra na tela de FAQ + When O usuário clica no botão "Adicionar Pergunta e Resposta" + Then O usuário preenche os campos de texto "fieldPergunta" com uma "pergunta" + Then O usuário clica no botão "Salvar" + Then É rejeitado o cadastro de uma nova resposta + Then Exibe um alerta "É necessário cadastrar uma resposta" + +Scenario: Usuário sem privilégios não pode interagir com botão de Adicionar Pergunta e Resposta + Given Usuário não logado com conta de administrador + And Usuário se encontra na tela de FAQ + Then O botão "Adicionar Pergunta e Resposta" deve estar indisponível + +Scenario: Usuário sem privilégios pode interagir com botão de Adicionar Sugestão de Pergunta e Resposta + Given Usuário não logado com conta de "teste@teste1.com" + And Usuário se encontra na tela de FAQ + Then O botão "Adicionar Sugestão de Pergunta e Resposta" deve estar disponível + +Scenario: Usuario cadastra nova pergunta e resposta em FAQ + Given Usuario esta logado com o email "teste@teste1.com" + And Usuario se encontra na tela de FAQ + When O usuário clica no botão "Adicionar Pergunta e Resposta" + Then O usuário preenche os campos de texto "fieldPergunta" e "fieldResposta" com uma "pergunta" e "resposta" + Then O usuário clica no botão "Salvar" + Then É cadastrado um novo par de sugestão Pergunta e Resposta + +Scenario: Usuario cadastra nova pergunta e resposta em FAQ + Given Usuario esta logado com o email "teste@teste1.com" + And Usuario se encontra na tela de FAQ + When O usuário clica no botão "Adicionar Pergunta e Resposta" + Then O usuário preenche os campos de texto "fieldPergunta" com uma "pergunta" + Then O usuário clica no botão "Salvar" + Then É rejeitado o cadastro de uma nova resposta + Then Exibe um alerta "É necessário cadastrar uma resposta para sua sugestão" \ No newline at end of file diff --git a/features/support/cadastro_topico_faq.feature b/features/support/cadastro_topico_faq.feature new file mode 100644 index 00000000..d9b94f59 --- /dev/null +++ b/features/support/cadastro_topico_faq.feature @@ -0,0 +1,15 @@ +Feature: Cadastro de Topico para o FAQ +Como um administrador, para que eu possa organizar as perguntas e respostas, eu gostaria de cadastrar tópicos para as perguntas e respostas + +Scenario: Usuário administrador cadastra novo tópico para organizar FAQ + Given Usuário está logado com "admin@cucumber.com" e "admin123" + And Usuário se encontra na tela de FAQ + When O usuário clica no botão "Adicionar tópico" + Then O usuário preenche o campo de texto "Tópico" com um "topico" + Then O usuário clica no botão "Salvar" + Then É cadastrado um novo tópico + +Scenario: Usuário sem privilégios não pode interagir com botão de adicionar Tópico + Given Usuário não logado com conta de administrador + And Usuário se encontra na tela de FAQ + Then O botão "Adicionar tópico" deve estar indisponível diff --git a/features/ver_perguntas_por_topico.feature b/features/ver_perguntas_por_topico.feature new file mode 100644 index 00000000..ab8069db --- /dev/null +++ b/features/ver_perguntas_por_topico.feature @@ -0,0 +1,13 @@ +Feature: Ver perguntas por topico +Como um usuário, para que eu possa me informar, eu gostaria de ver as perguntas separadas por tópicos + +Scenario: Ver pergunta por um topico + Given Que o usuário esta na tela "/faqs" + And a pergunta "como_editar", a resposta "editando" do tópico "editar_cadastro" existem + Then Ele pode visualizar a pergunta "como_editar", a resposta "editando" do tópico "editar_cadastro" + +Scenario: Ver pergunta por um topico + Given Que o usuário esta na tela "/faqs" + And a pergunta "como_editar", a resposta "editando" existem + And nenhum tópico está disponível + Then Ele não pode visualizar a pergunta "como_editar", a resposta "editando" separado por tópico \ No newline at end of file diff --git a/spec/controllers/faqs_controller_spec.rb b/spec/controllers/faqs_controller_spec.rb new file mode 100644 index 00000000..9a0c89de --- /dev/null +++ b/spec/controllers/faqs_controller_spec.rb @@ -0,0 +1,141 @@ +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. +# +# Also compared to earlier versions of this generator, there are no longer any +# expectations of assigns and templates rendered. These features have been +# removed from Rails core in Rails 5, but can be added back in via the +# `rails-controller-testing` gem. + +RSpec.describe FaqsController, type: :controller do + + # This should return the minimal set of attributes required to create a valid + # Faq. As you add validations to Faq, 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 + # FaqsController. Be sure to keep this updated too. + let(:valid_session) { {} } + + describe "GET #index" do + it "returns a success response" do + Faq.create! valid_attributes + get :index, params: {}, session: valid_session + expect(response).to be_successful + end + end + + describe "GET #show" do + it "returns a success response" do + faq = Faq.create! valid_attributes + get :show, params: {id: faq.to_param}, session: valid_session + expect(response).to be_successful + end + end + + describe "GET #new" do + it "returns a success response" do + get :new, params: {}, session: valid_session + expect(response).to be_successful + end + end + + describe "GET #edit" do + it "returns a success response" do + faq = Faq.create! valid_attributes + get :edit, params: {id: faq.to_param}, session: valid_session + expect(response).to be_successful + end + end + + describe "POST #create" do + context "with valid params" do + it "creates a new Faq" do + expect { + post :create, params: {faq: valid_attributes}, session: valid_session + }.to change(Faq, :count).by(1) + end + + it "redirects to the created faq" do + post :create, params: {faq: valid_attributes}, session: valid_session + expect(response).to redirect_to(Faq.last) + end + end + + context "with invalid params" do + it "returns a success response (i.e. to display the 'new' template)" do + post :create, params: {faq: invalid_attributes}, session: valid_session + expect(response).to be_successful + 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 faq" do + faq = Faq.create! valid_attributes + put :update, params: {id: faq.to_param, faq: new_attributes}, session: valid_session + faq.reload + skip("Add assertions for updated state") + end + + it "redirects to the faq" do + faq = Faq.create! valid_attributes + put :update, params: {id: faq.to_param, faq: valid_attributes}, session: valid_session + expect(response).to redirect_to(faq) + end + end + + context "with invalid params" do + it "returns a success response (i.e. to display the 'edit' template)" do + faq = Faq.create! valid_attributes + put :update, params: {id: faq.to_param, faq: invalid_attributes}, session: valid_session + expect(response).to be_successful + end + end + end + + describe "DELETE #destroy" do + it "destroys the requested faq" do + faq = Faq.create! valid_attributes + expect { + delete :destroy, params: {id: faq.to_param}, session: valid_session + }.to change(Faq, :count).by(-1) + end + + it "redirects to the faqs list" do + faq = Faq.create! valid_attributes + delete :destroy, params: {id: faq.to_param}, session: valid_session + expect(response).to redirect_to(faqs_url) + end + end + +end diff --git a/spec/controllers/faqs_suggestions_controller_spec.rb b/spec/controllers/faqs_suggestions_controller_spec.rb new file mode 100644 index 00000000..003159bc --- /dev/null +++ b/spec/controllers/faqs_suggestions_controller_spec.rb @@ -0,0 +1,141 @@ +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. +# +# Also compared to earlier versions of this generator, there are no longer any +# expectations of assigns and templates rendered. These features have been +# removed from Rails core in Rails 5, but can be added back in via the +# `rails-controller-testing` gem. + +RSpec.describe FaqsSuggestionsController, type: :controller do + + # This should return the minimal set of attributes required to create a valid + # FaqsSuggestion. As you add validations to FaqsSuggestion, 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 + # FaqsSuggestionsController. Be sure to keep this updated too. + let(:valid_session) { {} } + + describe "GET #index" do + it "returns a success response" do + FaqsSuggestion.create! valid_attributes + get :index, params: {}, session: valid_session + expect(response).to be_successful + end + end + + describe "GET #show" do + it "returns a success response" do + faqs_suggestion = FaqsSuggestion.create! valid_attributes + get :show, params: {id: faqs_suggestion.to_param}, session: valid_session + expect(response).to be_successful + end + end + + describe "GET #new" do + it "returns a success response" do + get :new, params: {}, session: valid_session + expect(response).to be_successful + end + end + + describe "GET #edit" do + it "returns a success response" do + faqs_suggestion = FaqsSuggestion.create! valid_attributes + get :edit, params: {id: faqs_suggestion.to_param}, session: valid_session + expect(response).to be_successful + end + end + + describe "POST #create" do + context "with valid params" do + it "creates a new FaqsSuggestion" do + expect { + post :create, params: {faqs_suggestion: valid_attributes}, session: valid_session + }.to change(FaqsSuggestion, :count).by(1) + end + + it "redirects to the created faqs_suggestion" do + post :create, params: {faqs_suggestion: valid_attributes}, session: valid_session + expect(response).to redirect_to(FaqsSuggestion.last) + end + end + + context "with invalid params" do + it "returns a success response (i.e. to display the 'new' template)" do + post :create, params: {faqs_suggestion: invalid_attributes}, session: valid_session + expect(response).to be_successful + 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 faqs_suggestion" do + faqs_suggestion = FaqsSuggestion.create! valid_attributes + put :update, params: {id: faqs_suggestion.to_param, faqs_suggestion: new_attributes}, session: valid_session + faqs_suggestion.reload + skip("Add assertions for updated state") + end + + it "redirects to the faqs_suggestion" do + faqs_suggestion = FaqsSuggestion.create! valid_attributes + put :update, params: {id: faqs_suggestion.to_param, faqs_suggestion: valid_attributes}, session: valid_session + expect(response).to redirect_to(faqs_suggestion) + end + end + + context "with invalid params" do + it "returns a success response (i.e. to display the 'edit' template)" do + faqs_suggestion = FaqsSuggestion.create! valid_attributes + put :update, params: {id: faqs_suggestion.to_param, faqs_suggestion: invalid_attributes}, session: valid_session + expect(response).to be_successful + end + end + end + + describe "DELETE #destroy" do + it "destroys the requested faqs_suggestion" do + faqs_suggestion = FaqsSuggestion.create! valid_attributes + expect { + delete :destroy, params: {id: faqs_suggestion.to_param}, session: valid_session + }.to change(FaqsSuggestion, :count).by(-1) + end + + it "redirects to the faqs_suggestions list" do + faqs_suggestion = FaqsSuggestion.create! valid_attributes + delete :destroy, params: {id: faqs_suggestion.to_param}, session: valid_session + expect(response).to redirect_to(faqs_suggestions_url) + end + end + +end diff --git a/spec/controllers/topics_controller_spec.rb b/spec/controllers/topics_controller_spec.rb new file mode 100644 index 00000000..a8431a1e --- /dev/null +++ b/spec/controllers/topics_controller_spec.rb @@ -0,0 +1,141 @@ +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. +# +# Also compared to earlier versions of this generator, there are no longer any +# expectations of assigns and templates rendered. These features have been +# removed from Rails core in Rails 5, but can be added back in via the +# `rails-controller-testing` gem. + +RSpec.describe TopicsController, type: :controller do + + # This should return the minimal set of attributes required to create a valid + # Topic. As you add validations to Topic, 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 + # TopicsController. Be sure to keep this updated too. + let(:valid_session) { {} } + + describe "GET #index" do + it "returns a success response" do + Topic.create! valid_attributes + get :index, params: {}, session: valid_session + expect(response).to be_successful + end + end + + describe "GET #show" do + it "returns a success response" do + topic = Topic.create! valid_attributes + get :show, params: {id: topic.to_param}, session: valid_session + expect(response).to be_successful + end + end + + describe "GET #new" do + it "returns a success response" do + get :new, params: {}, session: valid_session + expect(response).to be_successful + end + end + + describe "GET #edit" do + it "returns a success response" do + topic = Topic.create! valid_attributes + get :edit, params: {id: topic.to_param}, session: valid_session + expect(response).to be_successful + end + end + + describe "POST #create" do + context "with valid params" do + it "creates a new Topic" do + expect { + post :create, params: {topic: valid_attributes}, session: valid_session + }.to change(Topic, :count).by(1) + end + + it "redirects to the created topic" do + post :create, params: {topic: valid_attributes}, session: valid_session + expect(response).to redirect_to(Topic.last) + end + end + + context "with invalid params" do + it "returns a success response (i.e. to display the 'new' template)" do + post :create, params: {topic: invalid_attributes}, session: valid_session + expect(response).to be_successful + 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 topic" do + topic = Topic.create! valid_attributes + put :update, params: {id: topic.to_param, topic: new_attributes}, session: valid_session + topic.reload + skip("Add assertions for updated state") + end + + it "redirects to the topic" do + topic = Topic.create! valid_attributes + put :update, params: {id: topic.to_param, topic: valid_attributes}, session: valid_session + expect(response).to redirect_to(topic) + end + end + + context "with invalid params" do + it "returns a success response (i.e. to display the 'edit' template)" do + topic = Topic.create! valid_attributes + put :update, params: {id: topic.to_param, topic: invalid_attributes}, session: valid_session + expect(response).to be_successful + end + end + end + + describe "DELETE #destroy" do + it "destroys the requested topic" do + topic = Topic.create! valid_attributes + expect { + delete :destroy, params: {id: topic.to_param}, session: valid_session + }.to change(Topic, :count).by(-1) + end + + it "redirects to the topics list" do + topic = Topic.create! valid_attributes + delete :destroy, params: {id: topic.to_param}, session: valid_session + expect(response).to redirect_to(topics_url) + end + end + +end diff --git a/spec/helpers/faqs_helper_spec.rb b/spec/helpers/faqs_helper_spec.rb new file mode 100644 index 00000000..1d616aff --- /dev/null +++ b/spec/helpers/faqs_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the FaqsHelper. For example: +# +# describe FaqsHelper 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 FaqsHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/faqs_suggestions_helper_spec.rb b/spec/helpers/faqs_suggestions_helper_spec.rb new file mode 100644 index 00000000..ff2dca03 --- /dev/null +++ b/spec/helpers/faqs_suggestions_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the FaqsSuggestionsHelper. For example: +# +# describe FaqsSuggestionsHelper 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 FaqsSuggestionsHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/topics_helper_spec.rb b/spec/helpers/topics_helper_spec.rb new file mode 100644 index 00000000..6adfadb6 --- /dev/null +++ b/spec/helpers/topics_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the TopicsHelper. For example: +# +# describe TopicsHelper 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 TopicsHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/faq_spec.rb b/spec/models/faq_spec.rb new file mode 100644 index 00000000..d35212db --- /dev/null +++ b/spec/models/faq_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Faq, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/faqs_suggestion_spec.rb b/spec/models/faqs_suggestion_spec.rb new file mode 100644 index 00000000..3cdacd93 --- /dev/null +++ b/spec/models/faqs_suggestion_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe FaqsSuggestion, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/topic_spec.rb b/spec/models/topic_spec.rb new file mode 100644 index 00000000..b8c5a8e0 --- /dev/null +++ b/spec/models/topic_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Topic, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/requests/faqs_spec.rb b/spec/requests/faqs_spec.rb new file mode 100644 index 00000000..04ac8b2c --- /dev/null +++ b/spec/requests/faqs_spec.rb @@ -0,0 +1,10 @@ +require 'rails_helper' + +RSpec.describe "Faqs", type: :request do + describe "GET /faqs" do + it "works! (now write some real specs)" do + get faqs_path + expect(response).to have_http_status(200) + end + end +end diff --git a/spec/requests/faqs_suggestions_spec.rb b/spec/requests/faqs_suggestions_spec.rb new file mode 100644 index 00000000..b41c3a5f --- /dev/null +++ b/spec/requests/faqs_suggestions_spec.rb @@ -0,0 +1,10 @@ +require 'rails_helper' + +RSpec.describe "FaqsSuggestions", type: :request do + describe "GET /faqs_suggestions" do + it "works! (now write some real specs)" do + get faqs_suggestions_path + expect(response).to have_http_status(200) + end + end +end diff --git a/spec/requests/topics_spec.rb b/spec/requests/topics_spec.rb new file mode 100644 index 00000000..3618347c --- /dev/null +++ b/spec/requests/topics_spec.rb @@ -0,0 +1,10 @@ +require 'rails_helper' + +RSpec.describe "Topics", type: :request do + describe "GET /topics" do + it "works! (now write some real specs)" do + get topics_path + expect(response).to have_http_status(200) + end + end +end diff --git a/spec/routing/faqs_routing_spec.rb b/spec/routing/faqs_routing_spec.rb new file mode 100644 index 00000000..1a047567 --- /dev/null +++ b/spec/routing/faqs_routing_spec.rb @@ -0,0 +1,38 @@ +require "rails_helper" + +RSpec.describe FaqsController, type: :routing do + describe "routing" do + it "routes to #index" do + expect(:get => "/faqs").to route_to("faqs#index") + end + + it "routes to #new" do + expect(:get => "/faqs/new").to route_to("faqs#new") + end + + it "routes to #show" do + expect(:get => "/faqs/1").to route_to("faqs#show", :id => "1") + end + + it "routes to #edit" do + expect(:get => "/faqs/1/edit").to route_to("faqs#edit", :id => "1") + end + + + it "routes to #create" do + expect(:post => "/faqs").to route_to("faqs#create") + end + + it "routes to #update via PUT" do + expect(:put => "/faqs/1").to route_to("faqs#update", :id => "1") + end + + it "routes to #update via PATCH" do + expect(:patch => "/faqs/1").to route_to("faqs#update", :id => "1") + end + + it "routes to #destroy" do + expect(:delete => "/faqs/1").to route_to("faqs#destroy", :id => "1") + end + end +end diff --git a/spec/routing/faqs_suggestions_routing_spec.rb b/spec/routing/faqs_suggestions_routing_spec.rb new file mode 100644 index 00000000..d8537dda --- /dev/null +++ b/spec/routing/faqs_suggestions_routing_spec.rb @@ -0,0 +1,38 @@ +require "rails_helper" + +RSpec.describe FaqsSuggestionsController, type: :routing do + describe "routing" do + it "routes to #index" do + expect(:get => "/faqs_suggestions").to route_to("faqs_suggestions#index") + end + + it "routes to #new" do + expect(:get => "/faqs_suggestions/new").to route_to("faqs_suggestions#new") + end + + it "routes to #show" do + expect(:get => "/faqs_suggestions/1").to route_to("faqs_suggestions#show", :id => "1") + end + + it "routes to #edit" do + expect(:get => "/faqs_suggestions/1/edit").to route_to("faqs_suggestions#edit", :id => "1") + end + + + it "routes to #create" do + expect(:post => "/faqs_suggestions").to route_to("faqs_suggestions#create") + end + + it "routes to #update via PUT" do + expect(:put => "/faqs_suggestions/1").to route_to("faqs_suggestions#update", :id => "1") + end + + it "routes to #update via PATCH" do + expect(:patch => "/faqs_suggestions/1").to route_to("faqs_suggestions#update", :id => "1") + end + + it "routes to #destroy" do + expect(:delete => "/faqs_suggestions/1").to route_to("faqs_suggestions#destroy", :id => "1") + end + end +end diff --git a/spec/routing/topics_routing_spec.rb b/spec/routing/topics_routing_spec.rb new file mode 100644 index 00000000..aa317a9d --- /dev/null +++ b/spec/routing/topics_routing_spec.rb @@ -0,0 +1,38 @@ +require "rails_helper" + +RSpec.describe TopicsController, type: :routing do + describe "routing" do + it "routes to #index" do + expect(:get => "/topics").to route_to("topics#index") + end + + it "routes to #new" do + expect(:get => "/topics/new").to route_to("topics#new") + end + + it "routes to #show" do + expect(:get => "/topics/1").to route_to("topics#show", :id => "1") + end + + it "routes to #edit" do + expect(:get => "/topics/1/edit").to route_to("topics#edit", :id => "1") + end + + + it "routes to #create" do + expect(:post => "/topics").to route_to("topics#create") + end + + it "routes to #update via PUT" do + expect(:put => "/topics/1").to route_to("topics#update", :id => "1") + end + + it "routes to #update via PATCH" do + expect(:patch => "/topics/1").to route_to("topics#update", :id => "1") + end + + it "routes to #destroy" do + expect(:delete => "/topics/1").to route_to("topics#destroy", :id => "1") + end + end +end diff --git a/spec/views/faq/index.html.erb_spec.rb b/spec/views/faq/index.html.erb_spec.rb new file mode 100644 index 00000000..8ca78177 --- /dev/null +++ b/spec/views/faq/index.html.erb_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe "faq/index.html.erb", type: :view do + pending "add some questions to (or delete) #{__FILE__}" +end diff --git a/spec/views/faqs/edit.html.erb_spec.rb b/spec/views/faqs/edit.html.erb_spec.rb new file mode 100644 index 00000000..4aeedc96 --- /dev/null +++ b/spec/views/faqs/edit.html.erb_spec.rb @@ -0,0 +1,47 @@ +require 'rails_helper' + +RSpec.describe "faqs/edit", type: :view do + before(:each) do + @faq = assign(:faq, Faq.create!( + :question => "MyString", + :answer => "MyString", + :topic => nil + )) + end + + it "renders the edit faq form" do + render + + assert_select "form[action=?][method=?]", faq_path(@faq), "post" do + + assert_select "input[name=?]", "faq[question]" + + assert_select "input[name=?]", "faq[answer]" + + assert_select "input[name=?]", "faq[topic_id]" + end + end +end + +RSpec.describe "topics/edit", type: :view do + before(:each) do + @faq = assign(:faq, Faq.create!( + :question => "MyString", + :answer => "MyString", + :topic => "MyString" + )) + end + + it "renders the edit faq form" do + render + + assert_select "form[action=?][method=?]", faq_path(@faq), "post" do + + assert_select "input[name=?]", "faq[question]" + + assert_select "input[name=?]", "faq[answer]" + + assert_select "input[name=?]", "faq[topic_id]" + end + end +end diff --git a/spec/views/faqs/index.html.erb_spec.rb b/spec/views/faqs/index.html.erb_spec.rb new file mode 100644 index 00000000..90d96bed --- /dev/null +++ b/spec/views/faqs/index.html.erb_spec.rb @@ -0,0 +1,25 @@ +require 'rails_helper' + +RSpec.describe "faqs/index", type: :view do + before(:each) do + assign(:faqs, [ + Faq.create!( + :question => "Question", + :answer => "Answer", + :topic => nil + ), + Faq.create!( + :question => "Question", + :answer => "Answer", + :topic => nil + ) + ]) + end + + it "renders a list of faqs" do + render + assert_select "tr>td", :text => "Question".to_s, :count => 2 + assert_select "tr>td", :text => "Answer".to_s, :count => 2 + assert_select "tr>td", :text => nil.to_s, :count => 2 + end +end diff --git a/spec/views/faqs/new.html.erb_spec.rb b/spec/views/faqs/new.html.erb_spec.rb new file mode 100644 index 00000000..b1194b55 --- /dev/null +++ b/spec/views/faqs/new.html.erb_spec.rb @@ -0,0 +1,24 @@ +require 'rails_helper' + +RSpec.describe "faqs/new", type: :view do + before(:each) do + assign(:faq, Faq.new( + :question => "MyString", + :answer => "MyString", + :topic => nil + )) + end + + it "renders new faq form" do + render + + assert_select "form[action=?][method=?]", faqs_path, "post" do + + assert_select "input[name=?]", "faq[question]" + + assert_select "input[name=?]", "faq[answer]" + + assert_select "input[name=?]", "faq[topic_id]" + end + end +end diff --git a/spec/views/faqs/newTopic.html.erb_spec.rb b/spec/views/faqs/newTopic.html.erb_spec.rb new file mode 100644 index 00000000..5be2a7ed --- /dev/null +++ b/spec/views/faqs/newTopic.html.erb_spec.rb @@ -0,0 +1,16 @@ +require 'rails_helper' + +RSpec.describe "topics/new", type: :view do + before(:each) do + assign(:faq, Faq.new( + :title => "MyString", + :question => nil + )) + end + + it "renders new faq form" do + render + + assert_select "input[name=?]", "faq[topic_id]" + end +end diff --git a/spec/views/faqs/show.html.erb_spec.rb b/spec/views/faqs/show.html.erb_spec.rb new file mode 100644 index 00000000..a1ae3ee5 --- /dev/null +++ b/spec/views/faqs/show.html.erb_spec.rb @@ -0,0 +1,36 @@ +require 'rails_helper' + +RSpec.describe "faqs/show", type: :view do + before(:each) do + @faq = assign(:faq, Faq.create!( + :question => "Question", + :answer => "Answer", + :topic => nil + )) + end + + it "renders attributes in

" do + render + expect(rendered).to match(/Question/) + expect(rendered).to match(/Answer/) + expect(rendered).to match(//) + end +end + +RSpec.describe "topics/show", type: :view do + before(:each) do + @faq = assign(:faq, Faq.create!( + :question => "Question", + :answer => "Answer", + :topic => "Topic" + )) + end + + it "renders attributes in

" do + render + expect(rendered).to match(/Question/) + expect(rendered).to match(/Answer/) + expect(rendered).to match(/Topic/) + end +end + diff --git a/spec/views/faqs_suggestions/edit.html.erb_spec.rb b/spec/views/faqs_suggestions/edit.html.erb_spec.rb new file mode 100644 index 00000000..d66e9794 --- /dev/null +++ b/spec/views/faqs_suggestions/edit.html.erb_spec.rb @@ -0,0 +1,24 @@ +require 'rails_helper' + +RSpec.describe "faqs_suggestions/edit", type: :view do + before(:each) do + @faqs_suggestion = assign(:faqs_suggestion, FaqsSuggestion.create!( + :question => "MyString", + :answer => "MyString", + :topic => nil + )) + end + + it "renders the edit faqs_suggestion form" do + render + + assert_select "form[action=?][method=?]", faqs_suggestion_path(@faqs_suggestion), "post" do + + assert_select "input[name=?]", "faqs_suggestion[question]" + + assert_select "input[name=?]", "faqs_suggestion[answer]" + + assert_select "input[name=?]", "faqs_suggestion[topic_id]" + end + end +end diff --git a/spec/views/faqs_suggestions/index.html.erb_spec.rb b/spec/views/faqs_suggestions/index.html.erb_spec.rb new file mode 100644 index 00000000..1605b3df --- /dev/null +++ b/spec/views/faqs_suggestions/index.html.erb_spec.rb @@ -0,0 +1,25 @@ +require 'rails_helper' + +RSpec.describe "faqs_suggestions/index", type: :view do + before(:each) do + assign(:faqs_suggestions, [ + FaqsSuggestion.create!( + :question => "Question", + :answer => "Answer", + :topic => nil + ), + FaqsSuggestion.create!( + :question => "Question", + :answer => "Answer", + :topic => nil + ) + ]) + end + + it "renders a list of faqs_suggestions" do + render + assert_select "tr>td", :text => "Question".to_s, :count => 2 + assert_select "tr>td", :text => "Answer".to_s, :count => 2 + assert_select "tr>td", :text => nil.to_s, :count => 2 + end +end diff --git a/spec/views/faqs_suggestions/new.html.erb_spec.rb b/spec/views/faqs_suggestions/new.html.erb_spec.rb new file mode 100644 index 00000000..94046571 --- /dev/null +++ b/spec/views/faqs_suggestions/new.html.erb_spec.rb @@ -0,0 +1,24 @@ +require 'rails_helper' + +RSpec.describe "faqs_suggestions/new", type: :view do + before(:each) do + assign(:faqs_suggestion, FaqsSuggestion.new( + :question => "MyString", + :answer => "MyString", + :topic => nil + )) + end + + it "renders new faqs_suggestion form" do + render + + assert_select "form[action=?][method=?]", faqs_suggestions_path, "post" do + + assert_select "input[name=?]", "faqs_suggestion[question]" + + assert_select "input[name=?]", "faqs_suggestion[answer]" + + assert_select "input[name=?]", "faqs_suggestion[topic_id]" + end + end +end diff --git a/spec/views/faqs_suggestions/show.html.erb_spec.rb b/spec/views/faqs_suggestions/show.html.erb_spec.rb new file mode 100644 index 00000000..404c8c2e --- /dev/null +++ b/spec/views/faqs_suggestions/show.html.erb_spec.rb @@ -0,0 +1,18 @@ +require 'rails_helper' + +RSpec.describe "faqs_suggestions/show", type: :view do + before(:each) do + @faqs_suggestion = assign(:faqs_suggestion, FaqsSuggestion.create!( + :question => "Question", + :answer => "Answer", + :topic => nil + )) + end + + it "renders attributes in

" do + render + expect(rendered).to match(/Question/) + expect(rendered).to match(/Answer/) + expect(rendered).to match(//) + end +end diff --git a/spec/views/topics/edit.html.erb_spec.rb b/spec/views/topics/edit.html.erb_spec.rb new file mode 100644 index 00000000..3a80bd95 --- /dev/null +++ b/spec/views/topics/edit.html.erb_spec.rb @@ -0,0 +1,18 @@ +require 'rails_helper' + +RSpec.describe "topics/edit", type: :view do + before(:each) do + @topic = assign(:topic, Topic.create!( + :titulo => "MyString" + )) + end + + it "renders the edit topic form" do + render + + assert_select "form[action=?][method=?]", topic_path(@topic), "post" do + + assert_select "input[name=?]", "topic[titulo]" + end + end +end diff --git a/spec/views/topics/index.html.erb_spec.rb b/spec/views/topics/index.html.erb_spec.rb new file mode 100644 index 00000000..6bf30731 --- /dev/null +++ b/spec/views/topics/index.html.erb_spec.rb @@ -0,0 +1,19 @@ +require 'rails_helper' + +RSpec.describe "topics/index", type: :view do + before(:each) do + assign(:topics, [ + Topic.create!( + :titulo => "Titulo" + ), + Topic.create!( + :titulo => "Titulo" + ) + ]) + end + + it "renders a list of topics" do + render + assert_select "tr>td", :text => "Titulo".to_s, :count => 2 + end +end diff --git a/spec/views/topics/new.html.erb_spec.rb b/spec/views/topics/new.html.erb_spec.rb new file mode 100644 index 00000000..f66599d6 --- /dev/null +++ b/spec/views/topics/new.html.erb_spec.rb @@ -0,0 +1,18 @@ +require 'rails_helper' + +RSpec.describe "topics/new", type: :view do + before(:each) do + assign(:topic, Topic.new( + :titulo => "MyString" + )) + end + + it "renders new topic form" do + render + + assert_select "form[action=?][method=?]", topics_path, "post" do + + assert_select "input[name=?]", "topic[titulo]" + end + end +end diff --git a/spec/views/topics/show.html.erb_spec.rb b/spec/views/topics/show.html.erb_spec.rb new file mode 100644 index 00000000..d7ad0234 --- /dev/null +++ b/spec/views/topics/show.html.erb_spec.rb @@ -0,0 +1,14 @@ +require 'rails_helper' + +RSpec.describe "topics/show", type: :view do + before(:each) do + @topic = assign(:topic, Topic.create!( + :titulo => "Titulo" + )) + end + + it "renders attributes in

" do + render + expect(rendered).to match(/Titulo/) + end +end