carlosbrando-remarkable 2.2.1 → 2.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +0 -83
- data/Rakefile +8 -1
- data/lib/remarkable.rb +1 -1
- data/lib/remarkable/active_record/macros/database/column_matcher.rb +6 -53
- data/lib/remarkable/active_record/macros/validations/allow_mass_assignment_of_matcher.rb +2 -2
- data/lib/remarkable/active_record/macros/validations/protect_attributes_matcher.rb +1 -1
- data/remarkable.gemspec +6 -5
- metadata +6 -87
- data/spec/controllers/posts_controller_spec.rb +0 -220
- data/spec/controllers/users_controller_spec.rb +0 -15
- data/spec/fixtures/addresses.yml +0 -3
- data/spec/fixtures/fleas.yml +0 -10
- data/spec/fixtures/friendships.yml +0 -0
- data/spec/fixtures/posts.yml +0 -5
- data/spec/fixtures/products.yml +0 -0
- data/spec/fixtures/taggings.yml +0 -0
- data/spec/fixtures/tags.yml +0 -9
- data/spec/fixtures/users.yml +0 -13
- data/spec/models/address_spec.rb +0 -65
- data/spec/models/dog_spec.rb +0 -78
- data/spec/models/flea_spec.rb +0 -39
- data/spec/models/friendship_spec.rb +0 -13
- data/spec/models/post_spec.rb +0 -69
- data/spec/models/product_spec.rb +0 -122
- data/spec/models/tag_spec.rb +0 -21
- data/spec/models/tagging_spec.rb +0 -37
- data/spec/models/user_spec.rb +0 -292
- data/spec/other/custom_macros_spec.rb +0 -27
- data/spec/other/my_own_matcher_spec.rb +0 -11
- data/spec/other/private_helpers_spec.rb +0 -31
- data/spec/rails_root/app/controllers/application.rb +0 -25
- data/spec/rails_root/app/controllers/posts_controller.rb +0 -87
- data/spec/rails_root/app/controllers/users_controller.rb +0 -84
- data/spec/rails_root/app/helpers/application_helper.rb +0 -3
- data/spec/rails_root/app/helpers/posts_helper.rb +0 -2
- data/spec/rails_root/app/helpers/users_helper.rb +0 -2
- data/spec/rails_root/app/models/address.rb +0 -7
- data/spec/rails_root/app/models/flea.rb +0 -7
- data/spec/rails_root/app/models/friendship.rb +0 -4
- data/spec/rails_root/app/models/pets/dog.rb +0 -12
- data/spec/rails_root/app/models/post.rb +0 -12
- data/spec/rails_root/app/models/product.rb +0 -14
- data/spec/rails_root/app/models/tag.rb +0 -8
- data/spec/rails_root/app/models/tagging.rb +0 -6
- data/spec/rails_root/app/models/user.rb +0 -43
- data/spec/rails_root/app/views/layouts/posts.rhtml +0 -19
- data/spec/rails_root/app/views/layouts/users.rhtml +0 -17
- data/spec/rails_root/app/views/layouts/wide.html.erb +0 -1
- data/spec/rails_root/app/views/posts/edit.rhtml +0 -27
- data/spec/rails_root/app/views/posts/index.rhtml +0 -25
- data/spec/rails_root/app/views/posts/new.rhtml +0 -26
- data/spec/rails_root/app/views/posts/show.rhtml +0 -18
- data/spec/rails_root/app/views/users/edit.rhtml +0 -22
- data/spec/rails_root/app/views/users/index.rhtml +0 -22
- data/spec/rails_root/app/views/users/new.rhtml +0 -21
- data/spec/rails_root/app/views/users/show.rhtml +0 -13
- data/spec/rails_root/config/boot.rb +0 -109
- data/spec/rails_root/config/database.yml +0 -3
- data/spec/rails_root/config/environment.rb +0 -16
- data/spec/rails_root/config/environments/test.rb +0 -0
- data/spec/rails_root/config/initializers/new_rails_defaults.rb +0 -15
- data/spec/rails_root/config/initializers/shoulda.rb +0 -8
- data/spec/rails_root/config/locales/en.yml +0 -8
- data/spec/rails_root/config/routes.rb +0 -6
- data/spec/rails_root/db/migrate/001_create_users.rb +0 -18
- data/spec/rails_root/db/migrate/002_create_posts.rb +0 -13
- data/spec/rails_root/db/migrate/003_create_taggings.rb +0 -12
- data/spec/rails_root/db/migrate/004_create_tags.rb +0 -11
- data/spec/rails_root/db/migrate/005_create_dogs.rb +0 -13
- data/spec/rails_root/db/migrate/006_create_addresses.rb +0 -14
- data/spec/rails_root/db/migrate/007_create_fleas.rb +0 -11
- data/spec/rails_root/db/migrate/008_create_dogs_fleas.rb +0 -12
- data/spec/rails_root/db/migrate/009_create_products.rb +0 -17
- data/spec/rails_root/db/migrate/010_create_friendships.rb +0 -14
- data/spec/rails_root/db/migrate/011_add_fleas_color.rb +0 -10
- data/spec/rails_root/db/migrate/012_add_fleas_address.rb +0 -10
- data/spec/rails_root/db/schema.rb +0 -0
- data/spec/rails_root/log/.keep +0 -0
- data/spec/rails_root/public/.htaccess +0 -40
- data/spec/rails_root/public/404.html +0 -30
- data/spec/rails_root/public/422.html +0 -30
- data/spec/rails_root/public/500.html +0 -30
- data/spec/rails_root/script/console +0 -3
- data/spec/rails_root/script/generate +0 -3
- data/spec/rails_root/spec/remarkable_macros/.keep +0 -0
- data/spec/rails_root/vendor/plugins/.keep +0 -0
- data/spec/rails_root/vendor/plugins/my_plugin/remarkable_macros/.keep +0 -0
- data/spec/rcov.opts +0 -2
- data/spec/spec.opts +0 -4
- data/spec/spec_helper.rb +0 -56
@@ -1,87 +0,0 @@
|
|
1
|
-
class PostsController < ApplicationController
|
2
|
-
before_filter :ensure_logged_in
|
3
|
-
before_filter :load_user
|
4
|
-
|
5
|
-
def index
|
6
|
-
@posts = @user.posts
|
7
|
-
@some_text = "foo bar"
|
8
|
-
|
9
|
-
respond_to do |format|
|
10
|
-
format.html # index.rhtml
|
11
|
-
format.xml { render :xml => @posts.to_xml }
|
12
|
-
format.rss do
|
13
|
-
headers['Content-Type'] = 'application/rss+xml'
|
14
|
-
session[:special] = '$2 off your next purchase'
|
15
|
-
session[:special_user_id] = @user.id
|
16
|
-
head :ok
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def show
|
22
|
-
@post = @user.posts.find(params[:id])
|
23
|
-
@false_flag = false
|
24
|
-
|
25
|
-
respond_to do |format|
|
26
|
-
format.html { render :layout => 'wide' }
|
27
|
-
format.xml { render :xml => @post.to_xml }
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def new
|
32
|
-
@post = @user.posts.build
|
33
|
-
render :layout => false
|
34
|
-
end
|
35
|
-
|
36
|
-
def edit
|
37
|
-
@post = @user.posts.find(params[:id])
|
38
|
-
end
|
39
|
-
|
40
|
-
def create
|
41
|
-
@post = @user.posts.build(params[:post])
|
42
|
-
|
43
|
-
respond_to do |format|
|
44
|
-
if @post.save
|
45
|
-
flash[:notice] = 'Post was successfully created.'
|
46
|
-
format.html { redirect_to user_post_url(@post.user, @post) }
|
47
|
-
format.xml { head :created, :location => user_post_url(@post.user, @post) }
|
48
|
-
else
|
49
|
-
format.html { render :action => "new" }
|
50
|
-
format.xml { render :xml => @post.errors.to_xml }
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def update
|
56
|
-
@post = @user.posts.find(params[:id])
|
57
|
-
|
58
|
-
respond_to do |format|
|
59
|
-
if @post.update_attributes(params[:post])
|
60
|
-
flash[:notice] = 'Post was successfully updated.'
|
61
|
-
format.html { redirect_to user_post_url(@post.user, @post) }
|
62
|
-
format.xml { head :ok }
|
63
|
-
else
|
64
|
-
format.html { render :action => "edit" }
|
65
|
-
format.xml { render :xml => @post.errors.to_xml }
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def destroy
|
71
|
-
@post = @user.posts.find(params[:id])
|
72
|
-
@post.destroy
|
73
|
-
|
74
|
-
flash[:notice] = "Post was removed"
|
75
|
-
|
76
|
-
respond_to do |format|
|
77
|
-
format.html { redirect_to user_posts_url(@post.user) }
|
78
|
-
format.xml { head :ok }
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
private
|
83
|
-
|
84
|
-
def load_user
|
85
|
-
@user = User.find(params[:user_id])
|
86
|
-
end
|
87
|
-
end
|
@@ -1,84 +0,0 @@
|
|
1
|
-
class UsersController < ApplicationController
|
2
|
-
|
3
|
-
filter_parameter_logging :ssn
|
4
|
-
|
5
|
-
# GET /users
|
6
|
-
# GET /users.xml
|
7
|
-
def index
|
8
|
-
@users = User.find(:all)
|
9
|
-
|
10
|
-
respond_to do |format|
|
11
|
-
format.html # index.rhtml
|
12
|
-
format.xml { render :xml => @users.to_xml }
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
# GET /users/1
|
17
|
-
# GET /users/1.xml
|
18
|
-
def show
|
19
|
-
@user = User.find(params[:id])
|
20
|
-
|
21
|
-
respond_to do |format|
|
22
|
-
format.html # show.rhtml
|
23
|
-
format.xml { render :xml => @user.to_xml }
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
# GET /users/new
|
28
|
-
def new
|
29
|
-
@user = User.new
|
30
|
-
end
|
31
|
-
|
32
|
-
# GET /users/1;edit
|
33
|
-
def edit
|
34
|
-
@user = User.find(params[:id])
|
35
|
-
end
|
36
|
-
|
37
|
-
# POST /users
|
38
|
-
# POST /users.xml
|
39
|
-
def create
|
40
|
-
@user = User.new(params[:user])
|
41
|
-
|
42
|
-
respond_to do |format|
|
43
|
-
if @user.save
|
44
|
-
flash[:notice] = 'User was successfully created.'
|
45
|
-
format.html { redirect_to user_url(@user) }
|
46
|
-
format.xml { head :created, :location => user_url(@user) }
|
47
|
-
else
|
48
|
-
format.html { render :action => "new" }
|
49
|
-
format.xml { render :xml => @user.errors.to_xml }
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
# PUT /users/1
|
55
|
-
# PUT /users/1.xml
|
56
|
-
def update
|
57
|
-
@user = User.find(params[:id])
|
58
|
-
|
59
|
-
respond_to do |format|
|
60
|
-
if @user.update_attributes(params[:user])
|
61
|
-
flash[:notice] = 'User was successfully updated.'
|
62
|
-
format.html { redirect_to user_url(@user) }
|
63
|
-
format.xml { head :ok }
|
64
|
-
else
|
65
|
-
format.html { render :action => "edit" }
|
66
|
-
format.xml { render :xml => @user.errors.to_xml }
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
# DELETE /users/1
|
72
|
-
# DELETE /users/1.xml
|
73
|
-
def destroy
|
74
|
-
@user = User.find(params[:id])
|
75
|
-
@user.destroy
|
76
|
-
|
77
|
-
flash[:notice] = "User was removed"
|
78
|
-
|
79
|
-
respond_to do |format|
|
80
|
-
format.html { redirect_to users_url }
|
81
|
-
format.xml { head :ok }
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
@@ -1,7 +0,0 @@
|
|
1
|
-
class Address < ActiveRecord::Base
|
2
|
-
belongs_to :addressable, :polymorphic => true
|
3
|
-
validates_uniqueness_of :title, :scope => [:addressable_type, :addressable_id]
|
4
|
-
|
5
|
-
validates_length_of :zip, :minimum => 5, :allow_nil => true
|
6
|
-
validates_numericality_of :zip, :less_than => 20, :greater_than => 10
|
7
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
module Pets
|
2
|
-
class Dog < ActiveRecord::Base
|
3
|
-
belongs_to :user, :foreign_key => :owner_id
|
4
|
-
belongs_to :address
|
5
|
-
has_and_belongs_to_many :fleas, :join_table => :fleas
|
6
|
-
|
7
|
-
validates_numericality_of :age, :allow_blank => true, :only_integer => true, :odd => true, :greater_than_or_equal_to => 10
|
8
|
-
validates_numericality_of :owner_id, :allow_nil => true, :even => true, :less_than_or_equal_to => 10
|
9
|
-
|
10
|
-
validates_presence_of :owner_id
|
11
|
-
end
|
12
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
class Post < ActiveRecord::Base
|
2
|
-
belongs_to :user
|
3
|
-
belongs_to :owner, :foreign_key => :user_id, :class_name => 'User'
|
4
|
-
has_many :taggings
|
5
|
-
has_many :tags, :through => :taggings
|
6
|
-
has_many :through_tags, :through => :taggings, :source => :tag
|
7
|
-
|
8
|
-
validates_uniqueness_of :title
|
9
|
-
validates_presence_of :title
|
10
|
-
validates_presence_of :body, :message => 'Seriously... wtf'
|
11
|
-
validates_numericality_of :user_id
|
12
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
class Product < ActiveRecord::Base
|
2
|
-
validates_presence_of :title
|
3
|
-
|
4
|
-
validates_inclusion_of :price, :in => 0..99, :unless => :tangible
|
5
|
-
validates_exclusion_of :weight, :in => 10..100, :unless => :tangible
|
6
|
-
validates_format_of :size, :with => /^\d+\D+$/, :unless => :tangible
|
7
|
-
|
8
|
-
validates_presence_of :price, :if => :tangible
|
9
|
-
validates_inclusion_of :price, :in => 1..9999, :if => :tangible, :allow_nil => true
|
10
|
-
validates_inclusion_of :weight, :in => 1..100, :if => :tangible, :allow_blank => true
|
11
|
-
validates_inclusion_of :size, :in => %w(S M L XL), :if => :tangible, :allow_blank => true
|
12
|
-
validates_exclusion_of :size, :in => %w(XS XM), :if => :tangible
|
13
|
-
validates_length_of :size, :in => 5..20, :if => :tangible, :allow_blank => true
|
14
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
class User < ActiveRecord::Base
|
2
|
-
has_many :posts
|
3
|
-
has_many :dogs, :foreign_key => :owner_id, :class_name => "Pets::Dog", :validate => false
|
4
|
-
|
5
|
-
has_many :friendships
|
6
|
-
has_many :friends, :through => :friendships
|
7
|
-
|
8
|
-
has_one :address, :as => :addressable, :dependent => :destroy
|
9
|
-
|
10
|
-
validates_associated :address, :posts
|
11
|
-
|
12
|
-
named_scope :old, :conditions => "age > 50"
|
13
|
-
named_scope :eighteen, :conditions => { :age => 18 }
|
14
|
-
named_scope :recent, lambda {|count| { :limit => count } }
|
15
|
-
|
16
|
-
def self.recent_via_method(count)
|
17
|
-
scoped(:limit => count)
|
18
|
-
end
|
19
|
-
|
20
|
-
attr_accessor :username, :username_confirmation, :terms
|
21
|
-
attr_protected :password
|
22
|
-
attr_readonly :name
|
23
|
-
|
24
|
-
validates_format_of :email, :with => /\w*@\w*.com/
|
25
|
-
validates_length_of :email, :in => 2..100, :allow_nil => false, :allow_blank => false
|
26
|
-
validates_uniqueness_of :email, :scope => :name
|
27
|
-
|
28
|
-
validates_inclusion_of :age, :in => 2..100
|
29
|
-
|
30
|
-
validates_length_of :ssn, :is => 9, :message => "Social Security Number is not the right length"
|
31
|
-
validates_numericality_of :ssn, :equal_to => 123456789
|
32
|
-
|
33
|
-
validates_acceptance_of :eula
|
34
|
-
validates_acceptance_of :terms, :allow_nil => false, :accept => true
|
35
|
-
|
36
|
-
validates_confirmation_of :username, :email
|
37
|
-
|
38
|
-
after_create :send_welcome_email
|
39
|
-
before_validation_on_update :some_weird_callback
|
40
|
-
|
41
|
-
def send_welcome_email; end
|
42
|
-
def some_weird_callback; end
|
43
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
-
|
4
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
-
<head>
|
6
|
-
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
|
7
|
-
<meta name="description" content="Posts, posts and more posts" />
|
8
|
-
<meta name='keywords' content='posts' />
|
9
|
-
<title>Posts: <%= controller.action_name %></title>
|
10
|
-
<%= stylesheet_link_tag 'scaffold' %>
|
11
|
-
</head>
|
12
|
-
<body>
|
13
|
-
|
14
|
-
<p style="color: green"><%= flash[:notice] %></p>
|
15
|
-
|
16
|
-
<%= yield %>
|
17
|
-
|
18
|
-
</body>
|
19
|
-
</html>
|
@@ -1,17 +0,0 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
-
|
4
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
-
<head>
|
6
|
-
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
|
7
|
-
<title>Users: <%= controller.action_name %></title>
|
8
|
-
<%= stylesheet_link_tag 'scaffold' %>
|
9
|
-
</head>
|
10
|
-
<body>
|
11
|
-
|
12
|
-
<p style="color: green"><%= flash[:notice] %></p>
|
13
|
-
|
14
|
-
<%= yield %>
|
15
|
-
|
16
|
-
</body>
|
17
|
-
</html>
|
@@ -1 +0,0 @@
|
|
1
|
-
<html><%= yield %></html>
|
@@ -1,27 +0,0 @@
|
|
1
|
-
<h1>Editing post</h1>
|
2
|
-
|
3
|
-
<%= error_messages_for :post %>
|
4
|
-
|
5
|
-
<% form_for(:post, :url => user_post_path(@post.user, @post), :html => { :method => :put }) do |f| %>
|
6
|
-
<p>
|
7
|
-
<b>User</b><br />
|
8
|
-
<%= f.text_field :user_id %>
|
9
|
-
</p>
|
10
|
-
|
11
|
-
<p>
|
12
|
-
<b>Title</b><br />
|
13
|
-
<%= f.text_field :title %>
|
14
|
-
</p>
|
15
|
-
|
16
|
-
<p>
|
17
|
-
<b>Body</b><br />
|
18
|
-
<%= f.text_area :body %>
|
19
|
-
</p>
|
20
|
-
|
21
|
-
<p>
|
22
|
-
<%= submit_tag "Update" %>
|
23
|
-
</p>
|
24
|
-
<% end %>
|
25
|
-
|
26
|
-
<%= link_to 'Show', user_post_path(@post.user, @post) %> |
|
27
|
-
<%= link_to 'Back', user_posts_path(@post.user) %>
|
@@ -1,25 +0,0 @@
|
|
1
|
-
<h1>Listing posts</h1>
|
2
|
-
|
3
|
-
<table>
|
4
|
-
<tr>
|
5
|
-
<th>User</th>
|
6
|
-
<th>Title</th>
|
7
|
-
<th>Body</th>
|
8
|
-
</tr>
|
9
|
-
|
10
|
-
<% for post in @posts %>
|
11
|
-
<tr>
|
12
|
-
<td><%=h post.user_id %></td>
|
13
|
-
<td><%=h post.title %></td>
|
14
|
-
<td><%=h post.body %></td>
|
15
|
-
<td><%= link_to 'Show', user_post_path(post.user, post) %></td>
|
16
|
-
<td><%= link_to 'Edit', edit_user_post_path(post.user, post) %></td>
|
17
|
-
<td><%= link_to 'Destroy', user_post_path(post.user, post), :confirm => 'Are you sure?',
|
18
|
-
:method => :delete %></td>
|
19
|
-
</tr>
|
20
|
-
<% end %>
|
21
|
-
</table>
|
22
|
-
|
23
|
-
<br />
|
24
|
-
|
25
|
-
<%= link_to 'New post', new_user_post_path(post.user) %>
|
@@ -1,26 +0,0 @@
|
|
1
|
-
<h1>New post</h1>
|
2
|
-
|
3
|
-
<%= error_messages_for :post %>
|
4
|
-
|
5
|
-
<% form_for(:post, :url => user_posts_path(@user)) do |f| %>
|
6
|
-
<p>
|
7
|
-
<b>User</b><br />
|
8
|
-
<%= f.text_field :user_id %>
|
9
|
-
</p>
|
10
|
-
|
11
|
-
<p>
|
12
|
-
<b>Title</b><br />
|
13
|
-
<%= f.text_field :title %>
|
14
|
-
</p>
|
15
|
-
|
16
|
-
<p>
|
17
|
-
<b>Body</b><br />
|
18
|
-
<%= f.text_area :body %>
|
19
|
-
</p>
|
20
|
-
|
21
|
-
<p>
|
22
|
-
<%= submit_tag "Create" %>
|
23
|
-
</p>
|
24
|
-
<% end %>
|
25
|
-
|
26
|
-
<%= link_to 'Back', user_posts_path(@user) %>
|