strain 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.rspec +3 -0
  4. data/.ruby-version +1 -0
  5. data/Gemfile +17 -0
  6. data/Guardfile +72 -0
  7. data/LICENSE +20 -0
  8. data/README.md +74 -0
  9. data/Rakefile +26 -0
  10. data/app/assets/javascripts/strain/jsonapi/articles.js +2 -0
  11. data/app/assets/javascripts/strain/jsonapi/variants.js +2 -0
  12. data/app/assets/stylesheets/strain/jsonapi/articles.css +4 -0
  13. data/app/assets/stylesheets/strain/jsonapi/variants.css +4 -0
  14. data/app/controllers/strain/application_controller.rb +5 -0
  15. data/app/controllers/strain/jsonapi/articles_controller.rb +6 -0
  16. data/app/controllers/strain/jsonapi/jsonapi_controller.rb +10 -0
  17. data/app/controllers/strain/jsonapi/variants_controller.rb +7 -0
  18. data/app/helpers/strain/jsonapi/articles_helper.rb +4 -0
  19. data/app/helpers/strain/jsonapi/variants_helper.rb +4 -0
  20. data/app/models/strain/article.rb +37 -0
  21. data/app/models/strain/variant.rb +32 -0
  22. data/app/resources/strain/jsonapi/article_resource.rb +21 -0
  23. data/app/resources/strain/jsonapi/variant_resource.rb +16 -0
  24. data/bin/_guard-core +16 -0
  25. data/bin/guard +16 -0
  26. data/bin/rails +12 -0
  27. data/bin/rake +16 -0
  28. data/bin/rspec +16 -0
  29. data/config/initializers/jsonapi_resources.rb +4 -0
  30. data/config/routes.rb +8 -0
  31. data/db/migrate/20151103060035_enable_uuid.rb +5 -0
  32. data/db/migrate/20151103060224_create_strain_variants.rb +11 -0
  33. data/db/migrate/20151104200908_create_strain_articles.rb +14 -0
  34. data/lib/json_schema/draft_4_meta_schema.json +150 -0
  35. data/lib/strain/engine.rb +21 -0
  36. data/lib/strain/schema_tools/defaults.rb +53 -0
  37. data/lib/strain/version.rb +3 -0
  38. data/lib/strain.rb +17 -0
  39. data/lib/tasks/strain_tasks.rake +4 -0
  40. data/spec/factories/strain_articles.rb +15 -0
  41. data/spec/factories/strain_variants.rb +34 -0
  42. data/spec/lib/strain/schema_tools/defaults_spec.rb +234 -0
  43. data/spec/models/strain/article_spec.rb +72 -0
  44. data/spec/models/strain/variant_spec.rb +42 -0
  45. data/spec/rails_helper.rb +59 -0
  46. data/spec/requests/strain/jsonapi/articles_spec.rb +220 -0
  47. data/spec/requests/strain/jsonapi/variants_spec.rb +159 -0
  48. data/spec/spec_helper.rb +99 -0
  49. data/spec/test_app/README.rdoc +28 -0
  50. data/spec/test_app/Rakefile +6 -0
  51. data/spec/test_app/app/assets/javascripts/application.js +13 -0
  52. data/spec/test_app/app/assets/stylesheets/application.css +15 -0
  53. data/spec/test_app/app/controllers/application_controller.rb +5 -0
  54. data/spec/test_app/app/helpers/application_helper.rb +2 -0
  55. data/spec/test_app/app/models/tweet.rb +4 -0
  56. data/spec/test_app/app/views/layouts/application.html.erb +14 -0
  57. data/spec/test_app/bin/bundle +3 -0
  58. data/spec/test_app/bin/rails +4 -0
  59. data/spec/test_app/bin/rake +4 -0
  60. data/spec/test_app/bin/setup +29 -0
  61. data/spec/test_app/config/application.rb +32 -0
  62. data/spec/test_app/config/boot.rb +5 -0
  63. data/spec/test_app/config/database.yml +85 -0
  64. data/spec/test_app/config/environment.rb +5 -0
  65. data/spec/test_app/config/environments/development.rb +41 -0
  66. data/spec/test_app/config/environments/production.rb +79 -0
  67. data/spec/test_app/config/environments/test.rb +42 -0
  68. data/spec/test_app/config/initializers/assets.rb +11 -0
  69. data/spec/test_app/config/initializers/backtrace_silencers.rb +7 -0
  70. data/spec/test_app/config/initializers/cookies_serializer.rb +3 -0
  71. data/spec/test_app/config/initializers/filter_parameter_logging.rb +4 -0
  72. data/spec/test_app/config/initializers/inflections.rb +16 -0
  73. data/spec/test_app/config/initializers/mime_types.rb +4 -0
  74. data/spec/test_app/config/initializers/session_store.rb +3 -0
  75. data/spec/test_app/config/initializers/wrap_parameters.rb +14 -0
  76. data/spec/test_app/config/locales/en.yml +23 -0
  77. data/spec/test_app/config/routes.rb +4 -0
  78. data/spec/test_app/config/secrets.yml +22 -0
  79. data/spec/test_app/config.ru +4 -0
  80. data/spec/test_app/db/schema.rb +42 -0
  81. data/spec/test_app/log/development.log +2854 -0
  82. data/spec/test_app/log/test.log +40082 -0
  83. data/spec/test_app/public/404.html +67 -0
  84. data/spec/test_app/public/422.html +67 -0
  85. data/spec/test_app/public/500.html +66 -0
  86. data/spec/test_app/public/favicon.ico +0 -0
  87. metadata +262 -0
