database_cleaner-remote_api 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 37f2daab2be71e5d98bdaede177ee178dc476f23
4
+ data.tar.gz: 5bff14bab383a928f2d0dc9a775c11855ff349da
5
+ SHA512:
6
+ metadata.gz: 0aab52bc67d1fa6f37804ad1db97fd0d0b694b17d8e9f1c58621298d5e748617281901cbdb733fc26d21661080cee43a071b37f5e2dbf7a05f9a207d6ff92bf4
7
+ data.tar.gz: 87117a8f3ffab847c0078beeaebf1e7403c07695c2efe8c572123431782a57a1821794276e25701713c1075c5fb3f1d98b4faeee427fe995f70ffdb70e3c3b4c
@@ -0,0 +1,20 @@
1
+ Copyright 2013 Julian Tescher
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,78 @@
1
+ # DatabaseCleaner::RemoteApi
2
+
3
+ Simply creates an HTTP API for cleaning your database to be used by client tests.
4
+
5
+ Tested against ruby-head, ruby 2.0.0, ruby 1.9.3, jruby-19mode, jruby-head, and rbx-19mode
6
+
7
+ [![Build Status](https://travis-ci.org/jtescher/database_cleaner-remote_api.png?branch=master)]
8
+ (https://travis-ci.org/jtescher/database_cleaner-remote_api)
9
+ [![Code Climate](https://codeclimate.com/github/jtescher/database_cleaner-remote_api.png)]
10
+ (https://codeclimate.com/github/jtescher/database_cleaner-remote_api)
11
+ [![Dependency Status](https://gemnasium.com/jtescher/database_cleaner-remote_api.png)]
12
+ (https://gemnasium.com/jtescher/database_cleaner-remote_api)
13
+
14
+
15
+ ##Installation
16
+
17
+ Add this line to your application's Gemfile:
18
+
19
+ ```ruby
20
+ gem 'database_cleaner-remote_api', '~> 0.0.1'
21
+ ```
22
+
23
+ And then execute:
24
+ ```bash
25
+ $ bundle
26
+ ```
27
+
28
+ Or install it yourself as:
29
+ ```bash
30
+ $ gem install database_cleaner-remote_api
31
+ ```
32
+
33
+ Then mount as an engine in your config/routes.rb file.
34
+ ```ruby
35
+ Rails.application.routes.draw do
36
+ ...
37
+ mount DatabaseCleaner::RemoteApi::Engine => '/database_cleaner' if Rails.env.test?
38
+ ...
39
+ end
40
+ ```
41
+
42
+
43
+ ## Usage
44
+
45
+ First install [DatabaseCleaner](https://github.com/bmabey/database_cleaner).
46
+
47
+ To use with a client application, start rails in the `test` environment (or whichever environment mounted the engine).
48
+ ```bash
49
+ $ rails server -e test
50
+ ```
51
+
52
+ Then you can clean the database remotely via `/mount_path/clean`
53
+
54
+ ### Example
55
+
56
+ Given a user in the database:
57
+ ```ruby
58
+ User.count #=> 1
59
+ ```
60
+
61
+ When you clean the database via any client:
62
+ ```bash
63
+ $ curl http://localhost:3000/database_cleaner/clean
64
+ ```
65
+
66
+ Then the users have been removed:
67
+ ```ruby
68
+ User.count #=> 0
69
+ ```
70
+
71
+
72
+ ## Contributing
73
+
74
+ 1. Fork it
75
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
76
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
77
+ 4. Push to the branch (`git push origin my-new-feature`)
78
+ 5. Create new Pull Request
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'DatabaseCleaner::RemoteApi'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
24
+ load 'rails/tasks/engine.rake'
25
+
26
+ # Load all tasks
27
+ Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
28
+
29
+ Bundler::GemHelper.install_tasks
30
+
31
+ begin
32
+ require 'rspec/core'
33
+ require 'rspec/core/rake_task'
34
+ RSpec::Core::RakeTask.new(spec: %w[app:db:migrate app:db:test:prepare])
35
+ rescue LoadError
36
+ desc 'spec rake task not available (rspec not installed)'
37
+ task :spec do
38
+ abort 'Spec rake task is not available. Be sure to install rspec as gem.'
39
+ end
40
+ end
41
+
42
+ task default: :spec
@@ -0,0 +1,15 @@
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 vendor/assets/javascripts of plugins, if any, 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
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require_tree .
@@ -0,0 +1,13 @@
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 vendor/assets/stylesheets of plugins, if any, 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 top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,6 @@
1
+ module DatabaseCleaner
2
+ module RemoteApi
3
+ class ApplicationController < ActionController::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,12 @@
1
+ module DatabaseCleaner
2
+ module RemoteApi
3
+ class DatabaseCleansController < DatabaseCleaner::RemoteApi::ApplicationController
4
+
5
+ def show
6
+ DatabaseCleaner.clean
7
+ render json: {}
8
+ end
9
+
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,6 @@
1
+ module DatabaseCleaner
2
+ module RemoteApi
3
+ module ApplicationHelper
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>DatabaseCleaner::RemoteApi</title>
5
+ <%= stylesheet_link_tag "database_cleaner/remote_api/application", :media => "all" %>
6
+ <%= javascript_include_tag "database_cleaner/remote_api/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,3 @@
1
+ DatabaseCleaner::RemoteApi::Engine.routes.draw do
2
+ match 'clean' => 'database_cleans#show', via: [:get, :post], defaults: { format: :json }
3
+ end
@@ -0,0 +1,2 @@
1
+ require 'database_cleaner'
2
+ require 'database_cleaner/remote_api/engine'
@@ -0,0 +1,7 @@
1
+ module DatabaseCleaner
2
+ module RemoteApi
3
+ class Engine < ::Rails::Engine
4
+ isolate_namespace DatabaseCleaner::RemoteApi
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ module DatabaseCleaner
2
+ module RemoteApi
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :database_cleaner/remote_api do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: database_cleaner-remote_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Julian Tescher
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-06-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 3.2.13
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 3.2.13
27
+ - !ruby/object:Gem::Dependency
28
+ name: database_cleaner
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 1.0.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: sqlite3
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 1.3.7
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.3.7
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 2.13.2
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 2.13.2
69
+ - !ruby/object:Gem::Dependency
70
+ name: capybara
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 2.1.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 2.1.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: 0.7.1
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: 0.7.1
97
+ description: Simply creates an HTTP API for cleaning your database to be used by client
98
+ tests.
99
+ email:
100
+ - jatescher@gmail.com
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - app/assets/javascripts/database_cleaner-remote_api/application.js
106
+ - app/assets/stylesheets/database_cleaner-remote_api/application.css
107
+ - app/controllers/database_cleaner/remote_api/application_controller.rb
108
+ - app/controllers/database_cleaner/remote_api/database_cleans_controller.rb
109
+ - app/helpers/database_cleaner/remote_api/application_helper.rb
110
+ - app/views/layouts/database_cleaner/remote_api/application.html.erb
111
+ - config/routes.rb
112
+ - lib/database_cleaner/remote_api/engine.rb
113
+ - lib/database_cleaner/remote_api/version.rb
114
+ - lib/database_cleaner/remote_api.rb
115
+ - lib/tasks/database_cleaner-remote_api_tasks.rake
116
+ - MIT-LICENSE
117
+ - Rakefile
118
+ - README.md
119
+ homepage: https://github.com/jtescher/database_cleaner-remote_api
120
+ licenses: []
121
+ metadata: {}
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - '>='
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - '>='
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 2.0.0
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: An API for database_cleaner remote wipes
142
+ test_files: []