From cb454379afa2cd2615732d320abd67d5c5860713 Mon Sep 17 00:00:00 2001 From: MaxAlmeida Date: Fri, 24 Oct 2014 00:03:37 -0200 Subject: [PATCH 001/198] Adding gem cucumber --- Gemfile | 1 + Gemfile.lock | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/Gemfile b/Gemfile index 7cec9c1..cdb4b21 100644 --- a/Gemfile +++ b/Gemfile @@ -18,6 +18,7 @@ gem 'rspec-its' group :development, :test do gem 'rspec-rails' gem 'guard-rspec' + gem 'cucumber' end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index 338697d..4a61a93 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -52,12 +52,20 @@ GEM execjs coffee-script-source (1.8.0) commonjs (0.2.7) + cucumber (1.3.17) + builder (>= 2.1.2) + diff-lcs (>= 1.1.3) + gherkin (~> 2.12) + multi_json (>= 1.7.5, < 2.0) + multi_test (>= 0.1.1) diff-lcs (1.2.5) docile (1.1.5) erubis (2.7.0) execjs (2.2.1) ffi (1.9.3) formatador (0.2.5) + gherkin (2.12.2) + multi_json (~> 1.3) guard (2.6.1) formatador (>= 0.2.4) listen (~> 2.7) @@ -93,6 +101,7 @@ GEM mime-types (1.25.1) mini_portile (0.6.0) multi_json (1.10.1) + multi_test (0.1.1) mysql2 (0.3.16) nokogiri (1.6.3.1) mini_portile (= 0.6.0) @@ -208,6 +217,7 @@ DEPENDENCIES bootstrap-will_paginate (= 0.0.6) capybara coffee-rails (~> 3.2.1) + cucumber guard-rspec jquery-rails less-rails From 5648bca9a87eac71e7478e690a41f342982922b0 Mon Sep 17 00:00:00 2001 From: Ricardo Lupiano Andrade Date: Fri, 24 Oct 2014 21:31:31 -0200 Subject: [PATCH 002/198] Creating test for customer_service index method --- spec/controllers/customer_service_controller_spec.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/spec/controllers/customer_service_controller_spec.rb b/spec/controllers/customer_service_controller_spec.rb index c23d8d2..652b841 100644 --- a/spec/controllers/customer_service_controller_spec.rb +++ b/spec/controllers/customer_service_controller_spec.rb @@ -13,11 +13,16 @@ genre_customer_service: "Grave", cep_customer_service: "11111111") end describe "GET show" do - it "should find the account by its id" do + it "should find the customer_service by its id" do get :show, :id => @customer_service.id assigns[:customer_service].description_subject_customer_service.should == "Atendimento" end end - + describe "GET index" do + it "should list all the customer_service" do + get :index + expect(response).to have_http_status(:success) + end + end end \ No newline at end of file From 5ef850f22c49d0454858cc8a53ef7425577a7905 Mon Sep 17 00:00:00 2001 From: Ricardo Lupiano Andrade Date: Fri, 24 Oct 2014 21:50:16 -0200 Subject: [PATCH 003/198] Creating test for user_controller index and allusers methods --- spec/controllers/user_controller_spec.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index 7fcf545..b34472d 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -27,6 +27,20 @@ it { should respond_to(:password) } it { should respond_to(:password_confirmation) } it { should be_valid } + describe "GET all users" do + + it "should get all users" do + get :allusers, {} + expect(assigns(:allusers)).to be(@users) + end + end + describe "GET index" do + + it "should get all users" do + get :index, {} + expect(assigns(:index)).to be(@users) + end + end describe "GET show" do From d4f49e6216c44acf58d495eec1b06b25c15e0381 Mon Sep 17 00:00:00 2001 From: Dylan Date: Sat, 25 Oct 2014 10:45:36 -0200 Subject: [PATCH 004/198] installing girlsfactory, changing unity_procon_controller spec name, improving sessionscontroller tests --- Gemfile | 1 + Gemfile.lock | 9 +++++++++ config/environments/test.rb | 7 +++++++ .../unity_procons_controller_spec.rb | 18 ++++++++++++++++++ spec/controllers/user_controller_spec.rb | 10 +--------- spec/factories.rb | 8 ++++++++ spec/helpers/sessions_helper_spec.rb | 10 ++++++++++ spec/models/user_spec.rb | 1 + 8 files changed, 55 insertions(+), 9 deletions(-) create mode 100644 spec/controllers/unity_procons_controller_spec.rb create mode 100644 spec/factories.rb diff --git a/Gemfile b/Gemfile index cdb4b21..2d2a89a 100644 --- a/Gemfile +++ b/Gemfile @@ -22,6 +22,7 @@ group :development, :test do end group :test do + gem 'factory_girl_rails', '4.1.0' gem 'selenium-webdriver' gem 'capybara' end diff --git a/Gemfile.lock b/Gemfile.lock index 4a61a93..d1227ca 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -62,6 +62,11 @@ GEM docile (1.1.5) erubis (2.7.0) execjs (2.2.1) + factory_girl (4.1.0) + activesupport (>= 3.0.0) + factory_girl_rails (4.1.0) + factory_girl (~> 4.1.0) + railties (>= 3.0.0) ffi (1.9.3) formatador (0.2.5) gherkin (2.12.2) @@ -217,7 +222,11 @@ DEPENDENCIES bootstrap-will_paginate (= 0.0.6) capybara coffee-rails (~> 3.2.1) + cucumber + + factory_girl_rails (= 4.1.0) +sessionscontroller tests guard-rspec jquery-rails less-rails diff --git a/config/environments/test.rb b/config/environments/test.rb index 6982910..21a1c9b 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -34,4 +34,11 @@ # Print deprecation notices to the stderr config.active_support.deprecation = :stderr + + # Speed up tests by lowering BCrypt's cost function. + require 'bcrypt' + silence_warnings do + BCrypt::Engine::DEFAULT_COST = BCrypt::Engine::MIN_COST + end + end diff --git a/spec/controllers/unity_procons_controller_spec.rb b/spec/controllers/unity_procons_controller_spec.rb new file mode 100644 index 0000000..39e8d91 --- /dev/null +++ b/spec/controllers/unity_procons_controller_spec.rb @@ -0,0 +1,18 @@ +require 'rails_helper' +require 'spec_helper' +require 'capybara/rspec' + +describe UnityProconsController, :type => :controller do + before do + @unity_procon = UnityProcon.create(address_unity_procon: "SQS BRASILIA", + name_coordinator_unity_procon: "Cordenador", uf_procon: "DF", + email_unity_procon: "procon@procon.com.br", list_phones: "123123123") + end + + describe "GET show" do + it "should find the account by its id" do + get :show, :id => @unity_procon.id + assigns[:unity_procon].address_unity_procon.should == "SQS BRASILIA" + end + end +end \ No newline at end of file diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index b34472d..73877e8 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -8,15 +8,7 @@ password: "teste1234", address_user: "DF", password_confirmation: "teste1234") end - let(:valid_attributes) { - skip(name_user: "UserTest", email_user: "usertest@test.com", - password: "teste1234", address_user: "DF") - } - - let(:invalid_attributes) { - skip(name_user: "", email_user: "emailerrado", - password: "zzzz", address_user: "") - } + let(:valid_session) { {} } diff --git a/spec/factories.rb b/spec/factories.rb new file mode 100644 index 0000000..85614a0 --- /dev/null +++ b/spec/factories.rb @@ -0,0 +1,8 @@ +FactoryGirl.define do + factory :user do + name "User Test" + email "usertest@test.com" + password "teste123" + password_confirmation "teste123" + end +end \ No newline at end of file diff --git a/spec/helpers/sessions_helper_spec.rb b/spec/helpers/sessions_helper_spec.rb index 4580117..741d390 100644 --- a/spec/helpers/sessions_helper_spec.rb +++ b/spec/helpers/sessions_helper_spec.rb @@ -31,4 +31,14 @@ sign_out expect(current_user).to be(nil) end + + it "expect current_uf to be uf from current_user" do + sign_in(@user) + expect(current_uf).to be(@user.address_user) + end + + it "expect current_uf to match method current_uf=" do + current_uf=(@user.address_user) + expect(current_uf).to equal(@user.address_user) + end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 68835bd..642a380 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -3,6 +3,7 @@ require 'rails_helper' describe User do + let(:user) { FactoryGirl.create(:user) } before do @user = User.new(name_user: "UserTest", email_user: "usertest@test.com", password: "teste1234", address_user: "DF", From 1f8d9a5115a4d57475def850b3e47d4d826f4ca0 Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Sat, 25 Oct 2014 12:24:38 -0200 Subject: [PATCH 005/198] new tests for methods index and ranking @unityprocons_controller_spec --- spec/controllers/unity_procons_controller_spec.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spec/controllers/unity_procons_controller_spec.rb b/spec/controllers/unity_procons_controller_spec.rb index 39e8d91..057dd65 100644 --- a/spec/controllers/unity_procons_controller_spec.rb +++ b/spec/controllers/unity_procons_controller_spec.rb @@ -15,4 +15,19 @@ assigns[:unity_procon].address_unity_procon.should == "SQS BRASILIA" end end + + describe "GET index" do + it "expect index to be valid" do + get :index, {} + expect(response).to have_http_status(:success) + end + end + + describe "GET ranking" do + it "expect ranking to be valid" do + get :ranking, {} + expect(response).to have_http_status(:success) + end + end + end \ No newline at end of file From c3237bc6c923e68c6fa8c64a24f666038e813afc Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Sat, 25 Oct 2014 12:32:12 -0200 Subject: [PATCH 006/198] changing unity_procon controller spec name, doing the pattern for the sessions_controller_spec --- spec/controllers/rating_controller_spec.rb | 9 +++++++ spec/controllers/sessions_controller_spec.rb | 24 +++++++++++++++++++ ...pec.rb => unity_procon_controller_spec.rb} | 0 spec/controllers/unity_procon_spec.rb | 18 -------------- 4 files changed, 33 insertions(+), 18 deletions(-) create mode 100644 spec/controllers/rating_controller_spec.rb rename spec/controllers/{unity_procons_controller_spec.rb => unity_procon_controller_spec.rb} (100%) delete mode 100644 spec/controllers/unity_procon_spec.rb diff --git a/spec/controllers/rating_controller_spec.rb b/spec/controllers/rating_controller_spec.rb new file mode 100644 index 0000000..f5e6c23 --- /dev/null +++ b/spec/controllers/rating_controller_spec.rb @@ -0,0 +1,9 @@ +require 'rails_helper' +require 'spec_helper' +require 'capybara/rspec' + +describe RatingsController, :type => :controller do + + + +end \ No newline at end of file diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index 2a8cb7d..0e44c94 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -3,6 +3,30 @@ require 'capybara/rspec' describe SessionsController, :type => :controller do + describe "POST destroy" do + it "expect destroy to delete current session" do + end + + it "expect destroy to redirect to root_url" do + end + end + + describe "POST create" do + it "expect user to be finded by email" do + end + + it "expect user finded to be signed" do + end + + it "expect signed user to be redirected to his profile" do + end + + it "expect invalid user to return error message" do + end + + it "expect invalid user to rerender the session view" do + end + end end \ No newline at end of file diff --git a/spec/controllers/unity_procons_controller_spec.rb b/spec/controllers/unity_procon_controller_spec.rb similarity index 100% rename from spec/controllers/unity_procons_controller_spec.rb rename to spec/controllers/unity_procon_controller_spec.rb diff --git a/spec/controllers/unity_procon_spec.rb b/spec/controllers/unity_procon_spec.rb deleted file mode 100644 index 39e8d91..0000000 --- a/spec/controllers/unity_procon_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'rails_helper' -require 'spec_helper' -require 'capybara/rspec' - -describe UnityProconsController, :type => :controller do - before do - @unity_procon = UnityProcon.create(address_unity_procon: "SQS BRASILIA", - name_coordinator_unity_procon: "Cordenador", uf_procon: "DF", - email_unity_procon: "procon@procon.com.br", list_phones: "123123123") - end - - describe "GET show" do - it "should find the account by its id" do - get :show, :id => @unity_procon.id - assigns[:unity_procon].address_unity_procon.should == "SQS BRASILIA" - end - end -end \ No newline at end of file From 09fbf979eef6962b706c3f852410e61b9cdbdf8c Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Sat, 25 Oct 2014 13:14:48 -0200 Subject: [PATCH 007/198] refactored almost every spec that uses an object with before to work with girls factory --- .../customer_service_controller_spec.rb | 8 +--- spec/controllers/supplier_controller_spec.rb | 6 +-- .../unity_procon_controller_spec.rb | 6 +-- spec/controllers/user_controller_spec.rb | 40 ++++++------------- spec/factories.rb | 39 +++++++++++++++++- spec/helpers/sessions_helper_spec.rb | 4 +- spec/models/customer_service_spec.rb | 8 +--- spec/models/supplier_spec.rb | 4 +- spec/models/unity_procon_spec.rb | 6 +-- spec/models/user_spec.rb | 14 +------ 10 files changed, 62 insertions(+), 73 deletions(-) diff --git a/spec/controllers/customer_service_controller_spec.rb b/spec/controllers/customer_service_controller_spec.rb index 652b841..e52cf23 100644 --- a/spec/controllers/customer_service_controller_spec.rb +++ b/spec/controllers/customer_service_controller_spec.rb @@ -4,13 +4,7 @@ describe CustomerServicesController, :type => :controller do before do - @customer_service = CustomerService.create(year_customer_service: "2014", - trimester_customer_service: "2", month_customer_service: "05", - date_customer_service: "2014-05-23", region_customer_service: "Centro-Oeste", - uf_customer_service: "DF", description_customer_service: "Atendimento realizado", - code_subject_customer_service: "2", description_subject_customer_service: "Atendimento", - code_problem_customer_service: "4", description_problem_customer_service: "Duvida", - genre_customer_service: "Grave", cep_customer_service: "11111111") + @customer_service = FactoryGirl.create(:customer_service) end describe "GET show" do it "should find the customer_service by its id" do diff --git a/spec/controllers/supplier_controller_spec.rb b/spec/controllers/supplier_controller_spec.rb index 83d78f7..e5e72bf 100644 --- a/spec/controllers/supplier_controller_spec.rb +++ b/spec/controllers/supplier_controller_spec.rb @@ -4,15 +4,13 @@ describe SuppliersController, :type => :controller do before do - @supplier = Supplier.create(type_supplier: "SupplierTes", social_reason_supplier: "Razao", - fantasy_name_supplier: "Sup", cnpj: "12000184002", cnaep_main_code_supplier: "123123123", - description_cnaep_code_supplier: "46456456546") + @supplier = FactoryGirl.create(:supplier) end describe "GET show" do it "should find the account by its id" do get :show, :id => @supplier.id - assigns[:supplier].type_supplier.should == "SupplierTes" + assigns[:supplier].type_supplier.should == "PessoaJuridica" end end diff --git a/spec/controllers/unity_procon_controller_spec.rb b/spec/controllers/unity_procon_controller_spec.rb index 057dd65..458afbf 100644 --- a/spec/controllers/unity_procon_controller_spec.rb +++ b/spec/controllers/unity_procon_controller_spec.rb @@ -4,15 +4,13 @@ describe UnityProconsController, :type => :controller do before do - @unity_procon = UnityProcon.create(address_unity_procon: "SQS BRASILIA", - name_coordinator_unity_procon: "Cordenador", uf_procon: "DF", - email_unity_procon: "procon@procon.com.br", list_phones: "123123123") + @unity_procon = FactoryGirl.create(:unity_procon) end describe "GET show" do it "should find the account by its id" do get :show, :id => @unity_procon.id - assigns[:unity_procon].address_unity_procon.should == "SQS BRASILIA" + assigns[:unity_procon].address_unity_procon.should == "Shopping Venancio" end end diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index 73877e8..a8cf7fe 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -4,64 +4,50 @@ describe UsersController, :type => :controller do before do - @user = User.create(name_user: "UserTes", email_user: "usertest@test.com", - password: "teste1234", address_user: "DF", - password_confirmation: "teste1234") + @user = FactoryGirl.create(:user) end - let(:valid_session) { {} } - - subject { @user } - it { should respond_to(:name_user) } - it { should respond_to(:email_user) } - it { should respond_to(:password_digest) } - it { should respond_to(:password) } - it { should respond_to(:password_confirmation) } - it { should be_valid } + #GET#allusers describe "GET all users" do - it "should get all users" do get :allusers, {} expect(assigns(:allusers)).to be(@users) end end + #GET#index describe "GET index" do - it "should get all users" do get :index, {} expect(assigns(:index)).to be(@users) end end - - describe "GET show" do - + #GET#show + describe "GET show" do it "should find the account by its id" do get :show, :id => @user.id - assigns[:user].name_user.should == "UserTes" + assigns[:user].name_user.should == "User Test" end - - describe "GET #new" do - it "assigns a new user as @user" do + end + #GET#new + describe "GET #new" do + it "assigns a new user as @user" do get :new, {} expect(assigns(:user)).to be_a_new(User) - end - end - + end end - + #GET#edit describe "GET edit" do it "assigns the requested place as @place" do get :edit, :id => @user.id expect(assigns(:user)).to eq(@user) end end - + #GET#new describe "GET new" do it "assigns all users as @users" do get :new, {}, valid_session expect(assigns(:user)).to be_a_new(User) end end - end \ No newline at end of file diff --git a/spec/factories.rb b/spec/factories.rb index 85614a0..08d6998 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -1,8 +1,43 @@ FactoryGirl.define do factory :user do - name "User Test" - email "usertest@test.com" + name_user "User Test" + email_user "teste@teste.com" password "teste123" password_confirmation "teste123" + address_user "DF" + end + + factory :supplier do + type_supplier "PessoaJuridica" + social_reason_supplier "Importante" + fantasy_name_supplier "Tchanananas" + cnpj "222777-13" + cnaep_main_code_supplier "aCnaepCode" + description_cnaep_code_supplier "aCnaepDescription" + end + + factory :customer_service do + year_customer_service "2014" + trimester_customer_service "2" + month_customer_service "05" + date_customer_service "2014-05-23" + region_customer_service "Centro-Oeste" + uf_customer_service "DF" + description_customer_service "Atendimento realizado" + code_subject_customer_service "2" + description_subject_customer_service "Atendimento" + code_problem_customer_service "4" + description_problem_customer_service "Duvida" + genre_customer_service "Grave" + cep_customer_service "11111111" + end + + factory :unity_procon do + address_unity_procon "Shopping Venancio" + name_coordinator_unity_procon "Roberto" + uf_procon "DF" + email_unity_procon "procon@procon.com" + list_phones "32323232" + position_unity_procon "1" end end \ No newline at end of file diff --git a/spec/helpers/sessions_helper_spec.rb b/spec/helpers/sessions_helper_spec.rb index 741d390..d71df75 100644 --- a/spec/helpers/sessions_helper_spec.rb +++ b/spec/helpers/sessions_helper_spec.rb @@ -4,9 +4,7 @@ describe SessionsHelper do before do - @user = User.create(name_user: "UserTes", email_user: "usertest@test.com", - password: "teste1234", address_user: "DF", - password_confirmation: "teste1234") + @user = FactoryGirl.create(:user) end it "expect signed user return signed_in = true" do diff --git a/spec/models/customer_service_spec.rb b/spec/models/customer_service_spec.rb index 11f3f12..120b5a1 100644 --- a/spec/models/customer_service_spec.rb +++ b/spec/models/customer_service_spec.rb @@ -4,11 +4,7 @@ describe CustomerService do before do - @customer_service = CustomerService.new(year_customer_service: "2014", trimester_customer_service: "2", - month_customer_service: "05", date_customer_service: "2014-05-23", region_customer_service: "Centro-Oeste", - uf_customer_service: "DF", description_customer_service: "Atendimento realizado", code_subject_customer_service: "2", - description_subject_customer_service: "Atendimento", code_problem_customer_service: "4", - description_problem_customer_service: "Duvida", genre_customer_service: "Grave", cep_customer_service: "11111111") + @customer_service = FactoryGirl.create(:customer_service) end subject { @customer_service } @@ -25,6 +21,4 @@ it { should respond_to(:description_problem_customer_service) } it { should respond_to(:genre_customer_service) } it { should respond_to(:cep_customer_service) } - - end \ No newline at end of file diff --git a/spec/models/supplier_spec.rb b/spec/models/supplier_spec.rb index 39489fe..762b950 100644 --- a/spec/models/supplier_spec.rb +++ b/spec/models/supplier_spec.rb @@ -4,9 +4,7 @@ describe Supplier do before do - @supplier = Supplier.new(type_supplier: "PessoaJuridica", social_reason_supplier: "Importante", - fantasy_name_supplier: "Tchanananas", cnpj: "222777-13", cnaep_main_code_supplier: "blablabla", - description_cnaep_code_supplier: "blablablas") + @supplier = FactoryGirl.create(:supplier) end subject { @supplier } diff --git a/spec/models/unity_procon_spec.rb b/spec/models/unity_procon_spec.rb index f3770a7..c440e6b 100644 --- a/spec/models/unity_procon_spec.rb +++ b/spec/models/unity_procon_spec.rb @@ -4,8 +4,7 @@ describe UnityProcon do before do - @unity_procon = UnityProcon.new(address_unity_procon: "Shopping Venancio", name_coordinator_unity_procon: "Roberto", - uf_procon: "DF", email_unity_procon: "procon@procon.com", list_phones: "32323232", position_unity_procon: "1") + @unity_procon = FactoryGirl.create(:unity_procon) end subject { @unity_procon } @@ -14,6 +13,7 @@ it { should respond_to(:uf_procon) } it { should respond_to(:email_unity_procon) } it { should respond_to(:list_phones) } - it { should respond_to(:position_unity_procon) } + it { should respond_to(:position_unity_procon) } + it { should be_valid } end \ No newline at end of file diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 642a380..7d79cef 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -3,11 +3,8 @@ require 'rails_helper' describe User do - let(:user) { FactoryGirl.create(:user) } before do - @user = User.new(name_user: "UserTest", email_user: "usertest@test.com", - password: "teste1234", address_user: "DF", - password_confirmation: "teste1234") + @user = FactoryGirl.create(:user) end subject { @user } @@ -44,15 +41,6 @@ end end end - describe "email already taken" do - before do - user_with_same_email = @user.dup - user_with_same_email.email_user = @user.email_user.upcase - user_with_same_email.save - end - - it { should_not be_valid } - end describe "password blank" do before do @user = User.new(name_user: "TesteUser", From bbdf296f7cbb0170814c41d65306ca55f194da2e Mon Sep 17 00:00:00 2001 From: omarroinuj Date: Sat, 25 Oct 2014 14:02:52 -0200 Subject: [PATCH 008/198] Adding gem cucumber --- Gemfile | 1 + Gemfile.lock | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/Gemfile b/Gemfile index 7cec9c1..cdb4b21 100644 --- a/Gemfile +++ b/Gemfile @@ -18,6 +18,7 @@ gem 'rspec-its' group :development, :test do gem 'rspec-rails' gem 'guard-rspec' + gem 'cucumber' end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index 338697d..4a61a93 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -52,12 +52,20 @@ GEM execjs coffee-script-source (1.8.0) commonjs (0.2.7) + cucumber (1.3.17) + builder (>= 2.1.2) + diff-lcs (>= 1.1.3) + gherkin (~> 2.12) + multi_json (>= 1.7.5, < 2.0) + multi_test (>= 0.1.1) diff-lcs (1.2.5) docile (1.1.5) erubis (2.7.0) execjs (2.2.1) ffi (1.9.3) formatador (0.2.5) + gherkin (2.12.2) + multi_json (~> 1.3) guard (2.6.1) formatador (>= 0.2.4) listen (~> 2.7) @@ -93,6 +101,7 @@ GEM mime-types (1.25.1) mini_portile (0.6.0) multi_json (1.10.1) + multi_test (0.1.1) mysql2 (0.3.16) nokogiri (1.6.3.1) mini_portile (= 0.6.0) @@ -208,6 +217,7 @@ DEPENDENCIES bootstrap-will_paginate (= 0.0.6) capybara coffee-rails (~> 3.2.1) + cucumber guard-rspec jquery-rails less-rails From 6262c06aa72c889aa76c7390c48d7ef3b06b2789 Mon Sep 17 00:00:00 2001 From: Ricardo Lupiano Andrade Date: Fri, 24 Oct 2014 21:31:31 -0200 Subject: [PATCH 009/198] Creating test for customer_service index method --- spec/controllers/customer_service_controller_spec.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/spec/controllers/customer_service_controller_spec.rb b/spec/controllers/customer_service_controller_spec.rb index c23d8d2..652b841 100644 --- a/spec/controllers/customer_service_controller_spec.rb +++ b/spec/controllers/customer_service_controller_spec.rb @@ -13,11 +13,16 @@ genre_customer_service: "Grave", cep_customer_service: "11111111") end describe "GET show" do - it "should find the account by its id" do + it "should find the customer_service by its id" do get :show, :id => @customer_service.id assigns[:customer_service].description_subject_customer_service.should == "Atendimento" end end - + describe "GET index" do + it "should list all the customer_service" do + get :index + expect(response).to have_http_status(:success) + end + end end \ No newline at end of file From 7d8a433f19dea7fd3cdcf75c5f705c7af875996f Mon Sep 17 00:00:00 2001 From: Ricardo Lupiano Andrade Date: Fri, 24 Oct 2014 21:50:16 -0200 Subject: [PATCH 010/198] Creating test for user_controller index and allusers methods --- spec/controllers/user_controller_spec.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index 7fcf545..b34472d 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -27,6 +27,20 @@ it { should respond_to(:password) } it { should respond_to(:password_confirmation) } it { should be_valid } + describe "GET all users" do + + it "should get all users" do + get :allusers, {} + expect(assigns(:allusers)).to be(@users) + end + end + describe "GET index" do + + it "should get all users" do + get :index, {} + expect(assigns(:index)).to be(@users) + end + end describe "GET show" do From 622b7ed7d4c68da2f3ef46a3ab602c2176b125fe Mon Sep 17 00:00:00 2001 From: Dylan Date: Sat, 25 Oct 2014 10:45:36 -0200 Subject: [PATCH 011/198] installing girlsfactory, changing unity_procon_controller spec name, improving sessionscontroller tests --- Gemfile | 1 + Gemfile.lock | 9 +++++++++ config/environments/test.rb | 7 +++++++ .../unity_procons_controller_spec.rb | 18 ++++++++++++++++++ spec/controllers/user_controller_spec.rb | 10 +--------- spec/factories.rb | 8 ++++++++ spec/helpers/sessions_helper_spec.rb | 10 ++++++++++ spec/models/user_spec.rb | 1 + 8 files changed, 55 insertions(+), 9 deletions(-) create mode 100644 spec/controllers/unity_procons_controller_spec.rb create mode 100644 spec/factories.rb diff --git a/Gemfile b/Gemfile index cdb4b21..2d2a89a 100644 --- a/Gemfile +++ b/Gemfile @@ -22,6 +22,7 @@ group :development, :test do end group :test do + gem 'factory_girl_rails', '4.1.0' gem 'selenium-webdriver' gem 'capybara' end diff --git a/Gemfile.lock b/Gemfile.lock index 4a61a93..d1227ca 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -62,6 +62,11 @@ GEM docile (1.1.5) erubis (2.7.0) execjs (2.2.1) + factory_girl (4.1.0) + activesupport (>= 3.0.0) + factory_girl_rails (4.1.0) + factory_girl (~> 4.1.0) + railties (>= 3.0.0) ffi (1.9.3) formatador (0.2.5) gherkin (2.12.2) @@ -217,7 +222,11 @@ DEPENDENCIES bootstrap-will_paginate (= 0.0.6) capybara coffee-rails (~> 3.2.1) + cucumber + + factory_girl_rails (= 4.1.0) +sessionscontroller tests guard-rspec jquery-rails less-rails diff --git a/config/environments/test.rb b/config/environments/test.rb index 6982910..21a1c9b 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -34,4 +34,11 @@ # Print deprecation notices to the stderr config.active_support.deprecation = :stderr + + # Speed up tests by lowering BCrypt's cost function. + require 'bcrypt' + silence_warnings do + BCrypt::Engine::DEFAULT_COST = BCrypt::Engine::MIN_COST + end + end diff --git a/spec/controllers/unity_procons_controller_spec.rb b/spec/controllers/unity_procons_controller_spec.rb new file mode 100644 index 0000000..39e8d91 --- /dev/null +++ b/spec/controllers/unity_procons_controller_spec.rb @@ -0,0 +1,18 @@ +require 'rails_helper' +require 'spec_helper' +require 'capybara/rspec' + +describe UnityProconsController, :type => :controller do + before do + @unity_procon = UnityProcon.create(address_unity_procon: "SQS BRASILIA", + name_coordinator_unity_procon: "Cordenador", uf_procon: "DF", + email_unity_procon: "procon@procon.com.br", list_phones: "123123123") + end + + describe "GET show" do + it "should find the account by its id" do + get :show, :id => @unity_procon.id + assigns[:unity_procon].address_unity_procon.should == "SQS BRASILIA" + end + end +end \ No newline at end of file diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index b34472d..73877e8 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -8,15 +8,7 @@ password: "teste1234", address_user: "DF", password_confirmation: "teste1234") end - let(:valid_attributes) { - skip(name_user: "UserTest", email_user: "usertest@test.com", - password: "teste1234", address_user: "DF") - } - - let(:invalid_attributes) { - skip(name_user: "", email_user: "emailerrado", - password: "zzzz", address_user: "") - } + let(:valid_session) { {} } diff --git a/spec/factories.rb b/spec/factories.rb new file mode 100644 index 0000000..85614a0 --- /dev/null +++ b/spec/factories.rb @@ -0,0 +1,8 @@ +FactoryGirl.define do + factory :user do + name "User Test" + email "usertest@test.com" + password "teste123" + password_confirmation "teste123" + end +end \ No newline at end of file diff --git a/spec/helpers/sessions_helper_spec.rb b/spec/helpers/sessions_helper_spec.rb index 4580117..741d390 100644 --- a/spec/helpers/sessions_helper_spec.rb +++ b/spec/helpers/sessions_helper_spec.rb @@ -31,4 +31,14 @@ sign_out expect(current_user).to be(nil) end + + it "expect current_uf to be uf from current_user" do + sign_in(@user) + expect(current_uf).to be(@user.address_user) + end + + it "expect current_uf to match method current_uf=" do + current_uf=(@user.address_user) + expect(current_uf).to equal(@user.address_user) + end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 68835bd..642a380 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -3,6 +3,7 @@ require 'rails_helper' describe User do + let(:user) { FactoryGirl.create(:user) } before do @user = User.new(name_user: "UserTest", email_user: "usertest@test.com", password: "teste1234", address_user: "DF", From 257333e816a5ce925f96e7d0f5053c09135d8a0b Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Sat, 25 Oct 2014 12:24:38 -0200 Subject: [PATCH 012/198] new tests for methods index and ranking @unityprocons_controller_spec --- spec/controllers/unity_procons_controller_spec.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spec/controllers/unity_procons_controller_spec.rb b/spec/controllers/unity_procons_controller_spec.rb index 39e8d91..057dd65 100644 --- a/spec/controllers/unity_procons_controller_spec.rb +++ b/spec/controllers/unity_procons_controller_spec.rb @@ -15,4 +15,19 @@ assigns[:unity_procon].address_unity_procon.should == "SQS BRASILIA" end end + + describe "GET index" do + it "expect index to be valid" do + get :index, {} + expect(response).to have_http_status(:success) + end + end + + describe "GET ranking" do + it "expect ranking to be valid" do + get :ranking, {} + expect(response).to have_http_status(:success) + end + end + end \ No newline at end of file From 4b905467a10f0a9efecb0d69a517bcb7169b2b69 Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Sat, 25 Oct 2014 12:32:12 -0200 Subject: [PATCH 013/198] changing unity_procon controller spec name, doing the pattern for the sessions_controller_spec --- spec/controllers/rating_controller_spec.rb | 9 +++++++ spec/controllers/sessions_controller_spec.rb | 24 +++++++++++++++++++ ...pec.rb => unity_procon_controller_spec.rb} | 0 spec/controllers/unity_procon_spec.rb | 18 -------------- 4 files changed, 33 insertions(+), 18 deletions(-) create mode 100644 spec/controllers/rating_controller_spec.rb rename spec/controllers/{unity_procons_controller_spec.rb => unity_procon_controller_spec.rb} (100%) delete mode 100644 spec/controllers/unity_procon_spec.rb diff --git a/spec/controllers/rating_controller_spec.rb b/spec/controllers/rating_controller_spec.rb new file mode 100644 index 0000000..f5e6c23 --- /dev/null +++ b/spec/controllers/rating_controller_spec.rb @@ -0,0 +1,9 @@ +require 'rails_helper' +require 'spec_helper' +require 'capybara/rspec' + +describe RatingsController, :type => :controller do + + + +end \ No newline at end of file diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index 2a8cb7d..0e44c94 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -3,6 +3,30 @@ require 'capybara/rspec' describe SessionsController, :type => :controller do + describe "POST destroy" do + it "expect destroy to delete current session" do + end + + it "expect destroy to redirect to root_url" do + end + end + + describe "POST create" do + it "expect user to be finded by email" do + end + + it "expect user finded to be signed" do + end + + it "expect signed user to be redirected to his profile" do + end + + it "expect invalid user to return error message" do + end + + it "expect invalid user to rerender the session view" do + end + end end \ No newline at end of file diff --git a/spec/controllers/unity_procons_controller_spec.rb b/spec/controllers/unity_procon_controller_spec.rb similarity index 100% rename from spec/controllers/unity_procons_controller_spec.rb rename to spec/controllers/unity_procon_controller_spec.rb diff --git a/spec/controllers/unity_procon_spec.rb b/spec/controllers/unity_procon_spec.rb deleted file mode 100644 index 39e8d91..0000000 --- a/spec/controllers/unity_procon_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'rails_helper' -require 'spec_helper' -require 'capybara/rspec' - -describe UnityProconsController, :type => :controller do - before do - @unity_procon = UnityProcon.create(address_unity_procon: "SQS BRASILIA", - name_coordinator_unity_procon: "Cordenador", uf_procon: "DF", - email_unity_procon: "procon@procon.com.br", list_phones: "123123123") - end - - describe "GET show" do - it "should find the account by its id" do - get :show, :id => @unity_procon.id - assigns[:unity_procon].address_unity_procon.should == "SQS BRASILIA" - end - end -end \ No newline at end of file From acdf32da733aa9c2299b73f3da40e31a27fdd21a Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Sat, 25 Oct 2014 13:14:48 -0200 Subject: [PATCH 014/198] refactored almost every spec that uses an object with before to work with girls factory --- .../customer_service_controller_spec.rb | 8 +--- spec/controllers/supplier_controller_spec.rb | 6 +-- .../unity_procon_controller_spec.rb | 6 +-- spec/controllers/user_controller_spec.rb | 40 ++++++------------- spec/factories.rb | 39 +++++++++++++++++- spec/helpers/sessions_helper_spec.rb | 4 +- spec/models/customer_service_spec.rb | 8 +--- spec/models/supplier_spec.rb | 4 +- spec/models/unity_procon_spec.rb | 6 +-- spec/models/user_spec.rb | 14 +------ 10 files changed, 62 insertions(+), 73 deletions(-) diff --git a/spec/controllers/customer_service_controller_spec.rb b/spec/controllers/customer_service_controller_spec.rb index 652b841..e52cf23 100644 --- a/spec/controllers/customer_service_controller_spec.rb +++ b/spec/controllers/customer_service_controller_spec.rb @@ -4,13 +4,7 @@ describe CustomerServicesController, :type => :controller do before do - @customer_service = CustomerService.create(year_customer_service: "2014", - trimester_customer_service: "2", month_customer_service: "05", - date_customer_service: "2014-05-23", region_customer_service: "Centro-Oeste", - uf_customer_service: "DF", description_customer_service: "Atendimento realizado", - code_subject_customer_service: "2", description_subject_customer_service: "Atendimento", - code_problem_customer_service: "4", description_problem_customer_service: "Duvida", - genre_customer_service: "Grave", cep_customer_service: "11111111") + @customer_service = FactoryGirl.create(:customer_service) end describe "GET show" do it "should find the customer_service by its id" do diff --git a/spec/controllers/supplier_controller_spec.rb b/spec/controllers/supplier_controller_spec.rb index 83d78f7..e5e72bf 100644 --- a/spec/controllers/supplier_controller_spec.rb +++ b/spec/controllers/supplier_controller_spec.rb @@ -4,15 +4,13 @@ describe SuppliersController, :type => :controller do before do - @supplier = Supplier.create(type_supplier: "SupplierTes", social_reason_supplier: "Razao", - fantasy_name_supplier: "Sup", cnpj: "12000184002", cnaep_main_code_supplier: "123123123", - description_cnaep_code_supplier: "46456456546") + @supplier = FactoryGirl.create(:supplier) end describe "GET show" do it "should find the account by its id" do get :show, :id => @supplier.id - assigns[:supplier].type_supplier.should == "SupplierTes" + assigns[:supplier].type_supplier.should == "PessoaJuridica" end end diff --git a/spec/controllers/unity_procon_controller_spec.rb b/spec/controllers/unity_procon_controller_spec.rb index 057dd65..458afbf 100644 --- a/spec/controllers/unity_procon_controller_spec.rb +++ b/spec/controllers/unity_procon_controller_spec.rb @@ -4,15 +4,13 @@ describe UnityProconsController, :type => :controller do before do - @unity_procon = UnityProcon.create(address_unity_procon: "SQS BRASILIA", - name_coordinator_unity_procon: "Cordenador", uf_procon: "DF", - email_unity_procon: "procon@procon.com.br", list_phones: "123123123") + @unity_procon = FactoryGirl.create(:unity_procon) end describe "GET show" do it "should find the account by its id" do get :show, :id => @unity_procon.id - assigns[:unity_procon].address_unity_procon.should == "SQS BRASILIA" + assigns[:unity_procon].address_unity_procon.should == "Shopping Venancio" end end diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index 73877e8..a8cf7fe 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -4,64 +4,50 @@ describe UsersController, :type => :controller do before do - @user = User.create(name_user: "UserTes", email_user: "usertest@test.com", - password: "teste1234", address_user: "DF", - password_confirmation: "teste1234") + @user = FactoryGirl.create(:user) end - let(:valid_session) { {} } - - subject { @user } - it { should respond_to(:name_user) } - it { should respond_to(:email_user) } - it { should respond_to(:password_digest) } - it { should respond_to(:password) } - it { should respond_to(:password_confirmation) } - it { should be_valid } + #GET#allusers describe "GET all users" do - it "should get all users" do get :allusers, {} expect(assigns(:allusers)).to be(@users) end end + #GET#index describe "GET index" do - it "should get all users" do get :index, {} expect(assigns(:index)).to be(@users) end end - - describe "GET show" do - + #GET#show + describe "GET show" do it "should find the account by its id" do get :show, :id => @user.id - assigns[:user].name_user.should == "UserTes" + assigns[:user].name_user.should == "User Test" end - - describe "GET #new" do - it "assigns a new user as @user" do + end + #GET#new + describe "GET #new" do + it "assigns a new user as @user" do get :new, {} expect(assigns(:user)).to be_a_new(User) - end - end - + end end - + #GET#edit describe "GET edit" do it "assigns the requested place as @place" do get :edit, :id => @user.id expect(assigns(:user)).to eq(@user) end end - + #GET#new describe "GET new" do it "assigns all users as @users" do get :new, {}, valid_session expect(assigns(:user)).to be_a_new(User) end end - end \ No newline at end of file diff --git a/spec/factories.rb b/spec/factories.rb index 85614a0..08d6998 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -1,8 +1,43 @@ FactoryGirl.define do factory :user do - name "User Test" - email "usertest@test.com" + name_user "User Test" + email_user "teste@teste.com" password "teste123" password_confirmation "teste123" + address_user "DF" + end + + factory :supplier do + type_supplier "PessoaJuridica" + social_reason_supplier "Importante" + fantasy_name_supplier "Tchanananas" + cnpj "222777-13" + cnaep_main_code_supplier "aCnaepCode" + description_cnaep_code_supplier "aCnaepDescription" + end + + factory :customer_service do + year_customer_service "2014" + trimester_customer_service "2" + month_customer_service "05" + date_customer_service "2014-05-23" + region_customer_service "Centro-Oeste" + uf_customer_service "DF" + description_customer_service "Atendimento realizado" + code_subject_customer_service "2" + description_subject_customer_service "Atendimento" + code_problem_customer_service "4" + description_problem_customer_service "Duvida" + genre_customer_service "Grave" + cep_customer_service "11111111" + end + + factory :unity_procon do + address_unity_procon "Shopping Venancio" + name_coordinator_unity_procon "Roberto" + uf_procon "DF" + email_unity_procon "procon@procon.com" + list_phones "32323232" + position_unity_procon "1" end end \ No newline at end of file diff --git a/spec/helpers/sessions_helper_spec.rb b/spec/helpers/sessions_helper_spec.rb index 741d390..d71df75 100644 --- a/spec/helpers/sessions_helper_spec.rb +++ b/spec/helpers/sessions_helper_spec.rb @@ -4,9 +4,7 @@ describe SessionsHelper do before do - @user = User.create(name_user: "UserTes", email_user: "usertest@test.com", - password: "teste1234", address_user: "DF", - password_confirmation: "teste1234") + @user = FactoryGirl.create(:user) end it "expect signed user return signed_in = true" do diff --git a/spec/models/customer_service_spec.rb b/spec/models/customer_service_spec.rb index 11f3f12..120b5a1 100644 --- a/spec/models/customer_service_spec.rb +++ b/spec/models/customer_service_spec.rb @@ -4,11 +4,7 @@ describe CustomerService do before do - @customer_service = CustomerService.new(year_customer_service: "2014", trimester_customer_service: "2", - month_customer_service: "05", date_customer_service: "2014-05-23", region_customer_service: "Centro-Oeste", - uf_customer_service: "DF", description_customer_service: "Atendimento realizado", code_subject_customer_service: "2", - description_subject_customer_service: "Atendimento", code_problem_customer_service: "4", - description_problem_customer_service: "Duvida", genre_customer_service: "Grave", cep_customer_service: "11111111") + @customer_service = FactoryGirl.create(:customer_service) end subject { @customer_service } @@ -25,6 +21,4 @@ it { should respond_to(:description_problem_customer_service) } it { should respond_to(:genre_customer_service) } it { should respond_to(:cep_customer_service) } - - end \ No newline at end of file diff --git a/spec/models/supplier_spec.rb b/spec/models/supplier_spec.rb index 39489fe..762b950 100644 --- a/spec/models/supplier_spec.rb +++ b/spec/models/supplier_spec.rb @@ -4,9 +4,7 @@ describe Supplier do before do - @supplier = Supplier.new(type_supplier: "PessoaJuridica", social_reason_supplier: "Importante", - fantasy_name_supplier: "Tchanananas", cnpj: "222777-13", cnaep_main_code_supplier: "blablabla", - description_cnaep_code_supplier: "blablablas") + @supplier = FactoryGirl.create(:supplier) end subject { @supplier } diff --git a/spec/models/unity_procon_spec.rb b/spec/models/unity_procon_spec.rb index f3770a7..c440e6b 100644 --- a/spec/models/unity_procon_spec.rb +++ b/spec/models/unity_procon_spec.rb @@ -4,8 +4,7 @@ describe UnityProcon do before do - @unity_procon = UnityProcon.new(address_unity_procon: "Shopping Venancio", name_coordinator_unity_procon: "Roberto", - uf_procon: "DF", email_unity_procon: "procon@procon.com", list_phones: "32323232", position_unity_procon: "1") + @unity_procon = FactoryGirl.create(:unity_procon) end subject { @unity_procon } @@ -14,6 +13,7 @@ it { should respond_to(:uf_procon) } it { should respond_to(:email_unity_procon) } it { should respond_to(:list_phones) } - it { should respond_to(:position_unity_procon) } + it { should respond_to(:position_unity_procon) } + it { should be_valid } end \ No newline at end of file diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 642a380..7d79cef 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -3,11 +3,8 @@ require 'rails_helper' describe User do - let(:user) { FactoryGirl.create(:user) } before do - @user = User.new(name_user: "UserTest", email_user: "usertest@test.com", - password: "teste1234", address_user: "DF", - password_confirmation: "teste1234") + @user = FactoryGirl.create(:user) end subject { @user } @@ -44,15 +41,6 @@ end end end - describe "email already taken" do - before do - user_with_same_email = @user.dup - user_with_same_email.email_user = @user.email_user.upcase - user_with_same_email.save - end - - it { should_not be_valid } - end describe "password blank" do before do @user = User.new(name_user: "TesteUser", From 945119e6346fc47229ffb96dc6e5ecb37e30cabf Mon Sep 17 00:00:00 2001 From: Ricardo Lupiano Andrade Date: Sat, 25 Oct 2014 17:42:51 -0200 Subject: [PATCH 015/198] Creating some tests for controllers sessions and rating. --- app/controllers/ratings_controller.rb | 39 +------------------- spec/controllers/sessions_controller_spec.rb | 16 +++++--- 2 files changed, 12 insertions(+), 43 deletions(-) diff --git a/app/controllers/ratings_controller.rb b/app/controllers/ratings_controller.rb index 055ee99..c8b9a80 100644 --- a/app/controllers/ratings_controller.rb +++ b/app/controllers/ratings_controller.rb @@ -1,41 +1,4 @@ class RatingsController < ApplicationController - def index # @List all Ratings - @rating = Rating.all - end - - def new # @Instantiate one rating - @rating = Rating.new - end - - def create # @Create one rating - @rating = Rating.new(user_params) - if @rating.save - redirect_to :action => :show, :id => @rating.id - else - render 'new' - end - end - - def show # @List one rating associated with the id given. - @rating = Rating.find(params[:id]) - end - - def edit # @Edit one rating. - @rating = Rating.find(params[:id]) - end - - def update # @Update one edited id. - @rating = Rating.find(params[:idRating]) - if @rating.update_attributes(user_params) - redirect_to @rating - else - render 'edit' - end - end - - def destroy # @Erase one rating. - @rating = Rating.find(params[:id]) - @rating.destroy - end + end \ No newline at end of file diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index 0e44c94..266dccb 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -1,14 +1,20 @@ require 'rails_helper' require 'spec_helper' require 'capybara/rspec' +include SessionsHelper describe SessionsController, :type => :controller do + before do + @user = FactoryGirl.create(:user) + end + let(:valid_session) { {} } describe "POST destroy" do - it "expect destroy to delete current session" do - end - - it "expect destroy to redirect to root_url" do - end + it "should logout" do + sign_in(@user) + get :destroy + session[:user_id].should be(nil) + response.should be_redirect + end end describe "POST create" do From ffdc261bc667a7a99baa933f8079c0153b89ca91 Mon Sep 17 00:00:00 2001 From: "Matheus S. Pereira" Date: Sat, 25 Oct 2014 21:10:20 -0200 Subject: [PATCH 016/198] Adding search menu in index of unity_procons --- app/views/unity_procons/index.html.erb | 53 ++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/app/views/unity_procons/index.html.erb b/app/views/unity_procons/index.html.erb index deecd00..f6cfa8c 100644 --- a/app/views/unity_procons/index.html.erb +++ b/app/views/unity_procons/index.html.erb @@ -1,7 +1,59 @@
+ +
+
+
+ +






