Change role structure
Still needs to: change the views and create sub_roles in the dev.rake
This commit is contained in:
1 parent
e0cdedfa2e
commit
b7ac5478b4
45 files changed
+608
-492
No files matched your search
@@ -1,47 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe DesignController do
|
||||
|
||||
describe "GET 'index'" do
|
||||
it "should be successful" do
|
||||
get 'index'
|
||||
response.should be_success
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET 'new'" do
|
||||
it "should be successful" do
|
||||
get 'new'
|
||||
response.should be_success
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET 'update'" do
|
||||
it "should be successful" do
|
||||
get 'update'
|
||||
response.should be_success
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET 'edit'" do
|
||||
it "should be successful" do
|
||||
get 'edit'
|
||||
response.should be_success
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET 'destroy'" do
|
||||
it "should be successful" do
|
||||
get 'destroy'
|
||||
response.should be_success
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET 'create'" do
|
||||
it "should be successful" do
|
||||
get 'create'
|
||||
response.should be_success
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,15 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
# Specs in this file have access to a helper object that includes
|
||||
# the DesignHelper. For example:
|
||||
#
|
||||
# describe DesignHelper do
|
||||
# describe "string concat" do
|
||||
# it "concats two strings with spaces" do
|
||||
# helper.concat_strings("this","that").should == "this that"
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
describe DesignHelper do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
@@ -1,5 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Design do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
@@ -0,0 +1,109 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Role do
|
||||
before do
|
||||
@role = Role.create(:key => 'teacher',
|
||||
:i18n_variable => {:key => 'teacher', :en => 'Teacher', :zh_tw => 'Teacher in Chinese', :document_class => 'Role'},
|
||||
:sub_roles => [{:key => 'undergrad',
|
||||
:attribute_fields => [{:key => 'department'},
|
||||
{:key => 'room'}]},
|
||||
{:key => 'master',
|
||||
:attribute_fields => [{:key => 'department'}]}])
|
||||
end
|
||||
describe 'New role' do
|
||||
describe '#Role' do
|
||||
it 'should have :built_in false' do
|
||||
@role.built_in.should be false
|
||||
end
|
||||
it 'should have :disabled false' do
|
||||
@role.disabled.should be false
|
||||
end
|
||||
it 'should have a i18n_variable' do
|
||||
@role.i18n_variable.should be_an_instance_of I18nVariable
|
||||
end
|
||||
it 'should create sub_roles' do
|
||||
@role.should have(2).sub_roles
|
||||
end
|
||||
it 'should create attribute_fields' do
|
||||
@role.sub_roles[1].should have(1).attribute_fields
|
||||
end
|
||||
end
|
||||
describe '#SubRole' do
|
||||
it 'should have :built_in false' do
|
||||
@role.sub_roles[0].built_in.should be false
|
||||
end
|
||||
it 'should have :disabled false' do
|
||||
@role.sub_roles[0].disabled.should be false
|
||||
end
|
||||
end
|
||||
describe '#AttributeField' do
|
||||
it 'should have :built_in false' do
|
||||
@role.sub_roles[0].attribute_fields[0].built_in.should be false
|
||||
end
|
||||
it 'should have :disabled false' do
|
||||
@role.sub_roles[0].attribute_fields[0].disabled.should be false
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'Edit role' do
|
||||
describe '#Role' do
|
||||
before do
|
||||
@role.update_attributes({:key => 'student', :i18n_variable => {:en => 'Student'},
|
||||
:sub_roles => [{:key => 'new',
|
||||
:attribute_fields => [{:key => 'bob'},
|
||||
{:key => 'great'}]},
|
||||
{:id => @role.sub_roles[0].id},
|
||||
{:id => @role.sub_roles[1].id}]})
|
||||
end
|
||||
it 'should not be the old :key' do
|
||||
@role.key.should_not == 'teacher'
|
||||
end
|
||||
it 'should be the new :key' do
|
||||
@role.key.should == 'student'
|
||||
end
|
||||
it 'should not be the old :i18n_variable[:en]' do
|
||||
@role.i18n_variable[:en].should_not == 'Teacher'
|
||||
end
|
||||
it 'should be the new :i18n_variable[:en]' do
|
||||
@role.i18n_variable[:en].should == 'Student'
|
||||
end
|
||||
it 'should have one more SubRole' do
|
||||
@role.should have(3).sub_roles
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'Destroy' do
|
||||
describe '#AttributeField' do
|
||||
before do
|
||||
@role.update_attributes(:key => 'teacher',
|
||||
:i18n_variable => {:key => 'teacher', :en => 'Teacher', :zh_tw => 'Teacher in Chinese', :document_class => 'Role'},
|
||||
:sub_roles_attributes => {'0' => {:id => @role.sub_roles[0].id,
|
||||
:key => 'undergrad',
|
||||
:attribute_fields_attributes => {'0' => {:id => @role.sub_roles[0].attribute_fields[0].id,
|
||||
:key => 'department'},
|
||||
'1' => {:id => @role.sub_roles[0].attribute_fields[1].id,
|
||||
:key => 'room', :_destroy => true}}}})
|
||||
end
|
||||
it 'should have only one AttributeField for the first SubRole' do
|
||||
@role.sub_roles[0].should have(1).attribute_fields
|
||||
end
|
||||
end
|
||||
describe '#I18nVariable' do
|
||||
before do
|
||||
@role.update_attributes(:key => 'teacher',
|
||||
:i18n_variable_attributes => {:id => @role.i18n_variable.id, :key => 'teacher', :en => 'Teacher', :zh_tw => 'Teacher in Chinese', :document_class => 'Role', :_destroy => true})
|
||||
end
|
||||
it 'should not have a I18nVariable' do
|
||||
@role.i18n_variable.should_not be_an_instance_of I18nVariable
|
||||
end
|
||||
end
|
||||
describe '#Role' do
|
||||
it 'should destroy the I18nVariable' do
|
||||
id = @role.i18n_variable.id
|
||||
@role.destroy
|
||||
lambda {I18nVariable.find(id)}.should raise_error
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,4 +0,0 @@
|
||||
--colour
|
||||
--format progress
|
||||
--loadby mtime
|
||||
--reverse
|
||||
+53
-22
@@ -1,27 +1,58 @@
|
||||
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
||||
ENV["RAILS_ENV"] ||= 'test'
|
||||
require File.expand_path("../../config/environment", __FILE__)
|
||||
require 'rspec/rails'
|
||||
require 'rubygems'
|
||||
require 'spork'
|
||||
|
||||
# Requires supporting ruby files with custom matchers and macros, etc,
|
||||
# in spec/support/ and its subdirectories.
|
||||
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
|
||||
Spork.prefork do
|
||||
# Loading more in this block will cause your tests to run faster. However,
|
||||
# if you change any configuration or code from libraries loaded here, you'll
|
||||
# need to restart spork for it take effect.
|
||||
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
||||
ENV["RAILS_ENV"] ||= 'test'
|
||||
require File.expand_path("../../config/environment", __FILE__)
|
||||
require 'rspec/rails'
|
||||
require 'rspec/autorun'
|
||||
|
||||
RSpec.configure do |config|
|
||||
# == Mock Framework
|
||||
#
|
||||
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
||||
#
|
||||
# config.mock_with :mocha
|
||||
# config.mock_with :flexmock
|
||||
# config.mock_with :rr
|
||||
config.mock_with :rspec
|
||||
# Requires supporting ruby files with custom matchers and macros, etc,
|
||||
# in spec/support/ and its subdirectories.
|
||||
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
|
||||
|
||||
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
||||
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
||||
RSpec.configure do |config|
|
||||
# == Mock Framework
|
||||
#
|
||||
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
||||
#
|
||||
# config.mock_with :mocha
|
||||
# config.mock_with :flexmock
|
||||
# config.mock_with :rr
|
||||
config.mock_with :rspec
|
||||
|
||||
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
||||
# examples within a transaction, remove the following line or assign false
|
||||
# instead of true.
|
||||
config.use_transactional_fixtures = true
|
||||
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
||||
# config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
||||
|
||||
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
||||
# examples within a transaction, remove the following line or assign false
|
||||
# instead of true.
|
||||
# config.use_transactional_fixtures = true
|
||||
|
||||
# If true, the base class of anonymous controllers will be inferred
|
||||
# automatically. This will be the default behavior in future versions of
|
||||
# rspec-rails.
|
||||
config.infer_base_class_for_anonymous_controllers = false
|
||||
end
|
||||
end
|
||||
|
||||
Spork.each_run do
|
||||
# This code will be run each time you run your specs.
|
||||
load "#{Rails.root}/config/routes.rb"
|
||||
Dir["#{Rails.root}/app/**/*.rb"].each { |f| load f }
|
||||
end
|
||||
|
||||
# --- Instructions ---
|
||||
# - Sort through your spec_helper file. Place as much environment loading
|
||||
# code that you don't normally modify during development in the
|
||||
# Spork.prefork block.
|
||||
# - Place the rest under Spork.each_run block
|
||||
# - Any code that is left outside of the blocks will be ran during preforking
|
||||
# and during each_run!
|
||||
# - These instructions should self-destruct in 10 seconds. If they don't,
|
||||
# feel free to delete them.
|
||||
#
|
||||
@@ -1,5 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "design/create.html.erb" do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
@@ -1,5 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "design/destroy.html.erb" do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
@@ -1,5 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "design/edit.html.erb" do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
@@ -1,5 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "design/index.html.erb" do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
@@ -1,5 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "design/new.html.erb" do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
@@ -1,5 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "design/update.html.erb" do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
Reference in new issue
Block a user