Permalink
Browse files

add some testing

  • Loading branch information...
1 parent 134dfdf commit 77fd39cf760fab9c4c105c812228ef112ea7b6c6 @varid007 committed May 21, 2012
Showing with 8,907 additions and 34 deletions.
  1. +2 −2 store/Gemfile
  2. +7 −1 store/Gemfile.lock
  3. +37 −0 store/Gemfile~
  4. +1 −1 store/app/controllers/articles_controller.rb
  5. +1 −1 store/app/controllers/comments_controller.rb
  6. +2 −2 store/app/controllers/products_controller.rb
  7. +3 −2 store/app/controllers/users_controller.rb
  8. +1 −0 store/app/models/article.rb
  9. +1 −1 store/app/models/comment.rb
  10. +6 −8 store/app/models/user.rb
  11. +2 −11 store/app/views/categories/show.html.erb
  12. +1 −2 store/app/views/layouts/application.html.erb
  13. +1 −1 store/app/views/layouts/application.html.erb~
  14. +1,546 −0 store/coverage/.resultset.json
  15. +88 −0 store/coverage/assets/0.5.3/app.js
  16. BIN store/coverage/assets/0.5.3/fancybox/blank.gif
  17. BIN store/coverage/assets/0.5.3/fancybox/fancy_close.png
  18. BIN store/coverage/assets/0.5.3/fancybox/fancy_loading.png
  19. BIN store/coverage/assets/0.5.3/fancybox/fancy_nav_left.png
  20. BIN store/coverage/assets/0.5.3/fancybox/fancy_nav_right.png
  21. BIN store/coverage/assets/0.5.3/fancybox/fancy_shadow_e.png
  22. BIN store/coverage/assets/0.5.3/fancybox/fancy_shadow_n.png
  23. BIN store/coverage/assets/0.5.3/fancybox/fancy_shadow_ne.png
  24. BIN store/coverage/assets/0.5.3/fancybox/fancy_shadow_nw.png
  25. BIN store/coverage/assets/0.5.3/fancybox/fancy_shadow_s.png
  26. BIN store/coverage/assets/0.5.3/fancybox/fancy_shadow_se.png
  27. BIN store/coverage/assets/0.5.3/fancybox/fancy_shadow_sw.png
  28. BIN store/coverage/assets/0.5.3/fancybox/fancy_shadow_w.png
  29. BIN store/coverage/assets/0.5.3/fancybox/fancy_title_left.png
  30. BIN store/coverage/assets/0.5.3/fancybox/fancy_title_main.png
  31. BIN store/coverage/assets/0.5.3/fancybox/fancy_title_over.png
  32. BIN store/coverage/assets/0.5.3/fancybox/fancy_title_right.png
  33. BIN store/coverage/assets/0.5.3/fancybox/fancybox-x.png
  34. BIN store/coverage/assets/0.5.3/fancybox/fancybox-y.png
  35. BIN store/coverage/assets/0.5.3/fancybox/fancybox.png
  36. +363 −0 store/coverage/assets/0.5.3/fancybox/jquery.fancybox-1.3.1.css
  37. +44 −0 store/coverage/assets/0.5.3/fancybox/jquery.fancybox-1.3.1.pack.js
  38. BIN store/coverage/assets/0.5.3/favicon_green.png
  39. BIN store/coverage/assets/0.5.3/favicon_red.png
  40. BIN store/coverage/assets/0.5.3/favicon_yellow.png
  41. +129 −0 store/coverage/assets/0.5.3/highlight.css
  42. +1 −0 store/coverage/assets/0.5.3/highlight.pack.js
  43. +18 −0 store/coverage/assets/0.5.3/jquery-1.6.2.min.js
  44. +152 −0 store/coverage/assets/0.5.3/jquery.dataTables.min.js
  45. +141 −0 store/coverage/assets/0.5.3/jquery.timeago.js
  46. +174 −0 store/coverage/assets/0.5.3/jquery.url.js
  47. BIN store/coverage/assets/0.5.3/loading.gif
  48. BIN store/coverage/assets/0.5.3/magnify.png
  49. BIN store/coverage/assets/0.5.3/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png
  50. BIN store/coverage/assets/0.5.3/smoothness/images/ui-bg_flat_75_ffffff_40x100.png
  51. BIN store/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png
  52. BIN store/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_65_ffffff_1x400.png
  53. BIN store/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_75_dadada_1x400.png
  54. BIN store/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png
  55. BIN store/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png
  56. BIN store/coverage/assets/0.5.3/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png
  57. BIN store/coverage/assets/0.5.3/smoothness/images/ui-icons_222222_256x240.png
  58. BIN store/coverage/assets/0.5.3/smoothness/images/ui-icons_2e83ff_256x240.png
  59. BIN store/coverage/assets/0.5.3/smoothness/images/ui-icons_454545_256x240.png
  60. BIN store/coverage/assets/0.5.3/smoothness/images/ui-icons_888888_256x240.png
  61. BIN store/coverage/assets/0.5.3/smoothness/images/ui-icons_cd0a0a_256x240.png
  62. +295 −0 store/coverage/assets/0.5.3/smoothness/jquery-ui-1.8.4.custom.css
  63. +383 −0 store/coverage/assets/0.5.3/stylesheet.css
  64. +5,259 −0 store/coverage/index.html
  65. +69 −2 store/test/functional/users_controller_test.rb
  66. +2 −0 store/test/test_helper.rb
  67. +42 −0 store/test/unit/article_test.rb
  68. +9 −0 store/test/unit/article_test.rb~
  69. +29 −0 store/test/unit/category_test.rb
  70. +6 −0 store/test/unit/comment_test.rb
  71. +16 −0 store/test/unit/product_test.rb
  72. +76 −0 store/test/unit/user_test.rb
