rails3_artifactor 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.3
1
+ 0.2.4
@@ -25,7 +25,7 @@ module Rails3::Assist::Artifact
25
25
 
26
26
  module Permit
27
27
  def permit_marker name, options=nil
28
- "#{name.to_s.camelize}"
28
+ "#{name.to_s.camelize}Permit < Permit::Base"
29
29
  end
30
30
 
31
31
  extend self
@@ -1,3 +1,13 @@
1
+ module RubyMutator
2
+ def remove_superclass
3
+ self.gsub! /(class\s+\w+\s*)<\s*(\w|::)+/, '\1'
4
+ end
5
+
6
+ def inherit_from superclass
7
+ self.gsub! /(class\s+(\w|::)+)/, '\1' + " < #{superclass.to_s.camelize}\n"
8
+ end
9
+ end
10
+
1
11
  module Rails3::Assist::Artifact::CRUD
2
12
  module Create
3
13
  include Rails3::Assist::Artifact::Marker
@@ -9,6 +19,15 @@ module Rails3::Assist::Artifact::CRUD
9
19
 
10
20
  create_artifact_dir(file)
11
21
  content = get_content(name, type, options, &block)
22
+
23
+ superclass = options[:superclass] if options[:superclass]
24
+
25
+ if superclass
26
+ content.extend(RubyMutator)
27
+ content.remove_superclass
28
+ content.inherit_from "#{superclass}_permit"
29
+ end
30
+
12
31
  return if content.blank?
13
32
 
14
33
  File.overwrite file, content
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rails3_artifactor}
8
- s.version = "0.2.3"
8
+ s.version = "0.2.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kristian Mandrup"]
12
- s.date = %q{2010-09-17}
12
+ s.date = %q{2010-09-18}
13
13
  s.description = %q{Helpers for handling Rails 3 artifacts in general, such as CRUD operations etc.}
14
14
  s.email = %q{kmandrup@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -60,6 +60,7 @@ Gem::Specification.new do |s|
60
60
  "spec/rails3_artifactor/artifact/crud/model_active_record_spec.rb",
61
61
  "spec/rails3_artifactor/artifact/crud/model_spec.rb",
62
62
  "spec/rails3_artifactor/artifact/crud/observer_spec.rb",
63
+ "spec/rails3_artifactor/artifact/crud/permit_spec.rb",
63
64
  "spec/rails3_artifactor/artifact/crud/view_controller_action_spec.rb",
64
65
  "spec/rails3_artifactor/artifact/crud/view_controller_default_action_spec.rb",
65
66
  "spec/rails3_artifactor/artifact/file_name/artifacts_spec.rb",
@@ -94,6 +95,7 @@ Gem::Specification.new do |s|
94
95
  "spec/rails3_artifactor/artifact/crud/model_active_record_spec.rb",
95
96
  "spec/rails3_artifactor/artifact/crud/model_spec.rb",
96
97
  "spec/rails3_artifactor/artifact/crud/observer_spec.rb",
98
+ "spec/rails3_artifactor/artifact/crud/permit_spec.rb",
97
99
  "spec/rails3_artifactor/artifact/crud/view_controller_action_spec.rb",
98
100
  "spec/rails3_artifactor/artifact/crud/view_controller_default_action_spec.rb",
99
101
  "spec/rails3_artifactor/artifact/file_name/artifacts_spec.rb",
@@ -0,0 +1,71 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'permit' do
4
+ use_helpers :permit
5
+
6
+ before :each do
7
+ Rails3::Assist::Directory.rails_root = fixtures_dir
8
+
9
+ remove_permit :account if has_permit? :account
10
+ create_permit :account do
11
+ %q{ licenses :fishing, :blogging}
12
+ end
13
+
14
+ create_permit :super_admin, :superclass => :admin do
15
+ %q{ licenses :admin_users}
16
+ end
17
+
18
+ # puts read_permit :super_admin
19
+ end
20
+
21
+ after :each do
22
+ remove_permit :account
23
+ remove_permit :super_admin
24
+ end
25
+
26
+ context "Non-existant permit(s)" do
27
+ it "should not fail trying to remove non-existant permits" do
28
+ remove_permits :person, :user
29
+ remove_artifacts :permit, :person, :user
30
+
31
+ remove_permit :person
32
+ remove_artifact :permit, :person
33
+ end
34
+
35
+ it "should not find a non-existant permit" do
36
+ permit_file :person do |person|
37
+ fail "should not find person permit!"
38
+ end
39
+
40
+ has_permit?(:person).should be_false
41
+ has_permits?(:person, :user).should be_false
42
+ end
43
+
44
+ it "should not insert into non-existant permit" do
45
+ insert_into_permit(:person, :after => 'Hello', :content => 'Yes').should_not be_true
46
+ end
47
+
48
+ it "should not read from non-existant permit" do
49
+ read_permit :person do |content|
50
+ fail "should not find person content!"
51
+ end.should_not be_true
52
+ end
53
+ end
54
+
55
+ it "should have an account_permit file that contains a #mail_it method and two inserted comments" do
56
+ has_permit?(:account).should be_true
57
+ has_permit?(:super_admin).should be_true
58
+
59
+ insert_into_permit :account, :content => '# hello'
60
+ insert_into_permit :account do
61
+ '# goodbye'
62
+ end
63
+ read_permit(:account).should have_comment 'hello'
64
+ puts read_permit(:account)
65
+ # root_dir.should have_permit :account do |permit_file|
66
+ # permit_file.should have_method :index
67
+ # permit_file.should have_comment 'hello'
68
+ # permit_file.should have_comment 'goodbye'
69
+ # end
70
+ end
71
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 3
9
- version: 0.2.3
8
+ - 4
9
+ version: 0.2.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Kristian Mandrup
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-09-17 00:00:00 +02:00
17
+ date: 2010-09-18 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -149,6 +149,7 @@ files:
149
149
  - spec/rails3_artifactor/artifact/crud/model_active_record_spec.rb
150
150
  - spec/rails3_artifactor/artifact/crud/model_spec.rb
151
151
  - spec/rails3_artifactor/artifact/crud/observer_spec.rb
152
+ - spec/rails3_artifactor/artifact/crud/permit_spec.rb
152
153
  - spec/rails3_artifactor/artifact/crud/view_controller_action_spec.rb
153
154
  - spec/rails3_artifactor/artifact/crud/view_controller_default_action_spec.rb
154
155
  - spec/rails3_artifactor/artifact/file_name/artifacts_spec.rb
@@ -209,6 +210,7 @@ test_files:
209
210
  - spec/rails3_artifactor/artifact/crud/model_active_record_spec.rb
210
211
  - spec/rails3_artifactor/artifact/crud/model_spec.rb
211
212
  - spec/rails3_artifactor/artifact/crud/observer_spec.rb
213
+ - spec/rails3_artifactor/artifact/crud/permit_spec.rb
212
214
  - spec/rails3_artifactor/artifact/crud/view_controller_action_spec.rb
213
215
  - spec/rails3_artifactor/artifact/crud/view_controller_default_action_spec.rb
214
216
  - spec/rails3_artifactor/artifact/file_name/artifacts_spec.rb