wordjelly-auth 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (202) hide show
  1. checksums.yaml +4 -4
  2. data/lib/auth/version.rb +1 -1
  3. data/spec/auth_test.rb +7 -0
  4. data/spec/controllers/auth/admin_create_users_controller_spec.rb +141 -0
  5. data/spec/controllers/auth/clients_controller_spec.rb +223 -0
  6. data/spec/controllers/auth/search_controller_spec.rb +5 -0
  7. data/spec/controllers/auth/shopping/discounts_controller_spec.rb +54 -0
  8. data/spec/controllers/auth/users/profiles_controller_spec.rb +5 -0
  9. data/spec/dummy/README.rdoc +28 -0
  10. data/spec/dummy/Rakefile +6 -0
  11. data/spec/dummy/app/assets/javascripts/activity.js +2 -0
  12. data/spec/dummy/app/assets/javascripts/application.js +16 -0
  13. data/spec/dummy/app/assets/javascripts/home.js +2 -0
  14. data/spec/dummy/app/assets/javascripts/pollymer.min.js +170 -0
  15. data/spec/dummy/app/assets/javascripts/tests.js +2 -0
  16. data/spec/dummy/app/assets/javascripts/topics.js +2 -0
  17. data/spec/dummy/app/assets/stylesheets/activity.css +4 -0
  18. data/spec/dummy/app/assets/stylesheets/application.scss +16 -0
  19. data/spec/dummy/app/assets/stylesheets/home.css +4 -0
  20. data/spec/dummy/app/assets/stylesheets/tests.css +4 -0
  21. data/spec/dummy/app/assets/stylesheets/topics.css +4 -0
  22. data/spec/dummy/app/controllers/activity_controller.rb +3 -0
  23. data/spec/dummy/app/controllers/admins/confirmations_controller.rb +28 -0
  24. data/spec/dummy/app/controllers/admins/omniauth_callbacks_controller.rb +28 -0
  25. data/spec/dummy/app/controllers/admins/passwords_controller.rb +32 -0
  26. data/spec/dummy/app/controllers/admins/registrations_controller.rb +60 -0
  27. data/spec/dummy/app/controllers/admins/sessions_controller.rb +5 -0
  28. data/spec/dummy/app/controllers/admins/unlocks_controller.rb +28 -0
  29. data/spec/dummy/app/controllers/application_controller.rb +49 -0
  30. data/spec/dummy/app/controllers/home_controller.rb +13 -0
  31. data/spec/dummy/app/controllers/otp_controller.rb +3 -0
  32. data/spec/dummy/app/controllers/shopping/cart_items_controller.rb +28 -0
  33. data/spec/dummy/app/controllers/shopping/carts_controller.rb +4 -0
  34. data/spec/dummy/app/controllers/shopping/discounts_controller.rb +3 -0
  35. data/spec/dummy/app/controllers/shopping/payments_controller.rb +5 -0
  36. data/spec/dummy/app/controllers/shopping/products_controller.rb +2 -0
  37. data/spec/dummy/app/controllers/tests_controller.rb +58 -0
  38. data/spec/dummy/app/controllers/topics_controller.rb +63 -0
  39. data/spec/dummy/app/controllers/users/sessions_controller.rb +3 -0
  40. data/spec/dummy/app/controllers/webhooks_controller.rb +13 -0
  41. data/spec/dummy/app/helpers/activity_helper.rb +2 -0
  42. data/spec/dummy/app/helpers/api/v1/token_auth_helper.rb +2 -0
  43. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  44. data/spec/dummy/app/helpers/home_helper.rb +2 -0
  45. data/spec/dummy/app/helpers/tests_helper.rb +2 -0
  46. data/spec/dummy/app/helpers/topics_helper.rb +2 -0
  47. data/spec/dummy/app/mailers/application_mailer.rb +4 -0
  48. data/spec/dummy/app/mailers/new.rb +3 -0
  49. data/spec/dummy/app/models/activity.rb +3 -0
  50. data/spec/dummy/app/models/admin.rb +12 -0
  51. data/spec/dummy/app/models/noti.rb +48 -0
  52. data/spec/dummy/app/models/noti_response.rb +9 -0
  53. data/spec/dummy/app/models/shopping/cart.rb +3 -0
  54. data/spec/dummy/app/models/shopping/cart_item.rb +7 -0
  55. data/spec/dummy/app/models/shopping/discount.rb +3 -0
  56. data/spec/dummy/app/models/shopping/payment.rb +16 -0
  57. data/spec/dummy/app/models/shopping/product.rb +6 -0
  58. data/spec/dummy/app/models/test.rb +5 -0
  59. data/spec/dummy/app/models/topic.rb +75 -0
  60. data/spec/dummy/app/models/user.rb +95 -0
  61. data/spec/dummy/app/views/home/index.html.erb +6 -0
  62. data/spec/dummy/app/views/home/send_notification.html.erb +2 -0
  63. data/spec/dummy/app/views/layouts/application.html.erb +26 -0
  64. data/spec/dummy/app/views/layouts/mailer.html.erb +8 -0
  65. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  66. data/spec/dummy/app/views/new/notification.html.erb +1 -0
  67. data/spec/dummy/app/views/new/notification.text.erb +1 -0
  68. data/spec/dummy/app/views/shopping/_navigation_options.html.erb +1 -0
  69. data/spec/dummy/app/views/tests/_form.html.erb +25 -0
  70. data/spec/dummy/app/views/tests/edit.html.erb +6 -0
  71. data/spec/dummy/app/views/tests/index.html.erb +33 -0
  72. data/spec/dummy/app/views/tests/new.html.erb +5 -0
  73. data/spec/dummy/app/views/tests/show.html.erb +14 -0
  74. data/spec/dummy/app/views/topics/_form.html.erb +25 -0
  75. data/spec/dummy/app/views/topics/edit.html.erb +6 -0
  76. data/spec/dummy/app/views/topics/index.html.erb +29 -0
  77. data/spec/dummy/app/views/topics/new.html.erb +5 -0
  78. data/spec/dummy/app/views/topics/show.html.erb +14 -0
  79. data/spec/dummy/app/views/users/sessions/create.js.erb +6 -0
  80. data/spec/dummy/bin/bundle +3 -0
  81. data/spec/dummy/bin/rails +4 -0
  82. data/spec/dummy/bin/rake +4 -0
  83. data/spec/dummy/bin/setup +29 -0
  84. data/spec/dummy/config.ru +8 -0
  85. data/spec/dummy/config/application.rb +31 -0
  86. data/spec/dummy/config/boot.rb +5 -0
  87. data/spec/dummy/config/environment.rb +4 -0
  88. data/spec/dummy/config/environments/development.rb +57 -0
  89. data/spec/dummy/config/environments/production.rb +92 -0
  90. data/spec/dummy/config/environments/test.rb +44 -0
  91. data/spec/dummy/config/initializers/assets.rb +11 -0
  92. data/spec/dummy/config/initializers/aws.rb +15 -0
  93. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  94. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  95. data/spec/dummy/config/initializers/devise.rb +273 -0
  96. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  97. data/spec/dummy/config/initializers/inflections.rb +16 -0
  98. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  99. data/spec/dummy/config/initializers/preinitializer.rb +167 -0
  100. data/spec/dummy/config/initializers/redis.rb +9 -0
  101. data/spec/dummy/config/initializers/session_store.rb +3 -0
  102. data/spec/dummy/config/initializers/wrap_parameters.rb +9 -0
  103. data/spec/dummy/config/locales/devise.en.yml +62 -0
  104. data/spec/dummy/config/locales/en.yml +25 -0
  105. data/spec/dummy/config/mongoid.yml +142 -0
  106. data/spec/dummy/config/redis.yml +14 -0
  107. data/spec/dummy/config/routes.rb +38 -0
  108. data/spec/dummy/config/secrets.yml +22 -0
  109. data/spec/dummy/db/seeds.rb +48 -0
  110. data/spec/dummy/lib/admin/parameter_sanitizer.rb +9 -0
  111. data/spec/dummy/lib/assets/files/test_names.json +1 -0
  112. data/spec/dummy/lib/user/parameter_sanitizer.rb +8 -0
  113. data/spec/dummy/public/404.html +67 -0
  114. data/spec/dummy/public/422.html +67 -0
  115. data/spec/dummy/public/500.html +66 -0
  116. data/spec/dummy/public/favicon.ico +0 -0
  117. data/spec/dummy/shoryuken.yml +5 -0
  118. data/spec/dummy/sidekiq.yml +9 -0
  119. data/spec/dummy/sidekiq_prep.sh +6 -0
  120. data/spec/dummy/spec/controllers/activity_controller_spec.rb +5 -0
  121. data/spec/dummy/spec/controllers/tests_controller_spec.rb +141 -0
  122. data/spec/dummy/spec/factories/tests.rb +6 -0
  123. data/spec/dummy/spec/fixtures/new/send_notification +3 -0
  124. data/spec/dummy/spec/helpers/activity_helper_spec.rb +15 -0
  125. data/spec/dummy/spec/helpers/tests_helper_spec.rb +15 -0
  126. data/spec/dummy/spec/mailers/new_spec.rb +18 -0
  127. data/spec/dummy/spec/mailers/previews/new_preview.rb +13 -0
  128. data/spec/dummy/spec/models/test_spec.rb +5 -0
  129. data/spec/dummy/spec/requests/tests_spec.rb +10 -0
  130. data/spec/dummy/spec/routing/tests_routing_spec.rb +39 -0
  131. data/spec/dummy/spec/views/tests/edit.html.erb_spec.rb +21 -0
  132. data/spec/dummy/spec/views/tests/index.html.erb_spec.rb +22 -0
  133. data/spec/dummy/spec/views/tests/new.html.erb_spec.rb +21 -0
  134. data/spec/dummy/spec/views/tests/show.html.erb_spec.rb +16 -0
  135. data/spec/dummy/test/controllers/api/v1/token_auth_controller_test.rb +7 -0
  136. data/spec/dummy/test/controllers/home_controller_test.rb +9 -0
  137. data/spec/dummy/test/controllers/oauth_tests_controller_test.rb +7 -0
  138. data/spec/dummy/test/fixtures/oauth_tests.yml +11 -0
  139. data/spec/dummy/test/fixtures/users.yml +7 -0
  140. data/spec/dummy/test/models/oauth_test_test.rb +7 -0
  141. data/spec/dummy/test/models/user_test.rb +7 -0
  142. data/spec/factories/client_factory.rb +77 -0
  143. data/spec/features/additional_login_param_feature_spec.rb +63 -0
  144. data/spec/features/extension_spec.rb +680 -0
  145. data/spec/features/redirect_disable_spec.rb +74 -0
  146. data/spec/fixtures/auth/clients.yml +13 -0
  147. data/spec/helpers/auth/admin_create_users_helper_spec.rb +15 -0
  148. data/spec/helpers/auth/resource_helper_spec.rb +15 -0
  149. data/spec/helpers/auth/search_helper_spec.rb +15 -0
  150. data/spec/helpers/auth/users/profiles_helper_spec.rb +15 -0
  151. data/spec/integration/navigation_test.rb +8 -0
  152. data/spec/mailers/auth/notifier_spec.rb +5 -0
  153. data/spec/mailers/previews/auth/notifier_preview.rb +4 -0
  154. data/spec/models/auth/admin_create_user_spec.rb +5 -0
  155. data/spec/models/auth/client_test.rb +9 -0
  156. data/spec/models/auth/shopping/discount_spec.rb +5 -0
  157. data/spec/rails_helper.rb +70 -0
  158. data/spec/requests/admin/confirmation_request_spec.rb +164 -0
  159. data/spec/requests/admin/password_request_spec.rb +191 -0
  160. data/spec/requests/admin/registration_request_spec.rb +574 -0
  161. data/spec/requests/admin/session_request_spec.rb +352 -0
  162. data/spec/requests/admin/unlock_request_spec.rb +178 -0
  163. data/spec/requests/admin_create_user_request_spec.rb +303 -0
  164. data/spec/requests/background_job_request_spec.rb +28 -0
  165. data/spec/requests/cart_item_request_spec.rb +381 -0
  166. data/spec/requests/cart_request_spec.rb +451 -0
  167. data/spec/requests/client_request_spec.rb +65 -0
  168. data/spec/requests/discount_request_spec.rb +589 -0
  169. data/spec/requests/payment_request_spec.rb +1254 -0
  170. data/spec/requests/search_request_spec.rb +173 -0
  171. data/spec/requests/topic_request_spec.rb +138 -0
  172. data/spec/requests/user/additional_login_param_and_email_validation_spec.rb +673 -0
  173. data/spec/requests/user/confirmation_request_spec.rb +189 -0
  174. data/spec/requests/user/omniauth_callbacks_request_spec.rb +682 -0
  175. data/spec/requests/user/otp_basic_flow_request_spec.rb +512 -0
  176. data/spec/requests/user/password_request_spec.rb +216 -0
  177. data/spec/requests/user/registration_request_spec.rb +615 -0
  178. data/spec/requests/user/session_request_spec.rb +361 -0
  179. data/spec/requests/user/unlock_request_spec.rb +208 -0
  180. data/spec/routing/admin/admin_routes_spec.rb +15 -0
  181. data/spec/routing/auth/admin_create_users_routing_spec.rb +39 -0
  182. data/spec/routing/clients_controller_routes_spec.rb +75 -0
  183. data/spec/routing/engine_routes_spec.rb +16 -0
  184. data/spec/spec_helper.rb +138 -0
  185. data/spec/support/factory_girl.rb +3 -0
  186. data/spec/support/omniauth_macros.rb +195 -0
  187. data/spec/support/payumoney_support.rb +11 -0
  188. data/spec/support/sign_in_support.rb +361 -0
  189. data/spec/support/wait_for_ajax.rb +11 -0
  190. data/spec/views/auth/admin_create_users/edit.html.erb_spec.rb +14 -0
  191. data/spec/views/auth/admin_create_users/index.html.erb_spec.rb +14 -0
  192. data/spec/views/auth/admin_create_users/new.html.erb_spec.rb +14 -0
  193. data/spec/views/auth/admin_create_users/show.html.erb_spec.rb +11 -0
  194. data/spec/views/auth/shopping/discounts/create.html.erb_spec.rb +5 -0
  195. data/spec/views/auth/shopping/discounts/destroy.html.erb_spec.rb +5 -0
  196. data/spec/views/auth/shopping/discounts/edit.html.erb_spec.rb +5 -0
  197. data/spec/views/auth/shopping/discounts/index.html.erb_spec.rb +5 -0
  198. data/spec/views/auth/shopping/discounts/new.html.erb_spec.rb +5 -0
  199. data/spec/views/auth/shopping/discounts/show.html.erb_spec.rb +5 -0
  200. data/spec/views/auth/shopping/discounts/update.html.erb_spec.rb +5 -0
  201. data/spec/views/profile/show.html.erb_spec.rb +5 -0
  202. metadata +401 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ef02ce9d43e00c962580b0bd31e2ab548bde0986
