diff --git a/Gemfile b/Gemfile index d034287e..8cada8c0 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 @@ -52,6 +52,7 @@ group :development do # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' + gem 'factory_bot_rails' end group :test do @@ -64,6 +65,9 @@ group :test do # database_cleaner is not required, but highly recommended gem 'database_cleaner' gem 'shoulda-matchers' + # Factory + gem 'factory_bot_rails' + gem 'rails-controller-testing' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem diff --git a/Gemfile.lock b/Gemfile.lock index 1c0f8f1e..0a9e4f86 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) @@ -261,7 +261,7 @@ DEPENDENCIES 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) diff --git a/README.md b/README.md index 7db80e4c..ba725cdd 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,30 @@ -# README +# GRUPO 1 - Sprint 2 -This README would normally document whatever steps are necessary to get the -application up and running. +* Carlos Eduardo de Sousa - 160057701 +* Edilton Costa Alves - 170002365 +* Eduardo Vaz Fagundes Rech - 180075161 +* Estevam Galvão Albuquerque - 160005663 +* Kalley Wilkerson Rodrigues Alexandre - 170038050 -Things you may want to cover: -* Ruby version +## NOME DO PROJETO +#### Calendário de atividades - secretaria-ppgi -* System dependencies +## ESCOPO DO PROJETO +* Teste para cadastro de atividade e seu prazo de execução; +* Teste para inclusão de pessoas interessadas em cada atividade; +* Teste para notificação de pessoas interessadas; +* Teste para visualização de atividades cadastradas; +* Teste para visualização de atividades de interesse. -* Configuration -* Database creation +## ATRIBUIÇÕES -* Database initialization +### Scrum Master +#### Carlos Eduardo de Sousa - 160057701 -* How to run the test suite +### Product Owner +#### Kalley Wilkerson Rodrigues Alexandre - 170038050 -* Services (job queues, cache servers, search engines, etc.) - -* Deployment instructions - -* ... +## Problemas +Não foi possível fazer uma boa verificação se o usuário logado é administrador ou não à tempo, a execução do cucumber não permite o acesso a dados da sessão. Portanto, o método que a gente criou que fazia essa verificação, por mais que funcionasse como esperado na execução normal da aplicação, não funcionava nos testes. diff --git a/app/assets/javascripts/user_activities.coffee b/app/assets/javascripts/user_activities.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/user_activities.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/user_activities.scss b/app/assets/stylesheets/user_activities.scss new file mode 100644 index 00000000..5d2fe634 --- /dev/null +++ b/app/assets/stylesheets/user_activities.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the UserActivities 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/activities_controller.rb b/app/controllers/activities_controller.rb new file mode 100644 index 00000000..0f5b3efc --- /dev/null +++ b/app/controllers/activities_controller.rb @@ -0,0 +1,41 @@ +class ActivitiesController < ApplicationController + def index + @activities = Activity.all + end + + def new + end + + def create + @activity = Activity.new(activity_params) + if @activity.save + flash[:notice] = "Atividade cadastrada com sucesso." + redirect_to activities_path + elsif @activity.errors.any? + flash[:notice] = ["Atividade não cadastrada."] + @activity.errors.each do |attribute, message| + flash[:notice] << message + end + redirect_back(fallback_location: new_activity_path) + end + end + + def destroy + @activity = Activity.find(params[:id]) + if @activity.destroy + flash[:notice] = "Atividade deleteda com sucesso." + redirect_to activities_path + elsif @activity.errors.any? + flash[:notice] = ["Não foi possível deletar a Atividade."] + @activity.errors.each do |attribute, message| + flash[:notice] << message + end + redirect_back(fallback_location: root_path) + end + end + + private + def activity_params + params.fetch(:activity, {}).permit(:title, :due_date) + end +end \ No newline at end of file diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb new file mode 100644 index 00000000..3fe2754b --- /dev/null +++ b/app/controllers/notifications_controller.rb @@ -0,0 +1,6 @@ +class NotificationsController < ApplicationController + def create + flash[:notice] = "Notificação enviada aos interessados com sucesso." + redirect_to activities_path + end +end \ No newline at end of file diff --git a/app/controllers/user_activities_controller.rb b/app/controllers/user_activities_controller.rb new file mode 100644 index 00000000..044eb1bb --- /dev/null +++ b/app/controllers/user_activities_controller.rb @@ -0,0 +1,78 @@ +class UserActivitiesController < ApplicationController + def index + @user_activities = UserActivity.all + end + + def new + end + + def create + @user_activity = UserActivity.new(user_activity_params) + if @user_activity.save + notify(@user_activity.user_id, @user_activity.activity_id, "cadastrado") + redirect_to user_activities_path + elsif @user_activity.errors.any? + error(@user_activity.user_id, @user_activity.activity_id, "cadastrar") + end + end + + def self.create(user_id, activity_id) + if UserActivity.find_by(user_id: user_id, activity_id: activity_id) == nil + @user_activity = UserActivity.new + @user_activity.user_id = user_id + @user_activity.activity_id = activity_id + @user_activity.interested = true + @user_activity.active = false + @user_activity.save! + end + end + + def show + @user_activity = find + end + + def edit + @user_activity = find + end + + def update + @user_activity = find + if @user_activity.update(update_user_activity_params) + notify(UserActivity.getUser(@user_activity.user_id), UserActivity.getActivity(@user_activity.activity_id), "atualizado") + redirect_to user_activities_path + elsif @user_activity.errors.any? + error(UserActivity.getUser(@user_activity.user_id), UserActivity.getActivity(@user_activity.activity_id), "atualizar") + end + end + + def destroy + @user_activity = find + if @user_activity.destroy + notify(UserActivity.getUser(@user_activity.user_id), UserActivity.getActivity(@user_activity.activity_id), "deletado") + redirect_to user_activities_path + elsif @user_activity.errors.any? + error(UserActivity.getUser(@user_activity.user_id), UserActivity.getActivity(@user_activity.activity_id), "deletar") + end + end + + private + def user_activity_params + params.require(:user_activity).permit(:user_id, :activity_id) + end + + def update_user_activity_params + params.require(:user_activity).permit(:user_id, :activity_id, :interested, :active) + end + + def find + UserActivity.find(params[:id]) + end + + def notify(name, title, msg) + flash[:notice] = "#{title} #{msg} de #{name} com sucesso" + end + + def error(name, title, msg) + flash[:notice] = "Não foi possível #{msg} #{name} de #{title}" + end +end diff --git a/app/helpers/user_activities_helper.rb b/app/helpers/user_activities_helper.rb new file mode 100644 index 00000000..e948cfad --- /dev/null +++ b/app/helpers/user_activities_helper.rb @@ -0,0 +1,2 @@ +module UserActivitiesHelper +end diff --git a/app/models/activity.rb b/app/models/activity.rb new file mode 100644 index 00000000..0944d131 --- /dev/null +++ b/app/models/activity.rb @@ -0,0 +1,4 @@ +class Activity < ApplicationRecord + validates :title, presence: { message: "O Nome da atividade deve ser informado." } + validates :due_date, presence: { message: "O Prazo de execução da atividade deve ser informado." } +end diff --git a/app/models/user_activity.rb b/app/models/user_activity.rb new file mode 100644 index 00000000..419a1c6c --- /dev/null +++ b/app/models/user_activity.rb @@ -0,0 +1,12 @@ +class UserActivity < ApplicationRecord + validates :user_id, presence: { message: "Usuário deve ser informado." } + validates :activity_id, presence: { message: "Atividade deve ser informada." } + + def self.getUser(user_id) + User.find_by(id: user_id).full_name + end + + def self.getActivity(activity_id) + Activity.find_by(id: activity_id).title + end +end diff --git a/app/views/activities/index.html.erb b/app/views/activities/index.html.erb new file mode 100644 index 00000000..e998d60c --- /dev/null +++ b/app/views/activities/index.html.erb @@ -0,0 +1,27 @@ +

Atividades

+ +<%= link_to 'Adicionar atividade', new_activity_path %> +
+<%= link_to 'Notificar integrantes', new_notification_path %> + + + + + + + + + + <% @activities.each do |activity| %> + + + + + + + + + <% end %> +
TítuloPrazo de execuçãoDescrição
<%= activity.title %><%= activity.due_date.to_formatted_s(:rfc822) %><%= activity.description %><%= check_box_tag(:interest, false, false, :onclick => "UserActivitiesController.create(current_user.id, activity.id);") %>Demonstrar Interesse<%= link_to 'Remover Atividade', activity_path(activity), :method => :delete, :confirm => 'Tem certeza ?' %>
+
+<%= link_to 'Minhas Atividades de interesse', user_activities_path %> \ No newline at end of file diff --git a/app/views/activities/new.html.erb b/app/views/activities/new.html.erb new file mode 100644 index 00000000..b306de82 --- /dev/null +++ b/app/views/activities/new.html.erb @@ -0,0 +1,17 @@ +

Cadastrar nova atividade

+ +<%= form_with scope: :activity, url: activities_path,local: true do |form| %> +

+ <%= form.label :title, "Nome da atividade" %>
+ <%= form.text_field :title %> +

+ +

+ <%= form.label :due_date, "Prazo de execução" %>
+ <%= form.date_field :due_date %> +

+ +

+ <%= form.submit "Salvar" %> +

+<% end %> \ No newline at end of file diff --git a/app/views/notifications/index.html.erb b/app/views/notifications/index.html.erb new file mode 100644 index 00000000..2c9cd80a --- /dev/null +++ b/app/views/notifications/index.html.erb @@ -0,0 +1 @@ +

Notifications

