<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>app/views/layouts/_admin_flash_boxes.html.haml</filename>
    </added>
    <added>
      <filename>test/integration/administrative_panel_test.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -4,7 +4,7 @@ class Admin::CategoriesController &lt; ApplicationController
   
   # GET /admin/categories
   def index
-    @categories = Category.all(:order =&gt; 'position ASC')
+    @categories = Category.list
   end
   
   # GET /admin/categories/1
@@ -15,9 +15,11 @@ class Admin::CategoriesController &lt; ApplicationController
   
   # POST /admin/categories
   def create
-    temp = Category.find_by_sql &quot;SELECT MAX(position) as position FROM categories&quot; 
-    @category = Category.new(:name =&gt; 'New category', :value =&gt; 'newcategory', :position =&gt; temp[0].position + 1)
+    max_position = Category.find_by_sql &quot;SELECT MAX(position) as position FROM categories&quot; 
+    max_id = Category.find_by_sql &quot;SELECT MAX(id) as id FROM categories&quot; 
+    @category = Category.new(:name =&gt; 'New category', :value =&gt; &quot;newcategory#{max_id[0].id + 1}&quot;, :position =&gt; max_position[0].position + 1)
     @category.save
+    flash_notice(&quot;Category has been added&quot;)
     
     respond_to do |format|
       format.html { redirect_to admin_categories_url }
@@ -28,11 +30,22 @@ class Admin::CategoriesController &lt; ApplicationController
   # PUT /admin/categories/1
   def update
     @category = Category.find(params[:id])
+    flash_notice(&quot;Category has been updated&quot;)
     
     respond_to do |format|
       if @category.update_attributes(:name =&gt; params[:name], :value =&gt; params[:url])
         format.html { redirect_to admin_categories_url }
         format.js # admin/categories/update.js.rjs
+      else
+        format.html { redirect_to admin_categories_url }
+        format.js {
+          render :update do |page|
+            @category.reload            
+            page.alert @category.errors.full_messages.join(&quot;\n&quot;)
+            page.replace(&quot;category_#{@category.id}&quot;, :partial =&gt; 'admin/categories/category', :category =&gt; @category)
+            page.sortable 'categoriesContainer', :tag =&gt; 'div', :url =&gt; saveorder_admin_categories_path
+          end
+        }
       end
     end
   end
@@ -43,6 +56,7 @@ class Admin::CategoriesController &lt; ApplicationController
       category = Category.find(id)
       category.update_attribute('position', position)
     end
+    flash_notice(&quot;Categories order changed. Saving ...&quot;)
     
     respond_to do |format|
       format.html { redirect_to admin_categories_url }
@@ -54,6 +68,7 @@ class Admin::CategoriesController &lt; ApplicationController
   def destroy
     @category = Category.find(params[:id])
     @category.destroy if @category.jobs.empty?
+    flash_notice(&quot;Category has been deleted&quot;)
     
     respond_to do |format|
       format.html { redirect_to admin_categories_url }</diff>
      <filename>app/controllers/admin/categories_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -15,6 +15,7 @@ class Admin::JobsController &lt; ApplicationController
   # PUT /admin/jobs/1
   def update
     @job = Job.find(params[:id])
+    flash_notice(&quot;Job has been activated/deactivated&quot;)
 
     respond_to do |format|
       if @job.update_attributes(:is_active =&gt; @job.is_active ? false : true)
@@ -28,6 +29,7 @@ class Admin::JobsController &lt; ApplicationController
   def destroy
     @job = Job.find(params[:id])
     @job.destroy
+    flash_notice(&quot;Job has been deleted&quot;)
     
     respond_to do |format|
       format.html { redirect_to admin_jobs_url }</diff>
      <filename>app/controllers/admin/jobs_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -20,6 +20,11 @@ class ApplicationController &lt; ActionController::Base
       redirect_to login_url
     end
   end
+  
+  def flash_notice(string)
+    flash[:notice] = string
+    flash.discard(:notice)
+  end
  
   protected
   def production?</diff>
      <filename>app/controllers/application.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,6 +4,6 @@ module Admin::CategoriesHelper
   end
   
   def show_save_category(category_id)
-    &quot;Element.show('saveCategory#{category_id}');Element.replace('messagesContainer', '&lt;div id=\&quot;messagesContainer\&quot; style=\&quot;display:none\&quot;&gt;Value changed. You must save the change!&lt;/div&gt;');Element.show('messagesContainer')&quot;
+    &quot;Element.show('saveCategory#{category_id}')&quot;
   end
 end</diff>
      <filename>app/helpers/admin/categories_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -22,4 +22,8 @@ module ApplicationHelper
       return content_tag(:div, error_msg || error_list.join(&quot;, &quot;), :class =&gt; &quot;error-message&quot;)
     end
   end
+  
+  def display_notice    
+    page.insert_html :after, 'footer', :partial =&gt; 'layouts/admin_flash_boxes'
+  end
 end</diff>
      <filename>app/helpers/application_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,9 @@
 class Category &lt; ActiveRecord::Base
   has_many :jobs
-
+  
+  validates_presence_of :name, :value
+  validates_uniqueness_of :value
+  
   def to_param
     self.value
   end</diff>
      <filename>app/models/category.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,8 +2,4 @@ page.insert_html :bottom, 'categoriesContainer', :partial =&gt; 'admin/categories/c
 page.sortable 'categoriesContainer', :tag =&gt; 'div', :url =&gt; saveorder_admin_categories_path
 @category = nil
 page.replace_html &quot;categories&quot;, :partial =&gt; 'admin/categories/list'
-page.replace_html &quot;messagesContainer&quot;, &quot;Category has been added&quot;
-page.show &quot;messagesContainer&quot;
-page.delay(3) do
-  page.visual_effect :fade, &quot;messagesContainer&quot; 
-end
\ No newline at end of file
+page.display_notice
\ No newline at end of file</diff>
      <filename>app/views/admin/categories/create.js.rjs</filename>
    </modified>
    <modified>
      <diff>@@ -1,12 +1,10 @@
 if @category.jobs.empty?
-  page[&quot;category_#{@category.id}&quot;].visual_effect :switch_off, &quot;category_#{@category.id}&quot;
-  page.remove &quot;category_#{@category.id}&quot;
-  page.replace_html &quot;categories&quot;, :partial =&gt; 'admin/categories/list'
-  page.replace_html &quot;messagesContainer&quot;, &quot;Category has been deleted&quot;
-  page.show &quot;messagesContainer&quot;
-  page.delay(3) do
-    page.visual_effect :fade, &quot;messagesContainer&quot; 
+  page[&quot;category_#{@category.id}&quot;].visual_effect :fade, &quot;category_#{@category.id}&quot;
+  page.delay(1) do
+    page.remove &quot;category_#{@category.id}&quot;
   end
+  page.replace_html &quot;categories&quot;, :partial =&gt; 'admin/categories/list'
+  page.display_notice
 else
   page.alert(&quot;You cannot delete this category because there are jobs in this category!&quot;)
 end
\ No newline at end of file</diff>
      <filename>app/views/admin/categories/destroy.js.rjs</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,2 @@
 page.replace_html &quot;categories&quot;, :partial =&gt; 'admin/categories/list'
-page.replace_html &quot;messagesContainer&quot;, &quot;Categories order changed. Saving ...&quot;
-page.show &quot;messagesContainer&quot;
-page.delay(3) do
-  page.visual_effect :fade, &quot;messagesContainer&quot; 
-end
+page.display_notice
\ No newline at end of file</diff>
      <filename>app/views/admin/categories/saveorder.js.rjs</filename>
    </modified>
    <modified>
      <diff>@@ -2,8 +2,4 @@ page[&quot;category_#{@category.id}&quot;].visual_effect :pulsate, &quot;category_#{@category.i
 page.hide &quot;saveCategory#{@category.id}&quot;
 @category = nil
 page.replace_html &quot;categories&quot;, :partial =&gt; 'admin/categories/list'
-page.replace_html &quot;messagesContainer&quot;, &quot;Category has been updated&quot;
-page.show &quot;messagesContainer&quot;
-page.delay(3) do
-  page.visual_effect :fade, &quot;messagesContainer&quot; 
-end
\ No newline at end of file
+page.display_notice
\ No newline at end of file</diff>
      <filename>app/views/admin/categories/update.js.rjs</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,2 @@
 page[&quot;job_#{@job.id}&quot;].visual_effect :fade, &quot;job_#{@job.id}&quot;
-page.replace_html &quot;messagesContainer&quot;, &quot;Job has been deleted&quot;
-page.show &quot;messagesContainer&quot;
-page.delay(3) do
-  page.visual_effect :fade, &quot;messagesContainer&quot; 
-end
\ No newline at end of file
+page.display_notice
\ No newline at end of file</diff>
      <filename>app/views/admin/jobs/destroy.js.rjs</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,2 @@
 page.replace &quot;activate_#{@job.id}&quot;, activation_image_tag(@job)
-page.replace_html &quot;messagesContainer&quot;, &quot;Job has been activated/deactivated&quot;
-page.show &quot;messagesContainer&quot;
-page.delay(3) do
-  page.visual_effect :fade, &quot;messagesContainer&quot; 
-end
\ No newline at end of file
+page.display_notice
\ No newline at end of file</diff>
      <filename>app/views/admin/jobs/update.js.rjs</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
 #header
   %h1#logo= link_to AppConfig.site_name, root_path
   - if logged_in?
-    %ul#top{:style =&gt; 'padding-top:50px'}
+    %ul#top{:style =&gt; 'padding-top:40px'}
       %li= link_to &quot;Pages&quot;, &quot;#&quot;
       = bull
       %li= link_to &quot;Categories&quot;, admin_categories_path
@@ -9,8 +9,6 @@
       %li= link_to &quot;Change your password&quot;, &quot;#&quot;
       = bull
       %li= link_to &quot;Logout&quot;, logout_path
-
-  = partial &quot;layouts/flash_boxes&quot;
-  
+ 
 - unless logged_in?
   #categs-nav
\ No newline at end of file</diff>
      <filename>app/views/layouts/_admin_header.html.haml</filename>
    </modified>
    <modified>
      <diff>@@ -19,5 +19,5 @@
       #content
         = yield
      
-    .footer
-    #messagesContainer{:style =&gt; 'display:none'}
\ No newline at end of file
+    #footer
+    = render :partial =&gt; 'layouts/admin_flash_boxes'
\ No newline at end of file</diff>
      <filename>app/views/layouts/admin.html.haml</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,6 @@
 .login_status
   - if logged_in?
     = &quot;You are logged as #{current_user.login} &quot; + link_to('Logout', logout_path)
+    = link_to '/ Admin tools', admin_path
   - else
     = link_to 'Login', login_path
\ No newline at end of file</diff>
      <filename>app/views/sessions/_login_status.html.haml</filename>
    </modified>
    <modified>
      <diff>@@ -1024,15 +1024,27 @@ div.footer {
     z-index:3000;
 }
 
-#messagesContainer {
+#notice_message {
     left:50%;
     margin-left:-150px;
     position:absolute;
     top:0pt;
     width:300px;
     background-color:#fff;
-    height:30px;
     border:8px solid #eeeeee;
     font-size:9px;
     padding-top:10px;
+    text-align:center;
+}
+
+#error_message {
+    left:50%;
+    margin-left:-150px;
+    position:absolute;
+    top:0pt;
+    width:300px;
+    background-color:#fff;
+    border:8px solid #ec0f0f;
+    font-size:9px;
+    padding-top:10px;
 }
\ No newline at end of file</diff>
      <filename>public/stylesheets/styles.css</filename>
    </modified>
    <modified>
      <diff>@@ -4,7 +4,7 @@ bob:
 
 mark:
   login: mark
-  password: a94a8fe5ccb19ba61c4c0873d391e987982fbbd3 # longtest
+  password: bf5a0cb861642b94cb8635dce9d197d375569e1f # longtest
 
 admin:
   login: admin</diff>
      <filename>test/fixtures/admins.yml</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
-full-time:
+fulltime:
   name: Full-time
   value: fulltime
 
-part-time:
+parttime:
   name: Part-time
   value: parttime</diff>
      <filename>test/fixtures/job_types.yml</filename>
    </modified>
    <modified>
      <diff>@@ -9,7 +9,7 @@ one:
   outside_location: 
   poster_email: temp@temp.us
   apply_online: false
-  job_type: full-time
+  job_type: fulltime
   category: programmer
   location: seatle
 
@@ -24,6 +24,6 @@ two:
   outside_location: 
   poster_email: admin@admin.sd
   apply_online: false
-  job_type: part-time
+  job_type: parttime
   category: designer
   location: tampa
\ No newline at end of file</diff>
      <filename>test/fixtures/jobs.yml</filename>
    </modified>
    <modified>
      <diff>@@ -23,21 +23,33 @@ class Admin::CategoriesControllerTest &lt; ActionController::TestCase
     assert_difference('Category.count') do
       xhr :post, :create
     end
+    assert_select_rjs :insert_html, :bottom, 'categoriesContainer'
   end
   
   def test_should_update_category    
     login_as(:admin)
-    xhr :put, :update, {:id =&gt; categories(:programmer).id, :name =&gt; &quot;New name&quot;}
+    get :index
+    xhr :put, :update, {:id =&gt; categories(:programmer).id, :name =&gt; &quot;New name&quot;, :url =&gt; 'new_value23'}
+    assert_response :success
     categories(:programmer).reload
     assert_equal('New name', categories(:programmer).name)
   end
   
+  def test_should_not_update_category
+    login_as(:mark)
+    category = categories(:programmer)
+    xhr :put, :update, {:id =&gt; categories(:programmer).id, :name =&gt; &quot;Programmers&quot;, :url =&gt; 'new_value23'}
+    categories(:programmer).reload
+    assert_equal category.name, categories(:programmer).name
+  end
+  
   def test_should_delete_category_without_jobs
     login_as(:bob)
     assert_difference('Category.count', -1) do
       xhr :delete, :destroy, :id =&gt; categories(:administrator).id
     end    
     assert_response :success
+    assert_select_rjs :remove, &quot;category_#{categories(:administrator).id}&quot;
   end
   
   def test_should_not_delete_category_with_jobs</diff>
      <filename>test/functional/admin/categories_controller_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,10 +1,12 @@
 require 'test_helper'
 
 class AdminTest &lt; ActiveSupport::TestCase
-  self.use_instantiated_fixtures  = true
 
   def test_authentication
-    assert_equal @mark, Admin.authenticate(&quot;mark&quot;, &quot;longtest&quot;)
+    
+    assert_not_nil Admin.authenticate(&quot;admin&quot;, &quot;admin&quot;)
+    
+    assert_equal admins(:mark), Admin.authenticate(&quot;mark&quot;, &quot;longtest&quot;)
     
     # wrong username
     assert_nil Admin.authenticate(&quot;adminnn&quot;, &quot;admin&quot;) </diff>
      <filename>test/unit/admin_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>fbcb87c1c5134dc216a68f9a0ac78a63dab51bd7</id>
    </parent>
  </parents>
  <author>
    <name>wlodars</name>
    <email>wlodars@gmail.com</email>
  </author>
  <url>http://github.com/jcnetdev/jobberrails/commit/2eb39d7be5b263f081e4cf0f8b43314dbd8679a9</url>
  <id>2eb39d7be5b263f081e4cf0f8b43314dbd8679a9</id>
  <committed-date>2008-07-08T03:54:15-07:00</committed-date>
  <authored-date>2008-07-08T03:54:15-07:00</authored-date>
  <message>Add category validation, made some fixes and add integration tests</message>
  <tree>b430b3ea3289fbab7a43b94eec62a3e5772b41c9</tree>
  <committer>
    <name>wlodars</name>
    <email>wlodars@gmail.com</email>
  </committer>
</commit>
