cross_spec_rails 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b5871ecbc30415e519a7b16f6a53173df02dcf42
4
- data.tar.gz: 321df9327b4c99e4366482fd9723d6da02d4e33b
3
+ metadata.gz: 2b93b514b34ca1af477833e1f9fe983dd8528a9e
4
+ data.tar.gz: 015ab1c9cbba62a9cc38f10c8e6b5b8be9807336
5
5
  SHA512:
6
- metadata.gz: 30c20470455c8ac006d8fa4f2fda7c082b4805e2b69b34ef5665921f8d7ee0654342ebbf7212119c41a84429637a6e7824f1070c108f9b336707fb4e39aa3098
7
- data.tar.gz: 5ebf444ea72b700d98d8b51deff672bc67a9e570fbd9f1a2457d5b3041637179583caf3b6cd920a4e2b099bc5a08e7b07a00dcd8bb305d71b5c6dedf34547c6b
6
+ metadata.gz: a057ab56945708e17eaf1f1117d499d7fe3c6f490d8ea95046b211ad6b84fb945d1b74c871b9e4bab2213a00261d2c656eb782a4e6093338e38d62e2af1ebd0d
7
+ data.tar.gz: c9ea2a3db62fd998844b263984b66cd7d79f8ed70ad838f49166d7fe2a6bca079c142cfaa5ae1e8d4443c7add77b20524c6b47fb3e0986f3e066ed88b9d530b9
@@ -19,8 +19,20 @@ module CrossSpecRails
19
19
  def create
20
20
  factory = params[:factory]
21
21
  traits = Array(params[:traits])
22
- attributes = params.except(:action, :controller, :factory, :traits).permit!.to_h
23
- render json: factory_klass.create(factory, *traits, attributes)
22
+ attributes = params[:attributes]&.permit!.to_h
23
+ includes = params[:includes]
24
+ instance = factory_klass.create(factory, *traits, attributes)
25
+ render json: instance.to_json(params[:to_json_args])
26
+ end
27
+
28
+ def create_list
29
+ factory = params[:factory]
30
+ traits = Array(params[:traits])
31
+ attributes = params[:attributes]&.permit!.to_h
32
+ includes = params[:includes]
33
+ num = params[:num].to_i
34
+ instances = factory_klass.create_list(factory, num, *traits, attributes)
35
+ render json: instance.map { |instance| instance.to_json(params[:to_json_args]) }
24
36
  end
25
37
 
26
38
  private
data/config/routes.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  CrossSpecRails::Engine.routes.draw do
2
2
  post 'factories/:factory', to: 'factories#create'
3
+ post 'factories_list/:factory', to: 'factories#create_list'
3
4
  end
@@ -1,3 +1,3 @@
1
1
  module CrossSpecRails
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cross_spec_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Fischer