+

BUSCAR

+ + Busca Textual
+ + <% # = form_tag('/customer_services/', method: :get) %> + <% # input type="text" name=idteste> %> + <% # = submit_tag "Pesquisar", class:"form_submit" %> + +
+ + +
+ + + + Regiões +
+ + Norte + Nordeste + Sul + Centro-Oeste + Sudeste + +
+
+ + + Unidades Federativas +
+ + + AC + AP + AM + PA + RO + RR + TO + + + + +
+

Lista de Unidades do Procon

+
<%= will_paginate =%> @@ -29,6 +81,7 @@ <%= will_paginate =%>
+
From 435449047e881a4604af04eda859038f32638f0b Mon Sep 17 00:00:00 2001 From: "Matheus S. Pereira" Date: Sat, 25 Oct 2014 21:29:08 -0200 Subject: [PATCH 017/198] Creating the function build_row() --- app/assets/javascripts/unity_procons.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 app/assets/javascripts/unity_procons.js diff --git a/app/assets/javascripts/unity_procons.js b/app/assets/javascripts/unity_procons.js new file mode 100644 index 0000000..31758fe --- /dev/null +++ b/app/assets/javascripts/unity_procons.js @@ -0,0 +1,13 @@ +(function() +{ + function build_row(data) + { + var html = ""; + + html += "ID: "+data.id+""; + html += "Endereço: "+data.address_unity_procon+""; + + html += ""; + return html; + } +} \ No newline at end of file From ceefcc81ecdc7041b7396decfbbee891a133b8f6 Mon Sep 17 00:00:00 2001 From: Filipe Ribeiro Date: Sat, 25 Oct 2014 21:59:34 -0200 Subject: [PATCH 018/198] Creating the function custom_search() --- app/assets/javascripts/unity_procons.js | 19 +++++++++++++++++++ app/controllers/unity_procons_controller.rb | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/app/assets/javascripts/unity_procons.js b/app/assets/javascripts/unity_procons.js index 31758fe..88a0f47 100644 --- a/app/assets/javascripts/unity_procons.js +++ b/app/assets/javascripts/unity_procons.js @@ -10,4 +10,23 @@ html += ""; return html; } + + function custom_search(search, unities) + { + $.ajax( + { + url: "/unity_procon/custom_search", + type: "GET", + data: { "search":search, "unities":unities,"page":1 }, + success : function(response) + { + var html = ""; + for(var i = 0; i < response.length; i++) + { + html += build_row(response[i]); + } + $("#unity_procons").html(html); + } + }); + } } \ No newline at end of file diff --git a/app/controllers/unity_procons_controller.rb b/app/controllers/unity_procons_controller.rb index ccd5437..68b72c1 100644 --- a/app/controllers/unity_procons_controller.rb +++ b/app/controllers/unity_procons_controller.rb @@ -14,4 +14,23 @@ def ranking @unity_procons = UnityProcon.order(:position_unity_procon) end + def custom_search + unless request.xhr? or params[:page].nil? or params[:search].nil? + redirect_to "/" + return + end + + sql = "1=1" + + if !params[:unities].nil? and params[:unities].length > 0 + params[:unities].each do |u| + + end + end + + sql = sql + data = UnityProcons.where(params[:search]).paginate(:page=>1) + render :json=>data.to_json + end + end \ No newline at end of file From a88ac7e4e334069ec833774cee2a4ccc5321293a Mon Sep 17 00:00:00 2001 From: TomazMartins Date: Sat, 25 Oct 2014 22:30:36 -0200 Subject: [PATCH 019/198] Fixing jQuery in function custom_search() in unity_procon_cotroller --- app/controllers/unity_procons_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/unity_procons_controller.rb b/app/controllers/unity_procons_controller.rb index 68b72c1..6ccd65b 100644 --- a/app/controllers/unity_procons_controller.rb +++ b/app/controllers/unity_procons_controller.rb @@ -29,8 +29,8 @@ def custom_search end sql = sql - data = UnityProcons.where(params[:search]).paginate(:page=>1) + data = UnityProcons.where("right(address_unity_procon, 2) = ?", params[:search]).paginate(:page=>1) render :json=>data.to_json end -end \ No newline at end of file +end From 734b36dc47f79bcb7349727d0c3f781fb9c6afad Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Sun, 26 Oct 2014 12:56:09 -0200 Subject: [PATCH 020/198] new spec for application_helper, new tests for users controller_spec --- app/controllers/sessions_controller.rb | 4 +-- spec/controllers/user_controller_spec.rb | 43 ++++++++++++++++++++++++ spec/factories.rb | 1 + spec/helpers/application_helper_spec.rb | 12 +++++++ 4 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 spec/helpers/application_helper_spec.rb diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index f152531..92e840f 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -9,11 +9,11 @@ def create sign_in user redirect_to user else - flash.now[:error] = 'Invalid email/password combination' + flash.now[:error] = "Invalid email/password combination" render 'new' end end - # Sing out + # Sign out def destroy sign_out redirect_to root_url diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index a8cf7fe..7f9b35f 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -8,6 +8,7 @@ end let(:valid_session) { {} } + let(:valid_attributes) { FactoryGirl.attributes_for :user, email_user: 'newuser@example.com' } #GET#allusers describe "GET all users" do it "should get all users" do @@ -50,4 +51,46 @@ expect(assigns(:user)).to be_a_new(User) end end + + describe "POST create" do + describe "with valid params" do + subject { post :create, user: valid_attributes } + + it "increase total number of users" do + expect { subject }.to change(User, :count).by(1) + end + end + + describe "with invalid params" do + subject { post :create, user: {} } + + it "not increase number of users" do + expect { subject }.to_not change(User, :count) + end + end + end + + describe "PUT Update" do + before { @user.id = "15" } + context "with valid params" do + before do + put :update, user: { email_user: "novoemail@exemplo.com" }, id: @user.id + end + + it "assigns the requested user as @user" do + assigns(:user).should eq(@user) + end + end + context "with invalid params" do + end + end + + describe "DELETE destroy" do + subject { delete :destroy, id: @user.id } + + it "destroys the requested user" do + expect { subject }.to change(User, :count).by(-1) + end + + end end \ No newline at end of file diff --git a/spec/factories.rb b/spec/factories.rb index 08d6998..86523f1 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -5,6 +5,7 @@ password "teste123" password_confirmation "teste123" address_user "DF" + id "15" end factory :supplier do diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb new file mode 100644 index 0000000..87030a2 --- /dev/null +++ b/spec/helpers/application_helper_spec.rb @@ -0,0 +1,12 @@ +require 'rspec/its' +require 'spec_helper' +require 'rails_helper' + +describe ApplicationHelper do + it "expect base title to be proconsulta if page title = blank" do + full_title("").should == "PROCONSULTA" + end + it "expect base title to be another base title if page title isn't blank" do + full_title("test_title").should == "PROCONSULTA | test_title" + end +end From 5f8306342312ebedbac7d2c94f730cb669de97b2 Mon Sep 17 00:00:00 2001 From: Eduardo Moreira Date: Sun, 26 Oct 2014 16:31:01 -0200 Subject: [PATCH 021/198] Adding structure for functional tests --- app/views/layouts/_header.html.erb | 2 +- features/cadastro.feature | 12 ++++++++++++ features/step_definitions/register_steps.rb | 7 +++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 features/cadastro.feature create mode 100644 features/step_definitions/register_steps.rb diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index 4289aae..328fa79 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -32,7 +32,7 @@ Acesso diff --git a/features/cadastro.feature b/features/cadastro.feature new file mode 100644 index 0000000..8d9a6c9 --- /dev/null +++ b/features/cadastro.feature @@ -0,0 +1,12 @@ +#language: pt + +Funcionalidade: Abrir página de cadastrar + Para poder utilizar as funcionalidades do aplicativo + Como usuário + Quero acessar a página para realizar meu cadastro + + Cenário: Carregar página de cadastrar + Ao carregar página de cadastro, é mostrado um formulário de cadastro para o usuário + + Quando eu clico no link "Registrar" + Então vejo o formulario de cadastro diff --git a/features/step_definitions/register_steps.rb b/features/step_definitions/register_steps.rb new file mode 100644 index 0000000..be35eb6 --- /dev/null +++ b/features/step_definitions/register_steps.rb @@ -0,0 +1,7 @@ +Quando(/^eu clico no link "(.*?)"$/) do |arg1| + +end + +Então(/^vejo o formulario de cadastro$/) do + +end From d3ad5a6afd7e4558f1d4184a75b20a608e16ca41 Mon Sep 17 00:00:00 2001 From: Filipe Ribeiro Date: Sun, 26 Oct 2014 21:49:08 -0200 Subject: [PATCH 022/198] Preparing the button to search. --- app/assets/javascripts/unity_procons.js | 19 +++++++++++++++++-- app/controllers/unity_procons_controller.rb | 3 +-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/unity_procons.js b/app/assets/javascripts/unity_procons.js index 88a0f47..cc829a6 100644 --- a/app/assets/javascripts/unity_procons.js +++ b/app/assets/javascripts/unity_procons.js @@ -21,12 +21,27 @@ success : function(response) { var html = ""; + for(var i = 0; i < response.length; i++) { html += build_row(response[i]); } + $("#unity_procons").html(html); } }); - } -} \ No newline at end of file + } + + $(document).ready(function() + { + $("#custom_search_button").click(function() + { + var search = $("#custom_search_text").val(); + var unities = []; + + unities.push(element.value); + + custom_search(search, unities); + }); + }); +})(); diff --git a/app/controllers/unity_procons_controller.rb b/app/controllers/unity_procons_controller.rb index 6ccd65b..6dd6a16 100644 --- a/app/controllers/unity_procons_controller.rb +++ b/app/controllers/unity_procons_controller.rb @@ -29,8 +29,7 @@ def custom_search end sql = sql - data = UnityProcons.where("right(address_unity_procon, 2) = ?", params[:search]).paginate(:page=>1) + data = UnityProcon.where("right(address_unity_procon, 2) = ?", params[:search]).paginate(:page=>1) render :json=>data.to_json end - end From 6d1005c0eebcc32217ddb79318e0af89e97c7b51 Mon Sep 17 00:00:00 2001 From: "Matheus S. Pereira" Date: Sun, 26 Oct 2014 23:10:19 -0200 Subject: [PATCH 023/198] Adding routes and refactoring unity_procons --- app/assets/javascripts/unity_procons.js | 15 +++++----- app/controllers/unity_procons_controller.rb | 6 ---- app/views/unity_procons/index.html.erb | 31 ++------------------- config/routes.rb | 1 + 4 files changed, 10 insertions(+), 43 deletions(-) diff --git a/app/assets/javascripts/unity_procons.js b/app/assets/javascripts/unity_procons.js index cc829a6..d17e015 100644 --- a/app/assets/javascripts/unity_procons.js +++ b/app/assets/javascripts/unity_procons.js @@ -11,13 +11,14 @@ return html; } - function custom_search(search, unities) + function custom_search(search) { + console.log("custom_search") $.ajax( { url: "/unity_procon/custom_search", type: "GET", - data: { "search":search, "unities":unities,"page":1 }, + data: { "search":search, "page":1 }, success : function(response) { var html = ""; @@ -34,14 +35,12 @@ $(document).ready(function() { - $("#custom_search_button").click(function() + console.log("ready") + $("#unity_search_button").click(function() { - var search = $("#custom_search_text").val(); - var unities = []; + var search = $("#unity_search_text").val(); - unities.push(element.value); - - custom_search(search, unities); + custom_search(search); }); }); })(); diff --git a/app/controllers/unity_procons_controller.rb b/app/controllers/unity_procons_controller.rb index 6dd6a16..e38db8e 100644 --- a/app/controllers/unity_procons_controller.rb +++ b/app/controllers/unity_procons_controller.rb @@ -22,12 +22,6 @@ def custom_search sql = "1=1" - if !params[:unities].nil? and params[:unities].length > 0 - params[:unities].each do |u| - - end - end - sql = sql data = UnityProcon.where("right(address_unity_procon, 2) = ?", params[:search]).paginate(:page=>1) render :json=>data.to_json diff --git a/app/views/unity_procons/index.html.erb b/app/views/unity_procons/index.html.erb index f6cfa8c..efde1f9 100644 --- a/app/views/unity_procons/index.html.erb +++ b/app/views/unity_procons/index.html.erb @@ -14,37 +14,10 @@ <% # = submit_tag "Pesquisar", class:"form_submit" %> - - + +
- - - Regiões -
- - Norte - Nordeste - Sul - Centro-Oeste - Sudeste - -
-
- - - Unidades Federativas -
- - - AC - AP - AM - PA - RO - RR - TO - diff --git a/config/routes.rb b/config/routes.rb index 6e7e514..16e1489 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -15,6 +15,7 @@ match '/ranking', to: 'unity_procons#ranking' get "/customer_service/custom_search", to: "customer_services#custom_search" + get "/unity_procon/custom_search", to: "unity_procons#custom_search" match '/faq', to: 'faqs#index' From a63e17e0a652a291af3271fbf5b8ef5aa4b74a3c Mon Sep 17 00:00:00 2001 From: Filipe Ribeiro Date: Sun, 26 Oct 2014 23:50:24 -0200 Subject: [PATCH 024/198] Adding state dropdown for search in the index unity_procon --- app/assets/javascripts/unity_procons.js | 2 +- app/views/unity_procons/index.html.erb | 31 +++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/unity_procons.js b/app/assets/javascripts/unity_procons.js index d17e015..bcc4ef4 100644 --- a/app/assets/javascripts/unity_procons.js +++ b/app/assets/javascripts/unity_procons.js @@ -38,7 +38,7 @@ console.log("ready") $("#unity_search_button").click(function() { - var search = $("#unity_search_text").val(); + var search = $("#unity_uf").val(); custom_search(search); }); diff --git a/app/views/unity_procons/index.html.erb b/app/views/unity_procons/index.html.erb index efde1f9..508fb9b 100644 --- a/app/views/unity_procons/index.html.erb +++ b/app/views/unity_procons/index.html.erb @@ -13,11 +13,38 @@ <% # input type="text" name=idteste> %> <% # = submit_tag "Pesquisar", class:"form_submit" %> + + -
- From 39b24b1106e8c56da2df8a98ebf35fdc2cdf31cd Mon Sep 17 00:00:00 2001 From: Eduardo Moreira Date: Tue, 28 Oct 2014 11:53:09 -0200 Subject: [PATCH 025/198] Creating scenarios to test faq feature. --- features/faq.feature | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 features/faq.feature diff --git a/features/faq.feature b/features/faq.feature new file mode 100644 index 0000000..4e7dd41 --- /dev/null +++ b/features/faq.feature @@ -0,0 +1,19 @@ +#language: pt + +Funcionalidade: Abrir do página do FAQ + Para poder visualizar as perguntas frequentes + Como usuário + Quero acessar a página do faq + + Cenário: Carregar página do faq + Ao carregar página do faq, é mostrada uma lista com perguntas e respostas frequentes. + + Quando eu clico no link "FAQ" + Então vejo a lista de perguntas + + + Cenário: Visualizar resposta de uma pergunta + Ao selecionar uma pergunta, é mostrada a resposta para essa pergunta. + + Quando eu clico na pergunta "Quais órgãos estão subordinados à essa Lei?" + Então vejo a resposta "Os órgãos da administração direta do Poder Executivo do Distrito Federal, a Câmara Legislativa do Distrito Federal e o Tribunal de Contas do Distrito Federal. As autarquias, fundações públicas, empresas públicas, sociedades de economia mista e demais entidades controladas direta ou indiretamente pelo Distrito Federal. No que couber, às entidades privadas sem fins lucrativos que recebam, para realização de ações de interesse público, recursos públicos diretamente do orçamento ou mediante subvenções sociais, contrato de gestão, termo de parceria, convênios, acordos, ajustes ou outros instrumentos congêneres." \ No newline at end of file From 5bafd642b068ccff5e0ee4987caa7d382b1d4af7 Mon Sep 17 00:00:00 2001 From: Eduardo Moreira Date: Tue, 28 Oct 2014 12:12:26 -0200 Subject: [PATCH 026/198] Creating scenarios to test list costumer service. --- features/list_costumer_service.feature | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 features/list_costumer_service.feature diff --git a/features/list_costumer_service.feature b/features/list_costumer_service.feature new file mode 100644 index 0000000..4867709 --- /dev/null +++ b/features/list_costumer_service.feature @@ -0,0 +1,21 @@ +#language: pt + +Funcionalidade: Abrir página de atendimentos + Para poder visualizar os atendimentos realizados pelo PROCON + Como usuário + Quero acessar a página de atendimentos + + Cenário: Carregar página de atendimentos + Ao carregar página de atendimentos, é mostrada uma lista com os atendimentos do PROCON + + Quando eu clico no link "Atendimentos" + Entao vejo a lista de atendimentos + E vejo os filtros para pesquisar atendimento + + + Cenário: Pesquisar atendimentos inexistentes por filtros + Ao buscar atendimentos por meio de filtros, é mostrada uma lista vazia + + Quando eu preencho "2010" em "Ano" + E aperto "Buscar" + Entao vejo a lista de atendimentos com os atendimentos "" \ No newline at end of file From 0d2421e5c72ef1b82ef0b08f02be4e4f0127345d Mon Sep 17 00:00:00 2001 From: Eduardo Moreira Date: Tue, 28 Oct 2014 12:38:54 -0200 Subject: [PATCH 027/198] Adding scenarios to list_costumer_service funcional test. --- features/list_costumer_service.feature | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/features/list_costumer_service.feature b/features/list_costumer_service.feature index 4867709..ad1f3d0 100644 --- a/features/list_costumer_service.feature +++ b/features/list_costumer_service.feature @@ -18,4 +18,22 @@ Funcionalidade: Abrir página de atendimentos Quando eu preencho "2010" em "Ano" E aperto "Buscar" - Entao vejo a lista de atendimentos com os atendimentos "" \ No newline at end of file + Entao vejo a lista de atendimentos com os atendimentos "" + + + Cenário: Pesquisar atendimentos por filtros + Ao buscar atendimentos por meio de filtros, é mostrada uma lista com os atendimentos filtrados. + + Quando eu preencho "2012" em "Ano" + E aperto "Buscar" + Entao vejo a lista de atendimentos com um atendimento: + |id |uf_procon | + |756 |GO | + + + Cenário: Visualizar profile de um atendimento selecionado + Ao clicar em um atendimento, é mostrada as informações do atendimento selecionado. + + Quando eu clico no atendimento "756" + Então vejo "7112345" + E vejo "Reclamação de produto com defeito" \ No newline at end of file From 6482f6ca9d13aa495d3e973b0762a969333d1bac Mon Sep 17 00:00:00 2001 From: Eduardo Moreira Date: Tue, 28 Oct 2014 12:39:45 -0200 Subject: [PATCH 028/198] Adding scenarios to register feature. --- features/cadastro.feature | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/features/cadastro.feature b/features/cadastro.feature index 8d9a6c9..0f1af8f 100644 --- a/features/cadastro.feature +++ b/features/cadastro.feature @@ -9,4 +9,30 @@ Funcionalidade: Abrir página de cadastrar Ao carregar página de cadastro, é mostrado um formulário de cadastro para o usuário Quando eu clico no link "Registrar" - Então vejo o formulario de cadastro + Entao vejo o formulario de cadastro + + + Cenário: Cadastrar novo usuário + Ao preencher informações do novo usuário e salvá-las, novo usuário é cadastrado. + + Quando eu preencho o campo "Nome" com "Eduardo" + E preencho o campo "E-mail" com "eduardo@hotmail.com" + E preencho o campo "Senha" com "123456" + E preencho o campo "Repetir" com "123456" + E preencho o campo "Estado" com "DF" + E pressionar o botão "Registrar conta" + Entao vejo "Nome: Eduardo" + E vejo "Estado: DF" + E vejo "E-Mail: moreira.edu@hotmail.com" + + + Cenário: Cadastrar usuário com senhas incompatíveis + Ao preencher informações do novo usuário com senhas diferentes, usuário não deve ser cadastrado. + + Quando eu preencho o campo "Nome" com "Eduardo" + E preencho o campo "E-mail" com "eduardo@hotmail.com" + E preencho o campo "Senha" com "123456" + E preencho o campo "Repetir" com "654321" + E preencho o campo "Estado" com "DF" + E pressionar o botão "Registrar conta" + Entao vejo "passwords don't match" From 0c2ab3506145da03e9c50aa3e41a04ee5644fc34 Mon Sep 17 00:00:00 2001 From: Eduardo Moreira Date: Tue, 28 Oct 2014 12:41:34 -0200 Subject: [PATCH 029/198] Changing feature name of list_costumer_service to portuguese 'listar_atendimento.feature'. --- features/listar_atendimento.feature | 39 +++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 features/listar_atendimento.feature diff --git a/features/listar_atendimento.feature b/features/listar_atendimento.feature new file mode 100644 index 0000000..41bccc1 --- /dev/null +++ b/features/listar_atendimento.feature @@ -0,0 +1,39 @@ +#language: pt + +Funcionalidade: Abrir página de atendimentos + Para poder visualizar os atendimentos realizados pelo PROCON + Como usuário + Quero acessar a página de atendimentos + + Cenário: Carregar página de atendimentos + Ao carregar página de atendimentos, é mostrada uma lista com os atendimentos do PROCON + + Quando eu clico no link "Atendimentos" + Entao vejo a lista de atendimentos + E vejo os filtros para pesquisar atendimento + + + Cenário: Pesquisar atendimentos inexistentes por filtros + Ao buscar atendimentos por meio de filtros, é mostrada uma lista vazia + + Quando eu preencho "2010" em "Ano" + E aperto "Buscar" + Entao vejo a lista de atendimentos com os atendimentos "" + + + Cenário: Pesquisar atendimentos por filtros + Ao buscar atendimentos por meio de filtros, é mostrada uma lista com os atendimentos filtrados. + + Quando eu preencho "2012" em "Ano" + E aperto "Buscar" + Entao vejo a lista de atendimentos com um atendimento: + |id |uf_procon | + |756 |GO | + + + Cenário: Visualizar profile de um atendimento selecionado + Ao clicar em um atendimento, é mostrada as informações do atendimento selecionado. + + Quando eu clico no atendimento "756" + Entao vejo "7112345" + E vejo "Reclamação de produto com defeito" \ No newline at end of file From 9fd11fc83ebe64e9a919622e97357f705cf53c5e Mon Sep 17 00:00:00 2001 From: Eduardo Moreira Date: Tue, 28 Oct 2014 12:45:32 -0200 Subject: [PATCH 030/198] Deleting 'list_costumer_service.feature'. --- features/list_costumer_service.feature | 39 -------------------------- 1 file changed, 39 deletions(-) delete mode 100644 features/list_costumer_service.feature diff --git a/features/list_costumer_service.feature b/features/list_costumer_service.feature deleted file mode 100644 index ad1f3d0..0000000 --- a/features/list_costumer_service.feature +++ /dev/null @@ -1,39 +0,0 @@ -#language: pt - -Funcionalidade: Abrir página de atendimentos - Para poder visualizar os atendimentos realizados pelo PROCON - Como usuário - Quero acessar a página de atendimentos - - Cenário: Carregar página de atendimentos - Ao carregar página de atendimentos, é mostrada uma lista com os atendimentos do PROCON - - Quando eu clico no link "Atendimentos" - Entao vejo a lista de atendimentos - E vejo os filtros para pesquisar atendimento - - - Cenário: Pesquisar atendimentos inexistentes por filtros - Ao buscar atendimentos por meio de filtros, é mostrada uma lista vazia - - Quando eu preencho "2010" em "Ano" - E aperto "Buscar" - Entao vejo a lista de atendimentos com os atendimentos "" - - - Cenário: Pesquisar atendimentos por filtros - Ao buscar atendimentos por meio de filtros, é mostrada uma lista com os atendimentos filtrados. - - Quando eu preencho "2012" em "Ano" - E aperto "Buscar" - Entao vejo a lista de atendimentos com um atendimento: - |id |uf_procon | - |756 |GO | - - - Cenário: Visualizar profile de um atendimento selecionado - Ao clicar em um atendimento, é mostrada as informações do atendimento selecionado. - - Quando eu clico no atendimento "756" - Então vejo "7112345" - E vejo "Reclamação de produto com defeito" \ No newline at end of file From 3980a1a0059dea8b7c86b322b977e35eea6df88e Mon Sep 17 00:00:00 2001 From: Eduardo Moreira Date: Tue, 28 Oct 2014 12:52:09 -0200 Subject: [PATCH 031/198] Changing sintax of funcional test faq. --- features/faq.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/faq.feature b/features/faq.feature index 4e7dd41..398dd64 100644 --- a/features/faq.feature +++ b/features/faq.feature @@ -9,11 +9,11 @@ Funcionalidade: Abrir do página do FAQ Ao carregar página do faq, é mostrada uma lista com perguntas e respostas frequentes. Quando eu clico no link "FAQ" - Então vejo a lista de perguntas + Entao vejo a lista de perguntas Cenário: Visualizar resposta de uma pergunta Ao selecionar uma pergunta, é mostrada a resposta para essa pergunta. Quando eu clico na pergunta "Quais órgãos estão subordinados à essa Lei?" - Então vejo a resposta "Os órgãos da administração direta do Poder Executivo do Distrito Federal, a Câmara Legislativa do Distrito Federal e o Tribunal de Contas do Distrito Federal. As autarquias, fundações públicas, empresas públicas, sociedades de economia mista e demais entidades controladas direta ou indiretamente pelo Distrito Federal. No que couber, às entidades privadas sem fins lucrativos que recebam, para realização de ações de interesse público, recursos públicos diretamente do orçamento ou mediante subvenções sociais, contrato de gestão, termo de parceria, convênios, acordos, ajustes ou outros instrumentos congêneres." \ No newline at end of file + Entao vejo a resposta "Os órgãos da administração direta do Poder Executivo do Distrito Federal, a Câmara Legislativa do Distrito Federal e o Tribunal de Contas do Distrito Federal. As autarquias, fundações públicas, empresas públicas, sociedades de economia mista e demais entidades controladas direta ou indiretamente pelo Distrito Federal. No que couber, às entidades privadas sem fins lucrativos que recebam, para realização de ações de interesse público, recursos públicos diretamente do orçamento ou mediante subvenções sociais, contrato de gestão, termo de parceria, convênios, acordos, ajustes ou outros instrumentos congêneres." \ No newline at end of file From 6202154ba4589b9965c4ab3f2b41e020dd42321a Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Wed, 29 Oct 2014 19:19:07 -0200 Subject: [PATCH 032/198] new shared messages for some methods. --- app/controllers/sessions_controller.rb | 1 + app/controllers/users_controller.rb | 5 +++-- app/views/users/new.html.erb | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 92e840f..095bae3 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -15,6 +15,7 @@ def create end # Sign out def destroy + flash[:sucess] = "Deslogado com exito." sign_out redirect_to root_url end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index adf803f..4489e54 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -16,8 +16,8 @@ def create @user = User.new(user_params) if @user.save sign_in @user - # flash[:sucess] = "Seja bem-vindo!" - redirect_to :action => :show, :id => @user.id + flash[:sucess] = "Seja bem-vindo!" + redirect_to :action => :show, :id => @user.id else render 'new' end @@ -34,6 +34,7 @@ def edit def update @user = User.find(params[:id]) if @user.update_attributes(user_params) + flash[:sucess] = "Usuario editado com exito!" redirect_to @user else render 'edit' diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb index fb3cbb3..30982df 100644 --- a/app/views/users/new.html.erb +++ b/app/views/users/new.html.erb @@ -1,3 +1,4 @@ +

