Permalink
Browse files

remove obsolete code

  • Loading branch information...
mkristian committed Jan 30, 2012
1 parent 2d678f6 commit 671c43e13bae038fc9bfbb14114b6b32733f80e1
Showing with 2 additions and 1,128 deletions.
  1. +0 −10 features/generators.feature
  2. +1 −82 features/step_definitions/simple_steps.rb
  3. +0 −13 lib/generators/active_record/templates/flavor_migration.rb
  4. +0 −8 lib/generators/active_record/templates/flavor_model.rb
  5. +0 −43 lib/generators/active_record/templates/group_model.rb
  6. +0 −13 lib/generators/active_record/templates/group_user_migration.rb
  7. +0 −124 lib/generators/active_record/templates/user_model.rb
  8. +0 −202 lib/generators/active_record/user_management_models_generator.rb
  9. +0 −10 lib/generators/erb/user_management_controller_generator.rb
  10. +0 −8 lib/generators/ixtlan/maintenance_scaffold/USAGE
  11. +0 −40 lib/generators/ixtlan/maintenance_scaffold/maintenance_scaffold_generator.rb
  12. +0 −8 lib/generators/ixtlan/permissions_scaffold/USAGE
  13. +0 −33 lib/generators/ixtlan/permissions_scaffold/permissions_scaffold_generator.rb
  14. +0 −8 lib/generators/ixtlan/user_management_controller/USAGE
  15. +0 −23 lib/generators/ixtlan/user_management_controller/user_management_controller_generator.rb
  16. +0 −8 lib/generators/ixtlan/user_management_models/USAGE
  17. +0 −19 lib/generators/ixtlan/user_management_models/user_management_models_generator.rb
  18. +0 −13 lib/generators/ixtlan/user_management_scaffold/user_management_scaffold_generator.rb
  19. +0 −45 lib/ixtlan/guard/controllers/maintenance_controller.rb
  20. +0 −41 lib/ixtlan/guard/controllers/permissions_controller.rb
  21. +0 −55 lib/ixtlan/guard/models/maintenance.rb
  22. +0 −95 lib/ixtlan/guard/models/user_update_manager.rb
  23. +0 −193 lib/ixtlan/guard/spec/user_management_models_spec.rb
  24. +1 −1 templates/ixtlan-guard.template
  25. +0 −6 templates/specs-user-management/user_management_models_spec.rb
  26. +0 −27 templates/user_management.template
