ajax_scaffold_generator 3.1.1 → 3.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -63,9 +63,9 @@ class AjaxScaffoldGenerator < ScaffoldGenerator
63
63
  m.directory File.join('test/functional', controller_class_path)
64
64
 
65
65
  # Model class, unit test, and fixtures.
66
- m.template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb")
67
- m.template 'unit_test.rb', File.join('test/unit', class_path, "#{file_name}_test.rb")
68
- m.template 'fixtures.yml', File.join('test/fixtures', class_path, "#{table_name}.yml")
66
+ m.template 'model.rb', File.join('app/models', "#{singular_name}.rb")
67
+ m.template 'unit_test.rb', File.join('test/unit', "#{singular_name}_test.rb")
68
+ m.template 'fixtures.yml', File.join('test/fixtures', "#{singular_name}.yml")
69
69
 
70
70
  # Scaffolded forms.
71
71
  m.complex_template 'form.rhtml',
@@ -41,8 +41,8 @@ class <%= controller_class_name %>Controller < ApplicationController
41
41
  update_params :default_scaffold_id => "<%= singular_name %>", :default_sort => nil, :default_sort_direction => "asc"
42
42
 
43
43
  @sort_sql = <%= model_name %>.scaffold_columns_hash[current_sort(params)].sort_sql rescue nil
44
- @sort_by = @sort_sql.nil? ? "<%= plural_name %>.id asc" : @sort_sql + " " + current_sort_direction(params)
45
- @paginator, @<%= plural_name %> = paginate(:<%= plural_name %>, :order_by => @sort_by, :per_page => default_per_page)
44
+ @sort_by = @sort_sql.nil? ? "#{<%= model_name %>.table_name}.#{<%= model_name %>.primary_key} asc" : @sort_sql + " " + current_sort_direction(params)
45
+ @paginator, @<%= plural_name %> = paginate(:<%= plural_name %>, :order => @sort_by, :per_page => default_per_page)
46
46
 
47
47
  render :action => "component", :layout => false
48
48
  end
@@ -51,7 +51,7 @@ class <%= controller_class_name %>Controller < ApplicationController
51
51
  @<%= singular_name %> = <%= model_name %>.new
52
52
  @successful = true
53
53
 
54
- return if request.xhr?
54
+ return render :action => 'new.rjs' if request.xhr?
55
55
 
56
56
  # Javascript disabled fallback
57
57
  if @successful
@@ -70,7 +70,7 @@ class <%= controller_class_name %>Controller < ApplicationController
70
70
  flash[:error], @successful = $!.to_s, false
71
71
  end
72
72
 
73
- return if request.xhr?
73
+ return render :action => 'create.rjs' if request.xhr?
74
74
  if @successful
75
75
  return_to_main
76
76
  else
@@ -87,7 +87,7 @@ class <%= controller_class_name %>Controller < ApplicationController
87
87
  flash[:error], @successful = $!.to_s, false
88
88
  end
89
89
 
90
- return if request.xhr?
90
+ return render :action => 'edit.rjs' if request.xhr?
91
91
 
92
92
  if @successful
93
93
  @options = { :scaffold_id => params[:scaffold_id], :action => "update", :id => params[:id] }
@@ -105,7 +105,7 @@ class <%= controller_class_name %>Controller < ApplicationController
105
105
  flash[:error], @successful = $!.to_s, false
106
106
  end
107
107
 
108
- return if request.xhr?
108
+ return render :action => 'update.rjs' if request.xhr?
109
109
 
110
110
  if @successful
111
111
  return_to_main
@@ -122,7 +122,7 @@ class <%= controller_class_name %>Controller < ApplicationController
122
122
  flash[:error], @successful = $!.to_s, false
123
123
  end
124
124
 
125
- return if request.xhr?
125
+ return render :action => 'destroy.rjs' if request.xhr?
126
126
 
127
127
  # Javascript disabled fallback
128
128
  return_to_main
@@ -131,7 +131,7 @@ class <%= controller_class_name %>Controller < ApplicationController
131
131
  def cancel
132
132
  @successful = true
133
133
 
134
- return if request.xhr?
134
+ return render :action => 'cancel.rjs' if request.xhr?
135
135
 
136
136
  return_to_main
137
137
  end
@@ -13,76 +13,6 @@ class <%= controller_class_name %>ControllerTest < Test::Unit::TestCase
13
13
  @response = ActionController::TestResponse.new