Cadastro de Usuário

<%= form_for(@user) do |f| %> <%= render 'shared/error_messages' %> @@ -26,3 +27,4 @@ <% end %>

+ \ No newline at end of file From 31c6ef4bb0df0002785dee411a1ee6326f8b98b0 Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Wed, 29 Oct 2014 20:12:35 -0200 Subject: [PATCH 033/198] shared messages working with en.yml --- app/controllers/users_controller.rb | 2 ++ app/views/layouts/application.html.erb | 1 + app/views/shared/_error_messages.html.erb | 4 ++-- config/locales/en.yml | 27 +++++++++++++++++++++++ 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4489e54..4601355 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -44,6 +44,8 @@ def update def destroy @user = User.find(params[:id]) @user.destroy + redirect_to root_path + flash[:sucess] = "Usuario excluido com exito." end private diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index a954d5a..ef7656d 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,4 +1,5 @@ + diff --git a/app/views/shared/_error_messages.html.erb b/app/views/shared/_error_messages.html.erb index c9c0ff4..c9ff4ea 100644 --- a/app/views/shared/_error_messages.html.erb +++ b/app/views/shared/_error_messages.html.erb @@ -1,11 +1,11 @@ <% if @user.errors.any? %>
- The form contains <%= pluralize(@user.errors.count, "error") %>. + Erros encontrados.
    <% @user.errors.full_messages.each do |msg| %> -
  • * <%= msg %>
  • +
  • <%= msg %>
  • <% end %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index 179c14c..a2f32c5 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -3,3 +3,30 @@ en: hello: "Hello world" + +en: + activerecord: + attributes: + user: + email_user: "E-mail" + password: "Senha" + password_confirmation: "Confirmação de senha" + name_user: "Nome" + password_digest: "" + errors: + models: + user: + attributes: + email_user: + blank: "não preenchido." + invalid: "inválido." + password: + blank: "não preenchida." + invalid: "inválida." + too_short: "muito curta." + name_user: + blank: "em branco." + password_digest: + blank: "" + + From 1a5041962e16e6282de522fc2d94cbf3ca9dbe8d Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Wed, 29 Oct 2014 20:29:54 -0200 Subject: [PATCH 034/198] fixed how the shared_messages are displayed @ layouts/application.html.erb --- app/controllers/sessions_controller.rb | 7 ++--- app/views/layouts/application.html.erb | 37 ++++++++++++-------------- app/views/sessions/new.html.erb | 2 ++ config/locales/en.yml | 3 ++- 4 files changed, 25 insertions(+), 24 deletions(-) diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 095bae3..3b72ff0 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -8,9 +8,10 @@ def create if user && user.authenticate(params[:session][:password]) sign_in user redirect_to user - else - flash.now[:error] = "Invalid email/password combination" - render 'new' + flash[:sucess] = "Logado com exito!" + else + flash.now[:error] = "Combinacao invalida de email e password." + render 'new' end end # Sign out diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index ef7656d..1c3ce7a 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,26 +1,23 @@ - - - -
