adminpanel 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +25 -15
- data/lib/adminpanel/version.rb +1 -1
- data/lib/tasks/adminpanel/adminpanel.rake +147 -0
- data/spec/dummy/.gitignore +19 -0
- data/spec/dummy/log/test.log +70636 -3884
- data/spec/spec_helper.rb +1 -0
- data/spec/tasks/adminpanel_rake_spec.rb +32 -0
- metadata +9 -5
- data/lib/tasks/adminpanel/populate.rake +0 -80
data/spec/spec_helper.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "adminpanel namespace task" do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
Rake.application.rake_require "tasks/adminpanel/adminpanel"
|
7
|
+
Rake::Task.define_task(:environment)
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "adminpanel:populate[20, product, name:name description:lorem price:number]" do
|
11
|
+
|
12
|
+
let(:has_nil_attribute) { false }
|
13
|
+
before do
|
14
|
+
Rake.application.invoke_task "adminpanel:populate[20, product, name:name description:lorem price:number]"
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
it "should generate 20 product records" do
|
19
|
+
Adminpanel::Product.count.should eq 20
|
20
|
+
end
|
21
|
+
|
22
|
+
it "attributes shouldn't be nil" do
|
23
|
+
Adminpanel::Product.all.each do |product|
|
24
|
+
if (product.name.nil? || product.description.nil? || product.price.nil? ||
|
25
|
+
product.name == "" || product.description == "" || product.price == "")
|
26
|
+
has_nil_attribute = true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
has_nil_attribute.should eq false
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adminpanel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 1
|
10
|
+
version: 1.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jose Ramon Camacho
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2014-03-
|
19
|
+
date: 2014-03-07 00:00:00 -06:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -486,7 +486,8 @@ files:
|
|
486
486
|
- lib/generators/adminpanel/resource/templates/controller.rb
|
487
487
|
- lib/generators/adminpanel/resource/templates/migration.rb
|
488
488
|
- lib/generators/adminpanel/resource/templates/resource.rb
|
489
|
-
- lib/tasks/adminpanel/
|
489
|
+
- lib/tasks/adminpanel/adminpanel.rake
|
490
|
+
- spec/dummy/.gitignore
|
490
491
|
- spec/dummy/README.rdoc
|
491
492
|
- spec/dummy/Rakefile
|
492
493
|
- spec/dummy/app/assets/images/hipster.jpg
|
@@ -548,6 +549,7 @@ files:
|
|
548
549
|
- spec/support/helper_methods.rb
|
549
550
|
- spec/support/submit_forms_without_button.rb
|
550
551
|
- spec/support/test_database.rb
|
552
|
+
- spec/tasks/adminpanel_rake_spec.rb
|
551
553
|
- spec/uploaders/gallery_uploader_spec.rb
|
552
554
|
- spec/uploaders/image_uploader_spec.rb
|
553
555
|
has_rdoc: true
|
@@ -586,6 +588,7 @@ signing_key:
|
|
586
588
|
specification_version: 3
|
587
589
|
summary: Developed with love for ruby 1.8.7
|
588
590
|
test_files:
|
591
|
+
- spec/dummy/.gitignore
|
589
592
|
- spec/dummy/README.rdoc
|
590
593
|
- spec/dummy/Rakefile
|
591
594
|
- spec/dummy/app/assets/images/hipster.jpg
|
@@ -647,5 +650,6 @@ test_files:
|
|
647
650
|
- spec/support/helper_methods.rb
|
648
651
|
- spec/support/submit_forms_without_button.rb
|
649
652
|
- spec/support/test_database.rb
|
653
|
+
- spec/tasks/adminpanel_rake_spec.rb
|
650
654
|
- spec/uploaders/gallery_uploader_spec.rb
|
651
655
|
- spec/uploaders/image_uploader_spec.rb
|
@@ -1,80 +0,0 @@
|
|
1
|
-
namespace :adminpanel do
|
2
|
-
desc "Populate database of adminpanel model"
|
3
|
-
|
4
|
-
task :populate, [:times, :model, :attributes] => :environment do |t, args|
|
5
|
-
puts "Generating #{args[:times]} records of #{args[:model]}"
|
6
|
-
model = "adminpanel/#{args[:model]}".classify.constantize
|
7
|
-
|
8
|
-
attributes = args[:attributes].split(" ")
|
9
|
-
prefixes = %W["Sir" "CEO" "Entrepeneur" "Bgr" "MVP"]
|
10
|
-
names = %W[Transito Jose Victor John Jane Ramon Katy]
|
11
|
-
l_names = %W[Camacho Magana Cuervo Gonzalez Lopez Doe Roe]
|
12
|
-
categories = %[CoDN Varios Comestibles Electronicos Web Basura lorem ipsum dolor]
|
13
|
-
lorem = %W[Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
|
14
|
-
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
|
15
|
-
minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex
|
16
|
-
ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
|
17
|
-
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
|
18
|
-
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
|
19
|
-
est laborum.]
|
20
|
-
domains = %W[codn.com gmail.com]
|
21
|
-
|
22
|
-
has_image = false
|
23
|
-
args[:times].to_i.times do |time|
|
24
|
-
instance = model.new
|
25
|
-
attributes.each do |attribute|
|
26
|
-
field = attribute.split(":").first
|
27
|
-
type = attribute.split(":").second
|
28
|
-
|
29
|
-
if type.nil? #no type
|
30
|
-
value = "#{time + 1} Lorem ipsum dolor sit amec"
|
31
|
-
|
32
|
-
elsif type == "name" #generate a name
|
33
|
-
value = "#{prefixes.sample} #{names.sample} #{l_names.sample}"
|
34
|
-
|
35
|
-
elsif type == "category" #generate a category name
|
36
|
-
value = categories.sample
|
37
|
-
|
38
|
-
elsif type == "description" || type == "lorem" #generate random lorem ipsum
|
39
|
-
value = ""
|
40
|
-
[*60..80].sample.times do
|
41
|
-
value = "#{value} #{lorem.sample}"
|
42
|
-
end
|
43
|
-
value = "#{value}."
|
44
|
-
|
45
|
-
elsif type == "number" #sample number
|
46
|
-
value = [*1..500].sample
|
47
|
-
|
48
|
-
elsif type == "id" #assign it to random instanes of Adminpanel::field
|
49
|
-
value = "adminpanel/#{field}".classify.constantize.order("RAND()").first.id
|
50
|
-
field = "#{field}_id"
|
51
|
-
|
52
|
-
elsif type = "email"
|
53
|
-
value = "#{names.sample.first}#{l_names.sample}@#{domains.sample}"
|
54
|
-
|
55
|
-
elsif type == "image" #force an image...
|
56
|
-
has_image = true
|
57
|
-
@file_url = "http://placehold.it/#{field}"
|
58
|
-
end
|
59
|
-
|
60
|
-
|
61
|
-
if(type != "image")
|
62
|
-
instance.send("#{field}=", value)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
instance.save
|
67
|
-
|
68
|
-
if(has_image) #forcing the image into the db
|
69
|
-
image_instance = Adminpanel::Image.new(
|
70
|
-
:model => model.display_name,
|
71
|
-
:foreign_key => instance.id
|
72
|
-
)
|
73
|
-
image_instance.save(:validate => false)
|
74
|
-
image_instance.update_column(:file, @file_url)
|
75
|
-
end
|
76
|
-
|
77
|
-
end
|
78
|
-
|
79
|
-
end
|
80
|
-
end
|