OSDN Git Service

アイテムマスタ設定に権限を追加
authorTaro Matsuzawa aka. btm <btm@tech.email.ne.jp>
Mon, 15 Aug 2011 08:51:08 +0000 (17:51 +0900)
committerTaro Matsuzawa aka. btm <btm@tech.email.ne.jp>
Mon, 15 Aug 2011 08:51:08 +0000 (17:51 +0900)
app/controllers/admin/service_cooperations_controller.rb
app/controllers/admin/service_cooperations_templates_controller.rb
db/migrate/20110815083247_add_data_functions_service_cooperations.rb [new file with mode: 0644]
spec/controllers/admin/service_cooperations_controller_spec.rb
spec/controllers/admin/service_cooperations_templates_controller_spec.rb

index d4f454b..0d17d69 100644 (file)
@@ -1,6 +1,8 @@
+# -*- coding: utf-8 -*-
 require "json"
 
 class Admin::ServiceCooperationsController < Admin::BaseController
+  before_filter :admin_permission_check_service_cooperation
 
   def index
     @services = ServiceCooperation.all
@@ -42,6 +44,8 @@ class Admin::ServiceCooperationsController < Admin::BaseController
         json = JSON::pretty_generate(data)
         render :text => json.to_s
       end
+    else
+      render :text => ""
     end
   end
 
index 849f687..3057d61 100644 (file)
@@ -1,4 +1,6 @@
+# -*- coding: utf-8 -*-
 class Admin::ServiceCooperationsTemplatesController < Admin::BaseController
+  before_filter :admin_permission_check_service_cooperation
 
   def index
     @templates = ServiceCooperationsTemplate.all
diff --git a/db/migrate/20110815083247_add_data_functions_service_cooperations.rb b/db/migrate/20110815083247_add_data_functions_service_cooperations.rb
new file mode 100644 (file)
index 0000000..17a7f6f
--- /dev/null
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+class AddDataFunctionsServiceCooperations < ActiveRecord::Migration
+  def self.up
+    Function.create(:name => 'アイテムマスタ設定', :code => 'service_cooperation', :position => 1005)
+    f = Function.find_by_code('service_cooperation')
+    now = ActiveRecord::Base.connection.quote(Time.now.utc)
+    Authority.find(:all).each do |auth|
+      execute("INSERT INTO authorities_functions (authority_id, create_at, function_id, update_at) VALUES (#{auth.id}, #{now}, #{f.id}, #{now})")
+    end
+  end
+
+  def self.down
+    f = Function.find_by_code('service_cooperation')
+    Authority.find(:all).each do |auth|
+      AuthoritiesFunction.delete_all(["authority_id = :authority_id and function_id = :function_id", {:authority_id => auth.id, :function_id => f.id}])
+    end
+    f.delete
+  end
+end
index 731c0aa..d4a6da4 100644 (file)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 require 'spec_helper'
 
 describe Admin::ServiceCooperationsController do
@@ -5,7 +6,7 @@ describe Admin::ServiceCooperationsController do
   
   before do
     session[:admin_user] = admin_users(:admin10)
-    @controller.class.skip_before_filter :admin_permission_check_template
+    @controller.class.skip_before_filter :admin_permission_check_service_cooperation
   end
 
   describe "GET 'index'管理画面サービス一覧ページ" do