14
14
  end
15
15
 
16
- <% for action in unscaffolded_actions -%>
17
- def test_<%= action %>
18
- get :<%= action %>
19
- assert_response :success
20
- assert_template '<%= action %>'
21
- end
22
-
23
- <% end -%>
24
- <% unless suffix -%>
25
- def test_index
26
- get :index
27
- assert_response :success
28
- assert_template 'list'
29
- end
30
-
31
- <% end -%>
32
- def test_list<%= suffix %>
33
- get :list<%= suffix %>
34
-
35
- assert_response :success
36
- assert_template 'list<%= suffix %>'
37
-
38
- assert_not_nil assigns(:<%= plural_name %>)
39
- end
40
-
41
- def test_new<%= suffix %>
42
- get :new<%= suffix %>
43
-
44
- assert_response :success
45
- assert_template 'new<%= suffix %>'
46
-
47
- assert_not_nil assigns(:<%= singular_name %>)
48
- end
49
-
50
- def test_create
51
- num_<%= plural_name %> = <%= model_name %>.count
52
-
53
- post :create<%= suffix %>, :<%= singular_name %> => {}
16
+ # A better generator might actually keep updated tests in here, until then its probably better to have nothing than something broken
54
17
 
55
- assert_response :redirect
56
- assert_redirected_to :action => 'list<%= suffix %>'
57
-
58
- assert_equal num_<%= plural_name %> + 1, <%= model_name %>.count
59
- end
60
-
61
- def test_edit<%= suffix %>
62
- get :edit<%= suffix %>, :id => 1
63
-
64
- assert_response :success
65
- assert_template 'edit<%= suffix %>'
66
-
67
- assert_not_nil assigns(:<%= singular_name %>)
68
- assert assigns(:<%= singular_name %>).valid?
69
- end
70
-
71
- def test_update<%= suffix %>
72
- post :update<%= suffix %>, :id => 1
73
- assert_response :redirect
74
- assert_redirected_to :action => 'show<%= suffix %>', :id => 1
75
- end
76
-
77
- def test_destroy<%= suffix %>
78
- assert_not_nil <%= model_name %>.find(1)
79
-
80
- post :destroy, :id => 1
81
- assert_response :redirect
82
- assert_redirected_to :action => 'list<%= suffix %>'
83
-
84
- assert_raise(ActiveRecord::RecordNotFound) {
85
- <%= model_name %>.find(1)
86
- }
87
- end
88
18
  end
@@ -152,7 +152,7 @@ module AjaxScaffold
152
152
  end
153
153
 
154
154
  def scaffold_column_header_id(options)
155
- "#{options[:scaffold_id]}-#{options[:column_name]}"
155
+ "#{options[:scaffold_id]}-#{options[:column_name]}-column"
156
156
  end
157
157
 
158
158
  def scaffold_tbody_id(options)
@@ -168,7 +168,7 @@ module AjaxScaffold
168
168
  end
169
169
 
170
170
  def element_row_id(options)
171
- "#{options[:scaffold_id]}-#{options[:action]}-#{options[:id]}"
171
+ "#{options[:scaffold_id]}-#{options[:action]}-#{options[:id]}-row"
172
172
  end
173
173
 
174
174
  def element_cell_id(options)
@@ -1,6 +1,6 @@
1
1
  <%% # The following is used when the browser doesn't have javascript enabled %>
2
2
  <%% classAttr = cycle("", "class=\"even\"") %>
3
- <%% @options = params.merge(:controller => '<%= controller_file_path %>', :action => "view", :id => <%= singular_name %>.id) %>
3
+ <%% @options = params.merge(:controller => '<%= controller_file_path %>', :action => "view", :id => <%= singular_name %>.send("#{<%= model_name %>.primary_key}")) %>
4
4
 
5
5
  <tr <%%= classAttr %> id="<%%= element_row_id(@options) %>" <%%= "style=\"display: none;\"" if hidden %>>
6
6
  <%% for scaffold_column in scaffold_columns %>
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: ajax_scaffold_generator
5
5
  version: !ruby/object:Gem::Version
6
- version: 3.1.1
7
- date: 2006-04-21 00:00:00 -04:00
6
+ version: 3.1.2
7
+ date: 2006-04-27 00:00:00 -04:00
8
8
  summary: Ajax scaffold generator is a rails generator for ajaxified scaffolds
9
9
  require_paths:
10
10
  - lib