adminpanel 0.0.4 → 0.0.5
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.
- data/.rspec +2 -0
- data/Gemfile +6 -1
- data/adminpanel.gemspec +3 -0
- data/app/controllers/adminpanel/products_controller.rb +1 -0
- data/app/models/adminpanel/image.rb +2 -0
- data/app/models/adminpanel/section.rb +4 -2
- data/app/models/adminpanel/user.rb +1 -0
- data/app/views/adminpanel/sections/edit.html.erb +5 -3
- data/app/views/adminpanel/sections/show.html.erb +5 -1
- data/config/locales/es.yml +3 -1
- data/lib/adminpanel/version.rb +1 -1
- data/spec/dummy/.gitignore +19 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/images/hipster.jpg +0 -0
- data/spec/dummy/app/assets/images/test.jpg +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +11 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +61 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/carrierwve.rb +6 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +41 -0
- data/spec/dummy/config/environments/production.rb +72 -0
- data/spec/dummy/config/environments/test.rb +41 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +8 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/db/schema.rb +65 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/models/adminpanel/category_spec.rb +59 -0
- data/spec/models/adminpanel/gallery_spec.rb +19 -0
- data/spec/models/adminpanel/image_uploader.rb +26 -0
- data/spec/models/adminpanel/product_spec.rb +52 -0
- data/spec/models/adminpanel/section_spec.rb +58 -0
- data/spec/models/adminpanel/user_spec.rb +107 -0
- data/spec/spec_helper.rb +26 -0
- data/spec/support/active_record.rb +60 -0
- data/spec/support/schema.rb +65 -0
- data/spec/uploaders/adminpanel/gallery_uploader_spec.rb +31 -0
- data/spec/uploaders/adminpanel/image_uploader_spec.rb +37 -0
- data/spec/uploaders/adminpanel/section_uploader_spec.rb +32 -0
- metadata +149 -8
- data/app/models/adminpanel/contact.rb +0 -25
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/422.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/500.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
23
|
+
</div>
|
24
|
+
</body>
|
25
|
+
</html>
|
File without changes
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require "support/active_record"
|
3
|
+
|
4
|
+
describe Adminpanel::Category do
|
5
|
+
before do
|
6
|
+
@category = Adminpanel::Category.new(
|
7
|
+
:name => "Test category"
|
8
|
+
)
|
9
|
+
end
|
10
|
+
|
11
|
+
subject { @category}
|
12
|
+
|
13
|
+
it {should respond_to(:name) }
|
14
|
+
|
15
|
+
describe "when name is not present" do
|
16
|
+
before {@category.name = " "}
|
17
|
+
it {should_not be_valid}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require "support/active_record"
|
3
|
+
|
4
|
+
describe Adminpanel::Gallery do
|
5
|
+
before do
|
6
|
+
@gallery = Adminpanel::Gallery.new(
|
7
|
+
:file => "Test file"
|
8
|
+
)
|
9
|
+
end
|
10
|
+
|
11
|
+
subject { @gallery }
|
12
|
+
|
13
|
+
it { should respond_to(:file) }
|
14
|
+
|
15
|
+
describe "when file is not present" do
|
16
|
+
before {@gallery.file = " "}
|
17
|
+
it {should_not be_valid}
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require "support/active_record"
|
3
|
+
|
4
|
+
describe Adminpanel::Image do
|
5
|
+
before do
|
6
|
+
@image = Adminpanel::Image.new(
|
7
|
+
:file => "Test file"
|
8
|
+
)
|
9
|
+
end
|
10
|
+
|
11
|
+
subject { @image }
|
12
|
+
|
13
|
+
it { should respond_to(:file) }
|
14
|
+
it { should respond_to(:foreign_key) }
|
15
|
+
it { should respond_to(:model) }
|
16
|
+
|
17
|
+
describe "when file is not present" do
|
18
|
+
before {@image.file = " "}
|
19
|
+
it {should_not be_valid}
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "when model is not present" do
|
23
|
+
before {@image.model = " "}
|
24
|
+
it {should_not be_valid}
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require "support/active_record"
|
3
|
+
|
4
|
+
describe Adminpanel::Product do
|
5
|
+
before do
|
6
|
+
@category = Adminpanel::Category.new(
|
7
|
+
:name => "test category",
|
8
|
+
:id => 1
|
9
|
+
)
|
10
|
+
@product = Adminpanel::Product.new(
|
11
|
+
:description => "Test description for product",
|
12
|
+
:name => "product name",
|
13
|
+
:category_id => "1",
|
14
|
+
:brief => "short description"
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
subject { @product }
|
19
|
+
|
20
|
+
it { should respond_to(:name) }
|
21
|
+
it { should respond_to(:description) }
|
22
|
+
it { should respond_to(:category_id) }
|
23
|
+
it { should respond_to(:brief) }
|
24
|
+
|
25
|
+
describe "when product belongs to a category" do
|
26
|
+
before {@category.save}
|
27
|
+
after {@category.delete}
|
28
|
+
it {@product.category.should eql(@category)}
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "when no name present" do
|
32
|
+
before {@product.name = " "}
|
33
|
+
it {should_not be_valid}
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "when no description present" do
|
37
|
+
before {@product.description = " "}
|
38
|
+
it {should_not be_valid}
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "when no category is present" do
|
42
|
+
before {@product.category_id = " "}
|
43
|
+
it {should_not be_valid}
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "when no brief is present" do
|
47
|
+
before {@product.brief = " "}
|
48
|
+
it {should_not be_valid}
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require "support/active_record"
|
3
|
+
|
4
|
+
describe Adminpanel::Section do
|
5
|
+
before do
|
6
|
+
@section = Adminpanel::Section.new(
|
7
|
+
:description => "Test description for product",
|
8
|
+
:file => "example.png",
|
9
|
+
:has_image => true,
|
10
|
+
:key => "example_key",
|
11
|
+
:has_description => true
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
subject { @section }
|
16
|
+
|
17
|
+
it { should respond_to(:description) }
|
18
|
+
it { should respond_to(:file) }
|
19
|
+
it { should respond_to(:has_image) }
|
20
|
+
it { should respond_to(:key) }
|
21
|
+
it { should respond_to(:name) }
|
22
|
+
it { should respond_to(:has_description) }
|
23
|
+
|
24
|
+
describe "when key is telephone and has less than 10 chars" do
|
25
|
+
before {@section.key = "telephone"}
|
26
|
+
before {@section.description = "1" * 9}
|
27
|
+
it {should_not be_valid}
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "when key is telephone and has more than 10 chars" do
|
31
|
+
before {@section.key = "telephone"}
|
32
|
+
before {@section.description = "1" * 11}
|
33
|
+
it {should_not be_valid}
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "when key is telephone and has 10 chars" do
|
37
|
+
before {
|
38
|
+
@section.key = "telephone"
|
39
|
+
@section.description = "1" * 10
|
40
|
+
}
|
41
|
+
it {@section.description.length.should eql(10)}
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "when key is blank" do
|
45
|
+
before {@section.key = " "}
|
46
|
+
it {should_not be_valid}
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "when name is blank" do
|
50
|
+
before {@section.name = " "}
|
51
|
+
it {should_not be_valid}
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "when description is blank" do
|
55
|
+
before {@section.description = " "}
|
56
|
+
it {should_not be_valid}
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'support/active_record'
|
3
|
+
|
4
|
+
describe Adminpanel::User do
|
5
|
+
|
6
|
+
before do
|
7
|
+
@user = Adminpanel::User.new(
|
8
|
+
:name => "Example User",
|
9
|
+
:email => "user@example.com",
|
10
|
+
:password => "foobar",
|
11
|
+
:password_confirmation => "foobar"
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
subject { @user }
|
16
|
+
|
17
|
+
it { should respond_to(:name) }
|
18
|
+
it { should respond_to(:email) }
|
19
|
+
it { should respond_to(:password_digest) }
|
20
|
+
it { should respond_to(:password) }
|
21
|
+
it { should respond_to(:password_confirmation) }
|
22
|
+
|
23
|
+
it { should be_valid }
|
24
|
+
it { should respond_to(:authenticate) }
|
25
|
+
|
26
|
+
describe "when name is not present" do
|
27
|
+
before { @user.name = " " }
|
28
|
+
it { should_not be_valid }
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "when email is not present" do
|
32
|
+
before { @user.email = " " }
|
33
|
+
it { should_not be_valid }
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "when email address is already taken" do
|
37
|
+
before do
|
38
|
+
user_with_same_email = @user.dup
|
39
|
+
user_with_same_email.email = @user.email.upcase
|
40
|
+
user_with_same_email.save
|
41
|
+
end
|
42
|
+
|
43
|
+
it { should_not be_valid }
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "when name is too long" do
|
47
|
+
before { @user.name = "a" * 51 }
|
48
|
+
it { should_not be_valid }
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "when email format is invalid" do
|
52
|
+
it "should be invalid" do
|
53
|
+
addresses = %w[user@foo,com user_at_foo.org example.user@foo.
|
54
|
+
foo@bar_baz.com foo@bar+baz.com]
|
55
|
+
addresses.each do |invalid_address|
|
56
|
+
@user.email = invalid_address
|
57
|
+
@user.should_not be_valid
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "when email format is valid" do
|
63
|
+
it "should be valid" do
|
64
|
+
addresses = %w[user@foo.COM A_US-ER@f.b.org frst.lst@foo.jp a+b@baz.cn]
|
65
|
+
addresses.each do |valid_address|
|
66
|
+
@user.email = valid_address
|
67
|
+
@user.should be_valid
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "when password is not present" do
|
73
|
+
before { @user.password = @user.password_confirmation = " " }
|
74
|
+
it { should_not be_valid }
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "when password doesn't match confirmation" do
|
78
|
+
before { @user.password_confirmation = "mismatch" }
|
79
|
+
it { should_not be_valid }
|
80
|
+
end
|
81
|
+
|
82
|
+
describe "when password confirmation is nil" do
|
83
|
+
before { @user.password_confirmation = nil }
|
84
|
+
it { should_not be_valid }
|
85
|
+
end
|
86
|
+
|
87
|
+
describe "with a password that's too short" do
|
88
|
+
before { @user.password = @user.password_confirmation = "a" * 5 }
|
89
|
+
it { should be_invalid }
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "return value of authenticate method" do
|
93
|
+
before { @user.save }
|
94
|
+
let(:found_user) { Adminpanel::User.find_by_email(@user.email) }
|
95
|
+
|
96
|
+
describe "with valid password" do
|
97
|
+
it { should == found_user.authenticate(@user.password) }
|
98
|
+
end
|
99
|
+
|
100
|
+
describe "with invalid password" do
|
101
|
+
let(:user_for_invalid_password) { found_user.authenticate("invalid") }
|
102
|
+
|
103
|
+
it { should_not == user_for_invalid_password }
|
104
|
+
specify { user_for_invalid_password.should be_false }
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
ENV["RAILS_ENV"] ||= 'test'
|
8
|
+
require File.expand_path("../dummy/config/environment", __FILE__)
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
12
|
+
config.run_all_when_everything_filtered = true
|
13
|
+
config.filter_run :focus
|
14
|
+
|
15
|
+
root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
16
|
+
ActiveRecord::Base.establish_connection(
|
17
|
+
:adapter => 'sqlite3',
|
18
|
+
:database => ':memory:'
|
19
|
+
)
|
20
|
+
|
21
|
+
# Run specs in random order to surface order dependencies. If you find an
|
22
|
+
# order dependency and want to debug it, you can fix the order by providing
|
23
|
+
# the seed, which is printed after each run.
|
24
|
+
# --seed 1234
|
25
|
+
config.order = 'random'
|
26
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require "active_record"
|
2
|
+
|
3
|
+
ActiveRecord::Migration.create_table :adminpanel_users do |t|
|
4
|
+
t.string :name
|
5
|
+
t.string :email
|
6
|
+
t.string :password_digest
|
7
|
+
t.string :remember_token
|
8
|
+
t.datetime :created_at, :null => false
|
9
|
+
t.datetime :updated_at, :null => false
|
10
|
+
end
|
11
|
+
ActiveRecord::Migration.create_table :adminpanel_categories do |t|
|
12
|
+
t.string :name
|
13
|
+
t.datetime :created_at, :null => false
|
14
|
+
t.datetime :updated_at, :null => false
|
15
|
+
end
|
16
|
+
ActiveRecord::Migration.create_table :adminpanel_galleries do |t|
|
17
|
+
t.string :file
|
18
|
+
t.datetime :created_at, :null => false
|
19
|
+
t.datetime :updated_at, :null => false
|
20
|
+
end
|
21
|
+
ActiveRecord::Migration.create_table :adminpanel_images do |t|
|
22
|
+
t.string :file
|
23
|
+
t.string :foreign_key
|
24
|
+
t.string :model
|
25
|
+
t.datetime :created_at, :null => false
|
26
|
+
t.datetime :updated_at, :null => false
|
27
|
+
end
|
28
|
+
ActiveRecord::Migration.create_table :adminpanel_products do |t|
|
29
|
+
t.string :name
|
30
|
+
t.text :description
|
31
|
+
t.datetime :created_at, :null => false
|
32
|
+
t.datetime :updated_at, :null => false
|
33
|
+
t.string :category_id
|
34
|
+
t.string :brief
|
35
|
+
end
|
36
|
+
ActiveRecord::Migration.create_table :adminpanel_sections do |t|
|
37
|
+
t.string :name
|
38
|
+
t.text :description
|
39
|
+
t.string :key
|
40
|
+
t.boolean :has_image
|
41
|
+
t.string :file
|
42
|
+
t.datetime :created_at, :null => false
|
43
|
+
t.datetime :updated_at, :null => false
|
44
|
+
t.boolean :has_description
|
45
|
+
end
|
46
|
+
module ActiveModel::Validations
|
47
|
+
def errors_on(attribute)
|
48
|
+
self.valid?
|
49
|
+
[self.errors[attribute]].flatten.compact
|
50
|
+
end
|
51
|
+
alias :error_on :errors_on
|
52
|
+
end
|
53
|
+
RSpec.configure do |config|
|
54
|
+
config.around do |example|
|
55
|
+
ActiveRecord::Base.transaction do
|
56
|
+
example.run
|
57
|
+
raise ActiveRecord::Rollback
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|