\ No newline at end of file diff --git a/app/views/notifications/new.html.erb b/app/views/notifications/new.html.erb new file mode 100644 index 00000000..0882d86d --- /dev/null +++ b/app/views/notifications/new.html.erb @@ -0,0 +1,22 @@ +

Criar nova notificação

+ +<%= form_with scope: :notification, url: notifications_path,local: true do |form| %> + +

+ <%= form.label :title, "Nome da notificação" %>
+ <%= form.text_field :title %> +

+ +

+ <%= form.label :content, "Conteúdo da notificação" %>
+ <%= form.text_area :content %> +

+ +

+ <%= form.label :interested, "Integrantes interessados" %>
+ <%= form.collection_select(:interested, User.roles, :second, :first) %> +

+

+ <%= form.submit "Enviar notificação" %> +

+<% end %> \ No newline at end of file diff --git a/app/views/user_activities/edit.html.erb b/app/views/user_activities/edit.html.erb new file mode 100644 index 00000000..4e5c4652 --- /dev/null +++ b/app/views/user_activities/edit.html.erb @@ -0,0 +1,35 @@ +

Cadastrar Usúario na Atividade

+ +<%= form_with(model: @user_activity, local: true) do |form| %> +

+ <%= form.label :user_id, "Id do usupario" %>
+ <%= form.text_field :user_id, value: @user_activity.user_id %> +

+ +

+ <%= form.label :activity_id, " Id da Atividade" %>
+ <%= form.text_field :activity_id, value: @user_activity.activity_id %> +

+ +

+ <%= form.label :interested, "Interessado" %>
+ <%= form.radio_button :interested, "True", :checked => true %> + <%= form.label :active, "True" %> + <%= form.radio_button :interested, "False" %> + <%= form.label :active, "False" %> +

+ +

+ <%= form.label :active, "Cadastrado" %>
+ <%= form.radio_button :active, "True" %> + <%= form.label :active, "True" %> + <%= form.radio_button :active, "False" %> + <%= form.label :active, value: "False" %> +

+ +

+ <%= form.submit "Salvar" %> +

+<% end %> + +<%= link_to 'Back', user_activities_path %> diff --git a/app/views/user_activities/index.html.erb b/app/views/user_activities/index.html.erb new file mode 100644 index 00000000..2cb9eb1c --- /dev/null +++ b/app/views/user_activities/index.html.erb @@ -0,0 +1,26 @@ +

Minhas Atividades de Interesse

