nps_surveys 0.0.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/nps_surveys/api_internal/responses_controller.rb +5 -5
- data/app/exceptions/app_exception/unprocessable_entity.rb~ +18 -0
- data/app/models/nps_surveys/response.rb +1 -3
- data/app/serializers/nps_surveys/response_presenter.rb +1 -1
- data/config/initializers/defaults.rb +5 -5
- data/config/initializers/mount_routes.rb +1 -1
- data/config/routes.rb +3 -3
- data/db/migrate/{20160614145840_create_survey_responses.rb → 20160614145840_create_nps_survey_responses.rb} +2 -2
- data/lib/nps_surveys/engine.rb +2 -2
- data/lib/nps_surveys/version.rb +2 -2
- data/lib/nps_surveys.rb +1 -1
- data/spec/controllers/nps_surveys/api_internal/responses_controller_spec.rb +3 -3
- data/spec/dummy/app/models/user.rb~ +8 -0
- data/spec/dummy/config/initializers/nps_surveys.rb~ +1 -0
- data/spec/dummy/config/routes.rb +1 -1
- data/spec/dummy/db/migrate/20160721092137_create_users.rb~ +12 -0
- data/spec/dummy/db/schema.rb +6 -2
- data/spec/dummy/log/test.log +184 -0
- data/spec/factories.rb~ +19 -0
- data/spec/models/nps_surveys/response_spec.rb +1 -1
- data/spec/support/application_controller_user.rb~ +4 -0
- data/spec/support/authenticated_test_helper.rb~ +29 -0
- metadata +46 -39
- data/spec/dummy/log/development.log +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e2e2fcac122892bc7f86fcbdaca1b277dbfe04c
|
4
|
+
data.tar.gz: 18093e363ec7a95c8e34c16e710fec2a34f95c9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 235d91f2cd04c163ffd32bd5aa901668c3a338e9b6e4a226b90ec4f50283d0da221aec69963e51e2bda3f5ad9f1de2c3730776bd0e4dcc8140bccfda9bac49ef
|
7
|
+
data.tar.gz: 5879a443a88c9a784a645ebf9cf9f6b65099e285deaa860685798a87d2ca8dcb553d5d6dc87c89fd1640732d30a5aaa5e90016f09f4aa2ccfd805a067ff8562d
|
@@ -1,7 +1,7 @@
|
|
1
|
-
module
|
1
|
+
module NPSSurveys
|
2
2
|
module ApiInternal
|
3
3
|
|
4
|
-
class ResponsesController <
|
4
|
+
class ResponsesController < NPSSurveys.controller_parent_class
|
5
5
|
def create
|
6
6
|
response = create_survey_response
|
7
7
|
|
@@ -15,7 +15,7 @@ module NpsSurveys
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def index
|
18
|
-
responses = ::
|
18
|
+
responses = ::NPSSurveys::Response.where(user_id: NPSSurveys.current_user.call.id).map do |response|
|
19
19
|
ResponseSerializer.new(response).to_json
|
20
20
|
end
|
21
21
|
|
@@ -25,8 +25,8 @@ module NpsSurveys
|
|
25
25
|
private
|
26
26
|
|
27
27
|
def create_survey_response
|
28
|
-
response = ::
|
29
|
-
response.user_id =
|
28
|
+
response = ::NPSSurveys::Response.new
|
29
|
+
response.user_id = NPSSurveys.current_user.call.id
|
30
30
|
response.score = params[:score],
|
31
31
|
response.feedback = params[:feedback],
|
32
32
|
response.survey = params[:survey]
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class AppException::UnprocessableEntity < AppException::Base
|
2
|
+
attr_accessor :object
|
3
|
+
|
4
|
+
# TODO: Deprecate second param
|
5
|
+
def initialize(object = nil, message = nil)
|
6
|
+
@object = object
|
7
|
+
super(message)
|
8
|
+
end
|
9
|
+
|
10
|
+
def body
|
11
|
+
JSON.generate(
|
12
|
+
error: {
|
13
|
+
message: 'Unprocessable Entity',
|
14
|
+
errors: errors || { message: message }
|
15
|
+
}
|
16
|
+
)
|
17
|
+
end
|
18
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
NPSSurveys.controller_parent_class = ::ApplicationController
|
2
|
+
NPSSurveys.route_namespace = :api_internal
|
3
|
+
NPSSurveys.route_path = 'api/internal'
|
4
|
+
NPSSurveys.route_scope = 'nps_surveys'
|
5
|
+
NPSSurveys.current_user = lambda { self.current_user }
|
data/config/routes.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
2
|
-
namespace
|
3
|
-
scope
|
1
|
+
NPSSurveys::Engine.routes.draw do
|
2
|
+
namespace NPSSurveys.route_namespace, path: NPSSurveys.route_path do
|
3
|
+
scope NPSSurveys.route_scope do
|
4
4
|
resources :responses, only: [:index, :create]
|
5
5
|
end
|
6
6
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
class
|
1
|
+
class CreateNpsSurveyResponses < ActiveRecord::Migration
|
2
2
|
def change
|
3
|
-
create_table :
|
3
|
+
create_table :nps_surveys_responses do |t|
|
4
4
|
t.string :survey, null: false
|
5
5
|
t.integer :user_id, null: false
|
6
6
|
t.integer :score
|
data/lib/nps_surveys/engine.rb
CHANGED
data/lib/nps_surveys/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module
|
2
|
-
VERSION = '0.0
|
1
|
+
module NPSSurveys
|
2
|
+
VERSION = '0.2.0'.freeze
|
3
3
|
end
|
data/lib/nps_surveys.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
module
|
3
|
+
module NPSSurveys
|
4
4
|
describe ApiInternal::ResponsesController do
|
5
5
|
before(:each) do
|
6
6
|
user = FactoryGirl.create(:user)
|
7
|
-
|
7
|
+
NPSSurveys.current_user = lambda do
|
8
8
|
user
|
9
9
|
end
|
10
10
|
end
|
@@ -16,7 +16,7 @@ module NpsSurveys
|
|
16
16
|
%w{ hola1 hola2 hola3 }.map do |s|
|
17
17
|
r = Response.new
|
18
18
|
r.survey = s
|
19
|
-
r.user_id =
|
19
|
+
r.user_id = NPSSurveys.current_user.call.id
|
20
20
|
r.save!
|
21
21
|
r
|
22
22
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
NpsSurveys.current_user = lambda { self.current_user }
|
data/spec/dummy/config/routes.rb
CHANGED
data/spec/dummy/db/schema.rb
CHANGED
@@ -11,9 +11,9 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended to check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(:version =>
|
14
|
+
ActiveRecord::Schema.define(:version => 20160728080202) do
|
15
15
|
|
16
|
-
create_table "
|
16
|
+
create_table "nps_surveys_responses", :force => true do |t|
|
17
17
|
t.string "survey", :null => false
|
18
18
|
t.integer "user_id", :null => false
|
19
19
|
t.integer "score"
|
@@ -22,6 +22,8 @@ ActiveRecord::Schema.define(:version => 20160721092137) do
|
|
22
22
|
t.datetime "updated_at", :null => false
|
23
23
|
end
|
24
24
|
|
25
|
+
add_index "nps_surveys_responses", ["user_id"], :name => "nps_surveys_responses_user_id_fk"
|
26
|
+
|
25
27
|
create_table "users", :force => true do |t|
|
26
28
|
t.string "login"
|
27
29
|
t.string "password"
|
@@ -29,4 +31,6 @@ ActiveRecord::Schema.define(:version => 20160721092137) do
|
|
29
31
|
t.datetime "updated_at", :null => false
|
30
32
|
end
|
31
33
|
|
34
|
+
add_foreign_key "nps_surveys_responses", "users", name: "nps_surveys_responses_user_id_fk"
|
35
|
+
|
32
36
|
end
|
@@ -0,0 +1,184 @@
|
|
1
|
+
Connecting to database specified by database.yml
|
2
|
+
[1m[36m (0.2ms)[0m [1mBEGIN[0m
|
3
|
+
[1m[35mSQL (0.3ms)[0m INSERT INTO `users` (`created_at`, `login`, `password`, `updated_at`) VALUES ('2016-07-28 07:53:38', 'gandhi_1', 'dragons22', '2016-07-28 07:53:38')
|
4
|
+
[1m[36m (7.0ms)[0m [1mCOMMIT[0m
|
5
|
+
[1m[35m (0.2ms)[0m BEGIN
|
6
|
+
[1m[36mSQL (0.2ms)[0m [1mINSERT INTO `surveys_responses` (`created_at`, `feedback`, `score`, `survey`, `updated_at`, `user_id`) VALUES ('2016-07-28 07:53:38', NULL, NULL, 'hola1', '2016-07-28 07:53:38', 1)[0m
|
7
|
+
[1m[35m (3.2ms)[0m COMMIT
|
8
|
+
[1m[36m (0.0ms)[0m [1mBEGIN[0m
|
9
|
+
[1m[35mSQL (0.1ms)[0m INSERT INTO `surveys_responses` (`created_at`, `feedback`, `score`, `survey`, `updated_at`, `user_id`) VALUES ('2016-07-28 07:53:38', NULL, NULL, 'hola2', '2016-07-28 07:53:38', 1)
|
10
|
+
[1m[36m (5.0ms)[0m [1mCOMMIT[0m
|
11
|
+
[1m[35m (0.0ms)[0m BEGIN
|
12
|
+
[1m[36mSQL (0.1ms)[0m [1mINSERT INTO `surveys_responses` (`created_at`, `feedback`, `score`, `survey`, `updated_at`, `user_id`) VALUES ('2016-07-28 07:53:38', NULL, NULL, 'hola3', '2016-07-28 07:53:38', 1)[0m
|
13
|
+
[1m[35m (2.8ms)[0m COMMIT
|
14
|
+
[1m[36m (0.0ms)[0m [1mBEGIN[0m
|
15
|
+
[1m[35mSQL (0.1ms)[0m INSERT INTO `users` (`created_at`, `login`, `password`, `updated_at`) VALUES ('2016-07-28 07:53:38', 'gandhi_2', 'dragons22', '2016-07-28 07:53:38')
|
16
|
+
[1m[36m (8.0ms)[0m [1mCOMMIT[0m
|
17
|
+
[1m[35m (0.1ms)[0m BEGIN
|
18
|
+
[1m[36mSQL (0.2ms)[0m [1mINSERT INTO `surveys_responses` (`created_at`, `feedback`, `score`, `survey`, `updated_at`, `user_id`) VALUES ('2016-07-28 07:53:38', NULL, NULL, 'hola4', '2016-07-28 07:53:38', 2)[0m
|
19
|
+
[1m[35m (5.5ms)[0m COMMIT
|
20
|
+
[1m[36m (0.1ms)[0m [1mBEGIN[0m
|
21
|
+
[1m[35mSQL (0.2ms)[0m INSERT INTO `users` (`created_at`, `login`, `password`, `updated_at`) VALUES ('2016-07-28 07:53:38', 'gandhi_3', 'dragons22', '2016-07-28 07:53:38')
|
22
|
+
[1m[36m (4.0ms)[0m [1mCOMMIT[0m
|
23
|
+
Processing by NPSSurveys::ApiInternal::ResponsesController#index as HTML
|
24
|
+
[1m[35mNPSSurveys::Response Load (0.5ms)[0m SELECT `surveys_responses`.* FROM `surveys_responses` WHERE `surveys_responses`.`user_id` = 1
|
25
|
+
Completed 200 OK in 5.9ms (Views: 0.1ms | ActiveRecord: 0.5ms)
|
26
|
+
[1m[36m (0.1ms)[0m [1mBEGIN[0m
|
27
|
+
[1m[35mSQL (0.3ms)[0m INSERT INTO `users` (`created_at`, `login`, `password`, `updated_at`) VALUES ('2016-07-28 07:53:38', 'gandhi_4', 'dragons22', '2016-07-28 07:53:38')
|
28
|
+
[1m[36m (4.6ms)[0m [1mCOMMIT[0m
|
29
|
+
Processing by NPSSurveys::ApiInternal::ResponsesController#create as HTML
|
30
|
+
Parameters: {"score"=>"4"}
|
31
|
+
[1m[35m (0.1ms)[0m BEGIN
|
32
|
+
[1m[36m (0.1ms)[0m [1mROLLBACK[0m
|
33
|
+
Completed 422 Unprocessable Entity in 9.9ms (Views: 0.2ms | ActiveRecord: 0.3ms)
|
34
|
+
[1m[35m (0.1ms)[0m BEGIN
|
35
|
+
[1m[36mSQL (0.2ms)[0m [1mINSERT INTO `users` (`created_at`, `login`, `password`, `updated_at`) VALUES ('2016-07-28 07:53:38', 'gandhi_5', 'dragons22', '2016-07-28 07:53:38')[0m
|
36
|
+
[1m[35m (4.1ms)[0m COMMIT
|
37
|
+
Processing by NPSSurveys::ApiInternal::ResponsesController#create as HTML
|
38
|
+
Parameters: {"survey"=>"hola", "score"=>"4"}
|
39
|
+
[1m[36m (0.1ms)[0m [1mBEGIN[0m
|
40
|
+
[1m[35mSQL (0.2ms)[0m INSERT INTO `surveys_responses` (`created_at`, `feedback`, `score`, `survey`, `updated_at`, `user_id`) VALUES ('2016-07-28 07:53:38', NULL, NULL, 'hola', '2016-07-28 07:53:38', 5)
|
41
|
+
[1m[36m (4.2ms)[0m [1mCOMMIT[0m
|
42
|
+
Completed 200 OK in 6.4ms (Views: 0.2ms | ActiveRecord: 4.5ms)
|
43
|
+
[1m[35mNPSSurveys::Response Load (0.3ms)[0m SELECT `surveys_responses`.* FROM `surveys_responses` ORDER BY `surveys_responses`.`id` DESC LIMIT 1
|
44
|
+
[1m[36m (0.1ms)[0m [1mBEGIN[0m
|
45
|
+
[1m[35mSQL (0.2ms)[0m INSERT INTO `users` (`created_at`, `login`, `password`, `updated_at`) VALUES ('2016-07-28 07:53:38', 'gandhi_6', 'dragons22', '2016-07-28 07:53:38')
|
46
|
+
[1m[36m (4.1ms)[0m [1mCOMMIT[0m
|
47
|
+
Processing by NPSSurveys::ApiInternal::ResponsesController#create as HTML
|
48
|
+
Parameters: {"survey"=>"hola", "score"=>"4"}
|
49
|
+
[1m[35m (0.1ms)[0m BEGIN
|
50
|
+
[1m[36mSQL (0.2ms)[0m [1mINSERT INTO `surveys_responses` (`created_at`, `feedback`, `score`, `survey`, `updated_at`, `user_id`) VALUES ('2016-07-28 07:53:38', NULL, NULL, 'hola', '2016-07-28 07:53:38', 6)[0m
|
51
|
+
[1m[35m (4.1ms)[0m COMMIT
|
52
|
+
Completed 200 OK in 6.2ms (Views: 0.2ms | ActiveRecord: 4.4ms)
|
53
|
+
Connecting to database specified by database.yml
|
54
|
+
[1m[36m (0.1ms)[0m [1mBEGIN[0m
|
55
|
+
[1m[35mSQL (0.2ms)[0m INSERT INTO `users` (`created_at`, `login`, `password`, `updated_at`) VALUES ('2016-07-28 07:54:49', 'gandhi_1', 'dragons22', '2016-07-28 07:54:49')
|
56
|
+
[1m[36m (5.4ms)[0m [1mCOMMIT[0m
|
57
|
+
Processing by NPSSurveys::ApiInternal::ResponsesController#create as HTML
|
58
|
+
Parameters: {"score"=>"4"}
|
59
|
+
[1m[35m (0.2ms)[0m BEGIN
|
60
|
+
[1m[36m (0.1ms)[0m [1mROLLBACK[0m
|
61
|
+
Completed 422 Unprocessable Entity in 4.1ms (Views: 0.3ms | ActiveRecord: 0.3ms)
|
62
|
+
[1m[35m (0.1ms)[0m BEGIN
|
63
|
+
[1m[36mSQL (0.2ms)[0m [1mINSERT INTO `users` (`created_at`, `login`, `password`, `updated_at`) VALUES ('2016-07-28 07:54:49', 'gandhi_2', 'dragons22', '2016-07-28 07:54:49')[0m
|
64
|
+
[1m[35m (4.5ms)[0m COMMIT
|
65
|
+
Processing by NPSSurveys::ApiInternal::ResponsesController#create as HTML
|
66
|
+
Parameters: {"survey"=>"hola", "score"=>"4"}
|
67
|
+
[1m[36m (0.1ms)[0m [1mBEGIN[0m
|
68
|
+
[1m[35mSQL (0.4ms)[0m INSERT INTO `surveys_responses` (`created_at`, `feedback`, `score`, `survey`, `updated_at`, `user_id`) VALUES ('2016-07-28 07:54:49', NULL, NULL, 'hola', '2016-07-28 07:54:49', 2)
|
69
|
+
[1m[36m (4.0ms)[0m [1mCOMMIT[0m
|
70
|
+
Completed 200 OK in 7.2ms (Views: 0.2ms | ActiveRecord: 4.5ms)
|
71
|
+
[1m[35mNPSSurveys::Response Load (0.2ms)[0m SELECT `surveys_responses`.* FROM `surveys_responses` ORDER BY `surveys_responses`.`id` DESC LIMIT 1
|
72
|
+
[1m[36m (0.1ms)[0m [1mBEGIN[0m
|
73
|
+
[1m[35mSQL (0.2ms)[0m INSERT INTO `users` (`created_at`, `login`, `password`, `updated_at`) VALUES ('2016-07-28 07:54:49', 'gandhi_3', 'dragons22', '2016-07-28 07:54:49')
|
74
|
+
[1m[36m (4.0ms)[0m [1mCOMMIT[0m
|
75
|
+
Processing by NPSSurveys::ApiInternal::ResponsesController#create as HTML
|
76
|
+
Parameters: {"survey"=>"hola", "score"=>"4"}
|
77
|
+
[1m[35m (0.1ms)[0m BEGIN
|
78
|
+
[1m[36mSQL (0.2ms)[0m [1mINSERT INTO `surveys_responses` (`created_at`, `feedback`, `score`, `survey`, `updated_at`, `user_id`) VALUES ('2016-07-28 07:54:49', NULL, NULL, 'hola', '2016-07-28 07:54:49', 3)[0m
|
79
|
+
[1m[35m (8.2ms)[0m COMMIT
|
80
|
+
Completed 200 OK in 10.5ms (Views: 0.3ms | ActiveRecord: 8.4ms)
|
81
|
+
[1m[36m (0.1ms)[0m [1mBEGIN[0m
|
82
|
+
[1m[35mSQL (0.1ms)[0m INSERT INTO `users` (`created_at`, `login`, `password`, `updated_at`) VALUES ('2016-07-28 07:54:49', 'gandhi_4', 'dragons22', '2016-07-28 07:54:49')
|
83
|
+
[1m[36m (4.0ms)[0m [1mCOMMIT[0m
|
84
|
+
[1m[35m (0.0ms)[0m BEGIN
|
85
|
+
[1m[36mSQL (0.1ms)[0m [1mINSERT INTO `surveys_responses` (`created_at`, `feedback`, `score`, `survey`, `updated_at`, `user_id`) VALUES ('2016-07-28 07:54:49', NULL, NULL, 'hola1', '2016-07-28 07:54:49', 4)[0m
|
86
|
+
[1m[35m (4.0ms)[0m COMMIT
|
87
|
+
[1m[36m (0.0ms)[0m [1mBEGIN[0m
|
88
|
+
[1m[35mSQL (0.1ms)[0m INSERT INTO `surveys_responses` (`created_at`, `feedback`, `score`, `survey`, `updated_at`, `user_id`) VALUES ('2016-07-28 07:54:49', NULL, NULL, 'hola2', '2016-07-28 07:54:49', 4)
|
89
|
+
[1m[36m (4.5ms)[0m [1mCOMMIT[0m
|
90
|
+
[1m[35m (0.0ms)[0m BEGIN
|
91
|
+
[1m[36mSQL (0.1ms)[0m [1mINSERT INTO `surveys_responses` (`created_at`, `feedback`, `score`, `survey`, `updated_at`, `user_id`) VALUES ('2016-07-28 07:54:49', NULL, NULL, 'hola3', '2016-07-28 07:54:49', 4)[0m
|
92
|
+
[1m[35m (4.1ms)[0m COMMIT
|
93
|
+
[1m[36m (0.0ms)[0m [1mBEGIN[0m
|
94
|
+
[1m[35mSQL (0.1ms)[0m INSERT INTO `users` (`created_at`, `login`, `password`, `updated_at`) VALUES ('2016-07-28 07:54:49', 'gandhi_5', 'dragons22', '2016-07-28 07:54:49')
|
95
|
+
[1m[36m (4.1ms)[0m [1mCOMMIT[0m
|
96
|
+
[1m[35m (0.0ms)[0m BEGIN
|
97
|
+
[1m[36mSQL (0.1ms)[0m [1mINSERT INTO `surveys_responses` (`created_at`, `feedback`, `score`, `survey`, `updated_at`, `user_id`) VALUES ('2016-07-28 07:54:49', NULL, NULL, 'hola4', '2016-07-28 07:54:49', 5)[0m
|
98
|
+
[1m[35m (4.0ms)[0m COMMIT
|
99
|
+
[1m[36m (0.2ms)[0m [1mBEGIN[0m
|
100
|
+
[1m[35mSQL (0.3ms)[0m INSERT INTO `users` (`created_at`, `login`, `password`, `updated_at`) VALUES ('2016-07-28 07:54:49', 'gandhi_6', 'dragons22', '2016-07-28 07:54:49')
|
101
|
+
[1m[36m (4.1ms)[0m [1mCOMMIT[0m
|
102
|
+
Processing by NPSSurveys::ApiInternal::ResponsesController#index as HTML
|
103
|
+
[1m[35mNPSSurveys::Response Load (0.2ms)[0m SELECT `surveys_responses`.* FROM `surveys_responses` WHERE `surveys_responses`.`user_id` = 4
|
104
|
+
Completed 200 OK in 3.8ms (Views: 0.1ms | ActiveRecord: 0.2ms)
|
105
|
+
Connecting to database specified by database.yml
|
106
|
+
Mysql2::Error: Table 'nps_surveys_test.surveys_responses' doesn't exist: SHOW FULL FIELDS FROM `surveys_responses`
|
107
|
+
Mysql2::Error: Table 'nps_surveys_test.surveys_responses' doesn't exist: SHOW FULL FIELDS FROM `surveys_responses`
|
108
|
+
[1m[36m (0.1ms)[0m [1mBEGIN[0m
|
109
|
+
[1m[35mSQL (0.3ms)[0m INSERT INTO `users` (`created_at`, `login`, `password`, `updated_at`) VALUES ('2016-07-28 11:23:06', 'gandhi_1', 'dragons22', '2016-07-28 11:23:06')
|
110
|
+
[1m[36m (6.7ms)[0m [1mCOMMIT[0m
|
111
|
+
Mysql2::Error: Table 'nps_surveys_test.surveys_responses' doesn't exist: SHOW FULL FIELDS FROM `surveys_responses`
|
112
|
+
[1m[35m (0.2ms)[0m BEGIN
|
113
|
+
[1m[36mSQL (0.3ms)[0m [1mINSERT INTO `users` (`created_at`, `login`, `password`, `updated_at`) VALUES ('2016-07-28 11:23:06', 'gandhi_2', 'dragons22', '2016-07-28 11:23:06')[0m
|
114
|
+
[1m[35m (2.8ms)[0m COMMIT
|
115
|
+
Processing by NPSSurveys::ApiInternal::ResponsesController#create as HTML
|
116
|
+
Parameters: {"survey"=>"hola", "score"=>"4"}
|
117
|
+
Mysql2::Error: Table 'nps_surveys_test.surveys_responses' doesn't exist: SHOW FULL FIELDS FROM `surveys_responses`
|
118
|
+
Completed 500 Internal Server Error in 1.0ms
|
119
|
+
[1m[36m (0.1ms)[0m [1mBEGIN[0m
|
120
|
+
[1m[35mSQL (0.2ms)[0m INSERT INTO `users` (`created_at`, `login`, `password`, `updated_at`) VALUES ('2016-07-28 11:23:06', 'gandhi_3', 'dragons22', '2016-07-28 11:23:06')
|
121
|
+
[1m[36m (5.1ms)[0m [1mCOMMIT[0m
|
122
|
+
Processing by NPSSurveys::ApiInternal::ResponsesController#create as HTML
|
123
|
+
Parameters: {"survey"=>"hola", "score"=>"4"}
|
124
|
+
Mysql2::Error: Table 'nps_surveys_test.surveys_responses' doesn't exist: SHOW FULL FIELDS FROM `surveys_responses`
|
125
|
+
Completed 500 Internal Server Error in 0.9ms
|
126
|
+
[1m[35m (0.1ms)[0m BEGIN
|
127
|
+
[1m[36mSQL (0.2ms)[0m [1mINSERT INTO `users` (`created_at`, `login`, `password`, `updated_at`) VALUES ('2016-07-28 11:23:06', 'gandhi_4', 'dragons22', '2016-07-28 11:23:06')[0m
|
128
|
+
[1m[35m (2.9ms)[0m COMMIT
|
129
|
+
Processing by NPSSurveys::ApiInternal::ResponsesController#create as HTML
|
130
|
+
Parameters: {"score"=>"4"}
|
131
|
+
Mysql2::Error: Table 'nps_surveys_test.surveys_responses' doesn't exist: SHOW FULL FIELDS FROM `surveys_responses`
|
132
|
+
Completed 500 Internal Server Error in 1.1ms
|
133
|
+
Connecting to database specified by database.yml
|
134
|
+
[1m[36m (0.1ms)[0m [1mBEGIN[0m
|
135
|
+
[1m[35mSQL (0.3ms)[0m INSERT INTO `users` (`created_at`, `login`, `password`, `updated_at`) VALUES ('2016-07-28 11:23:45', 'gandhi_1', 'dragons22', '2016-07-28 11:23:45')
|
136
|
+
[1m[36m (5.5ms)[0m [1mCOMMIT[0m
|
137
|
+
Processing by NPSSurveys::ApiInternal::ResponsesController#create as HTML
|
138
|
+
Parameters: {"score"=>"4"}
|
139
|
+
[1m[35m (0.1ms)[0m BEGIN
|
140
|
+
[1m[36m (0.1ms)[0m [1mROLLBACK[0m
|
141
|
+
Completed 422 Unprocessable Entity in 4.0ms (Views: 0.8ms | ActiveRecord: 0.2ms)
|
142
|
+
[1m[35m (0.1ms)[0m BEGIN
|
143
|
+
[1m[36mSQL (0.2ms)[0m [1mINSERT INTO `users` (`created_at`, `login`, `password`, `updated_at`) VALUES ('2016-07-28 11:23:46', 'gandhi_2', 'dragons22', '2016-07-28 11:23:46')[0m
|
144
|
+
[1m[35m (4.2ms)[0m COMMIT
|
145
|
+
Processing by NPSSurveys::ApiInternal::ResponsesController#create as HTML
|
146
|
+
Parameters: {"survey"=>"hola", "score"=>"4"}
|
147
|
+
[1m[36m (0.1ms)[0m [1mBEGIN[0m
|
148
|
+
[1m[35mSQL (0.2ms)[0m INSERT INTO `nps_surveys_responses` (`created_at`, `feedback`, `score`, `survey`, `updated_at`, `user_id`) VALUES ('2016-07-28 11:23:46', NULL, NULL, 'hola', '2016-07-28 11:23:46', 2)
|
149
|
+
[1m[36m (4.1ms)[0m [1mCOMMIT[0m
|
150
|
+
Completed 200 OK in 7.9ms (Views: 0.2ms | ActiveRecord: 4.5ms)
|
151
|
+
[1m[35mNPSSurveys::Response Load (0.3ms)[0m SELECT `nps_surveys_responses`.* FROM `nps_surveys_responses` ORDER BY `nps_surveys_responses`.`id` DESC LIMIT 1
|
152
|
+
[1m[36m (0.1ms)[0m [1mBEGIN[0m
|
153
|
+
[1m[35mSQL (0.2ms)[0m INSERT INTO `users` (`created_at`, `login`, `password`, `updated_at`) VALUES ('2016-07-28 11:23:46', 'gandhi_3', 'dragons22', '2016-07-28 11:23:46')
|
154
|
+
[1m[36m (4.2ms)[0m [1mCOMMIT[0m
|
155
|
+
Processing by NPSSurveys::ApiInternal::ResponsesController#create as HTML
|
156
|
+
Parameters: {"survey"=>"hola", "score"=>"4"}
|
157
|
+
[1m[35m (0.1ms)[0m BEGIN
|
158
|
+
[1m[36mSQL (0.2ms)[0m [1mINSERT INTO `nps_surveys_responses` (`created_at`, `feedback`, `score`, `survey`, `updated_at`, `user_id`) VALUES ('2016-07-28 11:23:46', NULL, NULL, 'hola', '2016-07-28 11:23:46', 3)[0m
|
159
|
+
[1m[35m (8.2ms)[0m COMMIT
|
160
|
+
Completed 200 OK in 11.1ms (Views: 0.3ms | ActiveRecord: 8.5ms)
|
161
|
+
[1m[36m (0.1ms)[0m [1mBEGIN[0m
|
162
|
+
[1m[35mSQL (0.2ms)[0m INSERT INTO `users` (`created_at`, `login`, `password`, `updated_at`) VALUES ('2016-07-28 11:23:46', 'gandhi_4', 'dragons22', '2016-07-28 11:23:46')
|
163
|
+
[1m[36m (4.7ms)[0m [1mCOMMIT[0m
|
164
|
+
[1m[35m (0.1ms)[0m BEGIN
|
165
|
+
[1m[36mSQL (0.2ms)[0m [1mINSERT INTO `nps_surveys_responses` (`created_at`, `feedback`, `score`, `survey`, `updated_at`, `user_id`) VALUES ('2016-07-28 11:23:46', NULL, NULL, 'hola1', '2016-07-28 11:23:46', 4)[0m
|
166
|
+
[1m[35m (4.1ms)[0m COMMIT
|
167
|
+
[1m[36m (0.1ms)[0m [1mBEGIN[0m
|
168
|
+
[1m[35mSQL (0.2ms)[0m INSERT INTO `nps_surveys_responses` (`created_at`, `feedback`, `score`, `survey`, `updated_at`, `user_id`) VALUES ('2016-07-28 11:23:46', NULL, NULL, 'hola2', '2016-07-28 11:23:46', 4)
|
169
|
+
[1m[36m (4.3ms)[0m [1mCOMMIT[0m
|
170
|
+
[1m[35m (0.1ms)[0m BEGIN
|
171
|
+
[1m[36mSQL (0.2ms)[0m [1mINSERT INTO `nps_surveys_responses` (`created_at`, `feedback`, `score`, `survey`, `updated_at`, `user_id`) VALUES ('2016-07-28 11:23:46', NULL, NULL, 'hola3', '2016-07-28 11:23:46', 4)[0m
|
172
|
+
[1m[35m (4.1ms)[0m COMMIT
|
173
|
+
[1m[36m (0.1ms)[0m [1mBEGIN[0m
|
174
|
+
[1m[35mSQL (0.2ms)[0m INSERT INTO `users` (`created_at`, `login`, `password`, `updated_at`) VALUES ('2016-07-28 11:23:46', 'gandhi_5', 'dragons22', '2016-07-28 11:23:46')
|
175
|
+
[1m[36m (4.0ms)[0m [1mCOMMIT[0m
|
176
|
+
[1m[35m (0.1ms)[0m BEGIN
|
177
|
+
[1m[36mSQL (0.1ms)[0m [1mINSERT INTO `nps_surveys_responses` (`created_at`, `feedback`, `score`, `survey`, `updated_at`, `user_id`) VALUES ('2016-07-28 11:23:46', NULL, NULL, 'hola4', '2016-07-28 11:23:46', 5)[0m
|
178
|
+
[1m[35m (4.0ms)[0m COMMIT
|
179
|
+
[1m[36m (0.1ms)[0m [1mBEGIN[0m
|
180
|
+
[1m[35mSQL (0.2ms)[0m INSERT INTO `users` (`created_at`, `login`, `password`, `updated_at`) VALUES ('2016-07-28 11:23:46', 'gandhi_6', 'dragons22', '2016-07-28 11:23:46')
|
181
|
+
[1m[36m (4.4ms)[0m [1mCOMMIT[0m
|
182
|
+
Processing by NPSSurveys::ApiInternal::ResponsesController#index as HTML
|
183
|
+
[1m[35mNPSSurveys::Response Load (0.3ms)[0m SELECT `nps_surveys_responses`.* FROM `nps_surveys_responses` WHERE `nps_surveys_responses`.`user_id` = 4
|
184
|
+
Completed 200 OK in 4.0ms (Views: 0.1ms | ActiveRecord: 0.3ms)
|
data/spec/factories.rb~
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'factory_girl'
|
2
|
+
|
3
|
+
FactoryGirl.define do
|
4
|
+
factory :user do
|
5
|
+
login { generate(:login) }
|
6
|
+
email { generate(:email) }
|
7
|
+
first_name 'Andrew'
|
8
|
+
last_name 'Wiggin'
|
9
|
+
password 'dragons22'
|
10
|
+
password_confirmation 'dragons22'
|
11
|
+
confirmed_user true
|
12
|
+
total_chat_messages 0
|
13
|
+
settings(show_welcome: false)
|
14
|
+
|
15
|
+
trait :with_card do
|
16
|
+
association :card
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module AuthenticatedTestHelper
|
2
|
+
protected
|
3
|
+
|
4
|
+
def login_as(user, *args)
|
5
|
+
user = ensure_user_for_login(user, *args)
|
6
|
+
session[:user_id] = user.id
|
7
|
+
session[:user_crypted_password] = user.crypted_password
|
8
|
+
user
|
9
|
+
end
|
10
|
+
|
11
|
+
def login_as_with_oauth_scope(user, scope, *args)
|
12
|
+
user = ensure_user_for_login(user, *args)
|
13
|
+
app = ClientApplication.first || FactoryGirl.create(:client_application)
|
14
|
+
user.current_token = OauthToken.find_by_user_id(user.id) || Oauth2Token.create!(user: user, client_application: app, scope: scope)
|
15
|
+
user.current_token.scope = scope
|
16
|
+
user.current_token.save
|
17
|
+
user
|
18
|
+
end
|
19
|
+
|
20
|
+
def authorize_as(user)
|
21
|
+
@request.env['HTTP_AUTHORIZATION'] = user ? ActionController::HttpAuthentication::Basic.encode_credentials(users(user).login, 'monkey') : nil
|
22
|
+
end
|
23
|
+
|
24
|
+
protected
|
25
|
+
|
26
|
+
def ensure_user_for_login(user, *args)
|
27
|
+
FactoryGirl.create(user, *args)
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nps_surveys
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Redbooth team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -28,22 +28,16 @@ dependencies:
|
|
28
28
|
name: foreigner
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '1.7'
|
34
31
|
- - ">="
|
35
32
|
- !ruby/object:Gem::Version
|
36
|
-
version:
|
33
|
+
version: '0'
|
37
34
|
type: :runtime
|
38
35
|
prerelease: false
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
40
37
|
requirements:
|
41
|
-
- - "~>"
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: '1.7'
|
44
38
|
- - ">="
|
45
39
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
40
|
+
version: '0'
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
42
|
name: rspec-rails
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,12 +116,13 @@ extensions: []
|
|
122
116
|
extra_rdoc_files: []
|
123
117
|
files:
|
124
118
|
- app/controllers/nps_surveys/api_internal/responses_controller.rb
|
119
|
+
- app/exceptions/app_exception/unprocessable_entity.rb~
|
125
120
|
- app/models/nps_surveys/response.rb
|
126
121
|
- app/serializers/nps_surveys/response_presenter.rb
|
127
122
|
- config/initializers/defaults.rb
|
128
123
|
- config/initializers/mount_routes.rb
|
129
124
|
- config/routes.rb
|
130
|
-
- db/migrate/
|
125
|
+
- db/migrate/20160614145840_create_nps_survey_responses.rb
|
131
126
|
- lib/nps_surveys.rb
|
132
127
|
- lib/nps_surveys/engine.rb
|
133
128
|
- lib/nps_surveys/version.rb
|
@@ -139,6 +134,7 @@ files:
|
|
139
134
|
- spec/dummy/app/controllers/application_controller.rb
|
140
135
|
- spec/dummy/app/helpers/application_helper.rb
|
141
136
|
- spec/dummy/app/models/user.rb
|
137
|
+
- spec/dummy/app/models/user.rb~
|
142
138
|
- spec/dummy/app/views/layouts/application.html.erb
|
143
139
|
- spec/dummy/config.ru
|
144
140
|
- spec/dummy/config/application.rb
|
@@ -151,24 +147,29 @@ files:
|
|
151
147
|
- spec/dummy/config/initializers/backtrace_silencers.rb
|
152
148
|
- spec/dummy/config/initializers/inflections.rb
|
153
149
|
- spec/dummy/config/initializers/mime_types.rb
|
150
|
+
- spec/dummy/config/initializers/nps_surveys.rb~
|
154
151
|
- spec/dummy/config/initializers/secret_token.rb
|
155
152
|
- spec/dummy/config/initializers/session_store.rb
|
156
153
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
157
154
|
- spec/dummy/config/locales/en.yml
|
158
155
|
- spec/dummy/config/routes.rb
|
159
156
|
- spec/dummy/db/migrate/20160721092137_create_users.rb
|
157
|
+
- spec/dummy/db/migrate/20160721092137_create_users.rb~
|
160
158
|
- spec/dummy/db/schema.rb
|
161
|
-
- spec/dummy/log/
|
159
|
+
- spec/dummy/log/test.log
|
162
160
|
- spec/dummy/public/404.html
|
163
161
|
- spec/dummy/public/422.html
|
164
162
|
- spec/dummy/public/500.html
|
165
163
|
- spec/dummy/public/favicon.ico
|
166
164
|
- spec/dummy/script/rails
|
167
165
|
- spec/factories.rb
|
166
|
+
- spec/factories.rb~
|
168
167
|
- spec/models/nps_surveys/response_spec.rb
|
169
168
|
- spec/spec_helper.rb
|
170
169
|
- spec/support/api_json_parser.rb
|
170
|
+
- spec/support/application_controller_user.rb~
|
171
171
|
- spec/support/authenticated_test_helper.rb
|
172
|
+
- spec/support/authenticated_test_helper.rb~
|
172
173
|
homepage:
|
173
174
|
licenses: []
|
174
175
|
metadata: {}
|
@@ -188,46 +189,52 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
188
189
|
version: '0'
|
189
190
|
requirements: []
|
190
191
|
rubyforge_project:
|
191
|
-
rubygems_version: 2.4.5
|
192
|
+
rubygems_version: 2.4.5
|
192
193
|
signing_key:
|
193
194
|
specification_version: 4
|
194
195
|
summary: Summary of NPS Surveys.
|
195
196
|
test_files:
|
196
197
|
- spec/controllers/nps_surveys/api_internal/responses_controller_spec.rb
|
197
|
-
- spec/
|
198
|
-
- spec/
|
198
|
+
- spec/spec_helper.rb
|
199
|
+
- spec/support/authenticated_test_helper.rb
|
200
|
+
- spec/support/application_controller_user.rb~
|
201
|
+
- spec/support/api_json_parser.rb
|
202
|
+
- spec/support/authenticated_test_helper.rb~
|
203
|
+
- spec/factories.rb
|
204
|
+
- spec/factories.rb~
|
205
|
+
- spec/models/nps_surveys/response_spec.rb
|
199
206
|
- spec/dummy/app/controllers/application_controller.rb
|
207
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
200
208
|
- spec/dummy/app/helpers/application_helper.rb
|
209
|
+
- spec/dummy/app/assets/javascripts/application.js
|
210
|
+
- spec/dummy/app/assets/stylesheets/application.css
|
201
211
|
- spec/dummy/app/models/user.rb
|
202
|
-
- spec/dummy/app/
|
203
|
-
- spec/dummy/
|
204
|
-
- spec/dummy/
|
212
|
+
- spec/dummy/app/models/user.rb~
|
213
|
+
- spec/dummy/db/migrate/20160721092137_create_users.rb
|
214
|
+
- spec/dummy/db/migrate/20160721092137_create_users.rb~
|
215
|
+
- spec/dummy/db/schema.rb
|
216
|
+
- spec/dummy/log/test.log
|
217
|
+
- spec/dummy/Rakefile
|
218
|
+
- spec/dummy/public/500.html
|
219
|
+
- spec/dummy/public/422.html
|
220
|
+
- spec/dummy/public/404.html
|
221
|
+
- spec/dummy/public/favicon.ico
|
222
|
+
- spec/dummy/script/rails
|
205
223
|
- spec/dummy/config/database.yml
|
206
|
-
- spec/dummy/config/environment.rb
|
207
|
-
- spec/dummy/config/environments/development.rb
|
208
|
-
- spec/dummy/config/environments/production.rb
|
209
|
-
- spec/dummy/config/environments/test.rb
|
210
224
|
- spec/dummy/config/initializers/backtrace_silencers.rb
|
211
|
-
- spec/dummy/config/initializers/
|
212
|
-
- spec/dummy/config/initializers/mime_types.rb
|
213
|
-
- spec/dummy/config/initializers/secret_token.rb
|
225
|
+
- spec/dummy/config/initializers/nps_surveys.rb~
|
214
226
|
- spec/dummy/config/initializers/session_store.rb
|
215
227
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
228
|
+
- spec/dummy/config/initializers/mime_types.rb
|
229
|
+
- spec/dummy/config/initializers/secret_token.rb
|
230
|
+
- spec/dummy/config/initializers/inflections.rb
|
231
|
+
- spec/dummy/config/environments/development.rb
|
232
|
+
- spec/dummy/config/environments/production.rb
|
233
|
+
- spec/dummy/config/environments/test.rb
|
216
234
|
- spec/dummy/config/locales/en.yml
|
235
|
+
- spec/dummy/config/application.rb
|
236
|
+
- spec/dummy/config/boot.rb
|
237
|
+
- spec/dummy/config/environment.rb
|
217
238
|
- spec/dummy/config/routes.rb
|
218
239
|
- spec/dummy/config.ru
|
219
|
-
- spec/dummy/db/migrate/20160721092137_create_users.rb
|
220
|
-
- spec/dummy/db/schema.rb
|
221
|
-
- spec/dummy/log/development.log
|
222
|
-
- spec/dummy/public/404.html
|
223
|
-
- spec/dummy/public/422.html
|
224
|
-
- spec/dummy/public/500.html
|
225
|
-
- spec/dummy/public/favicon.ico
|
226
|
-
- spec/dummy/Rakefile
|
227
240
|
- spec/dummy/README.rdoc
|
228
|
-
- spec/dummy/script/rails
|
229
|
-
- spec/factories.rb
|
230
|
-
- spec/models/nps_surveys/response_spec.rb
|
231
|
-
- spec/spec_helper.rb
|
232
|
-
- spec/support/api_json_parser.rb
|
233
|
-
- spec/support/authenticated_test_helper.rb
|
@@ -1,12 +0,0 @@
|
|
1
|
-
Connecting to database specified by database.yml
|
2
|
-
Connecting to database specified by database.yml
|
3
|
-
[1m[36m (0.3ms)[0m [1mSELECT `schema_migrations`.`version` FROM `schema_migrations` [0m
|
4
|
-
[1m[35m (41.8ms)[0m DROP DATABASE IF EXISTS `nps_surveys_test`
|
5
|
-
[1m[36m (0.2ms)[0m [1mCREATE DATABASE `nps_surveys_test` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`[0m
|
6
|
-
[1m[35m (29.2ms)[0m CREATE TABLE `surveys_responses` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `survey` varchar(255) NOT NULL, `user_id` int(11) NOT NULL, `score` int(11), `feedback` text, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
|
7
|
-
[1m[36m (27.7ms)[0m [1mCREATE TABLE `users` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `login` varchar(255), `password` varchar(255), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB[0m
|
8
|
-
[1m[35m (25.8ms)[0m CREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB
|
9
|
-
[1m[36m (52.3ms)[0m [1mCREATE UNIQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`)[0m
|
10
|
-
[1m[35m (0.2ms)[0m SELECT version FROM `schema_migrations`
|
11
|
-
[1m[36m (5.0ms)[0m [1mINSERT INTO `schema_migrations` (version) VALUES ('20160721092137')[0m
|
12
|
-
[1m[35m (4.6ms)[0m INSERT INTO `schema_migrations` (version) VALUES ('20160614145840')
|