unival 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/lib/unival/app.rb +2 -2
- data/lib/unival/version.rb +1 -1
- data/spec/app_spec.rb +34 -0
- data/unival.gemspec +4 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f131f2b231fa0981cc0dcdbf9a4c2c66e6a01c2
|
4
|
+
data.tar.gz: f909669d667ae23c4126135c99373270cda9b2a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab72aa119283e6b348bb7d1a0113f8dce488871e3f0eeba0cd8f62afd7ea85e464b5fb2fe7d310643dcc1c06ed5fea4d9c1b54b8ad8956b9f9fe1321e4e95308
|
7
|
+
data.tar.gz: 0873880dde74259563b8e0498a9144f1d934baf7da48c6a632bce5652a824b96a2734f27d24e517822e6dcdf6bfb47c126f6f05f701378240c4742e2da181378
|
data/lib/unival/app.rb
CHANGED
@@ -47,10 +47,10 @@ class Unival::App
|
|
47
47
|
|
48
48
|
is_create = req.post?
|
49
49
|
if model.valid?
|
50
|
-
d = {model: model_class, is_create: is_create, valid: true, errors: nil}
|
50
|
+
d = {model: model_class.to_s, is_create: is_create, valid: true, errors: nil}
|
51
51
|
[200, {'Content-Type' => 'application/json'}, [JSON.dump(d)]]
|
52
52
|
else
|
53
|
-
d = {model: model_class, is_create: is_create, valid: false, errors: model.errors.as_json}
|
53
|
+
d = {model: model_class.to_s, is_create: is_create, valid: false, errors: model.errors.as_json}
|
54
54
|
[409, {'Content-Type' => 'application/json'}, [JSON.dump(d)]]
|
55
55
|
end
|
56
56
|
rescue Exception => e
|
data/lib/unival/version.rb
CHANGED
data/spec/app_spec.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rack'
|
3
|
+
require 'rack/test'
|
4
|
+
require 'active_record'
|
5
|
+
require 'sqlite3'
|
6
|
+
|
7
|
+
describe 'Unival full-stack' do
|
8
|
+
include Rack::Test::Methods
|
9
|
+
let(:app) { Unival::App.new }
|
10
|
+
|
11
|
+
describe 'with a class that gives a nonsensical to_json' do
|
12
|
+
class Nonsense
|
13
|
+
def self.to_json(encoder)
|
14
|
+
"this should not be happening"
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(*);
|
18
|
+
end
|
19
|
+
|
20
|
+
def attributes=(*);
|
21
|
+
end
|
22
|
+
|
23
|
+
def valid?; true; end
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'uses the qualified module name as model return value' do
|
27
|
+
post '/?model=Nonsense', JSON.dump({name: 'Julik', email: 'julik@example.com'})
|
28
|
+
parsed = JSON.parse(last_response.body, symbolize_names: true)
|
29
|
+
|
30
|
+
expect(last_response).to be_ok
|
31
|
+
expect(parsed).to eq({:model => "Nonsense", :is_create => true, :valid => true, :errors => nil})
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/unival.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: unival 0.0.
|
5
|
+
# stub: unival 0.0.2 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "unival"
|
9
|
-
s.version = "0.0.
|
9
|
+
s.version = "0.0.2"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Julik Tarkhanov"]
|
14
|
-
s.date = "2016-05-
|
14
|
+
s.date = "2016-05-19"
|
15
15
|
s.description = " A minimal endpoint for driving server-side validations from a remote UI "
|
16
16
|
s.email = "me@julik.nl"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
"lib/unival.rb",
|
29
29
|
"lib/unival/app.rb",
|
30
30
|
"lib/unival/version.rb",
|
31
|
+
"spec/app_spec.rb",
|
31
32
|
"spec/full_stack_spec.rb",
|
32
33
|
"spec/spec_helper.rb",
|
33
34
|
"spec/unival_spec.rb",
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unival
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julik Tarkhanov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -168,6 +168,7 @@ files:
|
|
168
168
|
- lib/unival.rb
|
169
169
|
- lib/unival/app.rb
|
170
170
|
- lib/unival/version.rb
|
171
|
+
- spec/app_spec.rb
|
171
172
|
- spec/full_stack_spec.rb
|
172
173
|
- spec/spec_helper.rb
|
173
174
|
- spec/unival_spec.rb
|