@@ -0,0 +1,59 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV['RAILS_ENV'] ||= 'test'
3
+ require File.expand_path('../test_app/config/environment', __FILE__)
4
+ # Prevent database truncation if the environment is production
5
+ abort("The Rails environment is running in production mode!") if Rails.env.production?
6
+ require 'spec_helper'
7
+ require 'rspec/rails'
8
+ require 'factory_girl_rails'
9
+
10
+ # Add additional requires below this line. Rails is not loaded until this point!
11
+
12
+ # Requires supporting ruby files with custom matchers and macros, etc, in
13
+ # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
14
+ # run as spec files by default. This means that files in spec/support that end
15
+ # in _spec.rb will both be required and run as specs, causing the specs to be
16
+ # run twice. It is recommended that you do not name files matching this glob to
17
+ # end with _spec.rb. You can configure this pattern with the --pattern
18
+ # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
19
+ #
20
+ # The following line is provided for convenience purposes. It has the downside
21
+ # of increasing the boot-up time by auto-requiring all files in the support
22
+ # directory. Alternatively, in the individual `*_spec.rb` files, manually
23
+ # require only the support files necessary.
24
+ #
25
+ # Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
26
+
27
+ # Checks for pending migrations before tests are run.
28
+ # If you are not using ActiveRecord, you can remove this line.
29
+ ActiveRecord::Migration.maintain_test_schema!
30
+
31
+ RSpec.configure do |config|
32
+ config.include FactoryGirl::Syntax::Methods
33
+ config.include Strain::Engine.routes.url_helpers
34
+ # config.include main_app.routes.url_helpers
35
+ config.use_transactional_fixtures = true
36
+
37
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
38
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
39
+
40
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
41
+ # examples within a transaction, remove the following line or assign false
42
+ # instead of true.
43
+ config.use_transactional_fixtures = true
44
+
45
+ # RSpec Rails can automatically mix in different behaviours to your tests
46
+ # based on their file location, for example enabling you to call `get` and
47
+ # `post` in specs under `spec/controllers`.
48
+ #
49
+ # You can disable this behaviour by removing the line below, and instead
50
+ # explicitly tag your specs with their type, e.g.:
51
+ #
52
+ # RSpec.describe UsersController, :type => :controller do
53
+ # # ...
54
+ # end
55
+ #
56
+ # The different available types are documented in the features, such as in
57
+ # https://relishapp.com/rspec/rspec-rails/docs
58
+ config.infer_spec_type_from_file_location!
59
+ end
@@ -0,0 +1,220 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe "Articles", type: :request do
4
+
5
+ describe "Index / GET collection" do
6
+
7
+ before(:all) do
8
+ create :article
9
+ get jsonapi_variants_path
10
+ end
11
+
12
+ after(:all) do
13
+ Strain::Article.delete_all
14
+ Strain::Variant.delete_all
15
+ end
16
+
17
+ it "returns HTTP 200" do
18
+ expect(response).to have_http_status(200)
19
+ end
20
+
21
+ it "responds with JSONAPI media type" do
22
+ expect(response.header["Content-Type"]).to eq("application/vnd.api+json")
23
+ end
24
+
25
+ it "returns a list of Articles" do
26
+ data = JSON.parse(response.body).fetch("data")
27
+ expect(data.size).to eq(Strain::Article.all.count)
28
+ end
29
+
30
+ end
31
+
32
+ describe "Show / GET member" do
33
+
34
+ before(:all) do
35
+ @article = create(:article)
36
+ get jsonapi_article_path(@article)
37
+ @body = JSON.parse(response.body)
38
+ end
39
+ after(:all) do
40
+ Strain::Article.delete_all
41
+ Strain::Variant.delete_all
42
+ end
43
+
44
+ it "returns HTTP 200" do
45
+ expect(response).to have_http_status(200)
46
+ end
47
+
48
+ it "responds with JSONAPI media type" do
49
+ expect(response.header["Content-Type"]).to eq("application/vnd.api+json")
50
+ end
51
+
52
+ it "responds with the created article" do
53
+ returned = @body.fetch("data")
54
+ expect(returned["type"]).to eq("articles")
55
+ expect(returned["attributes"]).to have_key("slug")
56
+ expect(returned["attributes"]).to have_key("title")
57
+ # expect(returned["attributes"]).to have_key("variant")
58
+ expect(returned["attributes"]).to have_key("body")
59
+ expect(returned["id"]).to eq("#{@article.id}")
60
+ end
61
+
62
+ end
63
+
64
+ describe "Create / POST collection" do
65
+
66
+ context "when request is valid" do
67
+ before(:all) do
68
+ @variant = create :variant
69
+ headers = {
70
+ "Accept": "application/vnd.api+json",
71
+ "Content-Type": "application/vnd.api+json"
72
+ }
73
+ request_body = JSON.dump({
74
+ "data" => {
75
+ "type" => "articles",
76
+ "attributes" => {
77
+ "title" => "test title",
78
+ "slug" => "test-slug",
79
+ "body" => {
80
+ "summary" => "test_summary",
81
+ "main" => "test_main",
82
+ }
83
+ },
84
+ "relationships" => {
85
+ "variant" => {
86
+ "data" => {"type" => "variants", "id" => @variant.id}
87
+ }
88
+ }
89
+ }
90
+ })
91
+ post jsonapi_articles_path, request_body, headers
92
+ @body = JSON.parse(response.body)
93
+ end
94
+ after(:all) do
95
+ Strain::Variant.delete_all
96
+ Strain::Article.delete_all
97
+ end
98
+
99
+ it "returns HTTP 201(Created)" do
100
+ expect(response).to have_http_status(201)
101
+ end
102
+
103
+ it "returns the created Article" do
104
+ returned = @body.fetch("data")
105
+ expect(returned["type"]).to eq("articles")
106
+ expect(returned["attributes"]["body"]["summary"]).to eq("test_summary")
107
+ expect(returned["attributes"]["body"]["main"]).to eq("test_main")
108
+ end
109
+ end
110
+
111
+ context "when request is invalid" do
112
+ before(:all) do
113
+ @variant = create :variant
114
+ headers = {
115
+ "Accept": "application/vnd.api+json",
116
+ "Content-Type": "application/vnd.api+json"
117
+ }
118
+ request_body = JSON.dump({
119
+ "data" => {
120
+ "type" => "articles",
121
+ "attributes" => {
122
+ "title" => "test title",
123
+ "slug" => "test-slug",
124
+ "body" => {
125
+ "summary" => "test_summary",
126
+ "main" => "test_main",
127
+ "extra_propert" => "test"
128
+ }
129
+ },
130
+ "relationships" => {
131
+ "variant" => {
132
+ "data" => {"type" => "variants", "id" => @variant.id}
133
+ }
134
+ }
135
+ }
136
+ })
137
+ post jsonapi_articles_path, request_body, headers
138
+ @body = JSON.parse(response.body)
139
+ end
140
+ after(:all) do
141
+ Strain::Variant.delete_all
142
+ Strain::Article.delete_all
143
+ end
144
+
145
+ it "returns HTTP 422(unprocessable entity)" do
146
+ expect(response).to have_http_status(422)
147
+ end
148
+
149
+ it "returns an error hash" do
150
+ returned = @body.fetch("errors")
151
+ expect(returned).not_to be_empty
152
+ end
153
+ end
154
+
155
+ end
156
+
157
+ describe "Destroy / DELETE member" do
158
+
159
+ before(:all) do
160
+ @article = create :article
161
+ delete jsonapi_article_path(@article)
162
+ end
163
+ after(:all) do
164
+ Strain::Variant.delete_all
165
+ Strain::Article.delete_all
166
+ end
167
+
168
+ it "returns HTTP 204(successful/no content)" do
169
+ expect(response).to have_http_status(204)
170
+ end
171
+
172
+ it "deletes the Article" do
173
+ expect(Strain::Article.count).to eq(0)
174
+ end
175
+
176
+ end
177
+
178
+ describe "Update / PATCH member" do
179
+
180
+ before(:all) do
181
+ @article = create :article
182
+ headers = {
183
+ "Accept": "application/vnd.api+json",
184
+ "Content-Type": "application/vnd.api+json"
185
+ }
186
+ request_body = JSON.dump({
187
+ "data": {
188
+ "id": @article.id,
189
+ "type": "articles",
190
+ "attributes": {
191
+ "title": "updated"
192
+ }
193
+ }
194
+ })
195
+ patch jsonapi_article_path(@article), request_body, headers
196
+ end
197
+ after(:all) do
198
+ Strain::Variant.delete_all
199
+ Strain::Article.delete_all
200
+ end
201
+
202
+ it "returns HTTP 200(successful)" do
203
+ expect(response).to have_http_status(200)
204
+ end
205
+
206
+ it "returns the updated Article in the response body" do
207
+ returned = JSON.parse(response.body).fetch("data")
208
+ expect(returned["type"]).to eq("articles")
209
+ expect(returned["attributes"]["title"]).to eq("updated")
210
+ end
211
+
212
+ it "updates the Article" do
213
+ updated = Strain::Article.find(@article.id)
214
+ expect(updated.title).to eq("updated")
215
+ expect(@article.slug).to eq(updated.slug)
216
+ end
217
+
218
+ end
219
+
220
+ end
@@ -0,0 +1,159 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe "Variants", type: :request do
4
+
5
+ describe "Index / GET collection" do
6
+
7
+ context "when authenticated" do
8
+
9
+ before(:all) do
10
+ create :variant
11
+ get jsonapi_variants_path
12
+ end
13
+
14
+ after(:all) {Strain::Variant.delete_all}
15
+
16
+ it "returns HTTP 200" do
17
+ expect(response).to have_http_status(200)
18
+ end
19
+
20
+ it "responds with JSONAPI media type" do
21
+ expect(response.header["Content-Type"]).to eq("application/vnd.api+json")
22
+ end
23
+
24
+ it "returns a list of Variants" do
25
+ data = JSON.parse(response.body).fetch("data")
26
+ expect(data.size).to eq(Strain::Variant.all.count)
27
+ end
28
+ end
29
+ end
30
+
31
+ describe "Show / GET member" do
32
+ context "when authenticated" do
33
+
34
+ before(:all) do
35
+ @variant = create(:variant)
36
+ get jsonapi_variant_path(@variant)
37
+ @body = JSON.parse(response.body)
38
+ end
39
+ after(:all) {Strain::Variant.delete_all}
40
+
41
+ it "returns HTTP 200" do
42
+ expect(response).to have_http_status(200)
43
+ end
44
+
45
+ it "responds with JSONAPI media type" do
46
+ expect(response.header["Content-Type"]).to eq("application/vnd.api+json")
47
+ end
48
+
49
+ it "responds with the created Variant" do
50
+ returned = @body.fetch("data")
51
+ expect(returned["type"]).to eq("variants")
52
+ expect(returned["attributes"]).to have_key("name")
53
+ expect(returned["attributes"]).to have_key("schema")
54
+ expect(returned["id"]).to eq("#{@variant.id}")
55
+ end
56
+
57
+ end
58
+ end
59
+
60
+ describe "Create / POST collection" do
61
+ context "when authenticated" do
62
+
63
+ before(:all) do
64
+ request_body = JSON.dump({
65
+ "data": {
66
+ "type": "variants",
67
+ "attributes": {
68
+ "name": "test",
69
+ "schema": {"type": "object"}
70
+ }
71
+ }
72
+ })
73
+
74
+ headers = {
75
+ "Accept": "application/vnd.api+json",
76
+ "Content-Type": "application/vnd.api+json"
77
+ }
78
+
79
+ post jsonapi_variants_path, request_body, headers
80
+ @body = JSON.parse(response.body)
81
+ end
82
+ after(:all) {Strain::Variant.delete_all}
83
+
84
+ it "returns HTTP 201(Created)" do
85
+ expect(response).to have_http_status(201)
86
+ end
87
+
88
+ it "returns the created Variant" do
89
+ returned = @body.fetch("data")
90
+ expect(returned["type"]).to eq("variants")
91
+ expect(returned["attributes"]["name"]).to eq("test")
92
+ end
93
+
94
+ end
95
+ end
96
+
97
+ describe "Destroy / DELETE member" do
98
+ context "when authenticated" do
99
+ before(:all) do
100
+ @variant = create :variant
101
+ delete jsonapi_variant_path(@variant)
102
+ end
103
+ after(:all) do
104
+ Strain::Variant.delete_all
105
+ end
106
+
107
+ it "returns HTTP 204(successful/no content)" do
108
+ expect(response).to have_http_status(204)
109
+ end
110
+
111
+ it "deletes the Variant" do
112
+ expect(Strain::Variant.all.count).to eq(0)
113
+ end
114
+
115
+ end
116
+ end
117
+
118
+ describe "Update / PATCH member" do
119
+ context "when authenticated" do
120
+
121
+ before(:all) do
122
+ @variant = create :variant
123
+ headers = {
124
+ "Accept": "application/vnd.api+json",
125
+ "Content-Type": "application/vnd.api+json"
126
+ }
127
+ request_body = JSON.dump({
128
+ "data": {
129
+ "id": @variant.id,
130
+ "type": "variants",
131
+ "attributes": {
132
+ "name": "updated"
133
+ }
134
+ }
135
+ })
136
+ patch jsonapi_variant_path(@variant), request_body, headers
137
+ end
138
+ after(:all) { Strain::Variant.delete_all }
139
+
140
+ it "returns HTTP 200(successful)" do
141
+ expect(response).to have_http_status(200)
142
+ end
143
+
144
+ it "returns the updated Variant in the response body" do
145
+ returned = JSON.parse(response.body).fetch("data")
146
+ expect(returned["type"]).to eq("variants")
147
+ expect(returned["attributes"]["name"]).to eq("updated")
148
+ end
149
+
150
+ it "updates the Variant" do
151
+ updated = Strain::Variant.find(@variant.id)
152
+ expect(updated.name).to eq("updated")
153
+ expect(@variant.schema).to eq(updated.schema)
154
+ end
155
+
156
+ end
157
+ end
158
+
159
+ end
@@ -0,0 +1,99 @@
1
+ # This file was generated by the `rails generate rspec:install` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # The `.rspec` file also contains a few flags that are not defaults but that
16
+ # users commonly want.
17
+ #
18
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
19
+
20
+ RSpec.configure do |config|
21
+ # rspec-expectations config goes here. You can use an alternate
22
+ # assertion/expectation library such as wrong or the stdlib/minitest
23
+ # assertions if you prefer.
24
+ config.expect_with :rspec do |expectations|
25
+ # This option will default to `true` in RSpec 4. It makes the `description`
26
+ # and `failure_message` of custom matchers include text for helper methods
27
+ # defined using `chain`, e.g.:
28
+ # be_bigger_than(2).and_smaller_than(4).description
29
+ # # => "be bigger than 2 and smaller than 4"
30
+ # ...rather than:
31
+ # # => "be bigger than 2"
32
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
33
+
34
+ # Limits syntax to newer expect style
35
+ expectations.syntax = [:expect]
36
+ end
37
+
38
+ # rspec-mocks config goes here. You can use an alternate test double
39
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
40
+ config.mock_with :rspec do |mocks|
41
+ # Prevents you from mocking or stubbing a method that does not exist on
42
+ # a real object. This is generally recommended, and will default to
43
+ # `true` in RSpec 4.
44
+ mocks.verify_partial_doubles = true
45
+ end
46
+
47
+ config.filter_run :focus
48
+ config.run_all_when_everything_filtered = true
49
+
50
+ # The settings below are suggested to provide a good initial experience
51
+ # with RSpec, but feel free to customize to your heart's content.
52
+ =begin
53
+ # These two settings work together to allow you to limit a spec run
54
+ # to individual examples or groups you care about by tagging them with
55
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
56
+ # get run.
57
+ config.filter_run :focus
58
+ config.run_all_when_everything_filtered = true
59
+
60
+ # Allows RSpec to persist some state between runs in order to support
61
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
62
+ # you configure your source control system to ignore this file.
63
+ config.example_status_persistence_file_path = "spec/examples.txt"
64
+
65
+ # Limits the available syntax to the non-monkey patched syntax that is
66
+ # recommended. For more details, see:
67
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
68
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
69
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
70
+ config.disable_monkey_patching!
71
+
72
+ # Many RSpec users commonly either run the entire suite or an individual
73
+ # file, and it's useful to allow more verbose output when running an
74
+ # individual spec file.
75
+ if config.files_to_run.one?
76
+ # Use the documentation formatter for detailed output,
77
+ # unless a formatter has already been configured
78
+ # (e.g. via a command-line flag).
79
+ config.default_formatter = 'doc'
80
+ end
81
+
82
+ # Print the 10 slowest examples and example groups at the
83
+ # end of the spec run, to help surface which specs are running
84
+ # particularly slow.
85
+ config.profile_examples = 10
86
+
87
+ # Run specs in random order to surface order dependencies. If you find an
88
+ # order dependency and want to debug it, you can fix the order by providing
89
+ # the seed, which is printed after each run.
90
+ # --seed 1234
91
+ config.order = :random
92
+
93
+ # Seed global randomization in this process using the `--seed` CLI option.
94
+ # Setting this allows you to use `--seed` to deterministically reproduce
95
+ # test failures related to randomization by passing the same `--seed` value
96
+ # as the one that triggered the failure.
97
+ Kernel.srand config.seed
98
+ =end
99
+ end
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,4 @@
1
+ class Tweet < ::Strain::Article
2
+
3
+
4
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>TestApp</title>
5
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+
4
+ # path to your application root.
5
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6
+
7
+ Dir.chdir APP_ROOT do
8
+ # This script is a starting point to setup your application.
9
+ # Add necessary setup steps to this file:
10
+
11
+ puts "== Installing dependencies =="
12
+ system "gem install bundler --conservative"
13
+ system "bundle check || bundle install"
14
+
15
+ # puts "\n== Copying sample files =="
16
+ # unless File.exist?("config/database.yml")
17
+ # system "cp config/database.yml.sample config/database.yml"
18
+ # end
19
+
20
+ puts "\n== Preparing database =="
21
+ system "bin/rake db:setup"
22
+
23
+ puts "\n== Removing old logs and tempfiles =="
24
+ system "rm -f log/*"
25
+ system "rm -rf tmp/cache"
26
+
27
+ puts "\n== Restarting application server =="
28
+ system "touch tmp/restart.txt"
29
+ end