4
- data.tar.gz: e69e0438c8be1ed61a4d5167bba0d32038767326
3
+ metadata.gz: ed8947077309fdc03eecc96a02a02de94c7da2c2
4
+ data.tar.gz: fe88ac2c87e0db85a1de6b4482f09c4ff77e8e8b
5
5
  SHA512:
6
- metadata.gz: d0f1f75b0a0da450a3766e61aa0d15d1f386e172eb0f8f83b85137b29368344133d1437b5a4aa2a4a80f16f7063097d118a20c59742838f6f4f81c551fee5642
7
- data.tar.gz: b44dcac9942d04dea2ce111efaa43f7baf5aca45f903c59ab51553212d10c2c2f81133e8f191ad19598f1b55853c7273eb841deb51988fc766390bfdc803dc8e
6
+ metadata.gz: 5e852a69dc3781cdc2009deb7ca8645685f29a595ea4af792c04570722afab3d80921411274bd6bf76d70437e3e66b01be65106745ba279d025cd22e5d779904
7
+ data.tar.gz: e1100228a0166419c6508b0184d5aa35f5d5332ad2af4417fa1c84cbe5056b0e47ed3a0f0676960748dec7c577e8dc26fc152fd4116cb79db7300245e6b98bab
@@ -1,3 +1,3 @@
1
1
  module Auth
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class AuthTest < ActiveSupport::TestCase
4
+ test "truth" do
5
+ assert_kind_of Module, Auth
6
+ end
7
+ end
@@ -0,0 +1,141 @@
1
+ require 'rails_helper'
2
+
3
+ # This spec was generated by rspec-rails when you ran the scaffold generator.
4
+ # It demonstrates how one might use RSpec to specify the controller code that
5
+ # was generated by Rails when you ran the scaffold generator.
6
+ #
7
+ # It assumes that the implementation code is generated by the rails scaffold
8
+ # generator. If you are using any extension libraries to generate different
9
+ # controller code, this generated spec may or may not pass.
10
+ #
11
+ # It only uses APIs available in rails and/or rspec-rails. There are a number
12
+ # of tools you can use to make these specs even more expressive, but we're
13
+ # sticking to rails and rspec-rails APIs to keep things simple and stable.
14
+ #
15
+ # Compared to earlier versions of this generator, there is very limited use of
16
+ # stubs and message expectations in this spec. Stubs are only used when there
17
+ # is no simpler way to get a handle on the object needed for the example.
18
+ # Message expectations are only used when there is no simpler way to specify
19
+ # that an instance is receiving a specific message.
20
+ #
21
+ # Also compared to earlier versions of this generator, there are no longer any
22
+ # expectations of assigns and templates rendered. These features have been
23
+ # removed from Rails core in Rails 5, but can be added back in via the
24
+ # `rails-controller-testing` gem.
25
+
26
+ RSpec.describe Auth::AdminCreateUsersController, type: :controller do
27
+
28
+ # This should return the minimal set of attributes required to create a valid
29
+ # Auth::AdminCreateUser. As you add validations to Auth::AdminCreateUser, be sure to
30
+ # adjust the attributes here as well.
31
+ let(:valid_attributes) {
32
+ skip("Add a hash of attributes valid for your model")
33
+ }
34
+
35
+ let(:invalid_attributes) {
36
+ skip("Add a hash of attributes invalid for your model")
37
+ }
38
+
39
+ # This should return the minimal set of values that should be in the session
40
+ # in order to pass any filters (e.g. authentication) defined in
41
+ # Auth::AdminCreateUsersController. Be sure to keep this updated too.
42
+ let(:valid_session) { {} }
43
+
44
+ describe "GET #index" do
45
+ it "returns a success response" do
46
+ admin_create_user = Auth::AdminCreateUser.create! valid_attributes
47
+ get :index, {}, valid_session
48
+ expect(response).to be_success
49
+ end
50
+ end
51
+
52
+ describe "GET #show" do
53
+ it "returns a success response" do
54
+ admin_create_user = Auth::AdminCreateUser.create! valid_attributes
55
+ get :show, {:id => admin_create_user.to_param}, valid_session
56
+ expect(response).to be_success
57
+ end
58
+ end
59
+
60
+ describe "GET #new" do
61
+ it "returns a success response" do
62
+ get :new, {}, valid_session
63
+ expect(response).to be_success
64
+ end
65
+ end
66
+
67
+ describe "GET #edit" do
68
+ it "returns a success response" do
69
+ admin_create_user = Auth::AdminCreateUser.create! valid_attributes
70
+ get :edit, {:id => admin_create_user.to_param}, valid_session
71
+ expect(response).to be_success
72
+ end
73
+ end
74
+
75
+ describe "POST #create" do
76
+ context "with valid params" do
77
+ it "creates a new Auth::AdminCreateUser" do
78
+ expect {
79
+ post :create, {:auth_admin_create_user => valid_attributes}, valid_session
80
+ }.to change(Auth::AdminCreateUser, :count).by(1)
81
+ end
82
+
83
+ it "redirects to the created auth_admin_create_user" do
84
+ post :create, {:auth_admin_create_user => valid_attributes}, valid_session
85
+ expect(response).to redirect_to(Auth::AdminCreateUser.last)
86
+ end
87
+ end
88
+
89
+ context "with invalid params" do
90
+ it "returns a success response (i.e. to display the 'new' template)" do
91
+ post :create, {:auth_admin_create_user => invalid_attributes}, valid_session
92
+ expect(response).to be_success
93
+ end
94
+ end
95
+ end
96
+
97
+ describe "PUT #update" do
98
+ context "with valid params" do
99
+ let(:new_attributes) {
100
+ skip("Add a hash of attributes valid for your model")
101
+ }
102
+
103
+ it "updates the requested auth_admin_create_user" do
104
+ admin_create_user = Auth::AdminCreateUser.create! valid_attributes
105
+ put :update, {:id => admin_create_user.to_param, :auth_admin_create_user => new_attributes}, valid_session
106
+ admin_create_user.reload
107
+ skip("Add assertions for updated state")
108
+ end
109
+
110
+ it "redirects to the auth_admin_create_user" do
111
+ admin_create_user = Auth::AdminCreateUser.create! valid_attributes
112
+ put :update, {:id => admin_create_user.to_param, :auth_admin_create_user => valid_attributes}, valid_session
113
+ expect(response).to redirect_to(admin_create_user)
114
+ end
115
+ end
116
+
117
+ context "with invalid params" do
118
+ it "returns a success response (i.e. to display the 'edit' template)" do
119
+ admin_create_user = Auth::AdminCreateUser.create! valid_attributes
120
+ put :update, {:id => admin_create_user.to_param, :auth_admin_create_user => invalid_attributes}, valid_session
121
+ expect(response).to be_success
122
+ end
123
+ end
124
+ end
125
+
126
+ describe "DELETE #destroy" do
127
+ it "destroys the requested auth_admin_create_user" do
128
+ admin_create_user = Auth::AdminCreateUser.create! valid_attributes
129
+ expect {
130
+ delete :destroy, {:id => admin_create_user.to_param}, valid_session
131
+ }.to change(Auth::AdminCreateUser, :count).by(-1)
132
+ end
133
+
134
+ it "redirects to the auth_admin_create_users list" do
135
+ admin_create_user = Auth::AdminCreateUser.create! valid_attributes
136
+ delete :destroy, {:id => admin_create_user.to_param}, valid_session
137
+ expect(response).to redirect_to(auth_admin_create_users_url)
138
+ end
139
+ end
140
+
141
+ end
@@ -0,0 +1,223 @@
1
+ require "rails_helper"
2
+ =begin
3
+ ##if you want to test a controller that uses routes defined by the
4
+ describe Auth::ClientsController do
5
+
6
+ def main_app
7
+ Rails.application.class.routes.url_helpers
8
+ end
9
+
10
+ routes{Auth::Engine.routes}
11
+
12
+ context " -- ENFORCES JSON REQUESTS -- " do
13
+
14
+ context " -- non json requests -- " do
15
+
16
+ context " -- keeping the ensure_json_request_filter --- " do
17
+
18
+ it " -- should return a 406 code -- " do
19
+
20
+
21
+ get :index
22
+ expect(response.status).to be(406)
23
+
24
+ end
25
+
26
+ it " -- should return 406 even provided correct auth headers -- " do
27
+
28
+ @user = User.new(attributes_for(:user))
29
+ @user.save
30
+ @request.headers["X-User-Token"] = @user.authentication_token
31
+ @request.headers["X-User-Es"] = @user.es
32
+ get :index
33
+ expect(response.status).to be(406)
34
+
35
+ end
36
+
37
+ end
38
+
39
+ context " -- skipping the ensure json request filter --- " do
40
+
41
+ before(:example) do
42
+ controller.class.skip_before_filter :ensure_json_request
43
+ end
44
+
45
+ after(:example) do
46
+ controller.class.prepend_before_filter :ensure_json_request
47
+
48
+ end
49
+
50
+ it " -- should return a 302 code -- " do
51
+
52
+ get :index
53
+ expect(response.status).to be(302)
54
+
55
+ end
56
+
57
+ it " -- should return 200 -- " do
58
+
59
+ @user = User.new(attributes_for(:user))
60
+ @user.save
61
+ @request.headers["X-User-Token"] = @user.authentication_token
62
+ @request.headers["X-User-Es"] = @user.es
63
+ get :index
64
+ expect(response.status).to be(200)
65
+
66
+ end
67
+
68
+ end
69
+
70
+ end
71
+
72
+ context " -- json requests -- " do
73
+
74
+ before(:example) do
75
+ @request.headers["HTTP_ACCEPT"] = "application/json"
76
+ @request.headers["CONTENT_TYPE"] = "application/json"
77
+ end
78
+
79
+ it " -- should return a 401 not-authenticated code -- " do
80
+ get :index
81
+ expect(response.status).to be(401)
82
+
83
+ end
84
+
85
+ it " -- should return 200 -- " do
86
+
87
+ @user = User.new(attributes_for(:user))
88
+ @user.save
89
+ @request.headers["X-User-Token"] = @user.authentication_token
90
+ @request.headers["X-User-Es"] = @user.es
91
+ get :index
92
+ expect(response.status).to be(200)
93
+
94
+ end
95
+
96
+ end
97
+
98
+ end
99
+
100
+
101
+ context "-- no authentication headers ---" do
102
+
103
+
104
+ it " -- get request should produce 401 -- " do
105
+
106
+ get :index, :format => :json
107
+ expect( response.status ).to be(401)
108
+
109
+ end
110
+
111
+ it " -- post request should produce 401 -- " do
112
+
113
+ post :create, :params => attributes_for(:client), :format => :json
114
+ expect( response.status ).to be(401)
115
+
116
+ end
117
+
118
+
119
+ end
120
+
121
+
122
+ context " -- incorrect authentication headers --- " do
123
+
124
+ before(:example) do
125
+ @request.headers["X-User-Token"] = "wrong"
126
+ @request.headers["X-User-Es"] = "wrong"
127
+ @request.headers["HTTP_ACCEPT"] = "application/json"
128
+ @request.headers["CONTENT_TYPE"] = "application/json"
129
+ end
130
+
131
+
132
+ it " -- get request should produce 401 -- " do
133
+
134
+ get :index
135
+ expect( response.status ).to be(401)
136
+
137
+ end
138
+
139
+ it " -- post request should produce 401 -- " do
140
+
141
+ post :create, attributes_for(:client)
142
+
143
+ expect( response.status ).to be(401)
144
+
145
+ end
146
+
147
+ end
148
+
149
+ context " -- correct authentication headers --- " do
150
+
151
+ before(:example) do
152
+ @user = User.new(attributes_for(:user))
153
+ @user.es = "trachoma"
154
+ @user.authentication_token = "pallidum"
155
+ @user.save
156
+ @request.headers["X-User-Token"] = @user.authentication_token
157
+ @request.headers["X-User-Es"] = @user.es
158
+ @request.headers["HTTP_ACCEPT"] = "application/json"
159
+ @request.headers["CONTENT_TYPE"] = "application/json"
160
+ end
161
+
162
+ it " -- get request is successfull -- " do
163
+ get :index
164
+ expect(response.status).to be(200)
165
+ end
166
+
167
+ it " -- does not update if client does not exist -- " do
168
+ c = Auth::Client.new(:redirect_urls => ["http://www.google.com"])
169
+ c.user_id = BSON::ObjectId.new
170
+ put :update, :id => c.user_id, :client => c.attributes
171
+ client = assigns(:client)
172
+ expect(response.status).to be(404)
173
+ expect(client).to be(nil)
174
+ end
175
+
176
+ it " -- updates if urls are valid, with status code 204 -- " do
177
+ c = Auth::Client.new(:redirect_urls => ["http://www.google.com"])
178
+ c.user_id = @user.id
179
+ put :update, :id => c.user_id, :client => c.attributes
180
+ client = assigns(:client)
181
+ expect(response.status).to be(204)
182
+ expect(client.op_success?).to be(true)
183
+ end
184
+
185
+ it " -- update fails, with invalid url, with code 422 --- " do
186
+ ##we give some invalid urls and get the errors.
187
+ c = Auth::Client.new(:redirect_urls => ["dog"])
188
+ c.user_id = @user.id
189
+ put :update, :id => c.user_id, :client => c.attributes
190
+ client = assigns(:client)
191
+ expect(client.errors.full_messages).not_to be_empty
192
+ expect(response.status).to be(422)
193
+ end
194
+
195
+ it " -- destroys if client exists with 204 -- " do
196
+
197
+ c = Auth::Client.new
198
+ c.user_id = @user.id
199
+ delete :destroy, :id => c.user_id
200
+ expect(response.status).to be(204)
201
+ destroyed = Auth::Client.where(:id => c.user_id)
202
+ expect(destroyed.count).to be(0)
203
+
204
+ end
205
+
206
+ it " -- shows the client if it exists, with 200 --- " do
207
+
208
+ c = Auth::Client.new
209
+ c.user_id = @user.id
210
+ get :show, :id => c.user_id
211
+ client = assigns(:client)
212
+ expect(response.status).to be(200)
213
+ expect(client.user_id.to_s).to eq(c.user_id.to_s)
214
+
215
+ end
216
+
217
+
218
+ end
219
+
220
+
221
+
222
+ end
223
+ =end
@@ -0,0 +1,5 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe Auth::SearchController, type: :controller do
4
+
5
+ end
@@ -0,0 +1,54 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe Auth::Shopping::DiscountsController, type: :controller do
4
+
5
+ describe "GET #new" do
6
+ it "returns http success" do
7
+ get :new
8
+ expect(response).to have_http_status(:success)
9
+ end
10
+ end
11
+
12
+ describe "GET #show" do
13
+ it "returns http success" do
14
+ get :show
15
+ expect(response).to have_http_status(:success)
16
+ end
17
+ end
18
+
19
+ describe "GET #edit" do
20
+ it "returns http success" do
21
+ get :edit
22
+ expect(response).to have_http_status(:success)
23
+ end
24
+ end
25
+
26
+ describe "GET #index" do
27
+ it "returns http success" do
28
+ get :index
29
+ expect(response).to have_http_status(:success)
30
+ end
31
+ end
32
+
33
+ describe "GET #create" do
34
+ it "returns http success" do
35
+ get :create
36
+ expect(response).to have_http_status(:success)
37
+ end
38
+ end
39
+
40
+ describe "GET #update" do
41
+ it "returns http success" do
42
+ get :update
43
+ expect(response).to have_http_status(:success)
44
+ end
45
+ end
46
+
47
+ describe "GET #destroy" do
48
+ it "returns http success" do
49
+ get :destroy
50
+ expect(response).to have_http_status(:success)
51
+ end
52
+ end
53
+
54
+ end