- - <% flash.each do |key, value| %> -
<%= value %>
- <% end %> -
- <%= stylesheet_link_tag "application", media: "all" %> - <%= javascript_include_tag "application" %> - <%= csrf_meta_tags %> - - - + + + + <%= stylesheet_link_tag "application", media: "all" %> + <%= javascript_include_tag "application" %> + <%= csrf_meta_tags %> + + - <%= render 'layouts/header' %> - <%= render 'layouts/shim' %> + <%= render 'layouts/header' %> + <%= render 'layouts/shim' %> -
-



<%= yield %> +
+



- + <% flash.each do |key, value| %> +
<%= value %>
+ <% end %> + <%= yield %> + diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb index 5956ccd..b3d9f08 100644 --- a/app/views/sessions/new.html.erb +++ b/app/views/sessions/new.html.erb @@ -1,3 +1,5 @@ +
+
<%= form_for(:session, url: sessions_path) do |f| %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index a2f32c5..76fa59c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -12,7 +12,7 @@ en: password: "Senha" password_confirmation: "Confirmação de senha" name_user: "Nome" - password_digest: "" + password_digest: errors: models: user: @@ -20,6 +20,7 @@ en: email_user: blank: "não preenchido." invalid: "inválido." + too_long: "muito longo" password: blank: "não preenchida." invalid: "inválida." From 574cd6103c2eefd638cfc8f3caff649dbcd59f8d Mon Sep 17 00:00:00 2001 From: Omar Faria Date: Thu, 30 Oct 2014 14:33:30 -0200 Subject: [PATCH 035/198] Fixing capybara gem and improving register functional test. --- Gemfile | 1 + features/cadastro.feature | 3 ++- features/step_definitions/register_steps.rb | 14 ++++++++++---- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index 2d2a89a..7807e5f 100644 --- a/Gemfile +++ b/Gemfile @@ -19,6 +19,7 @@ group :development, :test do gem 'rspec-rails' gem 'guard-rspec' gem 'cucumber' + gem 'capybara' end group :test do diff --git a/features/cadastro.feature b/features/cadastro.feature index 0f1af8f..3a8f8cd 100644 --- a/features/cadastro.feature +++ b/features/cadastro.feature @@ -8,7 +8,8 @@ Funcionalidade: Abrir página de cadastrar Cenário: Carregar página de cadastrar Ao carregar página de cadastro, é mostrado um formulário de cadastro para o usuário - Quando eu clico no link "Registrar" + Dado que eu estou na home page + Quando eu clico no link "Registre-se!" Entao vejo o formulario de cadastro diff --git a/features/step_definitions/register_steps.rb b/features/step_definitions/register_steps.rb index be35eb6..839877b 100644 --- a/features/step_definitions/register_steps.rb +++ b/features/step_definitions/register_steps.rb @@ -1,7 +1,13 @@ -Quando(/^eu clico no link "(.*?)"$/) do |arg1| - +require File.expand_path(File.join(File.dirname(__FILE__),"..","support","paths")) + +Dado (/^que eu estou na home page$/) do + visit '/' end -Então(/^vejo o formulario de cadastro$/) do - +Quando(/^eu clico no link (.+)$/) do |text| + click_link text end + +Entao(/^vejo o formulario de cadastro$/) do + page.should have_content 'Repetir' +end \ No newline at end of file From 8b6f6802b2cd6f9fe8a217419b6adb977d38267f Mon Sep 17 00:00:00 2001 From: =Eduardo Moreira Date: Sat, 1 Nov 2014 15:41:32 -0200 Subject: [PATCH 036/198] Changing parameter of unity_procon search --- app/controllers/unity_procons_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/unity_procons_controller.rb b/app/controllers/unity_procons_controller.rb index e38db8e..8268f24 100644 --- a/app/controllers/unity_procons_controller.rb +++ b/app/controllers/unity_procons_controller.rb @@ -23,7 +23,7 @@ def custom_search sql = "1=1" sql = sql - data = UnityProcon.where("right(address_unity_procon, 2) = ?", params[:search]).paginate(:page=>1) + data = UnityProcon.where("uf_procon = ?", params[:search]).paginate(:page=>1) render :json=>data.to_json end end From 7479144c4c82027cc9bb12457932552ca09c575d Mon Sep 17 00:00:00 2001 From: Ricardo Lupiano Andrade Date: Sat, 1 Nov 2014 16:25:50 -0200 Subject: [PATCH 037/198] Adding search field in supplier's index --- app/views/suppliers/index.html.erb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/app/views/suppliers/index.html.erb b/app/views/suppliers/index.html.erb index c8e546c..2abfccd 100644 --- a/app/views/suppliers/index.html.erb +++ b/app/views/suppliers/index.html.erb @@ -1,7 +1,33 @@
+
+
+
+ +