View
@@ -10,8 +10,8 @@ gem 'execjs'
gem 'therubyracer'
gem 'bcrypt-ruby', :require => 'bcrypt'
gem 'recaptcha', :require => 'recaptcha/rails'
-
-
+gem 'simplecov'
+gem "multi_json", "~> 1.3.5"
# Gems used only for assets and not required
# in production environments by default.
group :assets do
View
@@ -56,7 +56,7 @@ GEM
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.18)
- multi_json (1.3.4)
+ multi_json (1.3.5)
mysql2 (0.3.11)
polyglot (0.3.3)
rack (1.3.6)
@@ -93,6 +93,10 @@ GEM
railties (~> 3.1.0)
sass (>= 3.1.10)
tilt (~> 1.3.2)
+ simplecov (0.6.4)
+ multi_json (~> 1.0)
+ simplecov-html (~> 0.5.3)
+ simplecov-html (0.5.3)
sprockets (2.0.4)
hike (~> 1.2)
rack (~> 1.0)
@@ -119,10 +123,12 @@ DEPENDENCIES
coffee-rails (~> 3.1.0)
execjs
jquery-rails
+ multi_json (~> 1.3.5)
mysql2
rails (= 3.1.0)
recaptcha
sass-rails (~> 3.1.0)
+ simplecov
therubyracer
turn
uglifier
View
@@ -0,0 +1,37 @@
+source 'http://rubygems.org'
+
+gem 'rails', '3.1.0'
+
+# Bundle edge Rails instead:
+# gem 'rails', :git => 'git://github.com/rails/rails.git'
+
+gem 'mysql2'
+gem 'execjs'
+gem 'therubyracer'
+gem 'bcrypt-ruby', :require => 'bcrypt'
+gem 'recaptcha', :require => 'recaptcha/rails'
+
+
+# Gems used only for assets and not required
+# in production environments by default.
+group :assets do
+ gem 'sass-rails', " ~> 3.1.0"
+ gem 'coffee-rails', "~> 3.1.0"
+ gem 'uglifier'
+end
+
+gem 'jquery-rails'
+
+# Use unicorn as the web server
+# gem 'unicorn'
+
+# Deploy with Capistrano
+# gem 'capistrano'
+
+# To use debugger
+# gem 'ruby-debug19', :require => 'ruby-debug'
+
+group :test do
+ # Pretty printed test output
+ gem 'turn', :require => false
+end
@@ -51,7 +51,7 @@ def find_article
end
end
def your_article
- user=User.find_by_email(current_user.email)
+ user=current_user
unless @article.user_id == user.id || current_user.is_admin
flash[:notice]="its not your article"
redirect_to articles_path
@@ -1,7 +1,7 @@
class CommentsController < ApplicationController
def create
- @user = User.find_by_email(current_user.email)
+ @user = current_user
@comment = @user.comments.new(params[:comment])
@article = Article.find_by_id(params[:comment][:article_id])
@comments=@article.comments
@@ -13,7 +13,7 @@ def new
def create
- @user = User.find_by_email(current_user.email)
+ @user = current_user
@product = @user.products.create(params[:product])
if @product.save
flash[:notice] = "Article was successfully created"
@@ -61,7 +61,7 @@ def find_product
end
def your_product
- user=User.find_by_email(current_user.email)
+ user=current_user
unless @product.id == user.id || current_user.is_admin
flash[:notice]="its not your product"
redirect_to products_path
@@ -19,7 +19,7 @@ def create
if @user.save
flash[:notice] = 'Account was Created, Log in ?'
- redirect_to new_session_path, :notice => "Signed up!"
+ redirect_to home_index_path, :notice => "Signed up!"
else
render :new
end
@@ -32,7 +32,7 @@ def edit
end
def update
if @user.update_attributes(params[:user])
- flash[:notice] = 'Article was succesful Update'
+ flash[:notice] = 'User was succesful Update'
redirect_to user_path
else
flash[:notice] = 'User faild Update'
@@ -42,6 +42,7 @@ def update
def destroy
@user.destroy
+ flash[:notice]="user has deleted"
redirect_to users_path
end
private
@@ -6,4 +6,5 @@ class Article < ActiveRecord::Base
:presence => true,
:length => {:minimum => 1, :maximum => 15},
:format => {:with => /[a-zA-Z\s]+$/}
+
end
@@ -2,5 +2,5 @@ class Comment < ActiveRecord::Base
belongs_to :user
belongs_to :article
-
+ validates :comment, :presence => true
end
View
@@ -3,14 +3,15 @@ class User < ActiveRecord::Base
has_many :articles
has_many :comments
- has_many :shared_articles,
- :class_name => "Article",
- :foreign_key => "user_id",
- :conditions =>"title like '%share%'"
-
attr_accessor :password
before_save :encrypt_password
+
+ validates :name, :presence => true,
+ :length => {:minimum => 1, :maximum => 20}
+
+ validates :address, :presence => true
+
validates :password, :presence => {:on => :create},
:confirmation => true
validates :email, :presence => true,
@@ -35,9 +36,6 @@ def self.authenticate(email, password)
def is_admin
if self.email == "farid@gmail.com"
- true
- else
- false
end
end
end
@@ -19,17 +19,8 @@
<td>
<%= link_to "Show", product_path(product.id) %>
- <% unless current_user.nil?%>
- <% if current_user.is_admin? %>
- <%= link_to "Edit", edit_product_path(product.id) %>
- <%= link_to 'Delete', product_path(product.id) , confirm: 'Do you want to delete this product?', method: :delete %>
- <% else%>
- <% if product.user_id == current_user.id %>
- <%= link_to "Edit", edit_product_path(product.id) %>
- <%= link_to 'Delete', product_path(product.id) , confirm: 'Do you want to delete this product?', method: :delete %>
- <% end %>
- <%end%>
- <%end%>
+
+
</td>
</tr>
<% end %>
@@ -2,8 +2,7 @@
<html>
<head>
<title>Store</title>
- <%= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" %>
- <%= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js" %>
+
<%= javascript_include_tag "jquery-rails.js" %>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
@@ -32,7 +32,7 @@
<%= render :partial => "home/menu_user"%><br/>
</td>
<% end %>
- <%= render :partial => "index"%><br/>
+ <%= render :partial => "categories/index"%><br/>
<td > <p class="error"><%= flash[:notice]|| flash[:error]%></p><br/><%= yield %></td>
</tr>
</table>
Oops, something went wrong.

0 comments on commit 77fd39c

Please sign in to comment.