mousereco 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. checksums.yaml +9 -9
  2. data/README.md +14 -3
  3. data/Rakefile +5 -11
  4. data/app/controllers/mousereco/api/v1/events_controller.rb +3 -1
  5. data/app/controllers/mousereco/application_controller.rb +2 -0
  6. data/app/controllers/mousereco/pageviews_controller.rb +8 -3
  7. data/app/controllers/mousereco/visitors_controller.rb +3 -1
  8. data/lib/generators/mousereco/install/install_generator.rb +9 -3
  9. data/lib/generators/mousereco/install/templates/mousereco.rb +4 -0
  10. data/lib/mousereco/version.rb +1 -1
  11. data/lib/mousereco.rb +6 -0
  12. data/spec/api/mousereco/events_api_spec.rb +11 -0
  13. data/spec/controllers/mousereco/pageviews_controller_spec.rb +1 -1
  14. data/spec/controllers/mousereco/visitors_controller_spec.rb +11 -2
  15. data/spec/dummy/Gemfile +0 -1
  16. data/spec/dummy/Gemfile.lock +1 -11
  17. data/spec/dummy/config/initializers/mousereco.rb +4 -0
  18. data/spec/dummy/db/development.sqlite3 +0 -0
  19. data/spec/dummy/db/schema.rb +1 -1
  20. data/spec/dummy/db/test.sqlite3 +0 -0
  21. data/spec/dummy/log/development.log +7893 -0
  22. data/spec/dummy/log/test.log +7364 -0
  23. data/spec/dummy/tmp/cache/assets/development/sprockets/2533caf6d0459a8624fd40d33cddde85 +0 -0
  24. data/spec/dummy/tmp/cache/assets/development/sprockets/29cde272ab8d39abcb99bfc3cba51e1b +0 -0
  25. data/spec/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  26. data/spec/dummy/tmp/cache/assets/development/sprockets/2fd3dabf7baee6c0702bc29f86d2a70c +0 -0
  27. data/spec/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  28. data/spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  29. data/spec/dummy/tmp/pids/server.pid +1 -1
  30. data/spec/fabricators/visitor.rb +1 -1
  31. data/spec/spec_helper.rb +4 -0
  32. data/spec/support/auth_helper.rb +7 -0
  33. data/spec/support/http_authenticated.rb +11 -0
  34. metadata +34 -41
  35. /data/spec/dummy/db/migrate/{20140128221416_create_mousereco_events.mousereco.rb → 20140216151256_create_mousereco_events.mousereco.rb} +0 -0
  36. /data/spec/dummy/db/migrate/{20140128221417_create_mousereco_pageviews.mousereco.rb → 20140216151257_create_mousereco_pageviews.mousereco.rb} +0 -0
  37. /data/spec/dummy/db/migrate/{20140128221418_create_mousereco_visitors.mousereco.rb → 20140216151258_create_mousereco_visitors.mousereco.rb} +0 -0
  38. /data/spec/dummy/db/migrate/{20140130215835_add_limit_to_timestamps.mousereco.rb → 20140216151259_add_limit_to_timestamps.mousereco.rb} +0 -0
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTI3YjRjZmNhZWMwN2M3NGUwYTcyMmFlOWI2ZDg0ZDlhNjg1ZjhkNw==
4
+ ZDkwMzY4NTAxMjc4NDAxNmFjZGE3ODE4NDNlMDNkZjIzODQwZDU1Zg==
5
5
  data.tar.gz: !binary |-
6
- NDJjZjQ1NTJhMWI5ZGM1MGIxOWI2NWI1YzIzNDMzMGJjZWFjYWJlNg==
7
- !binary "U0hBNTEy":
6
+ NjIxNmM1Njg4Yzc3ZjJkYmQ0Mjg5YTY4YTU2OGRjN2MyNzNmOTllNA==
7
+ SHA512:
8
8
  metadata.gz: !binary |-