+

BUSCAR

+ + Busca Textual
+ <% # = form_tag('/customer_services/', method: :get) %> + <% # input type="text" name=idteste> %> + <% # = submit_tag "Pesquisar", class:"form_submit" %> +
+ + +
+ + + + + +

Lista de Fornecedores

+
<%= will_paginate %> @@ -29,6 +55,7 @@ <%= will_paginate %>
+
From 774976f34eef5bd29923a81d44849fa63d7d57ee Mon Sep 17 00:00:00 2001 From: =Eduardo Moreira Date: Sat, 1 Nov 2014 16:34:50 -0200 Subject: [PATCH 038/198] Creating method custom_search in supplier's controller --- app/controllers/suppliers_controller.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/app/controllers/suppliers_controller.rb b/app/controllers/suppliers_controller.rb index bd5678e..35a84ee 100644 --- a/app/controllers/suppliers_controller.rb +++ b/app/controllers/suppliers_controller.rb @@ -8,5 +8,27 @@ def index def show @supplier = Supplier.find(params[:id]) end + def custom_search + unless request.xhr? or params[:page].nil? or params[:search].nil? + redirect_to "/" + return + end + + sql = "1=1" + + if !params[:type_search].nil? ! + sql += "AND #{params[:type_search]}_suppliers = ?" + end + + if !params[:unities].nil? and params[:unities].length > 0 + params[:unities].each do |u| + + end + end + + sql = sql + data = Supplier.where("#{params[:type_search]}_suppliers = ?", params[:search]).paginate(:page=>1) + render :json=>data.to_json + end end \ No newline at end of file From 11354f2f3a6c7f7c3e23e22be288aceb455fdfb6 Mon Sep 17 00:00:00 2001 From: Ricardo Lupiano Andrade Date: Sat, 1 Nov 2014 16:43:44 -0200 Subject: [PATCH 039/198] Creating javascript code for supplier's search --- app/assets/javascripts/suppliers.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 app/assets/javascripts/suppliers.js diff --git a/app/assets/javascripts/suppliers.js b/app/assets/javascripts/suppliers.js new file mode 100644 index 0000000..b51447c --- /dev/null +++ b/app/assets/javascripts/suppliers.js @@ -0,0 +1,16 @@ +(function() +{ + + $(document).ready(function() + { + $("#supplier_button").click(function() + { + var search = $("#supplier_text").val(); + var type_search = $(".search_type:checked").val(); + var suppliers = []; + + + + }); + }); +})(); From 605ab8bac30b5250139e655c4d8a358e4f4071d2 Mon Sep 17 00:00:00 2001 From: =Eduardo Moreira Date: Sat, 1 Nov 2014 16:51:40 -0200 Subject: [PATCH 040/198] Creating function to search suppliers by the given parameters --- app/assets/javascripts/suppliers.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/suppliers.js b/app/assets/javascripts/suppliers.js index b51447c..5928da2 100644 --- a/app/assets/javascripts/suppliers.js +++ b/app/assets/javascripts/suppliers.js @@ -1,6 +1,24 @@ (function() { + function custom_search(search, type_search, suppliers) + { + $.ajax( + { + url: "/supplier/custom_search", + type: "GET", + data: { "search":search, "type_search":type_search, "suppliers":suppliers,"page":1 }, + success : function(response) + { + var html = ""; + for(var i = 0; i < response.length; i++) + { + + } + $("#suppliers").html(html); + } + }); + } $(document).ready(function() { $("#supplier_button").click(function() @@ -9,7 +27,7 @@ var type_search = $(".search_type:checked").val(); var suppliers = []; - + custom_search(search, type_search, suppliers); }); }); From 269c42afa93b6cf3f5177f6e08c32d6bbc393028 Mon Sep 17 00:00:00 2001 From: Ricardo Lupiano Andrade Date: Sat, 1 Nov 2014 17:11:14 -0200 Subject: [PATCH 041/198] Creating function html to display the suppliers searcher --- app/assets/javascripts/suppliers.js | 19 ++++++++++++++----- app/controllers/suppliers_controller.rb | 4 ++-- app/views/suppliers/index.html.erb | 4 ++-- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/suppliers.js b/app/assets/javascripts/suppliers.js index 5928da2..53ed48b 100644 --- a/app/assets/javascripts/suppliers.js +++ b/app/assets/javascripts/suppliers.js @@ -1,19 +1,29 @@ (function() { + function build_row(data) + { + var html = ""; + + html += "Nome: "+data.fantasy_name_supplier+""; + html += "CNPJ: "+data.cnpj+""; + + html += ""; + return html; + } - function custom_search(search, type_search, suppliers) + function custom_search(search, type_search) { $.ajax( { url: "/supplier/custom_search", type: "GET", - data: { "search":search, "type_search":type_search, "suppliers":suppliers,"page":1 }, + data: { "search":search, "type_search":type_search,"page":1 }, success : function(response) { var html = ""; for(var i = 0; i < response.length; i++) { - + html += build_row(response[i]); } $("#suppliers").html(html); } @@ -25,9 +35,8 @@ { var search = $("#supplier_text").val(); var type_search = $(".search_type:checked").val(); - var suppliers = []; - custom_search(search, type_search, suppliers); + custom_search(search, type_search); }); }); diff --git a/app/controllers/suppliers_controller.rb b/app/controllers/suppliers_controller.rb index 35a84ee..5586150 100644 --- a/app/controllers/suppliers_controller.rb +++ b/app/controllers/suppliers_controller.rb @@ -17,7 +17,7 @@ def custom_search sql = "1=1" if !params[:type_search].nil? ! - sql += "AND #{params[:type_search]}_suppliers = ?" + sql += "AND #{params[:type_search]} = ?" end if !params[:unities].nil? and params[:unities].length > 0 @@ -27,7 +27,7 @@ def custom_search end sql = sql - data = Supplier.where("#{params[:type_search]}_suppliers = ?", params[:search]).paginate(:page=>1) + data = Supplier.where("#{params[:type_search]} = ?", params[:search]).paginate(:page=>1) render :json=>data.to_json end diff --git a/app/views/suppliers/index.html.erb b/app/views/suppliers/index.html.erb index 2abfccd..f0d5a2e 100644 --- a/app/views/suppliers/index.html.erb +++ b/app/views/suppliers/index.html.erb @@ -15,13 +15,13 @@
- +
From 0285b9269733230b58ab74cdc86f0299345109ed Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Sat, 1 Nov 2014 18:39:04 -0200 Subject: [PATCH 042/198] fixing cucumber installation --- Gemfile | 5 +- Gemfile.lock | 12 ++-- config/cucumber.yml | 8 +++ config/database.yml | 5 +- features/cadastro.feature | 2 +- features/signing_in.feature | 13 +++++ features/step_definitions/register_steps.rb | 13 ----- features/support/env.rb | 56 ++++++++++++++++++ lib/tasks/cucumber.rake | 65 +++++++++++++++++++++ script/cucumber | 10 ++++ 10 files changed, 166 insertions(+), 23 deletions(-) create mode 100644 config/cucumber.yml create mode 100644 features/signing_in.feature delete mode 100644 features/step_definitions/register_steps.rb create mode 100644 features/support/env.rb create mode 100644 lib/tasks/cucumber.rake create mode 100755 script/cucumber diff --git a/Gemfile b/Gemfile index 7807e5f..702b401 100644 --- a/Gemfile +++ b/Gemfile @@ -18,14 +18,13 @@ gem 'rspec-its' group :development, :test do gem 'rspec-rails' gem 'guard-rspec' - gem 'cucumber' - gem 'capybara' end group :test do gem 'factory_girl_rails', '4.1.0' gem 'selenium-webdriver' - gem 'capybara' + gem 'cucumber-rails', '1.2.1', :require => false + gem 'database_cleaner', '0.7.0' end # Gems used only for assets and not required diff --git a/Gemfile.lock b/Gemfile.lock index d1227ca..eb66358 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -58,6 +58,11 @@ GEM gherkin (~> 2.12) multi_json (>= 1.7.5, < 2.0) multi_test (>= 0.1.1) + cucumber-rails (1.2.1) + capybara (>= 1.1.2) + cucumber (>= 1.1.3) + nokogiri (>= 1.5.0) + database_cleaner (0.7.0) diff-lcs (1.2.5) docile (1.1.5) erubis (2.7.0) @@ -220,13 +225,10 @@ PLATFORMS DEPENDENCIES bcrypt-ruby (~> 3.0.0) bootstrap-will_paginate (= 0.0.6) - capybara coffee-rails (~> 3.2.1) - - cucumber - + cucumber-rails (= 1.2.1) + database_cleaner (= 0.7.0) factory_girl_rails (= 4.1.0) -sessionscontroller tests guard-rspec jquery-rails less-rails diff --git a/config/cucumber.yml b/config/cucumber.yml new file mode 100644 index 0000000..19b288d --- /dev/null +++ b/config/cucumber.yml @@ -0,0 +1,8 @@ +<% +rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : "" +rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}" +std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip" +%> +default: <%= std_opts %> features +wip: --tags @wip:3 --wip features +rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip diff --git a/config/database.yml b/config/database.yml index 4ff05d8..19235fc 100644 --- a/config/database.yml +++ b/config/database.yml @@ -13,7 +13,7 @@ development: # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. -test: +test: &test adapter: mysql2 database: proconsulta username: root @@ -28,3 +28,6 @@ production: password: proconsulta2014 host: localhost timeout: 5000 + +cucumber: + <<: *test \ No newline at end of file diff --git a/features/cadastro.feature b/features/cadastro.feature index 3a8f8cd..d358f5c 100644 --- a/features/cadastro.feature +++ b/features/cadastro.feature @@ -36,4 +36,4 @@ Funcionalidade: Abrir página de cadastrar E preencho o campo "Repetir" com "654321" E preencho o campo "Estado" com "DF" E pressionar o botão "Registrar conta" - Entao vejo "passwords don't match" + Entao vejo "passwords don't match" \ No newline at end of file diff --git a/features/signing_in.feature b/features/signing_in.feature new file mode 100644 index 0000000..e10d8cc --- /dev/null +++ b/features/signing_in.feature @@ -0,0 +1,13 @@ +Feature: Signing in + + Scenario: Unsuccessful signin + Given a user visits the signin page + When they submit invalid signin information + Then they should see an error message + + Scenario: Successful signin + Given a user visits the signin page + And the user has an account + When the user submits valid signin information + Then they should see their profile page + And they should see a signout link \ No newline at end of file diff --git a/features/step_definitions/register_steps.rb b/features/step_definitions/register_steps.rb deleted file mode 100644 index 839877b..0000000 --- a/features/step_definitions/register_steps.rb +++ /dev/null @@ -1,13 +0,0 @@ -require File.expand_path(File.join(File.dirname(__FILE__),"..","support","paths")) - -Dado (/^que eu estou na home page$/) do - visit '/' -end - -Quando(/^eu clico no link (.+)$/) do |text| - click_link text -end - -Entao(/^vejo o formulario de cadastro$/) do - page.should have_content 'Repetir' -end \ No newline at end of file diff --git a/features/support/env.rb b/features/support/env.rb new file mode 100644 index 0000000..b2cf673 --- /dev/null +++ b/features/support/env.rb @@ -0,0 +1,56 @@ +# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril. +# It is recommended to regenerate this file in the future when you upgrade to a +# newer version of cucumber-rails. Consider adding your own code to a new file +# instead of editing this one. Cucumber will automatically load all features/**/*.rb +# files. + +require 'cucumber/rails' + +# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In +# order to ease the transition to Capybara we set the default here. If you'd +# prefer to use XPath just remove this line and adjust any selectors in your +# steps to use the XPath syntax. +Capybara.default_selector = :css + +# By default, any exception happening in your Rails application will bubble up +# to Cucumber so that your scenario will fail. This is a different from how +# your application behaves in the production environment, where an error page will +# be rendered instead. +# +# Sometimes we want to override this default behaviour and allow Rails to rescue +# exceptions and display an error page (just like when the app is running in production). +# Typical scenarios where you want to do this is when you test your error pages. +# There are two ways to allow Rails to rescue exceptions: +# +# 1) Tag your scenario (or feature) with @allow-rescue +# +# 2) Set the value below to true. Beware that doing this globally is not +# recommended as it will mask a lot of errors for you! +# +ActionController::Base.allow_rescue = false + +# Remove/comment out the lines below if your app doesn't have a database. +# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead. +begin + DatabaseCleaner.strategy = :transaction +rescue NameError + raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it." +end + +# You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios. +# See the DatabaseCleaner documentation for details. Example: +# +# Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do +# DatabaseCleaner.strategy = :truncation, {:except => %w[widgets]} +# end +# +# Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do +# DatabaseCleaner.strategy = :transaction +# end +# + +# Possible values are :truncation and :transaction +# The :transaction strategy is faster, but might give you threading problems. +# See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature +Cucumber::Rails::Database.javascript_strategy = :truncation + diff --git a/lib/tasks/cucumber.rake b/lib/tasks/cucumber.rake new file mode 100644 index 0000000..83f7947 --- /dev/null +++ b/lib/tasks/cucumber.rake @@ -0,0 +1,65 @@ +# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril. +# It is recommended to regenerate this file in the future when you upgrade to a +# newer version of cucumber-rails. Consider adding your own code to a new file +# instead of editing this one. Cucumber will automatically load all features/**/*.rb +# files. + + +unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks + +vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first +$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil? + +begin + require 'cucumber/rake/task' + + namespace :cucumber do + Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t| + t.binary = vendored_cucumber_bin # If nil, the gem's binary is used. + t.fork = true # You may get faster startup if you set this to false + t.profile = 'default' + end + + Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t| + t.binary = vendored_cucumber_bin + t.fork = true # You may get faster startup if you set this to false + t.profile = 'wip' + end + + Cucumber::Rake::Task.new({:rerun => 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t| + t.binary = vendored_cucumber_bin + t.fork = true # You may get faster startup if you set this to false + t.profile = 'rerun' + end + + desc 'Run all features' + task :all => [:ok, :wip] + + task :statsetup do + require 'rails/code_statistics' + ::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features') + ::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?('features') + end + end + desc 'Alias for cucumber:ok' + task :cucumber => 'cucumber:ok' + + task :default => :cucumber + + task :features => :cucumber do + STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***" + end + + # In case we don't have ActiveRecord, append a no-op task that we can depend upon. + task 'db:test:prepare' do + end + + task :stats => 'cucumber:statsetup' +rescue LoadError + desc 'cucumber rake task not available (cucumber not installed)' + task :cucumber do + abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin' + end +end + +end diff --git a/script/cucumber b/script/cucumber new file mode 100755 index 0000000..7fa5c92 --- /dev/null +++ b/script/cucumber @@ -0,0 +1,10 @@ +#!/usr/bin/env ruby + +vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first +if vendored_cucumber_bin + load File.expand_path(vendored_cucumber_bin) +else + require 'rubygems' unless ENV['NO_RUBYGEMS'] + require 'cucumber' + load Cucumber::BINARY +end From f95b88d16326ecb6005a1c8cd5260e508377eb7f Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Sat, 1 Nov 2014 19:50:01 -0200 Subject: [PATCH 043/198] =?UTF-8?q?scenario=20'carregar=20p=C3=A1gina=20de?= =?UTF-8?q?=20cadastrar'=20done?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/_header.html.erb | 2 +- app/views/users/index.html.erb | 2 +- features/cadastro.feature | 6 ++-- .../step_definitions/authentication_steps.rb | 32 +++++++++++++++++++ 4 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 features/step_definitions/authentication_steps.rb diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index 328fa79..333198a 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -32,7 +32,7 @@ Acesso diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index 4c0b8df..4f89e7b 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -14,7 +14,7 @@

Seja bem-vindo, <%= current_user.name_user %>

<% else %> - Novo?<%= link_to " Registre-se!", "/signup" %>
+ Novo?<%= link_to "Registre-se!", signup_path %>
<%= link_to "Logar", "/signin" %>
<% end %> diff --git a/features/cadastro.feature b/features/cadastro.feature index d358f5c..c133553 100644 --- a/features/cadastro.feature +++ b/features/cadastro.feature @@ -9,14 +9,16 @@ Funcionalidade: Abrir página de cadastrar Ao carregar página de cadastro, é mostrado um formulário de cadastro para o usuário Dado que eu estou na home page - Quando eu clico no link "Registre-se!" + Quando eu clico no link "Registrar" Entao vejo o formulario de cadastro Cenário: Cadastrar novo usuário Ao preencher informações do novo usuário e salvá-las, novo usuário é cadastrado. - Quando eu preencho o campo "Nome" com "Eduardo" + + Quando eu clico no link "Registrar" + E preencho o campo "Nome" com "Eduardo" E preencho o campo "E-mail" com "eduardo@hotmail.com" E preencho o campo "Senha" com "123456" E preencho o campo "Repetir" com "123456" diff --git a/features/step_definitions/authentication_steps.rb b/features/step_definitions/authentication_steps.rb new file mode 100644 index 0000000..abc722f --- /dev/null +++ b/features/step_definitions/authentication_steps.rb @@ -0,0 +1,32 @@ +# encoding: utf-8 + +Dado(/^que eu estou na home page$/) do + visit root_path +end + +Quando(/^eu clico no link "(.*?)"$/) do |arg1| + click_link arg1 +end + +Entao(/^vejo o formulario de cadastro$/) do + assert page.has_text?("Nome") + assert page.has_text?("E-mail") + assert page.has_text?("Senha") + assert page.has_text?("Repetir") +end + +Quando(/^eu preencho o campo "(.*?)" com "(.*?)"$/) do |arg1, arg2| + fill_in arg1, with: arg2 +end + +Quando(/^preencho o campo "(.*?)" com "(.*?)"$/) do |arg1, arg2| + pending # express the regexp above with the code you wish you had +end + +Quando(/^pressionar o botão "(.*?)"$/) do |arg1| + pending # express the regexp above with the code you wish you had +end + +Entao(/^vejo "(.*?)"$/) do |arg1| + pending # express the regexp above with the code you wish you had +end From ef7c8543d117cb8040818d62eceeaecd6f1a16e1 Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Sat, 1 Nov 2014 20:39:21 -0200 Subject: [PATCH 044/198] more definitions for registering_user --- features/cadastro.feature | 15 ++++++----- .../step_definitions/authentication_steps.rb | 25 +++++++++++++++---- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/features/cadastro.feature b/features/cadastro.feature index c133553..5cab0c8 100644 --- a/features/cadastro.feature +++ b/features/cadastro.feature @@ -16,26 +16,25 @@ Funcionalidade: Abrir página de cadastrar Cenário: Cadastrar novo usuário Ao preencher informações do novo usuário e salvá-las, novo usuário é cadastrado. - + Dado que eu estou na home page Quando eu clico no link "Registrar" E preencho o campo "Nome" com "Eduardo" E preencho o campo "E-mail" com "eduardo@hotmail.com" E preencho o campo "Senha" com "123456" E preencho o campo "Repetir" com "123456" - E preencho o campo "Estado" com "DF" E pressionar o botão "Registrar conta" - Entao vejo "Nome: Eduardo" - E vejo "Estado: DF" - E vejo "E-Mail: moreira.edu@hotmail.com" + Entao sou redirecionado para a pagina "/users/1" + Entao vejo o texto "Seja bem-vindo" Cenário: Cadastrar usuário com senhas incompatíveis Ao preencher informações do novo usuário com senhas diferentes, usuário não deve ser cadastrado. - Quando eu preencho o campo "Nome" com "Eduardo" + Dado que eu estou na home page + Quando eu clico no link "Registrar" + E preencho o campo "Nome" com "Eduardo" E preencho o campo "E-mail" com "eduardo@hotmail.com" E preencho o campo "Senha" com "123456" E preencho o campo "Repetir" com "654321" - E preencho o campo "Estado" com "DF" E pressionar o botão "Registrar conta" - Entao vejo "passwords don't match" \ No newline at end of file + Entao erros aparecem \ No newline at end of file diff --git a/features/step_definitions/authentication_steps.rb b/features/step_definitions/authentication_steps.rb index abc722f..84e02a4 100644 --- a/features/step_definitions/authentication_steps.rb +++ b/features/step_definitions/authentication_steps.rb @@ -16,17 +16,32 @@ end Quando(/^eu preencho o campo "(.*?)" com "(.*?)"$/) do |arg1, arg2| - fill_in arg1, with: arg2 + pending # teste end -Quando(/^preencho o campo "(.*?)" com "(.*?)"$/) do |arg1, arg2| - pending # express the regexp above with the code you wish you had +E(/^preencho o campo "(.*?)" com "(.*?)"$/) do |arg1, arg2| + fill_in arg1, with: arg2 end Quando(/^pressionar o botão "(.*?)"$/) do |arg1| - pending # express the regexp above with the code you wish you had + click_button arg1 end Entao(/^vejo "(.*?)"$/) do |arg1| - pending # express the regexp above with the code you wish you had + assert page.has_text?(arg1) +end + +Entao(/^vejo o texto "(.*?)"$/) do |arg1| + assert page.has_text(arg1) +end + +Entao(/^sou redirecionado para a pagina "(.*?)"$/) do |arg1| + page.should redirect_to(arg1) end + +Entao(/^erros aparecem"$/) do + page.should have_selector('div.alert.alert-error') +end + + + From 566dc535c0edda4ded4c0c444c949a6d24d21da3 Mon Sep 17 00:00:00 2001 From: "Matheus S. Pereira" Date: Sun, 2 Nov 2014 10:04:12 -0200 Subject: [PATCH 045/198] repairing the supplier.js --- app/assets/javascripts/suppliers.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/suppliers.js b/app/assets/javascripts/suppliers.js index 53ed48b..99e0cfa 100644 --- a/app/assets/javascripts/suppliers.js +++ b/app/assets/javascripts/suppliers.js @@ -31,9 +31,9 @@ } $(document).ready(function() { - $("#supplier_button").click(function() + $("#supplier_search_button").click(function() { - var search = $("#supplier_text").val(); + var search = $("#supplier_search_text").val(); var type_search = $(".search_type:checked").val(); custom_search(search, type_search); From 33976155b7eb4a83e76fd8b5b32b4706a1ab3252 Mon Sep 17 00:00:00 2001 From: "Matheus S. Pereira" Date: Sun, 2 Nov 2014 10:06:53 -0200 Subject: [PATCH 046/198] repairing the custom_search method in suppliers_controller --- app/controllers/suppliers_controller.rb | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/app/controllers/suppliers_controller.rb b/app/controllers/suppliers_controller.rb index 5586150..27eb543 100644 --- a/app/controllers/suppliers_controller.rb +++ b/app/controllers/suppliers_controller.rb @@ -8,6 +8,7 @@ def index def show @supplier = Supplier.find(params[:id]) end + def custom_search unless request.xhr? or params[:page].nil? or params[:search].nil? redirect_to "/" @@ -16,16 +17,10 @@ def custom_search sql = "1=1" - if !params[:type_search].nil? ! + if !params[:type_search].nil? sql += "AND #{params[:type_search]} = ?" end - if !params[:unities].nil? and params[:unities].length > 0 - params[:unities].each do |u| - - end - end - sql = sql data = Supplier.where("#{params[:type_search]} = ?", params[:search]).paginate(:page=>1) render :json=>data.to_json From e39b19ad3d184e492f4ee79151884bb6f1206c83 Mon Sep 17 00:00:00 2001 From: "Matheus S. Pereira" Date: Sun, 2 Nov 2014 10:07:57 -0200 Subject: [PATCH 047/198] changing the name of some id's --- app/views/suppliers/index.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/suppliers/index.html.erb b/app/views/suppliers/index.html.erb index f0d5a2e..611b001 100644 --- a/app/views/suppliers/index.html.erb +++ b/app/views/suppliers/index.html.erb @@ -11,8 +11,8 @@ <% # input type="text" name=idteste> %> <% # = submit_tag "Pesquisar", class:"form_submit" %> - - + +
diff --git a/app/views/customer_services/list.html.erb b/app/views/customer_services/list.html.erb new file mode 100644 index 0000000..826b1c8 --- /dev/null +++ b/app/views/customer_services/list.html.erb @@ -0,0 +1,39 @@ +
+ <%= render 'layouts/searcher' %> +
+

Lista de Atendimentos

+
+
+
+
+ <%= will_paginate %> +
+ + + + + + + + + + + + <% @customer_services.each do |cs| %> + +
+
+ + + + + + <% end %> + +
AnoUFIDDescrição
<%= cs.year_customer_service %><%= cs.uf_customer_service %><%= link_to cs.id, '/customer_services/'+cs.id.to_s %><%= cs.description_problem_customer_service %>
+
+ <%= will_paginate %> +
+
+
+
\ No newline at end of file diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index 333198a..9c52fcc 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -6,7 +6,17 @@