From 9360c0090ea7936d190106c9c2ce11265af1e12d Mon Sep 17 00:00:00 2001 From: rgarcia Date: Thu, 10 Sep 2015 11:03:31 +0200 Subject: [PATCH 1/4] tracks level 2 verified users --- app/controllers/verification/sms_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/verification/sms_controller.rb b/app/controllers/verification/sms_controller.rb index 8b4d24b9f..9f282c2c9 100644 --- a/app/controllers/verification/sms_controller.rb +++ b/app/controllers/verification/sms_controller.rb @@ -27,6 +27,7 @@ class Verification::SmsController < ApplicationController @sms = Verification::Sms.new(sms_params.merge(user: current_user)) if @sms.verify? current_user.update(confirmed_phone: current_user.unconfirmed_phone) + ahoy.track :level_2_user, user_id: current_user.id if VerifiedUser.phone?(current_user) current_user.update(verified_at: Time.now) From a8edad2ab6c5e7d450ce68d5ae87c3115837092f Mon Sep 17 00:00:00 2001 From: rgarcia Date: Thu, 10 Sep 2015 11:03:48 +0200 Subject: [PATCH 2/4] refactors stats page --- app/controllers/stats_controller.rb | 2 +- app/views/stats/show.html.erb | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb index fe224eb8d..5802ee9e9 100644 --- a/app/controllers/stats_controller.rb +++ b/app/controllers/stats_controller.rb @@ -3,7 +3,7 @@ class StatsController < ApplicationController skip_authorization_check def show - @event_types = Ahoy::Event.select(:name).uniq.pluck(:name) + @event_types = Ahoy::Event.group(:name).count end private diff --git a/app/views/stats/show.html.erb b/app/views/stats/show.html.erb index f5df82b98..da366aa1a 100644 --- a/app/views/stats/show.html.erb +++ b/app/views/stats/show.html.erb @@ -10,13 +10,13 @@

Combined

- <%= events_chart_tag @event_types, id: 'combined' %> + <%= events_chart_tag @event_types.keys, id: 'combined' %>
- <% @event_types.each do |event_type| %> -

<%= event_type.titleize %>

- <%= events_chart_tag event_type %> + <% @event_types.each do |event, count| %> +

<%= event.titleize %> (<%= count %>)

+ <%= events_chart_tag event %> <% end %>
From e1d708dc1f44f2ac59b7d025ee8ba1b8622a101a Mon Sep 17 00:00:00 2001 From: rgarcia Date: Thu, 10 Sep 2015 11:03:59 +0200 Subject: [PATCH 3/4] adds specs for tracking level 2 users --- spec/features/stats_spec.rb | 21 +++++++++++++++++++++ spec/support/common_actions.rb | 13 +++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 spec/features/stats_spec.rb diff --git a/spec/features/stats_spec.rb b/spec/features/stats_spec.rb new file mode 100644 index 000000000..33c069e44 --- /dev/null +++ b/spec/features/stats_spec.rb @@ -0,0 +1,21 @@ +require 'rails_helper' + +feature 'Stats' do + + scenario 'Level 2 user', :focus do + admin = create(:administrator) + user = create(:user) + login_as(user) + + visit account_path + click_link 'Verify my account' + verify_residence + confirm_phone + + login_as(admin.user) + visit stats_path + + expect(page).to have_content "Level 2 User (1)" + end + +end \ No newline at end of file diff --git a/spec/support/common_actions.rb b/spec/support/common_actions.rb index 4753abbbb..c1d382b4e 100644 --- a/spec/support/common_actions.rb +++ b/spec/support/common_actions.rb @@ -110,4 +110,17 @@ module CommonActions click_button 'Verify residence' expect(page).to have_content 'Residence verified' end + + def confirm_phone + fill_in 'sms_phone', with: "611111111" + click_button 'Send' + + expect(page).to have_content 'Security code confirmation' + + user = User.last.reload + fill_in 'sms_confirmation_code', with: user.sms_confirmation_code + click_button 'Send' + + expect(page).to have_content 'Correct code' + end end From 289389d09e234065a497d86680540e2adc25ae52 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Thu, 10 Sep 2015 11:13:54 +0200 Subject: [PATCH 4/4] removes spec focus [#399] --- spec/features/stats_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/stats_spec.rb b/spec/features/stats_spec.rb index 33c069e44..2363e3ff6 100644 --- a/spec/features/stats_spec.rb +++ b/spec/features/stats_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' feature 'Stats' do - scenario 'Level 2 user', :focus do + scenario 'Level 2 user' do admin = create(:administrator) user = create(:user) login_as(user)