jintastic 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/.gitignore +5 -0
- data/MIT-LICENSE +21 -0
- data/README.md +97 -0
- data/Rakefile +59 -0
- data/VERSION.yml +5 -0
- data/assets/app/views/jintastic/_in_place_editor.html.erb +16 -0
- data/assets/public/javascripts/jintastic.js +35 -0
- data/config/locale/en.yml +4 -0
- data/init.rb +3 -0
- data/jintastic.gemspec +111 -0
- data/lib/jintastic.rb +61 -0
- data/test/jintastic_test.rb +7 -0
- data/test/test_helper.rb +10 -0
- data/vendor/plugins/formtastic/.gitignore +5 -0
- data/vendor/plugins/formtastic/MIT-LICENSE +20 -0
- data/vendor/plugins/formtastic/README.textile +553 -0
- data/vendor/plugins/formtastic/RELEASE_PROCESS +11 -0
- data/vendor/plugins/formtastic/Rakefile +101 -0
- data/vendor/plugins/formtastic/VERSION.yml +4 -0
- data/vendor/plugins/formtastic/formtastic.gemspec +142 -0
- data/vendor/plugins/formtastic/generators/form/USAGE +16 -0
- data/vendor/plugins/formtastic/generators/form/form_generator.rb +120 -0
- data/vendor/plugins/formtastic/generators/form/templates/view__form.html.erb +5 -0
- data/vendor/plugins/formtastic/generators/form/templates/view__form.html.haml +4 -0
- data/vendor/plugins/formtastic/generators/formtastic/formtastic_generator.rb +24 -0
- data/vendor/plugins/formtastic/generators/formtastic/templates/formtastic.css +144 -0
- data/vendor/plugins/formtastic/generators/formtastic/templates/formtastic_changes.css +10 -0
- data/vendor/plugins/formtastic/generators/formtastic/templates/formtastic_config.rb +54 -0
- data/vendor/plugins/formtastic/generators/formtastic_stylesheets/formtastic_stylesheets_generator.rb +16 -0
- data/vendor/plugins/formtastic/install.rb +2 -0
- data/vendor/plugins/formtastic/lib/formtastic.rb +1687 -0
- data/vendor/plugins/formtastic/lib/formtastic/i18n.rb +32 -0
- data/vendor/plugins/formtastic/lib/locale/en.yml +8 -0
- data/vendor/plugins/formtastic/rails/init.rb +3 -0
- data/vendor/plugins/formtastic/spec/buttons_spec.rb +149 -0
- data/vendor/plugins/formtastic/spec/commit_button_spec.rb +369 -0
- data/vendor/plugins/formtastic/spec/custom_builder_spec.rb +62 -0
- data/vendor/plugins/formtastic/spec/custom_macros.rb +561 -0
- data/vendor/plugins/formtastic/spec/defaults_spec.rb +20 -0
- data/vendor/plugins/formtastic/spec/error_proc_spec.rb +27 -0
- data/vendor/plugins/formtastic/spec/errors_spec.rb +85 -0
- data/vendor/plugins/formtastic/spec/form_helper_spec.rb +126 -0
- data/vendor/plugins/formtastic/spec/i18n_spec.rb +131 -0
- data/vendor/plugins/formtastic/spec/include_blank_spec.rb +70 -0
- data/vendor/plugins/formtastic/spec/input_spec.rb +628 -0
- data/vendor/plugins/formtastic/spec/inputs/boolean_input_spec.rb +93 -0
- data/vendor/plugins/formtastic/spec/inputs/check_boxes_input_spec.rb +162 -0
- data/vendor/plugins/formtastic/spec/inputs/country_input_spec.rb +80 -0
- data/vendor/plugins/formtastic/spec/inputs/date_input_spec.rb +60 -0
- data/vendor/plugins/formtastic/spec/inputs/datetime_input_spec.rb +169 -0
- data/vendor/plugins/formtastic/spec/inputs/file_input_spec.rb +33 -0
- data/vendor/plugins/formtastic/spec/inputs/hidden_input_spec.rb +52 -0
- data/vendor/plugins/formtastic/spec/inputs/numeric_input_spec.rb +44 -0
- data/vendor/plugins/formtastic/spec/inputs/password_input_spec.rb +46 -0
- data/vendor/plugins/formtastic/spec/inputs/radio_input_spec.rb +149 -0
- data/vendor/plugins/formtastic/spec/inputs/select_input_spec.rb +459 -0
- data/vendor/plugins/formtastic/spec/inputs/string_input_spec.rb +47 -0
- data/vendor/plugins/formtastic/spec/inputs/text_input_spec.rb +33 -0
- data/vendor/plugins/formtastic/spec/inputs/time_input_spec.rb +44 -0
- data/vendor/plugins/formtastic/spec/inputs/time_zone_input_spec.rb +102 -0
- data/vendor/plugins/formtastic/spec/inputs_spec.rb +395 -0
- data/vendor/plugins/formtastic/spec/label_spec.rb +48 -0
- data/vendor/plugins/formtastic/spec/semantic_errors_spec.rb +98 -0
- data/vendor/plugins/formtastic/spec/semantic_fields_for_spec.rb +44 -0
- data/vendor/plugins/formtastic/spec/spec.opts +2 -0
- data/vendor/plugins/formtastic/spec/spec_helper.rb +218 -0
- data/vendor/plugins/formtastic/uninstall.rb +1 -0
- metadata +132 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
|
3
|
+
|
|
4
|
+
describe 'SemanticFormBuilder#label' do
|
|
5
|
+
|
|
6
|
+
include FormtasticSpecHelper
|
|
7
|
+
|
|
8
|
+
before do
|
|
9
|
+
@output_buffer = ''
|
|
10
|
+
mock_everything
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'should humanize the given attribute' do
|
|
14
|
+
semantic_form_for(@new_post) do |builder|
|
|
15
|
+
builder.label(:login).should have_tag('label', :with => /Login/)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe 'when required is given' do
|
|
20
|
+
it 'should append a required note' do
|
|
21
|
+
semantic_form_for(@new_post) do |builder|
|
|
22
|
+
builder.label(:login, nil, :required => true).should have_tag('label abbr')
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'should allow require option to be given as second argument' do
|
|
27
|
+
semantic_form_for(@new_post) do |builder|
|
|
28
|
+
builder.label(:login, :required => true).should have_tag('label abbr')
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe 'when label is given' do
|
|
34
|
+
it 'should allow the text to be given as label option' do
|
|
35
|
+
semantic_form_for(@new_post) do |builder|
|
|
36
|
+
builder.label(:login, :required => true, :label => 'My label').should have_tag('label', :with => /My label/)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it 'should return nil if label is false' do
|
|
41
|
+
semantic_form_for(@new_post) do |builder|
|
|
42
|
+
builder.label(:login, :label => false).should be_blank
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
end
|
|
48
|
+
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
|
3
|
+
|
|
4
|
+
describe 'SemanticFormBuilder#semantic_errors' do
|
|
5
|
+
|
|
6
|
+
include FormtasticSpecHelper
|
|
7
|
+
|
|
8
|
+
before do
|
|
9
|
+
@output_buffer = ''
|
|
10
|
+
mock_everything
|
|
11
|
+
@title_errors = ['must not be blank', 'must be awesome']
|
|
12
|
+
@base_errors = ['base error message', 'nasty error']
|
|
13
|
+
@base_error = 'one base error'
|
|
14
|
+
@errors = mock('errors')
|
|
15
|
+
@new_post.stub!(:errors).and_return(@errors)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
describe 'when there is only one error on base' do
|
|
19
|
+
before do
|
|
20
|
+
@errors.stub!(:on_base).and_return(@base_error)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'should render an unordered list' do
|
|
24
|
+
semantic_form_for(@new_post) do |builder|
|
|
25
|
+
builder.semantic_errors.should have_tag('ul.errors li', @base_error)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe 'when there is more than one error on base' do
|
|
31
|
+
before do
|
|
32
|
+
@errors.stub!(:on_base).and_return(@base_errors)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'should render an unordered list' do
|
|
36
|
+
semantic_form_for(@new_post) do |builder|
|
|
37
|
+
builder.semantic_errors.should have_tag('ul.errors')
|
|
38
|
+
@base_errors.each do |error|
|
|
39
|
+
builder.semantic_errors.should have_tag('ul.errors li', error)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe 'when there are errors on title' do
|
|
46
|
+
before do
|
|
47
|
+
@errors.stub!(:[]).with(:title).and_return(@title_errors)
|
|
48
|
+
@errors.stub!(:on_base).and_return([])
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it 'should render an unordered list' do
|
|
52
|
+
semantic_form_for(@new_post) do |builder|
|
|
53
|
+
title_name = builder.send(:localized_string, :title, :title, :label) || builder.send(:humanized_attribute_name, :title)
|
|
54
|
+
builder.semantic_errors(:title).should have_tag('ul.errors li', title_name << " " << @title_errors.to_sentence)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
describe 'when there are errors on title and base' do
|
|
60
|
+
before do
|
|
61
|
+
@errors.stub!(:[]).with(:title).and_return(@title_errors)
|
|
62
|
+
@errors.stub!(:on_base).and_return(@base_error)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it 'should render an unordered list' do
|
|
66
|
+
semantic_form_for(@new_post) do |builder|
|
|
67
|
+
title_name = builder.send(:localized_string, :title, :title, :label) || builder.send(:humanized_attribute_name, :title)
|
|
68
|
+
builder.semantic_errors(:title).should have_tag('ul.errors li', title_name << " " << @title_errors.to_sentence)
|
|
69
|
+
builder.semantic_errors(:title).should have_tag('ul.errors li', @base_error)
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
describe 'when there are no errors' do
|
|
75
|
+
before do
|
|
76
|
+
@errors.stub!(:[]).with(:title).and_return(nil)
|
|
77
|
+
@errors.stub!(:on_base).and_return(nil)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it 'should return nil' do
|
|
81
|
+
semantic_form_for(@new_post) do |builder|
|
|
82
|
+
builder.semantic_errors(:title).should be_nil
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
describe 'when there is one error on base and options with class is passed' do
|
|
88
|
+
before do
|
|
89
|
+
@errors.stub!(:on_base).and_return(@base_error)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it 'should render an unordered list with given class' do
|
|
93
|
+
semantic_form_for(@new_post) do |builder|
|
|
94
|
+
builder.semantic_errors(:class => "awesome").should have_tag('ul.awesome li', @base_error)
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
|
3
|
+
|
|
4
|
+
describe 'SemanticFormBuilder#semantic_fields_for' do
|
|
5
|
+
|
|
6
|
+
include FormtasticSpecHelper
|
|
7
|
+
|
|
8
|
+
before do
|
|
9
|
+
@output_buffer = ''
|
|
10
|
+
mock_everything
|
|
11
|
+
@new_post.stub!(:author).and_return(::Author.new)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it 'yields an instance of SemanticFormHelper.builder' do
|
|
15
|
+
semantic_form_for(@new_post) do |builder|
|
|
16
|
+
builder.semantic_fields_for(:author) do |nested_builder|
|
|
17
|
+
nested_builder.class.should == ::Formtastic::SemanticFormHelper.builder
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'nests the object name' do
|
|
23
|
+
semantic_form_for(@new_post) do |builder|
|
|
24
|
+
builder.semantic_fields_for(@bob) do |nested_builder|
|
|
25
|
+
nested_builder.object_name.should == 'post[author]'
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'should sanitize html id for li tag' do
|
|
31
|
+
@bob.stub!(:column_for_attribute).and_return(mock('column', :type => :string, :limit => 255))
|
|
32
|
+
semantic_form_for(@new_post) do |builder|
|
|
33
|
+
builder.semantic_fields_for(@bob, :index => 1) do |nested_builder|
|
|
34
|
+
concat(nested_builder.inputs(:login))
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
output_buffer.should have_tag('form fieldset.inputs #post_author_1_login_input')
|
|
38
|
+
# Not valid selector, so using good ol' regex
|
|
39
|
+
output_buffer.should_not =~ /id="post\[author\]_1_login_input"/
|
|
40
|
+
# <=> output_buffer.should_not have_tag('form fieldset.inputs #post[author]_1_login_input')
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
require 'rubygems'
|
|
3
|
+
|
|
4
|
+
def smart_require(lib_name, gem_name, gem_version = '>= 0.0.0')
|
|
5
|
+
begin
|
|
6
|
+
require lib_name if lib_name
|
|
7
|
+
rescue LoadError
|
|
8
|
+
if gem_name
|
|
9
|
+
gem gem_name, gem_version
|
|
10
|
+
require lib_name if lib_name
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
smart_require 'spec', 'spec', '>= 1.2.6'
|
|
16
|
+
smart_require false, 'rspec-rails', '>= 1.2.6'
|
|
17
|
+
smart_require 'hpricot', 'hpricot', '>= 0.6.1'
|
|
18
|
+
smart_require 'rspec_tag_matchers', 'rspec_tag_matchers', '>= 1.0.0'
|
|
19
|
+
smart_require 'active_support', 'activesupport', '>= 2.3.4'
|
|
20
|
+
smart_require 'action_controller', 'actionpack', '>= 2.3.4'
|
|
21
|
+
smart_require 'action_view', 'actionpack', '>= 2.3.4'
|
|
22
|
+
|
|
23
|
+
require 'custom_macros'
|
|
24
|
+
|
|
25
|
+
Spec::Runner.configure do |config|
|
|
26
|
+
config.include(RspecTagMatchers)
|
|
27
|
+
config.include(CustomMacros)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '../lib/formtastic'))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
module FormtasticSpecHelper
|
|
34
|
+
include ActionView::Helpers::FormHelper
|
|
35
|
+
include ActionView::Helpers::FormTagHelper
|
|
36
|
+
include ActionView::Helpers::FormOptionsHelper
|
|
37
|
+
include ActionView::Helpers::UrlHelper
|
|
38
|
+
include ActionView::Helpers::TagHelper
|
|
39
|
+
include ActionView::Helpers::TextHelper
|
|
40
|
+
include ActionView::Helpers::ActiveRecordHelper
|
|
41
|
+
include ActionView::Helpers::RecordIdentificationHelper
|
|
42
|
+
include ActionView::Helpers::DateHelper
|
|
43
|
+
include ActionView::Helpers::CaptureHelper
|
|
44
|
+
include ActiveSupport
|
|
45
|
+
include ActionController::PolymorphicRoutes
|
|
46
|
+
|
|
47
|
+
include Formtastic::SemanticFormHelper
|
|
48
|
+
|
|
49
|
+
def default_input_type(column_type, column_name = :generic_column_name)
|
|
50
|
+
@new_post.stub!(column_name)
|
|
51
|
+
@new_post.stub!(:column_for_attribute).and_return(mock('column', :type => column_type)) unless column_type.nil?
|
|
52
|
+
|
|
53
|
+
semantic_form_for(@new_post) do |builder|
|
|
54
|
+
@default_type = builder.send(:default_input_type, column_name)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
return @default_type
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
class ::Post
|
|
61
|
+
def id
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
module ::Namespaced
|
|
65
|
+
class Post
|
|
66
|
+
def id
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
class ::Author
|
|
71
|
+
def to_label
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
class ::Continent
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def mock_everything
|
|
78
|
+
|
|
79
|
+
# Resource-oriented styles like form_for(@post) will expect a path method for the object,
|
|
80
|
+
# so we're defining some here.
|
|
81
|
+
def post_path(o); "/posts/1"; end
|
|
82
|
+
def posts_path; "/posts"; end
|
|
83
|
+
def new_post_path; "/posts/new"; end
|
|
84
|
+
|
|
85
|
+
def author_path(o); "/authors/1"; end
|
|
86
|
+
def authors_path; "/authors"; end
|
|
87
|
+
def new_author_path; "/authors/new"; end
|
|
88
|
+
|
|
89
|
+
@fred = mock('user')
|
|
90
|
+
@fred.stub!(:class).and_return(::Author)
|
|
91
|
+
@fred.stub!(:to_label).and_return('Fred Smith')
|
|
92
|
+
@fred.stub!(:login).and_return('fred_smith')
|
|
93
|
+
@fred.stub!(:id).and_return(37)
|
|
94
|
+
@fred.stub!(:new_record?).and_return(false)
|
|
95
|
+
@fred.stub!(:errors).and_return(mock('errors', :[] => nil))
|
|
96
|
+
|
|
97
|
+
@bob = mock('user')
|
|
98
|
+
@bob.stub!(:class).and_return(::Author)
|
|
99
|
+
@bob.stub!(:to_label).and_return('Bob Rock')
|
|
100
|
+
@bob.stub!(:login).and_return('bob')
|
|
101
|
+
@bob.stub!(:created_at)
|
|
102
|
+
@bob.stub!(:id).and_return(42)
|
|
103
|
+
@bob.stub!(:posts).and_return([])
|
|
104
|
+
@bob.stub!(:post_ids).and_return([])
|
|
105
|
+
@bob.stub!(:new_record?).and_return(false)
|
|
106
|
+
@bob.stub!(:errors).and_return(mock('errors', :[] => nil))
|
|
107
|
+
|
|
108
|
+
@james = mock('user')
|
|
109
|
+
@james.stub!(:class).and_return(::Author)
|
|
110
|
+
@james.stub!(:to_label).and_return('James Shock')
|
|
111
|
+
@james.stub!(:login).and_return('james')
|
|
112
|
+
@james.stub!(:id).and_return(75)
|
|
113
|
+
@james.stub!(:posts).and_return([])
|
|
114
|
+
@james.stub!(:post_ids).and_return([])
|
|
115
|
+
@james.stub!(:new_record?).and_return(false)
|
|
116
|
+
@james.stub!(:errors).and_return(mock('errors', :[] => nil))
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
::Author.stub!(:find).and_return([@fred, @bob])
|
|
120
|
+
::Author.stub!(:human_attribute_name).and_return { |column_name| column_name.humanize }
|
|
121
|
+
::Author.stub!(:human_name).and_return('::Author')
|
|
122
|
+
::Author.stub!(:reflect_on_validations_for).and_return([])
|
|
123
|
+
::Author.stub!(:reflect_on_association).and_return { |column_name| mock('reflection', :options => {}, :klass => Post, :macro => :has_many) if column_name == :posts }
|
|
124
|
+
::Author.stub!(:content_columns).and_return([mock('column', :name => 'login'), mock('column', :name => 'created_at')])
|
|
125
|
+
|
|
126
|
+
# Sometimes we need a mock @post object and some Authors for belongs_to
|
|
127
|
+
@new_post = mock('post')
|
|
128
|
+
@new_post.stub!(:class).and_return(::Post)
|
|
129
|
+
@new_post.stub!(:id).and_return(nil)
|
|
130
|
+
@new_post.stub!(:new_record?).and_return(true)
|
|
131
|
+
@new_post.stub!(:errors).and_return(mock('errors', :[] => nil))
|
|
132
|
+
@new_post.stub!(:author).and_return(nil)
|
|
133
|
+
@new_post.stub!(:main_post).and_return(nil)
|
|
134
|
+
@new_post.stub!(:sub_posts).and_return([]) #TODO should be a mock with methods for adding sub posts
|
|
135
|
+
|
|
136
|
+
@freds_post = mock('post')
|
|
137
|
+
@freds_post.stub!(:class).and_return(::Post)
|
|
138
|
+
@freds_post.stub!(:to_label).and_return('Fred Smith')
|
|
139
|
+
@freds_post.stub!(:id).and_return(19)
|
|
140
|
+
@freds_post.stub!(:author).and_return(@fred)
|
|
141
|
+
@freds_post.stub!(:author_id).and_return(@fred.id)
|
|
142
|
+
@freds_post.stub!(:authors).and_return([@fred])
|
|
143
|
+
@freds_post.stub!(:author_ids).and_return([@fred.id])
|
|
144
|
+
@freds_post.stub!(:new_record?).and_return(false)
|
|
145
|
+
@freds_post.stub!(:errors).and_return(mock('errors', :[] => nil))
|
|
146
|
+
@fred.stub!(:posts).and_return([@freds_post])
|
|
147
|
+
@fred.stub!(:post_ids).and_return([@freds_post.id])
|
|
148
|
+
|
|
149
|
+
::Post.stub!(:human_attribute_name).and_return { |column_name| column_name.humanize }
|
|
150
|
+
::Post.stub!(:human_name).and_return('Post')
|
|
151
|
+
::Post.stub!(:reflect_on_all_validations).and_return([])
|
|
152
|
+
::Post.stub!(:reflect_on_validations_for).and_return([])
|
|
153
|
+
::Post.stub!(:reflect_on_association).and_return do |column_name|
|
|
154
|
+
case column_name
|
|
155
|
+
when :author, :author_status
|
|
156
|
+
mock = mock('reflection', :options => {}, :klass => ::Author, :macro => :belongs_to)
|
|
157
|
+
mock.stub!(:[]).with(:class_name).and_return("Author")
|
|
158
|
+
mock
|
|
159
|
+
when :authors
|
|
160
|
+
mock('reflection', :options => {}, :klass => ::Author, :macro => :has_and_belongs_to_many)
|
|
161
|
+
when :sub_posts
|
|
162
|
+
mock('reflection', :options => {}, :klass => ::Post, :macro => :has_many)
|
|
163
|
+
when :main_post
|
|
164
|
+
mock('reflection', :options => {}, :klass => ::Post, :macro => :belongs_to)
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
end
|
|
168
|
+
::Post.stub!(:find).and_return([@freds_post])
|
|
169
|
+
::Post.stub!(:content_columns).and_return([mock('column', :name => 'title'), mock('column', :name => 'body'), mock('column', :name => 'created_at')])
|
|
170
|
+
|
|
171
|
+
@new_post.stub!(:title)
|
|
172
|
+
@new_post.stub!(:body)
|
|
173
|
+
@new_post.stub!(:published)
|
|
174
|
+
@new_post.stub!(:publish_at)
|
|
175
|
+
@new_post.stub!(:created_at)
|
|
176
|
+
@new_post.stub!(:secret)
|
|
177
|
+
@new_post.stub!(:time_zone)
|
|
178
|
+
@new_post.stub!(:category_name)
|
|
179
|
+
@new_post.stub!(:allow_comments)
|
|
180
|
+
@new_post.stub!(:column_for_attribute).with(:meta_description).and_return(mock('column', :type => :string, :limit => 255))
|
|
181
|
+
@new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :string, :limit => 50))
|
|
182
|
+
@new_post.stub!(:column_for_attribute).with(:body).and_return(mock('column', :type => :text))
|
|
183
|
+
@new_post.stub!(:column_for_attribute).with(:published).and_return(mock('column', :type => :boolean))
|
|
184
|
+
@new_post.stub!(:column_for_attribute).with(:publish_at).and_return(mock('column', :type => :date))
|
|
185
|
+
@new_post.stub!(:column_for_attribute).with(:time_zone).and_return(mock('column', :type => :string))
|
|
186
|
+
@new_post.stub!(:column_for_attribute).with(:allow_comments).and_return(mock('column', :type => :boolean))
|
|
187
|
+
|
|
188
|
+
@new_post.stub!(:author).and_return(@bob)
|
|
189
|
+
@new_post.stub!(:author_id).and_return(@bob.id)
|
|
190
|
+
|
|
191
|
+
@new_post.should_receive(:publish_at=).any_number_of_times
|
|
192
|
+
@new_post.should_receive(:title=).any_number_of_times
|
|
193
|
+
@new_post.stub!(:main_post_id).and_return(nil)
|
|
194
|
+
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
def self.included(base)
|
|
198
|
+
base.class_eval do
|
|
199
|
+
|
|
200
|
+
attr_accessor :output_buffer
|
|
201
|
+
|
|
202
|
+
def protect_against_forgery?
|
|
203
|
+
false
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
def with_config(config_method_name, value, &block)
|
|
210
|
+
old_value = ::Formtastic::SemanticFormBuilder.send(config_method_name)
|
|
211
|
+
::Formtastic::SemanticFormBuilder.send(:"#{config_method_name}=", value)
|
|
212
|
+
yield
|
|
213
|
+
::Formtastic::SemanticFormBuilder.send(:"#{config_method_name}=", old_value)
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
::ActiveSupport::Deprecation.silenced = false
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Uninstall hook code here
|
metadata
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: jintastic
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.2
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Nandor Komzak
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
|
|
12
|
+
date: 2010-02-13 00:00:00 +01:00
|
|
13
|
+
default_executable:
|
|
14
|
+
dependencies:
|
|
15
|
+
- !ruby/object:Gem::Dependency
|
|
16
|
+
name: formtastic
|
|
17
|
+
type: :runtime
|
|
18
|
+
version_requirement:
|
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
20
|
+
requirements:
|
|
21
|
+
- - ">="
|
|
22
|
+
- !ruby/object:Gem::Version
|
|
23
|
+
version: "0"
|
|
24
|
+
version:
|
|
25
|
+
description: jQuery based in-place editor generated by Formtastic
|
|
26
|
+
email: nandor.komzak@gmail.com
|
|
27
|
+
executables: []
|
|
28
|
+
|
|
29
|
+
extensions: []
|
|
30
|
+
|
|
31
|
+
extra_rdoc_files:
|
|
32
|
+
- README.md
|
|
33
|
+
files:
|
|
34
|
+
- .document
|
|
35
|
+
- .gitignore
|
|
36
|
+
- MIT-LICENSE
|
|
37
|
+
- README.md
|
|
38
|
+
- Rakefile
|
|
39
|
+
- VERSION.yml
|
|
40
|
+
- assets/app/views/jintastic/_in_place_editor.html.erb
|
|
41
|
+
- assets/public/javascripts/jintastic.js
|
|
42
|
+
- config/locale/en.yml
|
|
43
|
+
- init.rb
|
|
44
|
+
- jintastic.gemspec
|
|
45
|
+
- lib/jintastic.rb
|
|
46
|
+
- test/jintastic_test.rb
|
|
47
|
+
- test/test_helper.rb
|
|
48
|
+
- vendor/plugins/formtastic/.gitignore
|
|
49
|
+
- vendor/plugins/formtastic/MIT-LICENSE
|
|
50
|
+
- vendor/plugins/formtastic/README.textile
|
|
51
|
+
- vendor/plugins/formtastic/RELEASE_PROCESS
|
|
52
|
+
- vendor/plugins/formtastic/Rakefile
|
|
53
|
+
- vendor/plugins/formtastic/VERSION.yml
|
|
54
|
+
- vendor/plugins/formtastic/formtastic.gemspec
|
|
55
|
+
- vendor/plugins/formtastic/generators/form/USAGE
|
|
56
|
+
- vendor/plugins/formtastic/generators/form/form_generator.rb
|
|
57
|
+
- vendor/plugins/formtastic/generators/form/templates/view__form.html.erb
|
|
58
|
+
- vendor/plugins/formtastic/generators/form/templates/view__form.html.haml
|
|
59
|
+
- vendor/plugins/formtastic/generators/formtastic/formtastic_generator.rb
|
|
60
|
+
- vendor/plugins/formtastic/generators/formtastic/templates/formtastic.css
|
|
61
|
+
- vendor/plugins/formtastic/generators/formtastic/templates/formtastic_changes.css
|
|
62
|
+
- vendor/plugins/formtastic/generators/formtastic/templates/formtastic_config.rb
|
|
63
|
+
- vendor/plugins/formtastic/generators/formtastic_stylesheets/formtastic_stylesheets_generator.rb
|
|
64
|
+
- vendor/plugins/formtastic/install.rb
|
|
65
|
+
- vendor/plugins/formtastic/lib/formtastic.rb
|
|
66
|
+
- vendor/plugins/formtastic/lib/formtastic/i18n.rb
|
|
67
|
+
- vendor/plugins/formtastic/lib/locale/en.yml
|
|
68
|
+
- vendor/plugins/formtastic/rails/init.rb
|
|
69
|
+
- vendor/plugins/formtastic/spec/buttons_spec.rb
|
|
70
|
+
- vendor/plugins/formtastic/spec/commit_button_spec.rb
|
|
71
|
+
- vendor/plugins/formtastic/spec/custom_builder_spec.rb
|
|
72
|
+
- vendor/plugins/formtastic/spec/custom_macros.rb
|
|
73
|
+
- vendor/plugins/formtastic/spec/defaults_spec.rb
|
|
74
|
+
- vendor/plugins/formtastic/spec/error_proc_spec.rb
|
|
75
|
+
- vendor/plugins/formtastic/spec/errors_spec.rb
|
|
76
|
+
- vendor/plugins/formtastic/spec/form_helper_spec.rb
|
|
77
|
+
- vendor/plugins/formtastic/spec/i18n_spec.rb
|
|
78
|
+
- vendor/plugins/formtastic/spec/include_blank_spec.rb
|
|
79
|
+
- vendor/plugins/formtastic/spec/input_spec.rb
|
|
80
|
+
- vendor/plugins/formtastic/spec/inputs/boolean_input_spec.rb
|
|
81
|
+
- vendor/plugins/formtastic/spec/inputs/check_boxes_input_spec.rb
|
|
82
|
+
- vendor/plugins/formtastic/spec/inputs/country_input_spec.rb
|
|
83
|
+
- vendor/plugins/formtastic/spec/inputs/date_input_spec.rb
|
|
84
|
+
- vendor/plugins/formtastic/spec/inputs/datetime_input_spec.rb
|
|
85
|
+
- vendor/plugins/formtastic/spec/inputs/file_input_spec.rb
|
|
86
|
+
- vendor/plugins/formtastic/spec/inputs/hidden_input_spec.rb
|
|
87
|
+
- vendor/plugins/formtastic/spec/inputs/numeric_input_spec.rb
|
|
88
|
+
- vendor/plugins/formtastic/spec/inputs/password_input_spec.rb
|
|
89
|
+
- vendor/plugins/formtastic/spec/inputs/radio_input_spec.rb
|
|
90
|
+
- vendor/plugins/formtastic/spec/inputs/select_input_spec.rb
|
|
91
|
+
- vendor/plugins/formtastic/spec/inputs/string_input_spec.rb
|
|
92
|
+
- vendor/plugins/formtastic/spec/inputs/text_input_spec.rb
|
|
93
|
+
- vendor/plugins/formtastic/spec/inputs/time_input_spec.rb
|
|
94
|
+
- vendor/plugins/formtastic/spec/inputs/time_zone_input_spec.rb
|
|
95
|
+
- vendor/plugins/formtastic/spec/inputs_spec.rb
|
|
96
|
+
- vendor/plugins/formtastic/spec/label_spec.rb
|
|
97
|
+
- vendor/plugins/formtastic/spec/semantic_errors_spec.rb
|
|
98
|
+
- vendor/plugins/formtastic/spec/semantic_fields_for_spec.rb
|
|
99
|
+
- vendor/plugins/formtastic/spec/spec.opts
|
|
100
|
+
- vendor/plugins/formtastic/spec/spec_helper.rb
|
|
101
|
+
- vendor/plugins/formtastic/uninstall.rb
|
|
102
|
+
has_rdoc: true
|
|
103
|
+
homepage: http://github.com/rubymood/jintastic
|
|
104
|
+
licenses: []
|
|
105
|
+
|
|
106
|
+
post_install_message:
|
|
107
|
+
rdoc_options:
|
|
108
|
+
- --charset=UTF-8
|
|
109
|
+
require_paths:
|
|
110
|
+
- lib
|
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
112
|
+
requirements:
|
|
113
|
+
- - ">="
|
|
114
|
+
- !ruby/object:Gem::Version
|
|
115
|
+
version: "0"
|
|
116
|
+
version:
|
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
|
+
requirements:
|
|
119
|
+
- - ">="
|
|
120
|
+
- !ruby/object:Gem::Version
|
|
121
|
+
version: "0"
|
|
122
|
+
version:
|
|
123
|
+
requirements: []
|
|
124
|
+
|
|
125
|
+
rubyforge_project:
|
|
126
|
+
rubygems_version: 1.3.5
|
|
127
|
+
signing_key:
|
|
128
|
+
specification_version: 3
|
|
129
|
+
summary: jQuery based in-place editor generated by Formtastic
|
|
130
|
+
test_files:
|
|
131
|
+
- test/test_helper.rb
|
|
132
|
+
- test/jintastic_test.rb
|