@@ -6,13 +6,3 @@ Feature: Generators for ixtlan-guard
And I execute "rails generate scaffold account name:string --skip"
And I execute "rake db:migrate test"
Then the output should contain "7 tests, 10 assertions, 0 failures, 0 errors"
-
- Scenario: The user-management-model generator creates user/group models, etc
- Given I create new rails application with template "user_management.template" and "user-management" specs
- And I execute "rails generate rspec:install"
- And I execute "rails generate ixtlan:user_management_models user group name:string domain name:string locale code:string"
-# this tes env is needed since we execute the specs directly
- And I execute "rails rake db:migrate -- -Drails.env=test"
-# needed due to bug in rspec-maven-plugin with emtpy gem-path
- And I execute "gem exec ../rubygems/bin/rspec spec/user_management_models_spec.rb"
- Then the output should contain "14 examples, 0 failures"
@@ -1,82 +1 @@
-require 'fileutils'
-require File.join(File.dirname(__FILE__), 'ruby_maven')
-
-def rmvn
- @rmvn ||= Maven::RubyMaven.new
-end
-
-def copy_tests(tests)
- FileUtils.mkdir_p(@app_directory)
- FileUtils.cp_r(File.join('templates', "tests-#{tests}", "."),
- File.join(@app_directory, 'test'))
-end
-
-def copy_specs(specs)
- FileUtils.mkdir_p(@app_directory)
- FileUtils.cp_r(File.join('templates', "specs-#{specs}", "."),
- File.join(@app_directory, 'spec'))
-end
-
-def create_rails_application(template)
- name = template.sub(/.template$/, '')
- @app_directory = File.join('target', name)
-
- # rails version from gemspec
- gemspec = File.read(Dir.glob("*.gemspec")[0])
- rails_version = gemspec.split("\n").detect { |l| l =~ /development_dep.*rails/ }.sub(/'$/, '').sub(/.*'/, '')
-
- rmvn.options['-Dplugin.version'] = '0.28.4-SNAPSHOT'
- rmvn.options['-Drails.version'] = rails_version
- rmvn.options['-Dgem.home'] = ENV['GEM_HOME']
- rmvn.options['-Dgem.path'] = ENV['GEM_PATH']
- rmvn.options['-o'] = nil
-
- FileUtils.rm_rf(@app_directory)
-
- rmvn.exec("rails", "new", @app_directory, "-f")
-
- # TODO that should be done via the rails new task !!!
- rmvn.exec_in(@app_directory, "rails", "rake", "rails:template LOCATION=" + File.expand_path("templates/#{template}"))
-end
-
-Given /^I create new rails application with template "(.*)"$/ do |template|
- create_rails_application(template)
-end
-
-Given /^I create new rails application with template "(.*)" and "(.*)" tests$/ do |template, tests|
- create_rails_application(template)
- copy_tests(tests)
-end
-
-Given /^I create new rails application with template "(.*)" and "(.*)" specs$/ do |template, specs|
- create_rails_application(template)
- copy_specs(specs)
-end
-
-Given /^me an existing rails application "(.*)"$/ do |name|
- @app_directory = File.join('target', name)
-end
-
-Given /^me an existing rails application "(.*)" and "(.*)" tests$/ do |name, tests|
- @app_directory = File.join('target', name)
- copy_tests(tests)
-end
-
-Given /^me an existing rails application "(.*)" and "(.*)" specs$/ do |name, specs|
- @app_directory = File.join('target', name)
- copy_specs(specs)
-end
-
-And /^I execute \"(.*)\"$/ do |args|
- rmvn.options['-l'] = "output.log"
- rmvn.exec_in(@app_directory, args)
-end
-
-Then /^the output should contain \"(.*)\"$/ do |expected|
- result = File.read(File.join(@app_directory, "output.log"))
- expected.split(/\"?\s+and\s+\"?/).each do |exp|
- puts exp
- (result =~ /.*#{exp}.*/).should_not be_nil
- end
-end
-
+require 'maven/cucumber_steps'
@@ -1,13 +0,0 @@
-class Create<%= association_name.camelize %> < ActiveRecord::Migration
- def self.up
- create_table :<%= association_name %>, :id => false, :force => true do |t|
- <% [file_name, group_name, user_name].sort.each do |name| -%>
- t.integer :<%= name %>_id
- <% end -%>
- end
- end
-
- def self.down
- drop_table :<%= association_name %>
- end
-end
@@ -1,8 +0,0 @@
-class <%= association_class_name(plural_name) %> < <%= parent_class_name.classify %>
-<% attributes.select {|attr| attr.reference? }.each do |attribute| -%>
- belongs_to :<%= attribute.name %>
-<% end -%>
-<% [name, group_name, user_name].sort.each do |ref_name| -%>
- belongs_to :<%= ref_name %>
-<% end -%>
-end
@@ -1,43 +0,0 @@
-class <%= group_class_name %> < <%= parent_class_name.classify %>
-<% attributes.select {|attr| attr.reference? }.each do |attribute| -%>
- belongs_to :<%= attribute.name %>
-<% end -%>
-
- has_and_belongs_to_many :<%= plural_user_name %>
-
- ROOT = 'root'
- ADMIN = 'admin'
-
- def self.admin_group
- find_by_<%= attributes.first.name %>(ADMIN)
- end
-
- def self.root_group
- find_by_<%= attributes.first.name %>(ROOT)
- end
-
- def admin?
- <%= attributes.first.name %> == ADMIN
- end
-
- def root?
- <%= attributes.first.name %> == ROOT
- end
-
- def self.get(id_or_<%= attributes.first.name %>_or_<%= file_name %>)
- case id_or_<%= attributes.first.name %>_or_<%= file_name %>
- when Fixnum
- find(id_or_<%= attributes.first.name %>_or_<%= file_name %>)
- when String
- find_by_<%= attributes.first.name %>(id_or_<%= attributes.first.name %>_or_<%= file_name %>)
- when Symbol
- find_by_<%= attributes.first.name %>(id_or_<%= attributes.first.name %>_or_<%= file_name %>.to_s)
- else
- id_or_<%= attributes.first.name %>_or_<%= file_name %>
- end
- end
-
- def to_name
- <%= group_field_name %>
- end
-end
@@ -1,13 +0,0 @@
-class Create<%= group_user_name.camelize %> < ActiveRecord::Migration
- def self.up
- create_table :<%= group_user_name %>, :id => false, :force => true do |t|
- <% [group_name, user_name].sort.each do |name| -%>
- t.integer :<%= name %>_id
- <% end -%>
- end
- end
-
- def self.down
- drop_table :<%= group_user_name %>
- end
-end
@@ -1,124 +0,0 @@
-require 'ixtlan/guard/models/user_update_manager'
-class <%= user_class_name %> < <%= parent_class_name.classify %>
-<% attributes.select {|attr| attr.reference? }.each do |attribute| -%>
- belongs_to :<%= attribute.name %>
-<% end -%>
-
- has_and_belongs_to_many :<%= plural_group_name %>
-
- attr_accessor :id
-
- def self.update_manager
- @manager ||= Ixtlan::Guard::Models::UserUpdateManager.new( :group_model => <%= group_class_name %>, :user_id => :<%= user_name %>_id, :group_id => :<%= group_name %>_id, :plural_group_name => :<%= plural_group_name %> )
- end
-
- alias :create! :create
- def self.create(params = {})
- u = self.new
- u.current_user = params.delete("current_user") || params.delete(:current_user)
- u.update_attributes(params)
- u
- end
-
- def update_attributes(params)
- result = []
- <% flavors.each do |flavor| %>
- # update <%= flavor.pluralize %>
- if result.all?{|a| a}
- result << self.class.update_manager.update(self, params, :flavor_id => :<%= flavor %>_id, :flavors_for_group => :<%= flavor.pluralize %>_for_<%= group_name %>, :association_model => <%= association_class_name(flavor.pluralize) %>)
- end
-<% end -%>
-
- # update <%= plural_group_name %>
- self.class.update_manager.update_groups(self, params) if result.all?{|a| a}
- end
-
- unless respond_to? :current_user
- # do not use attr_accessor to allow them to be used
- # for mass_assignmnet_protection
- def current_user=(u)
- @current_user = u
- end
-
- def current_user
- @current_user
- end
-
- after_save do
- @current_user = nil
- end
- end
-
- def root?
- <%= plural_group_name %>.detect {|g| g.root? } != nil
- end
-
-<% flavors.each do |flavor|
- plural_flavor = flavor.pluralize %>
- def managed_<%= plural_flavor %>_for_<%= group_name %>(gid)
- <%= group_name %> = <%= group_class_name %>.get(gid)
- if <%= group_name %>.root?
- []
- else
- existing = <%= plural_flavor %>_for_<%= group_name %>(<%= group_name %>)
- managed = <%= plural_flavor %>_for_<%= group_name %>(<%= group_class_name %>.admin_group)
- (managed - (managed - existing))
- end
- end
-
- def <%= plural_flavor %>_for_<%= group_name %>(group_or_id)
- if root?
- <%= flavor.camelize %>.all
- else
- <%= group_name %> = <%= group_class_name %>.get(group_or_id)
- <%= association_class_name(plural_flavor) %>.all(:conditions => ["<%= user_name %>_id=? and <%= group_name %>_id=?", id, <%= group_name %>.id]).collect { |dgu| dgu.<%= flavor %> }
- end
- end
-
- def <%= flavor %>_<%= group_name %>?(<%= flavor %>, <%= group_name %>)
- <%= association_class_name(plural_flavor) %>.count(:conditions => ["<%= user_name %>_id=? and <%= group_name %>_id=? and <%= flavor %>_id=?", id, <%= group_name %>.id, <%= flavor %>.id]) == 1
- end
-
-<% end -%>
-
- def all_<%= plural_group_name %>
- if root?
- <%= group_class_name %>.all
- else
- <%= plural_group_name %>
- end
- end
-
- def to_xml
- to_hash.to_xml(:root => "<%= file_name %>")
- end
-
- def to_json
- { :<%= file_name %> => to_hash }.to_json
- end
-
- def to_hash
- map = attributes.dup
- g = (map[:<%= plural_group_name %>] = [])
- <%= plural_group_name %>.each do |<%= group_name %>|
- gg = <%= group_name %>.attributes.dup
- gg.delete("<%= group_name %>_id")
- gg.delete("<%= file_name %>_id")
-<% flavors.each do |flavor|
- plural_flavor = flavor.pluralize %>
- <%= plural_flavor %> = <%= plural_flavor %>_for_<%= group_name %>(<%= group_name %>)
- if <%= plural_flavor %>.size > 0
- d = (gg[:<%= plural_flavor %>] = [])
- <%= plural_flavor %>.each do |<%= flavor %>|
- dd = <%= flavor %>.attributes.dup
- dd.delete("created_at")
- dd.delete("updated_at")
- d << dd
- end
- end
-<% end -%>
- g << gg
- end
- map
- end
-end
Oops, something went wrong.

0 comments on commit 671c43e

Please sign in to comment.