we_bridge_rails_engine_nations 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +4 -0
  5. data/CODE_OF_CONDUCT.md +13 -0
  6. data/Gemfile +34 -0
  7. data/Gemfile.lock +254 -0
  8. data/LICENSE.txt +21 -0
  9. data/MIT-LICENSE +20 -0
  10. data/README.md +41 -0
  11. data/Rakefile +37 -0
  12. data/app/assets/javascripts/areas.js +2 -0
  13. data/app/assets/javascripts/currencies.js +2 -0
  14. data/app/assets/javascripts/nations.js +2 -0
  15. data/app/assets/javascripts/regions.js +2 -0
  16. data/app/assets/stylesheets/areas.css +4 -0
  17. data/app/assets/stylesheets/currencies.css +4 -0
  18. data/app/assets/stylesheets/nations.css +4 -0
  19. data/app/assets/stylesheets/regions.css +4 -0
  20. data/app/assets/stylesheets/scaffold.css +56 -0
  21. data/app/controllers/areas_controller.rb +7 -0
  22. data/app/controllers/currencies_controller.rb +58 -0
  23. data/app/controllers/nations_controller.rb +7 -0
  24. data/app/controllers/regions_controller.rb +7 -0
  25. data/app/helpers/areas_helper.rb +2 -0
  26. data/app/helpers/currencies_helper.rb +2 -0
  27. data/app/helpers/nations_helper.rb +2 -0
  28. data/app/helpers/regions_helper.rb +2 -0
  29. data/app/mailers/.keep +0 -0
  30. data/app/models/.keep +0 -0
  31. data/app/models/area.rb +14 -0
  32. data/app/models/area_text.rb +7 -0
  33. data/app/models/currency.rb +26 -0
  34. data/app/models/currency_nation_map.rb +4 -0
  35. data/app/models/currency_text.rb +7 -0
  36. data/app/models/nation.rb +45 -0
  37. data/app/models/nation_text.rb +7 -0
  38. data/app/models/region.rb +15 -0
  39. data/app/models/region_text.rb +7 -0
  40. data/app/views/.keep +0 -0
  41. data/app/views/areas/edit.html.builder +1 -0
  42. data/app/views/areas/index.html.builder +1 -0
  43. data/app/views/areas/new.html.builder +1 -0
  44. data/app/views/areas/show.html.builder +1 -0
  45. data/app/views/currencies/_form.html.builder +14 -0
  46. data/app/views/currencies/edit.html.builder +7 -0
  47. data/app/views/currencies/index.html.builder +25 -0
  48. data/app/views/currencies/new.html.builder +5 -0
  49. data/app/views/currencies/show.html.builder +8 -0
  50. data/app/views/nations/edit.html.builder +1 -0
  51. data/app/views/nations/index.html.builder +1 -0
  52. data/app/views/nations/new.html.builder +1 -0
  53. data/app/views/nations/show.html.builder +1 -0
  54. data/app/views/regions/edit.html.builder +1 -0
  55. data/app/views/regions/index.html.builder +1 -0
  56. data/app/views/regions/new.html.builder +1 -0
  57. data/app/views/regions/show.html.builder +1 -0
  58. data/bin/console +14 -0
  59. data/bin/rails +12 -0
  60. data/bin/setup +7 -0
  61. data/config/routes.rb +6 -0
  62. data/db/migrate/20151127040229_create_nations.rb +27 -0
  63. data/db/migrate/20151127040410_create_regions.rb +19 -0
  64. data/db/migrate/20151127040435_create_areas.rb +19 -0
  65. data/db/migrate/20151202041711_create_currencies.rb +28 -0
  66. data/db/seeds.rb +439 -0
  67. data/lib/tasks/we_bridge_rails_engine_nations_tasks.rake +4 -0
  68. data/lib/we_bridge_rails_engine_nations.rb +7 -0
  69. data/lib/we_bridge_rails_engine_nations/engine.rb +24 -0
  70. data/lib/we_bridge_rails_engine_nations/version.rb +3 -0
  71. data/spec/controllers/areas_controller_spec.rb +169 -0
  72. data/spec/controllers/currencies_controller_spec.rb +159 -0
  73. data/spec/controllers/nations_controller_spec.rb +169 -0
  74. data/spec/controllers/regions_controller_spec.rb +169 -0
  75. data/spec/dummy/README.rdoc +28 -0
  76. data/spec/dummy/Rakefile +6 -0
  77. data/spec/dummy/app/assets/javascripts/application.js +16 -0
  78. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  79. data/spec/dummy/app/controllers/application_controller.rb +8 -0
  80. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  81. data/spec/dummy/app/views/layouts/application.html.builder +14 -0
  82. data/spec/dummy/bin/bundle +3 -0
  83. data/spec/dummy/bin/rails +4 -0
  84. data/spec/dummy/bin/rake +4 -0
  85. data/spec/dummy/bin/setup +29 -0
  86. data/spec/dummy/config.ru +4 -0
  87. data/spec/dummy/config/application.rb +28 -0
  88. data/spec/dummy/config/boot.rb +5 -0
  89. data/spec/dummy/config/database.yml +25 -0
  90. data/spec/dummy/config/environment.rb +5 -0
  91. data/spec/dummy/config/environments/development.rb +41 -0
  92. data/spec/dummy/config/environments/production.rb +79 -0
  93. data/spec/dummy/config/environments/test.rb +42 -0
  94. data/spec/dummy/config/initializers/assets.rb +11 -0
  95. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  96. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  97. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  98. data/spec/dummy/config/initializers/inflections.rb +16 -0
  99. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  100. data/spec/dummy/config/initializers/provider_settings.rb +2 -0
  101. data/spec/dummy/config/initializers/session_store.rb +3 -0
  102. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  103. data/spec/dummy/config/locales/en.yml +23 -0
  104. data/spec/dummy/config/omniauth.yml +63 -0
  105. data/spec/dummy/config/omniauth.yml.org +63 -0
  106. data/spec/dummy/config/routes.rb +56 -0
  107. data/spec/dummy/config/secrets.yml +22 -0
  108. data/spec/dummy/db/development.sqlite3 +0 -0
  109. data/spec/dummy/db/schema.rb +221 -0
  110. data/spec/dummy/db/test.sqlite3 +0 -0
  111. data/spec/dummy/log/development.log +46295 -0
  112. data/spec/dummy/log/test.log +678 -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/tmp/cache/assets/development/sprockets/v3.0/3qWp1cfMUMB1L1B8w4KCdPJNoktDLzCgZhyGa-eLd0g.cache +1 -0
  118. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache +2 -0
  119. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/6VfBYgqqzYcjALfLCOpHzv3E06n_zzoM0lDBI4rnsx0.cache +0 -0
  120. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/6vg_COhVhYBSY6arqzRJFOy9-rF95BfYQsFuol_UGuQ.cache +1 -0
  121. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/Azqp0lWcLN5Iz5BDrWrNLqHomPvFzn6pENzB3pm95wo.cache +2 -0
  122. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/GYvDs3EBryNSEN-M5uVb3LOFo1oBWq0iDPijDjBVvUs.cache +1 -0
  123. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/H0uxW1DRyYygsm_fv_sMfVycqsGCazsfNJhSZU81CFY.cache +0 -0
  124. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/HcVN18DR0_BmshzEZLPjkeVDruXBZ9iXjboBWmO6Ozw.cache +1 -0
  125. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/JigkThideDLksj6ZrufTx6bLVyJBmNDbaouRbMbZdIA.cache +2 -0
  126. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/N2BTDMKiaaZ5__Eeqks0aWBzX-5T9Hg0d0015KmSRQo.cache +1 -0
  127. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/NrdOdaS5o4trMDBP6UBqLzFsRrmSPy7XJBBtdwktXqk.cache +1 -0
  128. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache +3 -0
  129. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/bUQg5IzV2hJHu0Ua4jOdDcbaLqfzpRqx6-qq9C23sts.cache +0 -0
  130. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/boUHvgQlz503FXEZntk5rEF6Z0dNUvT4VOQquML62dQ.cache +1 -0
  131. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/g5LtU2jYJLiGyWluzwkSuH9dRStTuMGHLO-ivn8wCYE.cache +0 -0
  132. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/gOWNSsYT5GN_cqGVL1MK1faY9XglwixonQVkDk9Pkvk.cache +0 -0
  133. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/h-W0KoQGAiH7Sn5Y6HjTaVkoEceKV_LeymnmENnyLYQ.cache +0 -0
  134. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/n5wUjw8Ag9zP7pgTsene8E7Lj3RyWbqUaf2apVdzwc0.cache +2 -0
  135. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/nYdpABG_YyXwDqCH1vBNjh0m2AlewuKD9vT92xFu9Qs.cache +1 -0
  136. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/nrXgDez-J-7C7rQSEpAiK0Xj5rK37sysOLNYmJIsb_Q.cache +1 -0
  137. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/r_WSE-C4C32WlhZaTBsdC4x3Mf7EQQ93zBA3xOKSw94.cache +1 -0
  138. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/s7AiRxV9LdOVAylAE38RiKCstOIGXxlkhZ15nV8_GfY.cache +2 -0
  139. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/tXQLPTRHFdkPsB5bF6KRKGiUir3uMwdTnxE0na0vmes.cache +0 -0
  140. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/vTbuVbqVUHIvOo23rSZvO1yTT8C-98lLVXe_JG_6Pr8.cache +1 -0
  141. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/x22RvUd8k76gbEMX05JmfJaBplbMc2omvEoreS8eAqg.cache +1 -0
  142. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/xQIYU3iVajL0UcrfbxTB8PIxGMuRDRvRjmq0ve9-s9U.cache +2 -0
  143. data/spec/factories/areas.rb +6 -0
  144. data/spec/factories/currencies.rb +6 -0
  145. data/spec/factories/nations.rb +6 -0
  146. data/spec/factories/regions.rb +6 -0
  147. data/spec/helpers/areas_helper_spec.rb +15 -0
  148. data/spec/helpers/currencies_helper_spec.rb +15 -0
  149. data/spec/helpers/nations_helper_spec.rb +15 -0
  150. data/spec/helpers/regions_helper_spec.rb +15 -0
  151. data/spec/models/area_spec.rb +5 -0
  152. data/spec/models/currency_spec.rb +24 -0
  153. data/spec/models/nation_spec.rb +24 -0
  154. data/spec/models/region_spec.rb +5 -0
  155. data/spec/rails_helper.rb +54 -0
  156. data/spec/routing/areas_routing_spec.rb +39 -0
  157. data/spec/routing/currencies_routing_spec.rb +39 -0
  158. data/spec/routing/nations_routing_spec.rb +39 -0
  159. data/spec/routing/regions_routing_spec.rb +39 -0
  160. data/spec/spec_helper.rb +2 -0
  161. data/spec/views/areas/edit.html.builder_spec.rb +14 -0
  162. data/spec/views/areas/index.html.builder_spec.rb +14 -0
  163. data/spec/views/areas/new.html.builder_spec.rb +14 -0
  164. data/spec/views/areas/show.html.builder_spec.rb +11 -0
  165. data/spec/views/currencies/edit.html.builder_spec.rb +14 -0
  166. data/spec/views/currencies/index.html.builder_spec.rb +14 -0
  167. data/spec/views/currencies/new.html.builder_spec.rb +14 -0
  168. data/spec/views/currencies/show.html.builder_spec.rb +11 -0
  169. data/spec/views/nations/edit.html.builder_spec.rb +14 -0
  170. data/spec/views/nations/index.html.builder_spec.rb +14 -0
  171. data/spec/views/nations/new.html.builder_spec.rb +14 -0
  172. data/spec/views/nations/show.html.builder_spec.rb +11 -0
  173. data/spec/views/regions/edit.html.builder_spec.rb +14 -0
  174. data/spec/views/regions/index.html.builder_spec.rb +14 -0
  175. data/spec/views/regions/new.html.builder_spec.rb +14 -0
  176. data/spec/views/regions/show.html.builder_spec.rb +11 -0
  177. data/spec/we_bridge_rails_engine_nations_spec.rb +7 -0
  178. data/we_bridge_rails_engine_nations.gemspec +42 -0
  179. metadata +482 -0
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :we_bridge_rails_engine_nations do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,7 @@
1
+ require "we_bridge_rails_engine_nations/version"
2
+ require "we_bridge_rails_engine_nations/engine"
3
+ require "we_bridge/auto_view_helper"
4
+ require "we_bridge/auto_view_helper/controller"
5
+ module WeBridgeRailsEngineNations
6
+ # Your code goes here...
7
+ end
@@ -0,0 +1,24 @@
1
+ module WeBridgeRailsEngineNations
2
+ class Engine < ::Rails::Engine
3
+ config.generators do |g|
4
+ g.test_framework :rspec, fixture: false, view_specs: true, helper_specs: true, controller_specs: true, request_specs: true, route_specs: true, model_specs: true
5
+ g.fixture_replacement :factory_girl, :dir => 'spec/factories'
6
+ g.template_engine :builder
7
+ g.assets true
8
+ g.helper true
9
+ g.stylesheets true
10
+ g.javascripts true
11
+ end
12
+ config.autoload_paths << File.expand_path('../../../app/controllers/concerns', __FILE__)
13
+ initializer :append_migrations_and_seeds do |app|
14
+ unless app.root.to_s.match root.to_s
15
+ config.paths["db/migrate"].expanded.each do |expanded_path|
16
+ app.config.paths["db/migrate"] << expanded_path
17
+ end
18
+ end
19
+ config.paths["db/seeds.rb"].existent.each do |expanded_path|
20
+ app.config.paths["db/seeds.rb"] << expanded_path
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,3 @@
1
+ module WeBridgeRailsEngineNations
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,169 @@
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
+ RSpec.describe AreasController, type: :controller do
22
+
23
+ # This should return the minimal set of attributes required to create a valid
24
+ # Area. As you add validations to Area, be sure to
25
+ # adjust the attributes here as well.
26
+ let(:valid_attributes) {
27
+ {name: 'Asia'}
28
+ }
29
+
30
+ let(:invalid_attributes) {
31
+ {name: ''}
32
+ }
33
+
34
+ # This should return the minimal set of values that should be in the session
35
+ # in order to pass any filters (e.g. authentication) defined in
36
+ # AreasController. Be sure to keep this updated too.
37
+ let(:valid_session) { {} }
38
+
39
+ describe "GET #index" do
40
+ it "assigns all areas as @areas" do
41
+ area = Area.create! valid_attributes
42
+ get :index, {}, valid_session
43
+ expect(assigns(:records)).to eq([area])
44
+ end
45
+ end
46
+
47
+ describe "GET #show" do
48
+ it "assigns the requested area as @area" do
49
+ area = Area.create! valid_attributes
50
+ get :show, {:id => area.to_param}, valid_session
51
+ expect(assigns(:record)).to eq(area)
52
+ end
53
+ end
54
+
55
+ describe "GET #new" do
56
+ it "assigns a new area as @area" do
57
+ get :new, {}, valid_session
58
+ expect(assigns(:record)).to be_a_new(Area)
59
+ end
60
+ end
61
+
62
+ describe "GET #edit" do
63
+ it "assigns the requested area as @area" do
64
+ area = Area.create! valid_attributes
65
+ get :edit, {:id => area.to_param}, valid_session
66
+ expect(assigns(:record)).to eq(area)
67
+ end
68
+ end
69
+
70
+ describe "POST #create" do
71
+ context "with valid params" do
72
+ it "creates a new Area" do
73
+ expect {
74
+ post :create, {:areas => valid_attributes}, valid_session
75
+ }.to change(Area, :count).by(1)
76
+ end
77
+
78
+ it "assigns a newly created area as @area" do
79
+ post :create, {:areas => valid_attributes}, valid_session
80
+ expect(assigns(:record)).to be_a(Area)
81
+ expect(assigns(:record)).to be_persisted
82
+ end
83
+
84
+ it "redirects to the created area" do
85
+ post :create, {:areas => valid_attributes}, valid_session
86
+ expect(response).to redirect_to(Area.last)
87
+ end
88
+ end
89
+
90
+ context "with invalid params" do
91
+ it "assigns a newly created but unsaved area as @area" do
92
+ post :create, {:areas => invalid_attributes}, valid_session
93
+ expect(assigns(:record)).to be_a_new(Area)
94
+ end
95
+
96
+ pending do
97
+ it "re-renders the 'new' template" do
98
+ post :create, {:areas => invalid_attributes}, valid_session
99
+ expect(response).to render_template("new")
100
+ end
101
+ end
102
+ end
103
+ end
104
+
105
+ describe "PUT #update" do
106
+ context "with valid params" do
107
+ let(:new_attributes) {
108
+ skip("Add a hash of attributes valid for your model")
109
+ }
110
+
111
+ it "updates the requested area" do
112
+ area = Area.create! valid_attributes
113
+ put :update, {:id => area.to_param, :areas => new_attributes}, valid_session
114
+ area.reload
115
+ skip("Add assertions for updated state")
116
+ end
117
+
118
+ it "assigns the requested area as @area" do
119
+ area = Area.create! valid_attributes
120
+ put :update, {:id => area.to_param, :areas => valid_attributes}, valid_session
121
+ expect(assigns(:record)).to eq(area)
122
+ end
123
+
124
+ pending do
125
+ it "redirects to the area" do
126
+ area = Area.create! valid_attributes
127
+ put :update, {:id => area.to_param, :areas => valid_attributes}, valid_session
128
+ expect(response).to redirect_to(area)
129
+ end
130
+ end
131
+ end
132
+
133
+ context "with invalid params" do
134
+ it "assigns the area as @area" do
135
+ area = Area.create! valid_attributes
136
+ put :update, {:id => area.to_param, :areas => invalid_attributes}, valid_session
137
+ expect(assigns(:record)).to eq(area)
138
+ end
139
+
140
+ pending do
141
+ it "re-renders the 'edit' template" do
142
+ area = Area.create! valid_attributes
143
+ put :update, {:id => area.to_param, :areas => invalid_attributes}, valid_session
144
+ expect(response).to render_template("edit")
145
+ end
146
+ end
147
+ end
148
+ end
149
+
150
+ describe "DELETE #destroy" do
151
+ pending do
152
+ it "destroys the requested area" do
153
+ area = Area.create! valid_attributes
154
+ expect {
155
+ delete :destroy, {:id => area.to_param}, valid_session
156
+ }.to change(Area, :count).by(-1)
157
+ end
158
+ end
159
+
160
+ pending do
161
+ it "redirects to the areas list" do
162
+ area = Area.create! valid_attributes
163
+ delete :destroy, {:id => area.to_param}, valid_session
164
+ expect(response).to redirect_to(areas_url)
165
+ end
166
+ end
167
+ end
168
+
169
+ end
@@ -0,0 +1,159 @@
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
+ RSpec.describe CurrenciesController, type: :controller do
22
+
23
+ # This should return the minimal set of attributes required to create a valid
24
+ # Currency. As you add validations to Currency, be sure to
25
+ # adjust the attributes here as well.
26
+ let(:valid_attributes) {
27
+ skip("Add a hash of attributes valid for your model")
28
+ }
29
+
30
+ let(:invalid_attributes) {
31
+ skip("Add a hash of attributes invalid for your model")
32
+ }
33
+
34
+ # This should return the minimal set of values that should be in the session
35
+ # in order to pass any filters (e.g. authentication) defined in
36
+ # CurrenciesController. Be sure to keep this updated too.
37
+ let(:valid_session) { {} }
38
+
39
+ describe "GET #index" do
40
+ it "assigns all currencies as @currencies" do
41
+ currency = Currency.create! valid_attributes
42
+ get :index, {}, valid_session
43
+ expect(assigns(:currencies)).to eq([currency])
44
+ end
45
+ end
46
+
47
+ describe "GET #show" do
48
+ it "assigns the requested currency as @currency" do
49
+ currency = Currency.create! valid_attributes
50
+ get :show, {:id => currency.to_param}, valid_session
51
+ expect(assigns(:currency)).to eq(currency)
52
+ end
53
+ end
54
+
55
+ describe "GET #new" do
56
+ it "assigns a new currency as @currency" do
57
+ get :new, {}, valid_session
58
+ expect(assigns(:currency)).to be_a_new(Currency)
59
+ end
60
+ end
61
+
62
+ describe "GET #edit" do
63
+ it "assigns the requested currency as @currency" do
64
+ currency = Currency.create! valid_attributes
65
+ get :edit, {:id => currency.to_param}, valid_session
66
+ expect(assigns(:currency)).to eq(currency)
67
+ end
68
+ end
69
+
70
+ describe "POST #create" do
71
+ context "with valid params" do
72
+ it "creates a new Currency" do
73
+ expect {
74
+ post :create, {:currency => valid_attributes}, valid_session
75
+ }.to change(Currency, :count).by(1)
76
+ end
77
+
78
+ it "assigns a newly created currency as @currency" do
79
+ post :create, {:currency => valid_attributes}, valid_session
80
+ expect(assigns(:currency)).to be_a(Currency)
81
+ expect(assigns(:currency)).to be_persisted
82
+ end
83
+
84
+ it "redirects to the created currency" do
85
+ post :create, {:currency => valid_attributes}, valid_session
86
+ expect(response).to redirect_to(Currency.last)
87
+ end
88
+ end
89
+
90
+ context "with invalid params" do
91
+ it "assigns a newly created but unsaved currency as @currency" do
92
+ post :create, {:currency => invalid_attributes}, valid_session
93
+ expect(assigns(:currency)).to be_a_new(Currency)
94
+ end
95
+
96
+ it "re-renders the 'new' template" do
97
+ post :create, {:currency => invalid_attributes}, valid_session
98
+ expect(response).to render_template("new")
99
+ end
100
+ end
101
+ end
102
+
103
+ describe "PUT #update" do
104
+ context "with valid params" do
105
+ let(:new_attributes) {
106
+ skip("Add a hash of attributes valid for your model")
107
+ }
108
+
109
+ it "updates the requested currency" do
110
+ currency = Currency.create! valid_attributes
111
+ put :update, {:id => currency.to_param, :currency => new_attributes}, valid_session
112
+ currency.reload
113
+ skip("Add assertions for updated state")
114
+ end
115
+
116
+ it "assigns the requested currency as @currency" do
117
+ currency = Currency.create! valid_attributes
118
+ put :update, {:id => currency.to_param, :currency => valid_attributes}, valid_session
119
+ expect(assigns(:currency)).to eq(currency)
120
+ end
121
+
122
+ it "redirects to the currency" do
123
+ currency = Currency.create! valid_attributes
124
+ put :update, {:id => currency.to_param, :currency => valid_attributes}, valid_session
125
+ expect(response).to redirect_to(currency)
126
+ end
127
+ end
128
+
129
+ context "with invalid params" do
130
+ it "assigns the currency as @currency" do
131
+ currency = Currency.create! valid_attributes
132
+ put :update, {:id => currency.to_param, :currency => invalid_attributes}, valid_session
133
+ expect(assigns(:currency)).to eq(currency)
134
+ end
135
+
136
+ it "re-renders the 'edit' template" do
137
+ currency = Currency.create! valid_attributes
138
+ put :update, {:id => currency.to_param, :currency => invalid_attributes}, valid_session
139
+ expect(response).to render_template("edit")
140
+ end
141
+ end
142
+ end
143
+
144
+ describe "DELETE #destroy" do
145
+ it "destroys the requested currency" do
146
+ currency = Currency.create! valid_attributes
147
+ expect {
148
+ delete :destroy, {:id => currency.to_param}, valid_session
149
+ }.to change(Currency, :count).by(-1)
150
+ end
151
+
152
+ it "redirects to the currencies list" do
153
+ currency = Currency.create! valid_attributes
154
+ delete :destroy, {:id => currency.to_param}, valid_session
155
+ expect(response).to redirect_to(currencies_url)
156
+ end
157
+ end
158
+
159
+ end
@@ -0,0 +1,169 @@
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
+ RSpec.describe NationsController, type: :controller do
22
+
23
+ # This should return the minimal set of attributes required to create a valid
24
+ # Nation. As you add validations to Nation, be sure to
25
+ # adjust the attributes here as well.
26
+ let(:valid_attributes) {
27
+ {name: 'Japan', code_alpha2: 'JP', code_alpha3: 'JPN', code_numeric: 392}
28
+ }
29
+
30
+ let(:invalid_attributes) {
31
+ {name: 'Japan', code_alpha2: 'JPN', code_alpha3: 'JAPAN', code_numeric: 392}
32
+ }
33
+
34
+ # This should return the minimal set of values that should be in the session
35
+ # in order to pass any filters (e.g. authentication) defined in
36
+ # NationsController. Be sure to keep this updated too.
37
+ let(:valid_session) { {} }
38
+
39
+ describe "GET #index" do
40
+ it "assigns all nations as @nations" do
41
+ nation = Nation.create! valid_attributes
42
+ get :index, {}, valid_session
43
+ expect(assigns(:records)).to eq([nation])
44
+ end
45
+ end
46
+
47
+ describe "GET #show" do
48
+ it "assigns the requested nation as @nation" do
49
+ nation = Nation.create! valid_attributes
50
+ get :show, {:id => nation.to_param}, valid_session
51
+ expect(assigns(:record)).to eq(nation)
52
+ end
53
+ end
54
+
55
+ describe "GET #new" do
56
+ it "assigns a new nation as @nation" do
57
+ get :new, {}, valid_session
58
+ expect(assigns(:record)).to be_a_new(Nation)
59
+ end
60
+ end
61
+
62
+ describe "GET #edit" do
63
+ it "assigns the requested nation as @nation" do
64
+ nation = Nation.create! valid_attributes
65
+ get :edit, {:id => nation.to_param}, valid_session
66
+ expect(assigns(:record)).to eq(nation)
67
+ end
68
+ end
69
+
70
+ describe "POST #create" do
71
+ context "with valid params" do
72
+ it "creates a new Nation" do
73
+ expect {
74
+ post :create, {:nations => valid_attributes}, valid_session
75
+ }.to change(Nation, :count).by(1)
76
+ end
77
+
78
+ it "assigns a newly created nation as @nation" do
79
+ post :create, {:nations => valid_attributes}, valid_session
80
+ expect(assigns(:record)).to be_a(Nation)
81
+ expect(assigns(:record)).to be_persisted
82
+ end
83
+
84
+ it "redirects to the created nation" do
85
+ post :create, {:nations => valid_attributes}, valid_session
86
+ expect(response).to redirect_to(Nation.last)
87
+ end
88
+ end
89
+
90
+ context "with invalid params" do
91
+ it "assigns a newly created but unsaved nation as @nation" do
92
+ post :create, {:nations => invalid_attributes}, valid_session
93
+ expect(assigns(:record)).to be_a_new(Nation)
94
+ end
95
+
96
+ pending do
97
+ it "re-renders the 'new' template" do
98
+ post :create, {:nations => invalid_attributes}, valid_session
99
+ expect(response).to render_template("new")
100
+ end
101
+ end
102
+ end
103
+ end
104
+
105
+ describe "PUT #update" do
106
+ context "with valid params" do
107
+ let(:new_attributes) {
108
+ skip("Add a hash of attributes valid for your model")
109
+ }
110
+
111
+ it "updates the requested nation" do
112
+ nation = Nation.create! valid_attributes
113
+ put :update, {:id => nation.to_param, :nations => new_attributes}, valid_session
114
+ nation.reload
115
+ skip("Add assertions for updated state")
116
+ end
117
+
118
+ it "assigns the requested nation as @nation" do
119
+ nation = Nation.create! valid_attributes
120
+ put :update, {:id => nation.to_param, :nations => valid_attributes}, valid_session
121
+ expect(assigns(:record)).to eq(nation)
122
+ end
123
+
124
+ pending do
125
+ it "redirects to the nation" do
126
+ nation = Nation.create! valid_attributes
127
+ put :update, {:id => nation.to_param, :nations => valid_attributes}, valid_session
128
+ expect(response).to redirect_to(nation)
129
+ end
130
+ end
131
+ end
132
+
133
+ context "with invalid params" do
134
+ it "assigns the nation as @nation" do
135
+ nation = Nation.create! valid_attributes
136
+ put :update, {:id => nation.to_param, :nations => invalid_attributes}, valid_session
137
+ expect(assigns(:record)).to eq(nation)
138
+ end
139
+
140
+ pending do
141
+ it "re-renders the 'edit' template" do
142
+ nation = Nation.create! valid_attributes
143
+ put :update, {:id => nation.to_param, :nations => invalid_attributes}, valid_session
144
+ expect(response).to render_template("edit")
145
+ end
146
+ end
147
+ end
148
+ end
149
+
150
+ describe "DELETE #destroy" do
151
+ pending do
152
+ it "destroys the requested nation" do
153
+ nation = Nation.create! valid_attributes
154
+ expect {
155
+ delete :destroy, {:id => nation.to_param}, valid_session
156
+ }.to change(Nation, :count).by(-1)
157
+ end
158
+ end
159
+
160
+ pending do
161
+ it "redirects to the nations list" do
162
+ nation = Nation.create! valid_attributes
163
+ delete :destroy, {:id => nation.to_param}, valid_session
164
+ expect(response).to redirect_to(nations_url)
165
+ end
166
+ end
167
+ end
168
+
169
+ end