Skip to content

Commit

Permalink
fixed conflicts
Browse files Browse the repository at this point in the history
Merge branch 'master' of git://github.com/thewordnerd/feather into thewordnerd/master

Conflicts:

	config/init.rb
	spec/controllers/admin/articles_spec.rb
	spec/models/user_spec.rb
  • Loading branch information
El Draper committed Jul 18, 2008
2 parents eafb186 + 658fab8 commit d9fdcdc
Show file tree
Hide file tree
Showing 32 changed files with 383 additions and 849 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
config/database.yml
config/database.yml*
db/*.sqlite3
app/plugins/*
public/plugins*
Expand Down
29 changes: 0 additions & 29 deletions app/controllers/admin/sessions.rb

This file was deleted.

51 changes: 0 additions & 51 deletions app/controllers/admin/users.rb

This file was deleted.

2 changes: 1 addition & 1 deletion app/controllers/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Application < Merb::Controller
before :load_plugins
before :fire_before_event
before :fix_cache_issue_with_merb_093

##
# This just makes sure that params[:format] isn't null, to get around the merb 0.9.3 cache issue
def fix_cache_issue_with_merb_093
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/global_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def menu_items
items << {:text => "Articles", :url => url(:admin_articles)}
items << {:text => "Plugins", :url => url(:admin_plugins)}
items << {:text => "Settings", :url => url(:admin_configurations)}
items << {:text => "Users", :url => url(:admin_users)}
items << {:text => "Users", :url => url(:users)}
if self.current_user == :false
items << {:text => "Login", :url => url(:login)}
else
Expand Down
36 changes: 2 additions & 34 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,39 +1,11 @@
require 'digest/sha1'
begin
require File.join(File.dirname(__FILE__), '..', '..', "lib", "authenticated_system", "authenticated_dependencies")
rescue
nil
end
class User
include DataMapper::Validate
include AuthenticatedSystem::Model
include DataMapper::Resource

attr_accessor :password, :password_confirmation
include MerbAuth::Adapter::DataMapper
include MerbAuth::Adapter::DataMapper::DefaultModelSetup

property :id, Integer, :key => true, :serial => true
property :login, String
property :email, String, :length => 255
property :crypted_password, String
property :salt, String
property :remember_token_expires_at, DateTime
property :remember_token, String
property :time_zone, String
property :created_at, DateTime
property :updated_at, DateTime
property :name, String
property :default_formatter, String

validates_length :login, :within => 3..40
validates_is_unique :login
validates_present :password, :if => :password_required?
validates_present :password_confirmation, :if => :password_required?
validates_length :password, :within => 4..40, :if => :password_required?
validates_is_confirmed :password, :groups => :create
validates_present :email

before :save, :encrypt_password

after :save, :set_create_activity
after :save, :set_update_activity

Expand All @@ -52,8 +24,4 @@ def set_update_activity
a.save
end
end

def login=(value);
attribute_set :login, value.downcase unless value.nil?
end
end
7 changes: 0 additions & 7 deletions app/views/admin/users/_user.html.erb

This file was deleted.

1 change: 1 addition & 0 deletions autotest/discover.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Autotest.add_discovery { "merb" }
149 changes: 149 additions & 0 deletions autotest/merb.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# Adapted from Autotest::Rails
require 'autotest'

class Autotest::Merb < Autotest

# +model_tests_dir+:: the directory to find model-centric tests
# +controller_tests_dir+:: the directory to find controller-centric tests
# +view_tests_dir+:: the directory to find view-centric tests
# +fixtures_dir+:: the directory to find fixtures in
attr_accessor :model_tests_dir, :controller_tests_dir, :view_tests_dir, :fixtures_dir

def initialize
super

initialize_test_layout

# Ignore any happenings in these directories
add_exception %r%^\./(?:doc|log|public|tmp)%

# Ignore any mappings that Autotest may have already set up
clear_mappings

# Any changes to a file in the root of the 'lib' directory will run any
# model test with a corresponding name.
add_mapping %r%^lib\/.*\.rb% do |filename, _|
files_matching Regexp.new(["^#{model_test_for(filename)}$"])
end

# Any changes to a fixture will run corresponding view, controller and
# model tests
add_mapping %r%^#{fixtures_dir}/(.*)s.yml% do |_, m|
[
model_test_for(m[1]),
controller_test_for(m[1]),
view_test_for(m[1])
]
end

# Any change to a test or test will cause it to be run
add_mapping %r%^test/(unit|models|integration|controllers|views|functional)/.*rb$% do |filename, _|
filename
end

# Any change to a model will cause it's corresponding test to be run
add_mapping %r%^app/models/(.*)\.rb$% do |_, m|
model_test_for(m[1])
end

# Any change to the global helper will result in all view and controller
# tests being run
add_mapping %r%^app/helpers/global_helpers.rb% do
files_matching %r%^test/(views|functional|controllers)/.*_test\.rb$%
end

# Any change to a helper will run it's corresponding view and controller
# tests, unless the helper is the global helper. Changes to the global
# helper run all view and controller tests.
add_mapping %r%^app/helpers/(.*)_helper(s)?.rb% do |_, m|
if m[1] == "global" then
files_matching %r%^test/(views|functional|controllers)/.*_test\.rb$%
else
[
view_test_for(m[1]),
controller_test_for(m[1])
]
end
end

# Changes to views result in their corresponding view and controller test
# being run
add_mapping %r%^app/views/(.*)/% do |_, m|
[
view_test_for(m[1]),
controller_test_for(m[1])
]
end

# Changes to a controller result in its corresponding test being run. If
# the controller is the exception or application controller, all
# controller tests are run.
add_mapping %r%^app/controllers/(.*)\.rb$% do |_, m|
if ["application", "exception"].include?(m[1])
files_matching %r%^test/(controllers|views|functional)/.*_test\.rb$%
else
controller_test_for(m[1])
end
end

# If a change is made to the router, run all controller and view tests
add_mapping %r%^config/router.rb$% do # FIX
files_matching %r%^test/(controllers|views|functional)/.*_test\.rb$%
end

# If any of the major files governing the environment are altered, run
# everything
add_mapping %r%^test/test_helper.rb|config/(init|rack|environments/test.rb|database.yml)% do # FIX
files_matching %r%^test/(unit|models|controllers|views|functional)/.*_test\.rb$%
end
end

private

# Determines the paths we can expect tests or specs to reside, as well as
# corresponding fixtures.
def initialize_test_layout
self.model_tests_dir = "test/unit"
self.controller_tests_dir = "test/functional"
self.view_tests_dir = "test/views"
self.fixtures_dir = "test/fixtures"
end

# Given a filename and the test type, this method will return the
# corresponding test's or spec's name.
#
# ==== Arguments
# +filename+<String>:: the file name of the model, view, or controller
# +kind_of_test+<Symbol>:: the type of test we that we should run
#
# ==== Returns
# String:: the name of the corresponding test or spec
#
# ==== Example
#
# > test_for("user", :model)
# => "user_test.rb"
# > test_for("login", :controller)
# => "login_controller_test.rb"
# > test_for("form", :view)
# => "form_view_spec.rb" # If you're running a RSpec-like suite
def test_for(filename, kind_of_test)
name = [filename]
name << kind_of_test.to_s if kind_of_test == :view
name << "test"
return name.join("_") + ".rb"
end

def model_test_for(filename)
[model_tests_dir, test_for(filename, :model)].join("/")
end

def controller_test_for(filename)
[controller_tests_dir, test_for(filename, :controller)].join("/")
end

def view_test_for(filename)
[view_tests_dir, test_for(filename, :view)].join("/")
end

end

0 comments on commit d9fdcdc

Please sign in to comment.