+ + + + + + + + + + + <% @user_activities.each do |user_activity| %> + + + + + + + + + + <% end %> +
UsuárioAtividadeInteresadoCadastrado
<%= UserActivity.getUser(user_activity.user_id) %><%= UserActivity.getActivity(user_activity.activity_id) %><%= user_activity.interested %><%= user_activity.active %><%= link_to 'Cadastrar Usuário', edit_user_activity_path(user_activity) %><%= link_to 'Remover Interesse', user_activity_path(user_activity), :method => :delete, :confirm => 'Tem certeza ?' %> +
+ +<%= link_to 'Voltar a Atividades', activities_path %> diff --git a/config/routes.rb b/config/routes.rb index f33f7f68..a9957dc5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,6 +3,12 @@ Rails.application.routes.draw do get 'home/index' devise_for :users + + resources :activities + resources :notifications + + resources :user_activities + # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html root to: 'home#index' end diff --git a/db/migrate/20201110171424_create_activities.rb b/db/migrate/20201110171424_create_activities.rb new file mode 100644 index 00000000..087a6c9e --- /dev/null +++ b/db/migrate/20201110171424_create_activities.rb @@ -0,0 +1,12 @@ +class CreateActivities < ActiveRecord::Migration[5.2] + def change + create_table :activities do |t| + t.string :title, null: false + t.string :description + t.date :due_date + t.binary :documents + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 96d61d72..daeefa2a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,11 +10,20 @@ # # 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_11_10_171424) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" + create_table "activities", force: :cascade do |t| + t.string "title", null: false + t.string "description" + t.date "due_date" + t.binary "documents" + 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 diff --git a/features/addActivity.feature b/features/addActivity.feature new file mode 100644 index 00000000..106f032d --- /dev/null +++ b/features/addActivity.feature @@ -0,0 +1,26 @@ +#language: pt + +Funcionalidade: Usuário pode adicionar uma atividade + + Como um administrador, para que eu tenha controle das atividades, + eu gostaria de cadastrar uma nova atividade e seu prazo de execução + +Cenário: Adicionar atividade de teste com sucesso + Dado que estou logado com usuário "admin@admin.com" e senha "admin123" + Dado que estou em "activities" + Quando clico em "Adicionar atividade" + Então devo ser redirecionado para "activities/new" + E devo ver "Cadastrar nova atividade" + Quando preencho "Nome da atividade" com o valor "Teste" + E preencho "Prazo de execução" com a data "30/04/1999" + E clico em "Salvar" + E devo ver "Atividade cadastrada com sucesso." + +Cenário: Adicionar atividade de teste sem sucesso + Dado que estou logado com usuário "admin@admin.com" e senha "admin123" + Dado que estou em "activities" + Quando clico em "Adicionar atividade" + Então devo ser redirecionado para "activities/new" + Quando preencho "Nome da atividade" com o valor "Teste 2" + E clico em "Salvar" + Então devo ver "O Prazo de execução da atividade deve ser informado." \ No newline at end of file diff --git a/features/addPersonOnActivite.feature b/features/addPersonOnActivite.feature new file mode 100644 index 00000000..5c7f1f38 --- /dev/null +++ b/features/addPersonOnActivite.feature @@ -0,0 +1,24 @@ +#language: pt + +Funcionalidade: Usuário pode adicionar pessoa interessada em uma atividade + + Como um administrador, para que eu possa informar a comunidade, eu gostaria de adicionar pessoas interessadas em cada atividade + + # Cenário Feliz + Cenário: Adicionar pessoa em atividade + Dado que estou logado com usuário "admin@admin.com" e senha "admin123" + Dado que estou na página "Atividades" + Quando eu clico em "Adicionar integrante" + Então eu devo ser redirecionado para "Cadastrar_novo_integrante" + Quando preencho o campo "Nome" com "Teste" + E preencho o campo "Email" com "teste@teste" + Então eu devo ser redirecionado para "Atividades" + E eu devo ver "Pessoa adicionada à atividade com sucesso" + + #Cenário Triste + Cenário: Página não encontrada + Dado que estou logado com usuário "admin@admin.com" e senha "admin123" + Dado que estou na página "Atividades" + Quando eu clico em "Adicionar pessoa interessada" + Então eu devo ser redirecionado para "404" + E eu devo ver "Página não encontrada" \ No newline at end of file diff --git a/features/notifyInterestedPeople.feature b/features/notifyInterestedPeople.feature new file mode 100644 index 00000000..4a38e7b6 --- /dev/null +++ b/features/notifyInterestedPeople.feature @@ -0,0 +1,30 @@ +#language: pt + +Funcionalidade: Administrador notificar as pessoas interessadas + + Como um administrador, + Para que eu possa notificar as pessoas interessadas em alguma atividade, + Eu gostaria de notificar as pessoas interessadas + + #Cenário feliz + Cenário: Notificar pessoas interessadas + Dado que estou logado com usuário "admin@admin.com" e senha "admin123" + Dado que eu me encontro na página "activities" + Quando pressiono "Notificar integrantes" + Então eu devo estar em "/notifications/new" + Quando preencho o campo "Nome da notificação" com "Título notificação" + E preencho o campo "Conteúdo da notificação" com "Conteúdo notificação" + Quando no campo "Integrantes interessados" eu seleciono "administrator" + E pressiono "Enviar notificação" + Então eu devo conseguir ver "Notificação enviada aos interessados com sucesso." + + #Cenário triste + Cenário: Página não encontrada + Dado que eu me encontro na página "activities" + Quando pressiono "Notificar integrantes" + Então devo ser redirecionado para a página "404" + E eu devo conseguir ver "The page you were looking for doesn't exist." + +#estou contando que "Atividades" seja a página home de administração + + diff --git a/features/showInterestActivity.feature b/features/showInterestActivity.feature new file mode 100644 index 00000000..6d98a45e --- /dev/null +++ b/features/showInterestActivity.feature @@ -0,0 +1,28 @@ +#language: en + +#Como um usuário, para que eu possa me informar, +#eu gostaria de ver as atividades que eu demonstrei interesse #40 + +Feature: User actions + To use calendar + As a system user + I would like to see interests activities + + Background: User logged in + Given I am on the '/' page and clik on 'Entrar' + And I fill in 'email' with 'student@student.com' + And I fill in 'password' with 'admin123' + When I press 'Log in' + Then I should be on '/' + + Scenario: See Activities page + Given I am on the 'activities' page + When I check 'teste aluno' + And I press 'Marcar interesse' + Then I should be on 'activities' page + + Scenario: See Calendar page + Given I am on the 'activities' page + When I check 'Mostrar apenas minhas atividades de interesse' + Then I should see on 'activities' page only 'interests activities' + diff --git a/features/step_definitions/addActivity_steps.rb b/features/step_definitions/addActivity_steps.rb new file mode 100644 index 00000000..8c1cf564 --- /dev/null +++ b/features/step_definitions/addActivity_steps.rb @@ -0,0 +1,31 @@ +Dado("que estou logado com usuário {string} e senha {string}") do |string, string2| + visit '/' + click_on 'Entrar' + fill_in 'Email', with: string + fill_in 'Password', with: string2 + click_on 'Log in' +end + +Dado("que estou em {string}") do |string| + visit "/#{string.downcase}" +end + +Quando("clico em {string}") do |string| + click_on string +end + +Então("devo ser redirecionado para {string}") do |string| + visit "/#{string.downcase}" +end + +Quando("preencho {string} com o valor {string}") do |string, string2| + fill_in string, with: string2 +end + +Quando("preencho {string} com a data {string}") do |string, string2| + fill_in string, with: string2 +end + +Então("devo ver {string}") do |string| + expect(page).to have_content string +end \ No newline at end of file diff --git a/features/step_definitions/addPersonOnActivite_steps.rb b/features/step_definitions/addPersonOnActivite_steps.rb new file mode 100644 index 00000000..90ca5e27 --- /dev/null +++ b/features/step_definitions/addPersonOnActivite_steps.rb @@ -0,0 +1,19 @@ +Dado("que estou na página {string}") do |string| + visit "localhost:3000/#{string.downcase}" +end + +Quando("eu clico em {string}") do |string| + click_on string +end + +Então("eu devo ser redirecionado para {string}") do |string| + visit "localhost:3000/#{string.downcase}" +end + +Quando("preencho o campo {string} com {string}") do |string1, string2| + fill_in string1, with: string2 +end + +E("eu devo ver {string}") do |string| + expect(page).to have_content string +end \ No newline at end of file diff --git a/features/step_definitions/notifyInterestedPeople_step.rb b/features/step_definitions/notifyInterestedPeople_step.rb new file mode 100644 index 00000000..3f90a5ad --- /dev/null +++ b/features/step_definitions/notifyInterestedPeople_step.rb @@ -0,0 +1,31 @@ + +#Cenário feliz +Dado("que eu me encontro na página {string}") do |string| + visit "/#{string.downcase}" +end + +Quando("pressiono {string}") do |string| + click_on(string) +end + +Então("eu devo estar em {string}") do |string| + expect(page).to have_current_path(string) +end + +Quando("preencho o campo {string} com os {string}") do |string1, string2| + fill_in string1, with: string2 +end + +Quando("no campo {string} eu seleciono {string}") do |string1, string2| + select string2, :from => string1 +end + + +Então("eu devo conseguir ver {string}") do |string| + expect(page).to have_content string +end + +#Cenário triste +Então("devo ser redirecionado para a página {string}") do |string| + visit "/#{string.downcase}" +end \ No newline at end of file diff --git a/features/step_definitions/showInterestActivity_steps.rb b/features/step_definitions/showInterestActivity_steps.rb new file mode 100644 index 00000000..8e67c675 --- /dev/null +++ b/features/step_definitions/showInterestActivity_steps.rb @@ -0,0 +1,36 @@ +Given("I am on the {string} page and clik on {string}") do |string1, string2| + visit string1 + click_on string2 + end + +And("I fill in 'email' with {string}") do |string| + fill_in 'Email', with: string +end + +And("I fill in 'password' with {string}") do |string| + fill_in 'Password', with: string +end + +And("I press {string}") do |string| + click_on string +end + +Then("I should be on {string}") do |string| + visit "/" +end + +Given("I am on the {string} page") do |string| + visit string +end + +Then("I should be on {string} page") do |string| + visit "localhost:3000/#{string.downcase}" +end + +When("I check {string}") do |string| + check string +end + +Then("I should see on 'calendar' page only {string}") do |string| + visit "localhost:3000/#{string.downcase}" +end diff --git a/index.html.erb b/index.html.erb new file mode 100644 index 00000000..0124d5eb --- /dev/null +++ b/index.html.erb @@ -0,0 +1,25 @@ +

Atividades

+ +<%= link_to 'Adicionar atividade', new_activity_path %> + + + + + + + + + + <% @activities.each do |activity| %> + + + + + + + + + <% end %> +
TítuloPrazo de execuçãoDescrição
<%= activity.title %><%= activity.due_date.to_formatted_s(:rfc822) %><%= activity.description %><%= check_box_tag(:interest, false, false, :onclick => "UserActivitiesController.create(current_user.id, activity.id);") %>Demonstrar Interesse<%= link_to 'Remover Atividade', activity_path(activity), :method => :delete, :confirm => 'Tem certeza ?' %>
+
+<%= link_to 'Minhas Atividades de interesse', user_activities_path %> \ No newline at end of file diff --git a/spec/addPersonOnActivite_spec.rb b/spec/addPersonOnActivite_spec.rb new file mode 100644 index 00000000..39b4232c --- /dev/null +++ b/spec/addPersonOnActivite_spec.rb @@ -0,0 +1,19 @@ +require 'rails_helper' + +RSpec.describe ".addPersonOnActivite" do + let(:uri) {'/Atividades'} + + context "Adicionar pessoa em atividade" do + let(:person) {Activity.addPerson("admin@admin.com", "admin123")} + + it "Mostra menssagem" do + page.driver.get uri + except(page.status_code).to be 200 + is_expected.to have "Pessoa adicionada com sucesso" + end + end + + context "Quando não encontrado" do + it {is_expected.to equal 404} + end +end \ No newline at end of file diff --git a/spec/controllers/activities_controller_spec.rb b/spec/controllers/activities_controller_spec.rb new file mode 100644 index 00000000..5b0349d2 --- /dev/null +++ b/spec/controllers/activities_controller_spec.rb @@ -0,0 +1,22 @@ +require 'rails_helper' + +describe ActivitiesController, type: :controller do + describe 'create a new Activity' do + it 'should call the model method that creates a new Activity' do + activity_attrs = attributes_for(:activity) + expect {post :create, params: {activity: activity_attrs}}.to change(Activity, :count).by(1) + end + + it 'should go back to the activities page after a successfully addition' do + activity_attrs = attributes_for(:activity) + post :create, params: {activity: activity_attrs} + expect(response).to redirect_to(activities_path) + end + + it 'should redirect to the same page when there was an error after adding an activity ' do + activity_attrs = attributes_for(:activity, title: "Testing the wrong way", due_date: nil) + post :create, params: {activity: activity_attrs} + expect(response).to redirect_to(new_activity_path) + end + end +end \ No newline at end of file diff --git a/spec/controllers/user_activities_controller_spec.rb b/spec/controllers/user_activities_controller_spec.rb new file mode 100644 index 00000000..7bb969b1 --- /dev/null +++ b/spec/controllers/user_activities_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe UserActivitiesController, type: :controller do + +end diff --git a/spec/factories.rb b/spec/factories.rb new file mode 100644 index 00000000..8b8458c0 --- /dev/null +++ b/spec/factories.rb @@ -0,0 +1,6 @@ +FactoryBot.define do + factory :activity do + title {"Testar"} + due_date {"30/04/1999"} + end +end \ No newline at end of file diff --git a/spec/helpers/user_activities_helper_spec.rb b/spec/helpers/user_activities_helper_spec.rb new file mode 100644 index 00000000..c1993ae3 --- /dev/null +++ b/spec/helpers/user_activities_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the UserActivitiesHelper. For example: +# +# describe UserActivitiesHelper 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 UserActivitiesHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/activity_spec.rb b/spec/models/activity_spec.rb new file mode 100644 index 00000000..b80b07e7 --- /dev/null +++ b/spec/models/activity_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Activity, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/user_activity_spec.rb b/spec/models/user_activity_spec.rb new file mode 100644 index 00000000..417dfa25 --- /dev/null +++ b/spec/models/user_activity_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe UserActivity, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/notifyInterestedPeople_spec.rb b/spec/notifyInterestedPeople_spec.rb new file mode 100644 index 00000000..a64ab365 --- /dev/null +++ b/spec/notifyInterestedPeople_spec.rb @@ -0,0 +1,19 @@ +require 'rails_helper' + +RSpec.describe ".notifyInterestedPeople" do + let(:uri) {'/Atividades'} + + context "Notificar pessoas interessadas" do + let(:admin) {Activite.selectInterestedPeople("Estudantes")} + + it "Mostrar mensagem" do + page.driver.get uri + except(page.status_code).to be 200 + is_expected.to have "Notificação enviada aos interessados com sucesso" + end + end + + context "Página não encontrada" do + it {is_expected.to equal 404} + end +end diff --git a/spec/showInterestActivities_spec.rb b/spec/showInterestActivities_spec.rb new file mode 100644 index 00000000..e5c300fd --- /dev/null +++ b/spec/showInterestActivities_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +RSpec.describe ".showInterestActivities" do + let(:uri) {'/Calendar'} + + context "Mostrar atividades de interesse" do + let(:activities) {showInterestActivities} + + it "Mostra menssagem" do + page.driver.get uri + except(page.status_code).to be 200 + is_expected.to have "localhost:3000/Calendar" + end + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ce33d66d..97f940d7 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,96 +1,102 @@ -# This file was generated by the `rails generate rspec:install` command. Conventionally, all -# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. -# The generated `.rspec` file contains `--require spec_helper` which will cause -# this file to always be loaded, without a need to explicitly require it in any -# files. -# -# Given that it is always loaded, you are encouraged to keep this file as -# light-weight as possible. Requiring heavyweight dependencies from this file -# will add to the boot time of your test suite on EVERY test run, even for an -# individual file that may not need all of that loaded. Instead, consider making -# a separate helper file that requires the additional dependencies and performs -# the additional setup, and require it from the spec files that actually need -# it. -# -# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration -RSpec.configure do |config| - # rspec-expectations config goes here. You can use an alternate - # assertion/expectation library such as wrong or the stdlib/minitest - # assertions if you prefer. - config.expect_with :rspec do |expectations| - # This option will default to `true` in RSpec 4. It makes the `description` - # and `failure_message` of custom matchers include text for helper methods - # defined using `chain`, e.g.: - # be_bigger_than(2).and_smaller_than(4).description - # # => "be bigger than 2 and smaller than 4" - # ...rather than: - # # => "be bigger than 2" - expectations.include_chain_clauses_in_custom_matcher_descriptions = true - end - - # rspec-mocks config goes here. You can use an alternate test double - # library (such as bogus or mocha) by changing the `mock_with` option here. - config.mock_with :rspec do |mocks| - # Prevents you from mocking or stubbing a method that does not exist on - # a real object. This is generally recommended, and will default to - # `true` in RSpec 4. - mocks.verify_partial_doubles = true - end - - # This option will default to `:apply_to_host_groups` in RSpec 4 (and will - # have no way to turn it off -- the option exists only for backwards - # compatibility in RSpec 3). It causes shared context metadata to be - # inherited by the metadata hash of host groups and examples, rather than - # triggering implicit auto-inclusion in groups with matching metadata. - config.shared_context_metadata_behavior = :apply_to_host_groups - -# The settings below are suggested to provide a good initial experience -# with RSpec, but feel free to customize to your heart's content. -=begin - # This allows you to limit a spec run to individual examples or groups - # you care about by tagging them with `:focus` metadata. When nothing - # is tagged with `:focus`, all examples get run. RSpec also provides - # aliases for `it`, `describe`, and `context` that include `:focus` - # metadata: `fit`, `fdescribe` and `fcontext`, respectively. - config.filter_run_when_matching :focus - - # Allows RSpec to persist some state between runs in order to support - # the `--only-failures` and `--next-failure` CLI options. We recommend - # you configure your source control system to ignore this file. - config.example_status_persistence_file_path = "spec/examples.txt" - - # Limits the available syntax to the non-monkey patched syntax that is - # recommended. For more details, see: - # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ - # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ - # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode - config.disable_monkey_patching! - - # Many RSpec users commonly either run the entire suite or an individual - # file, and it's useful to allow more verbose output when running an - # individual spec file. - if config.files_to_run.one? - # Use the documentation formatter for detailed output, - # unless a formatter has already been configured - # (e.g. via a command-line flag). - config.default_formatter = "doc" - end - - # Print the 10 slowest examples and example groups at the - # end of the spec run, to help surface which specs are running - # particularly slow. - config.profile_examples = 10 - - # Run specs in random order to surface order dependencies. If you find an - # order dependency and want to debug it, you can fix the order by providing - # the seed, which is printed after each run. - # --seed 1234 - config.order = :random - - # Seed global randomization in this process using the `--seed` CLI option. - # Setting this allows you to use `--seed` to deterministically reproduce - # test failures related to randomization by passing the same `--seed` value - # as the one that triggered the failure. - Kernel.srand config.seed -=end -end +require 'support/factory_bot' + +# This file was generated by the `rails generate rspec:install` command. Conventionally, all +# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. +# The generated `.rspec` file contains `--require spec_helper` which will cause +# this file to always be loaded, without a need to explicitly require it in any +# files. +# +# Given that it is always loaded, you are encouraged to keep this file as +# light-weight as possible. Requiring heavyweight dependencies from this file +# will add to the boot time of your test suite on EVERY test run, even for an +# individual file that may not need all of that loaded. Instead, consider making +# a separate helper file that requires the additional dependencies and performs +# the additional setup, and require it from the spec files that actually need +# it. +# +# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +RSpec.configure do |config| + # rspec-expectations config goes here. You can use an alternate + # assertion/expectation library such as wrong or the stdlib/minitest + # assertions if you prefer. + config.expect_with :rspec do |expectations| + # This option will default to `true` in RSpec 4. It makes the `description` + # and `failure_message` of custom matchers include text for helper methods + # defined using `chain`, e.g.: + # be_bigger_than(2).and_smaller_than(4).description + # # => "be bigger than 2 and smaller than 4" + # ...rather than: + # # => "be bigger than 2" + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + # rspec-mocks config goes here. You can use an alternate test double + # library (such as bogus or mocha) by changing the `mock_with` option here. + config.mock_with :rspec do |mocks| + # Prevents you from mocking or stubbing a method that does not exist on + # a real object. This is generally recommended, and will default to + # `true` in RSpec 4. + mocks.verify_partial_doubles = true + end + + # This option will default to `:apply_to_host_groups` in RSpec 4 (and will + # have no way to turn it off -- the option exists only for backwards + # compatibility in RSpec 3). It causes shared context metadata to be + # inherited by the metadata hash of host groups and examples, rather than + # triggering implicit auto-inclusion in groups with matching metadata. + config.shared_context_metadata_behavior = :apply_to_host_groups + +# The settings below are suggested to provide a good initial experience +# with RSpec, but feel free to customize to your heart's content. +=begin + # This allows you to limit a spec run to individual examples or groups + # you care about by tagging them with `:focus` metadata. When nothing + # is tagged with `:focus`, all examples get run. RSpec also provides + # aliases for `it`, `describe`, and `context` that include `:focus` + # metadata: `fit`, `fdescribe` and `fcontext`, respectively. + config.filter_run_when_matching :focus + + # Allows RSpec to persist some state between runs in order to support + # the `--only-failures` and `--next-failure` CLI options. We recommend + # you configure your source control system to ignore this file. + config.example_status_persistence_file_path = "spec/examples.txt" + + # Limits the available syntax to the non-monkey patched syntax that is + # recommended. For more details, see: + # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ + # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ + # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode + config.disable_monkey_patching! + + # This setting enables warnings. It's recommended, but in some cases may + # be too noisy due to issues in dependencies. + config.warnings = true + + # Many RSpec users commonly either run the entire suite or an individual + # file, and it's useful to allow more verbose output when running an + # individual spec file. + if config.files_to_run.one? + # Use the documentation formatter for detailed output, + # unless a formatter has already been configured + # (e.g. via a command-line flag). + config.default_formatter = "doc" + end + + # Print the 10 slowest examples and example groups at the + # end of the spec run, to help surface which specs are running + # particularly slow. + config.profile_examples = 10 + + # Run specs in random order to surface order dependencies. If you find an + # order dependency and want to debug it, you can fix the order by providing + # the seed, which is printed after each run. + # --seed 1234 + config.order = :random + + # Seed global randomization in this process using the `--seed` CLI option. + # Setting this allows you to use `--seed` to deterministically reproduce + # test failures related to randomization by passing the same `--seed` value + # as the one that triggered the failure. + Kernel.srand config.seed +=end +end diff --git a/spec/support/factory_bot.rb b/spec/support/factory_bot.rb new file mode 100644 index 00000000..72ba14df --- /dev/null +++ b/spec/support/factory_bot.rb @@ -0,0 +1,5 @@ +require 'factory_bot' + +RSpec.configure do |config| + config.include FactoryBot::Syntax::Methods +end \ No newline at end of file diff --git a/spec/views/user_activity/index.html.erb_spec.rb b/spec/views/user_activity/index.html.erb_spec.rb new file mode 100644 index 00000000..7b288226 --- /dev/null +++ b/spec/views/user_activity/index.html.erb_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe "user_activity/index.html.erb", type: :view do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/sprint_1-Grupo_1.md b/sprint_1-Grupo_1.md new file mode 100644 index 00000000..40e8779b --- /dev/null +++ b/sprint_1-Grupo_1.md @@ -0,0 +1,53 @@ +# GRUPO 1 + +* Carlos Eduardo de Sousa - 160057701 +* Edilton Costa Alves - 170002365 +* Eduardo Vaz Fagundes Rech - 180075161 +* Estevam Galvão Albuquerque - 160005663 +* Kalley Wilkerson Rodrigues Alexandre - 170038050 + + +## NOME DO PROJETO +#### Calendário de atividades - secretaria-ppgi + +## ESCOPO DO PROJETO +* Teste para cadastro de atividade e seu prazo de execução; +* Teste para inclusão de pessoas interessadas em cada atividade; +* Teste para notificação de pessoas interessadas; +* Teste para visualização de atividades cadastradas; +* Teste para visualização de atividades de interesse. + + +## ATRIBUIÇÕES +### Scrum Master +#### Kalley Wilkerson Rodrigues Alexandre - 170038050 + +### Product Owner +#### Edilton Costa Alves - 170002365 + +### Arquivo Markdown +#### Carlos Eduardo de Sousa - 160057701 + +### Funcionalidades desenvolvidas, regras de negócio e responsáveis para cada funcionalidade e Pontuação das histórias de usuários. +. +#### 36 (Pontuação: 1) - Como um administrador, para que eu tenha controle das atividades, eu gostaria de cadastrar uma nova atividade e seu prazo de execução +#### Responsável - Kalley Wilkerson Rodrigues Alexandre - 170038050 + +#### 37 (Pontuação: 2) - Como um administrador, para que eu possa informar a comunidade, eu gostaria de adicionar pessoas interessadas em cada atividade +#### Responsável - Eduardo Vaz Fagundes Rech - 180075161 + +#### 38 (Pontuação: 2) - Como um administrador, para que eu possa notificar as pessoas interessadas em alguma atividade, eu gostaria de notificar as pessoas interessadas +#### Responsável - Estevam Galvão Albuquerque - 160005663 + +#### 39 (Pontuação: 1) - Como um usuário, para que eu possa me informar, eu gostaria de ver as atividades cadastradas +#### Responsável - Edilton Costa Alves - 170002365 + +#### 40 (Pontuação: 2) - Como um usuário, para que eu possa me informar, eu gostaria de ver as atividades que eu demonstrei interesse +#### Responsável - Carlos Eduardo de Sousa - 160057701 + + + + + + +