9
- NWY4YWJhYjIyNjFhYTM4ZjNmYzVkNzI0YThmYjI2ZjQzMmQ5ZDc4M2U3OGZl
10
- OWM2NmRlN2E2YjkyYmQzNzVlZDAzNDRkZGY1ZGI3NjA0MWVmYjI3MzM5MDY1
11
- ZjVjZTRjZTUzZDIzZjljN2NmNDY5MjBmYTNlYTlmYTFhZmMyMjA=
9
+ NmMwOGZmOTgwODAxYTBlNjA5NmY2ZTE3NDk1NTQ1ZDIyNDI3YzFlODQ3MGMz
10
+ NGU2NDZmNDY3MmFlN2I0NzI1N2EzNzdlZjQ5OWMxNzNiMzQ4MWFkNDE2ZWU4
11
+ ZjgyNTk1ZGE2ZGU1Y2QyNTU1YjgzMmI3Yjc1NjJmMDZjOTQyODA=
12
12
  data.tar.gz: !binary |-
13
- NTkzMWEzM2VlMTEyYTM1OWI0YmJlMmZlZTFkMDFhYjE4MmIzMTQ3ZGEwODU4
14
- MWE0NmQyYjE3ZDI3N2VhNzc5YTAwOGZhZThkMjE1ODI5YzE1MTdiY2Y2YTNm
15
- ZDY5YjQ1M2I1MDE3MTdjN2VmOTNmOTc0ODIzZDJlYmJkYTZkODQ=
13
+ OTQ1MGRhMTg2NjRhYWQwYmE1MGNkOTJkZjBiNWMwM2FlMjE1YjIyZDA5ZTJh
14
+ NzBiYTg0MWY5OGM2NWFiODZiMTQ3ZGU1ZWI4NTQyZjljZjFhNzFlOTQwZTNi
15
+ ZmNmNDE2ZjFmMTRlNGM0Y2NhM2VjOGUxZjU4MzQ5ZGUzZjEwMTE=
data/README.md CHANGED
@@ -1,26 +1,37 @@
1
+ [![Build Status](https://travis-ci.org/pawelnguyen/mousereco.png?branch=master)](https://travis-ci.org/pawelnguyen/mousereco)
2
+
1
3
  # Mousereco
2
4
 
3
5
  Mousereco is a mouse recording Rails engine with a web interface used to replay user visits
4
6
 
5
7
  ## Installation
6
8
 
7
- Add this line to your application's Gemfile:
9
+ #### 1. Add this line to your application's Gemfile:
8
10
 
9
11
  gem 'mousereco'
10
12
 
11
- Execute:
13
+ #### 2. Execute:
12
14
 
13
15
  $ bundle
14
16
 
15
- And then run install generator:
17
+ #### 3. And then run install generator:
16
18
 
17
19
  $ rails generate mousereco:install
18
20
 
19
21
  It will:
22
+ - add ```initializers/mousereco.rb``` file
20
23
  - add a tracker js code to your application.js file
21
24
  - mount Mousereco at ```/mousereco``` route
22
25
  - install and run migrations needed for Mousereco
23
26
 
27
+ #### 4. Change your http basic authentication password:
28
+
29
+ Edit ```initializers/mousereco.rb``` file:
30
+
31
+ ```
32
+ config.http_auth_password = 'your_secret_password'
33
+ ```
34
+
24
35
  ## Usage
25
36
 
26
37
  By default Mousereco engine will be mounted at ```/mousereco``` path in your application. You can replay your recordings there
data/Rakefile CHANGED
@@ -14,21 +14,15 @@ RDoc::Task.new(:rdoc) do |rdoc|
14
14
  rdoc.rdoc_files.include('lib/**/*.rb')
15
15
  end
16
16
 
17
- APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
17
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
18
18
  load 'rails/tasks/engine.rake'
19
19
 
20
-
20
+ require "rspec/core/rake_task"
21
21
 
22
22
  Bundler::GemHelper.install_tasks
23
23
 
24
- require 'rake/testtask'
25
-
26
- Rake::TestTask.new(:test) do |t|
27
- t.libs << 'lib'
28
- t.libs << 'test'
29
- t.pattern = 'test/**/*_test.rb'
30
- t.verbose = false
24
+ RSpec::Core::RakeTask.new(:spec) do |spec|
25
+ spec.pattern = 'spec/**/*_spec.rb'
31
26
  end
32
27
 
33
-
34
- task default: :test
28
+ task default: :spec
@@ -3,7 +3,9 @@ module Mousereco
3
3
  module V1
4
4
  class EventsController < ApplicationController
5
5
  def create
6
- EventsService.create_collection(permitted_params[:events].values, permitted_params[:visitor_key], permitted_params[:pageview_key])
6
+ if permitted_params[:events].present?
7
+ EventsService.create_collection(permitted_params[:events].values, permitted_params[:visitor_key], permitted_params[:pageview_key])
8
+ end
7
9
  render json: {success: true}
8
10
  end
9
11
 
@@ -1,5 +1,7 @@
1
1
  module Mousereco
2
2
  class ApplicationController < ActionController::Base
3
+ http_basic_authenticate_with name: Mousereco.http_auth_user_name, password: Mousereco.http_auth_password
4
+
3
5
  layout 'mousereco/application'
4
6
  end
5
7
  end
@@ -1,8 +1,13 @@
1
1
  module Mousereco
2
2
  class PageviewsController < Mousereco::ApplicationController
3
- inherit_resources
4
- custom_actions resource: :page_html
5
-
6
3
  layout false, only: [:page_html]
4
+
5
+ def page_html
6
+ @pageview = Pageview.find(params[:id])
7
+ end
8
+
9
+ def show
10
+ @pageview = Pageview.find(params[:id])
11
+ end
7
12
  end
8
13
  end
@@ -1,5 +1,7 @@
1
1
  module Mousereco
2
2
  class VisitorsController < Mousereco::ApplicationController
3
- inherit_resources
3
+ def index
4
+ @visitors = Visitor.all
5
+ end
4
6
  end
5
7
  end
@@ -1,7 +1,13 @@
1
1
  module Mousereco
2
2
  module Generators
3
3
  class InstallGenerator < Rails::Generators::Base
4
- desc "This generator installs Mousereco"
4
+ source_root File.expand_path('../templates', __FILE__)
5
+
6
+ desc 'This generator installs Mousereco'
7
+
8
+ def copy_initializer_file
9
+ copy_file 'mousereco.rb', 'config/initializers/mousereco.rb'
10
+ end
5
11
 
6
12
  def add_assets
7
13
  js_manifest = 'app/assets/javascripts/application.js'
@@ -14,8 +20,8 @@ module Mousereco
14
20
  end
15
21
 
16
22
  def run_migrations
17
- rake "mousereco:install:migrations"
18
- rake "db:migrate"
23
+ rake 'mousereco:install:migrations'
24
+ rake 'db:migrate'
19
25
  end
20
26
  end
21
27
  end
@@ -0,0 +1,4 @@
1
+ Mousereco.setup do |config|
2
+ config.http_auth_user_name = 'admin'
3
+ config.http_auth_password = 'your_secret_password'
4
+ end
@@ -1,3 +1,3 @@
1
1
  module Mousereco
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/mousereco.rb CHANGED
@@ -1,4 +1,10 @@
1
1
  require "mousereco/engine"
2
2
 
3
3
  module Mousereco
4
+ mattr_accessor :http_auth_user_name
5
+ mattr_accessor :http_auth_password
6
+
7
+ def self.setup
8
+ yield self
9
+ end
4
10
  end
@@ -34,4 +34,15 @@ describe Mousereco::Api::V1::EventsController, type: :controller do
34
34
  Mousereco::Pageview.last.events.count.should eq data["events"].count
35
35
  Mousereco::Event.count.should eq data["events"].count
36
36
  end
37
+
38
+ context 'empty events array' do
39
+ let(:data) {
40
+ {"url" => "http://test.com",
41
+ "pageview_key" => pageview.key,
42
+ "visitor_key" => pageview.visitor.key
43
+ }
44
+ }
45
+
46
+ it { should be_success}
47
+ end
37
48
  end
@@ -7,6 +7,6 @@ describe Mousereco::PageviewsController do
7
7
  let(:pageview) { Fabricate(:pageview) }
8
8
  subject { get :show, {id: pageview.id}; response }
9
9
 
10
- its(:status) { should eq 200 }
10
+ it_behaves_like :http_authenticated
11
11
  end
12
12
  end
@@ -6,7 +6,16 @@ describe Mousereco::VisitorsController do
6
6
  describe '#index' do
7
7
  subject { get :index; response }
8
8
 
9
- its(:status) { should eq 200 }
10
- it { should be_success }
9
+ it_behaves_like :http_authenticated
10
+
11
+ context 'authenticated' do
12
+ render_views
13
+
14
+ before(:each) { http_login }
15
+ let!(:visitor_1) { Fabricate(:visitor) }
16
+ let!(:visitor_2) { Fabricate(:visitor) }
17
+
18
+ its(:body) { should include(visitor_1.key) }
19
+ end
11
20
  end
12
21
  end
data/spec/dummy/Gemfile CHANGED
@@ -26,6 +26,5 @@ group :production do
26
26
  end
27
27
 
28
28
  gem 'haml'
29
- gem 'inherited_resources'
30
29
  gem 'fabrication'
31
30
  gem 'mousereco', path: '../../'
@@ -1,8 +1,7 @@
1
1
  PATH
2
2
  remote: ../../
3
3
  specs:
4
- mousereco (0.0.2)
5
- inherited_resources
4
+ mousereco (0.0.4)
6
5
  jquery-rails
7
6
  rails (~> 4.0)
8
7
 
@@ -50,14 +49,8 @@ GEM
50
49
  fabrication (2.9.6)
51
50
  haml (4.0.5)
52
51
  tilt
53
- has_scope (0.6.0.rc)
54
- actionpack (>= 3.2, < 5)
55
- activesupport (>= 3.2, < 5)
56
52
  hike (1.2.3)
57
53
  i18n (0.6.9)
58
- inherited_resources (1.4.1)
59
- has_scope (~> 0.6.0.rc)
60
- responders (~> 1.0.0.rc)
61
54
  jbuilder (1.5.3)
62
55
  activesupport (>= 3.0.0)
63
56
  multi_json (>= 1.2.0)
@@ -102,8 +95,6 @@ GEM
102
95
  thor (>= 0.18.1, < 2.0)
103
96
  rake (10.1.1)
104
97
  ref (1.0.5)
105
- responders (1.0.0)
106
- railties (>= 3.2, < 5)
107
98
  rspec (2.14.1)
108
99
  rspec-core (~> 2.14.0)
109
100
  rspec-expectations (~> 2.14.0)
@@ -158,7 +149,6 @@ DEPENDENCIES
158
149
  coffee-rails (~> 4.0.0)
159
150
  fabrication
160
151
  haml
161
- inherited_resources
162
152
  jbuilder (~> 1.2)
163
153
  jquery-rails
164
154
  mousereco!
@@ -0,0 +1,4 @@
1
+ Mousereco.setup do |config|
2
+ config.http_auth_user_name = 'admin'
3
+ config.http_auth_password = 'your_secret_password'
4
+ end
Binary file
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # It's strongly recommended that you check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(version: 20140130215835) do
14
+ ActiveRecord::Schema.define(version: 20140216151259) do
15
15
 
16
16
  create_table "mousereco_events", force: true do |t|
17
17
  t.float "x"
Binary file