Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: test/unit/section_test.rb
- ===================================================================
- --- test/unit/section_test.rb (revision 2079)
- test/unit/section_test.rb (working copy)
- @@ -2,7 2,7 @@
- class SectionTest < Test::Unit::TestCase
- fixtures :sections, :contents, :assigned_sections, :sites, :users
- -
- def test_find_or_create_sanity_check
- assert_no_difference Section, :count do
- assert_equal sections(:home), sites(:first).sections.find_or_create_by_path('')
- Index: test/functional/admin/templates_controller_test.rb
- ===================================================================
- --- test/functional/admin/templates_controller_test.rb (revision 2079)
- test/functional/admin/templates_controller_test.rb (working copy)
- @@ -13,6 13,7 @@
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
- login_as :quentin
- users(:quentin).is_mephisto_admin
- end
- def test_should_show_edit_template_form
- Index: test/functional/admin/settings_controller_test.rb
- ===================================================================
- --- test/functional/admin/settings_controller_test.rb (revision 2079)
- test/functional/admin/settings_controller_test.rb (working copy)
- @@ -10,15 10,28 @@
- @controller = Admin::SettingsController.new
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
- - login_as :quentin
- end
- def test_should_not_show_settings
- login_as :arthur
- get :index
- assert_redirected_to :controller => 'account', :action => 'login'
- users(:arthur).is_admin_of sites(:hostess) # wrong site
- get :index
- assert_redirected_to :controller => 'account', :action => 'login'
- end
- def test_should_show_settings
- login_as :quentin
- users(:quentin).is_admin_of sites(:first)
- get :index
- assert_tag 'input', :attributes => { :id => 'site_title', :value => sites(:first).title }
- end
- def test_should_update_settings
- login_as :quentin
- users(:quentin).is_mephisto_admin
- post :update, :site => { :title => 'foo' }
- assert_equal 'foo', sites(:first).title
- assert_redirected_to :action => 'index'
- Index: test/functional/admin/users_controller_test.rb
- ===================================================================
- --- test/functional/admin/users_controller_test.rb (revision 2079)
- test/functional/admin/users_controller_test.rb (working copy)
- @@ -11,6 11,7 @@
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
- login_as :quentin
- users(:quentin).is_mephisto_admin
- end
- def test_should_not_explode_on_index
- @@ -18,6 19,35 @@
- assert_response :success
- end
- def test_should_require_login_for_index
- login_as :arthur
- get :index
- assert_redirected_to :controller => 'account', :action => 'login'
- users(:arthur).is_admin_of sites(:hostess) # wrong site
- get :index
- assert_redirected_to :controller => 'account', :action => 'login'
- end
- def test_should_require_login_for_create
- login_as :arthur
- post :create, :user => { :login => 'bob', :email => 'foo', :password => 'testy', :password_confirmation => 'testy' }
- assert_redirected_to :controller => 'account', :action => 'login'
- end
- def test_should_require_login_for_update
- login_as :arthur
- post :update, :id => users(:quentin).id, :user => { :email => 'foo', :password => 'testy', :password_confirmation => 'testy' }
- assert_redirected_to :controller => 'account', :action => 'login'
- end
- def test_site_admin_can_access_index
- login_as :arthur
- users(:arthur).is_admin_of sites(:first)
- get :index
- assert_response :success
- end
- def test_should_create_user
- assert_difference User, :count do
- post :create, :user => { :login => 'bob', :email => 'foo', :password => 'testy', :password_confirmation => 'testy' }
- Index: test/functional/admin/assets_controller_test.rb
- ===================================================================
- --- test/functional/admin/assets_controller_test.rb (revision 2079)
- test/functional/admin/assets_controller_test.rb (working copy)
- @@ -12,6 12,7 @@
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
- login_as :quentin
- users(:quentin).is_mephisto_admin
- end
- def test_should_visit_index
- Index: test/functional/admin/articles_controller_test.rb
- ===================================================================
- --- test/functional/admin/articles_controller_test.rb (revision 2079)
- test/functional/admin/articles_controller_test.rb (working copy)
- @@ -12,6 12,7 @@
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
- login_as :quentin
- users(:quentin).is_mephisto_admin
- FileUtils.mkdir_p ASSET_PATH
- end
- @@ -215,6 216,7 @@
- def test_should_update_article_with_given_sections
- login_as :arthur
- users(:arthur).is_member_of sites(:first)
- assert_difference AssignedSection, :count, -1 do
- post :update, :id => contents(:welcome).id, :article => { :title => "My Red Hot Car", :excerpt => "Blah Blah", :body => "Blah Blah", :section_ids => [sections(:home).id] }, :submit => :save
- assert_redirected_to :action => 'index'
- Index: test/functional/admin/assets_controller_upload_test.rb
- ===================================================================
- --- test/functional/admin/assets_controller_upload_test.rb (revision 2079)
- test/functional/admin/assets_controller_upload_test.rb (working copy)
- @@ -13,6 13,7 @@
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
- login_as :quentin
- users(:quentin).is_mephisto_admin
- Fixtures.delete_existing_fixtures_for(Asset.connection, :assets)
- end
- Index: test/functional/admin/overview_controller_test.rb
- ===================================================================
- --- test/functional/admin/overview_controller_test.rb (revision 2079)
- test/functional/admin/overview_controller_test.rb (working copy)
- @@ -11,6 11,7 @@
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
- login_as :quentin
- users(:quentin).is_mephisto_admin
- end
- def test_routing
- Index: test/functional/admin/sections_controller_test.rb
- ===================================================================
- --- test/functional/admin/sections_controller_test.rb (revision 2079)
- test/functional/admin/sections_controller_test.rb (working copy)
- @@ -12,6 12,7 @@
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
- login_as :quentin
- users(:quentin).is_mephisto_admin
- end
- def test_should_list_sections
- Index: test/functional/admin/design_controller_test.rb
- ===================================================================
- --- test/functional/admin/design_controller_test.rb (revision 2079)
- test/functional/admin/design_controller_test.rb (working copy)
- @@ -13,6 13,7 @@
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
- login_as :quentin
- users(:quentin).is_mephisto_admin
- end
- def test_should_show_all_templates
- @@ -26,7 27,19 @@
- assert_equal 'this is liquid', sites(:first).templates['my_little_pony'].read
- assert_redirected_to :controller => 'admin/templates', :action => 'edit', :filename => 'my_little_pony.liquid'
- end
- def test_should_not_show_all_templates
- login_as :arthur
- get :index
- assert_redirected_to :controller => 'account', :action => 'login'
- end
- def test_should_not_create_template
- login_as :arthur
- post :create, :data => 'this is liquid', :filename => 'my_little_pony'
- assert_redirected_to :controller => 'account', :action => 'login'
- end
- def test_should_create_css
- post :create, :data => 'body {}', :filename => 'styles.css'
- assert sites(:first).resources['styles.css'].file?
- Index: test/functional/admin/resources_controller_test.rb
- ===================================================================
- --- test/functional/admin/resources_controller_test.rb (revision 2079)
- test/functional/admin/resources_controller_test.rb (working copy)
- @@ -12,6 12,7 @@
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
- login_as :quentin
- users(:quentin).is_mephisto_admin
- end
- def test_should_show_edit_resource_form
- Index: test/integration/caching_test.rb
- ===================================================================
- --- test/integration/caching_test.rb (revision 2079)
- test/integration/caching_test.rb (working copy)
- @@ -182,6 182,7 @@
- assert_expires_pages section_url_for(:about), feed_url_for(:about), section_url_for(:about, :site_map) do
- login_as :quentin do |writer|
- users(:quentin).is_mephisto_admin
- writer.update_section sections(:about), :name => 'ABOUT'
- end
- end
- @@ -191,6 192,7 @@
- visit_sections_and_feeds_with visit
- assert_expires_pages section_url_for(:home), section_url_for(:about), feed_url_for(:home), feed_url_for(:about) do
- login_as :quentin do |writer|
- users(:quentin).is_mephisto_admin
- writer.update_template sites(:first).templates[:error], '<p>error!</p>'
- end
- end
- Index: app/models/user.rb
- ===================================================================
- --- app/models/user.rb (revision 2079)
- app/models/user.rb (working copy)
- @@ -1,6 1,7 @@
- class User < UserAuth
- has_many :articles
- acts_as_paranoid
- acts_as_authorized_user
- def to_liquid
- [:login, :email].inject({}) { |hsh, attr_name| hsh.merge attr_name.to_s => send(attr_name) }
- Index: app/models/asset.rb
- ===================================================================
- --- app/models/asset.rb (revision 2079)
- app/models/asset.rb (working copy)
- @@ -44,6 44,8 @@
- include Mephisto::TaggableMethods
- acts_as_authorizable
- belongs_to :site
- acts_as_attachment :storage => :file_system, :thumbnails => { :thumb => '120>', :tiny => '50>' }, :max_size => 30.megabytes
- before_validation_on_create :set_site_from_parent
- Index: app/models/article.rb
- ===================================================================
- --- app/models/article.rb (revision 2079)
- app/models/article.rb (working copy)
- @@ -28,6 28,8 @@
- end
- end
- acts_as_authorizable
- has_many :assigned_sections, :dependent => :destroy
- has_many :sections, :through => :assigned_sections, :order => 'sections.name'
- has_many :events, :order => 'created_at desc', :dependent => :delete_all
- Index: app/models/section.rb
- ===================================================================
- --- app/models/section.rb (revision 2079)
- app/models/section.rb (working copy)
- @@ -4,6 4,9 @@
- validates_presence_of :name, :site_id
- validates_exclusion_of :path, :in => [nil]
- validates_uniqueness_of :path, :case_sensitive => false, :scope => :site_id
- acts_as_authorizable
- belongs_to :site
- has_many :assigned_sections, :dependent => :delete_all
- has_many :articles, :order => 'position', :through => :assigned_sections do
- Index: app/models/site.rb
- ===================================================================
- --- app/models/site.rb (revision 2079)
- app/models/site.rb (working copy)
- @@ -2,6 2,8 @@
- include Mephisto::Attachments::AttachmentMethods
- cattr_accessor :multi_sites_enabled
- acts_as_authorizable
- has_many :sections do
- def home
- find_by_path ''
- @@ -49,6 51,14 @@
- end
- protected
- def accepts_role?( role_name, user )
- if role_name == 'member'
- user.has_role?('mephisto_admin') or user.has_role?('admin', self) or user.has_role?('member', self)
- else
- super
- end
- end
- def downcase_host
- self.host = host.to_s.downcase
- end
- Index: app/controllers/admin/base_controller.rb
- ===================================================================
- --- app/controllers/admin/base_controller.rb (revision 2079)
- app/controllers/admin/base_controller.rb (working copy)
- @@ -1,5 1,6 @@
- class Admin::BaseController < ApplicationController
- include AuthenticatedSystem
- before_filter :login_from_cookie
- - before_filter :login_required, :except => :feed
- permit "member of site", :except => :feed
- # before_filter :login_required, :except => :feed
- end
- Index: app/controllers/admin/templates_controller.rb
- ===================================================================
- --- app/controllers/admin/templates_controller.rb (revision 2079)
- app/controllers/admin/templates_controller.rb (working copy)
- @@ -1,4 1,6 @@
- class Admin::TemplatesController < Admin::BaseController
- # permit "mephisto_admin or admin of site"
- verify :params => :filename, :only => [:edit, :update],
- :add_flash => { :error => 'Template required' },
- :redirect_to => { :action => 'index' }
- Index: app/controllers/admin/settings_controller.rb
- ===================================================================
- --- app/controllers/admin/settings_controller.rb (revision 2079)
- app/controllers/admin/settings_controller.rb (working copy)
- @@ -1,6 1,6 @@
- class Admin::SettingsController < Admin::BaseController
- - before_filter :site
- -
- permit "mephisto_admin or admin of site"
- def update
- if site.update_attributes params[:site]
- redirect_to :action => 'index'
- Index: app/controllers/admin/users_controller.rb
- ===================================================================
- --- app/controllers/admin/users_controller.rb (revision 2079)
- app/controllers/admin/users_controller.rb (working copy)
- @@ -1,4 1,6 @@
- class Admin::UsersController < Admin::BaseController
- permit "mephisto_admin or admin of site"
- before_filter :find_all_users, :only => [:index, :show, :new]
- before_filter :find_user, :only => [:show, :update]
- def index
- Index: app/controllers/admin/sections_controller.rb
- ===================================================================
- --- app/controllers/admin/sections_controller.rb (revision 2079)
- app/controllers/admin/sections_controller.rb (working copy)
- @@ -1,4 1,6 @@
- class Admin::SectionsController < Admin::BaseController
- permit "mephisto_admin or admin of site"
- cache_sweeper :section_sweeper, :except => :index
- before_filter :find_and_sort_templates, :only => [:index, :edit]
- before_filter :find_and_reorder_sections, :only => [:index, :edit]
- Index: app/controllers/admin/design_controller.rb
- ===================================================================
- --- app/controllers/admin/design_controller.rb (revision 2079)
- app/controllers/admin/design_controller.rb (working copy)
- @@ -1,4 1,6 @@
- class Admin::DesignController < Admin::BaseController
- permit "mephisto_admin or admin of site"
- def create
- if params[:filename].blank? || params[:data].blank?
- render :action => 'index'
- Index: app/views/layouts/application.rhtml
- ===================================================================
- --- app/views/layouts/application.rhtml (revision 2079)
- app/views/layouts/application.rhtml (working copy)
- @@ -13,7 13,9 @@
- <div id="header">
- <ul id="sec-nav">
- <li><strong><%= link_to 'Blog', section_path([]) %></strong></li>
- <% if permit? "mephisto_admin or admin of site" %>
- <li><%= link_to 'Settings', :controller => 'settings' %></li>
- <% end %>
- <li><%= link_to 'Account', :controller => 'users', :action => 'show', :id => current_user %></li>
- <li><%= link_to 'Logout', :controller => '/account', :action => 'logout' %></li>
- </ul>
- @@ -28,11 30,13 @@
- <li><%= link_to 'Articles', :controller => '/admin/articles' %></li>
- <li><%= link_to 'Assets', :controller => '/admin/assets' %></li>
- </ul>
- - <ul id="nav-r">
- - <li><%= link_to 'Sections', :controller => '/admin/sections' %></li>
- - <li><%= link_to 'Design', :controller => '/admin/design' %></li>
- - <li><%= link_to "Users", :controller => "users" %></li>
- - </ul>
- <% if permit? "mephisto_admin or admin of site" %>
- <ul id="nav-r">
- <li><%= link_to 'Sections', :controller => '/admin/sections' %></li>
- <li><%= link_to 'Design', :controller => '/admin/design' %></li>
- <li><%= link_to "Users", :controller => "users" %></li>
- </ul>
- <% end %>
- <% end -%>
- </div>
- <!-- /div.nav -->
- Index: app/views/admin/overview/index.rhtml
- ===================================================================
- --- app/views/admin/overview/index.rhtml (revision 2079)
- app/views/admin/overview/index.rhtml (working copy)
- @@ -3,7 3,9 @@
- <div id="page-nav">
- <ul id="act-nav" class="clear">
- <li><%= link_to "Create new article", :controller => 'articles', :action => "new" %></li>
- <% if permit? "mephisto_admin or admin of site" %>
- <li><%= link_to "Create new section", :controller => 'sections' %></li>
- <% end %>
- <% if @articles.any? -%>
- <li><%= link_to "Moderate Comments", :controller => 'comments' %></li>
- Index: config/environment.rb
- ===================================================================
- --- config/environment.rb (revision 2079)
- config/environment.rb (working copy)
- @@ -33,6 33,11 @@
- config.active_record.schema_format = :ruby
- end
- # requires Authorization plugin
- AUTHORIZATION_MIXIN = 'object_roles'
- DEFAULT_REDIRECTION_HASH = { :controller => '/account', :action => 'login' }
- STORE_LOCATION_METHOD = :store_location
- # Include your application configuration below
- require 'mephisto_init'
- @@ -43,4 48,4 @@
- # Mephisto::SweeperMethods.cache_sweeper_tracing = true
- # Enable if you want to host multiple sites on this app
- -# Site.multi_sites_enabled = true
- \ No newline at end of file
- Site.multi_sites_enabled = true
- \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement