radiant 0.6.6 → 0.6.7
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of radiant might be problematic. Click here for more details.
- data/CHANGELOG +15 -0
- data/CONTRIBUTORS +8 -0
- data/app/controllers/admin/page_controller.rb +1 -11
- data/app/controllers/admin/welcome_controller.rb +5 -6
- data/app/controllers/application.rb +2 -0
- data/app/controllers/site_controller.rb +1 -0
- data/app/helpers/admin/page_helper.rb +36 -0
- data/app/helpers/admin/regions_helper.rb +28 -0
- data/app/helpers/admin/user_helper.rb +6 -0
- data/app/helpers/application_helper.rb +2 -1
- data/app/models/user.rb +7 -8
- data/app/views/admin/extension/index.html.haml +28 -0
- data/app/views/admin/layout/edit.html.haml +44 -0
- data/app/views/admin/layout/index.html.haml +25 -0
- data/app/views/admin/layout/remove.html.haml +16 -0
- data/app/views/admin/page/_meta_row.html.haml +6 -0
- data/app/views/admin/page/_node.html.haml +25 -0
- data/app/views/admin/page/_part.html.haml +17 -0
- data/app/views/admin/page/_tag_reference.html.haml +3 -0
- data/app/views/admin/page/children.html.haml +2 -0
- data/app/views/admin/page/edit.html.haml +114 -0
- data/app/views/admin/page/index.html.haml +28 -0
- data/app/views/admin/page/remove.html.haml +20 -0
- data/app/views/admin/snippet/edit.html.haml +36 -0
- data/app/views/admin/snippet/index.html.haml +20 -0
- data/app/views/admin/snippet/remove.html.haml +19 -0
- data/app/views/admin/user/edit.html.haml +80 -0
- data/app/views/admin/user/index.html.haml +23 -0
- data/app/views/admin/user/preferences.html.haml +28 -0
- data/app/views/admin/user/remove.html.haml +18 -0
- data/app/views/admin/welcome/login.html.haml +44 -0
- data/app/views/layouts/application.html.haml +54 -0
- data/app/views/site/not_found.html.haml +3 -0
- data/db/migrate/019_add_salt_to_users.rb +11 -0
- data/db/schema.rb +2 -1
- data/lib/login_system.rb +1 -0
- data/lib/radiant.rb +1 -1
- data/lib/radiant/admin_ui.rb +65 -0
- data/lib/radiant/admin_ui/region_partials.rb +18 -0
- data/lib/radiant/admin_ui/region_set.rb +35 -0
- data/lib/tasks/extensions.rake +33 -0
- data/public/javascripts/admin/admin.js +8 -2
- data/public/javascripts/admin/sitemap.js +2 -1
- data/public/stylesheets/admin/main.css +4 -0
- data/spec/controllers/admin/abstract_model_controller_spec.rb +2 -0
- data/spec/controllers/admin/page_controller_spec.rb +3 -28
- data/spec/controllers/admin/user_controller_spec.rb +1 -1
- data/spec/controllers/admin/welcome_controller_spec.rb +26 -0
- data/spec/helpers/admin/page_helper_spec.rb +4 -0
- data/spec/helpers/admin/regions_helper_spec.rb +47 -0
- data/spec/helpers/admin/user_helper_spec.rb +7 -0
- data/spec/helpers/application_helper_spec.rb +7 -3
- data/spec/lib/login_system_spec.rb +5 -0
- data/spec/lib/radiant/admin_ui/region_partials_spec.rb +35 -0
- data/spec/lib/radiant/admin_ui/region_set_spec.rb +61 -0
- data/spec/lib/radiant/admin_ui_spec.rb +74 -18
- data/spec/models/user_spec.rb +11 -4
- data/spec/scenarios/users_scenario.rb +2 -2
- data/vendor/plugins/haml/MIT-LICENSE +20 -0
- data/vendor/plugins/haml/README.rdoc +319 -0
- data/vendor/plugins/haml/Rakefile +158 -0
- data/vendor/plugins/haml/TODO +9 -0
- data/vendor/plugins/haml/VERSION +1 -0
- data/vendor/plugins/haml/bin/css2sass +7 -0
- data/vendor/plugins/haml/bin/haml +8 -0
- data/vendor/plugins/haml/bin/html2haml +7 -0
- data/vendor/plugins/haml/bin/sass +8 -0
- data/vendor/plugins/haml/extra/haml-mode.el +328 -0
- data/vendor/plugins/haml/extra/sass-mode.el +88 -0
- data/vendor/plugins/haml/init.rb +2 -0
- data/vendor/plugins/haml/lib/haml.rb +977 -0
- data/vendor/plugins/haml/lib/haml/buffer.rb +229 -0
- data/vendor/plugins/haml/lib/haml/engine.rb +274 -0
- data/vendor/plugins/haml/lib/haml/error.rb +23 -0
- data/vendor/plugins/haml/lib/haml/exec.rb +347 -0
- data/vendor/plugins/haml/lib/haml/filters.rb +249 -0
- data/vendor/plugins/haml/lib/haml/helpers.rb +413 -0
- data/vendor/plugins/haml/lib/haml/helpers/action_view_extensions.rb +45 -0
- data/vendor/plugins/haml/lib/haml/helpers/action_view_mods.rb +122 -0
- data/vendor/plugins/haml/lib/haml/html.rb +188 -0
- data/vendor/plugins/haml/lib/haml/precompiler.rb +757 -0
- data/vendor/plugins/haml/lib/haml/template.rb +43 -0
- data/vendor/plugins/haml/lib/haml/template/patch.rb +58 -0
- data/vendor/plugins/haml/lib/haml/template/plugin.rb +72 -0
- data/vendor/plugins/haml/lib/sass.rb +833 -0
- data/vendor/plugins/haml/lib/sass/constant.rb +245 -0
- data/vendor/plugins/haml/lib/sass/constant/color.rb +101 -0
- data/vendor/plugins/haml/lib/sass/constant/literal.rb +53 -0
- data/vendor/plugins/haml/lib/sass/constant/number.rb +87 -0
- data/vendor/plugins/haml/lib/sass/constant/operation.rb +30 -0
- data/vendor/plugins/haml/lib/sass/constant/string.rb +22 -0
- data/vendor/plugins/haml/lib/sass/css.rb +378 -0
- data/vendor/plugins/haml/lib/sass/engine.rb +459 -0
- data/vendor/plugins/haml/lib/sass/error.rb +35 -0
- data/vendor/plugins/haml/lib/sass/plugin.rb +165 -0
- data/vendor/plugins/haml/lib/sass/plugin/merb.rb +56 -0
- data/vendor/plugins/haml/lib/sass/plugin/rails.rb +24 -0
- data/vendor/plugins/haml/lib/sass/tree/attr_node.rb +53 -0
- data/vendor/plugins/haml/lib/sass/tree/comment_node.rb +20 -0
- data/vendor/plugins/haml/lib/sass/tree/directive_node.rb +46 -0
- data/vendor/plugins/haml/lib/sass/tree/node.rb +42 -0
- data/vendor/plugins/haml/lib/sass/tree/rule_node.rb +89 -0
- data/vendor/plugins/haml/lib/sass/tree/value_node.rb +16 -0
- data/vendor/plugins/haml/test/benchmark.rb +82 -0
- data/vendor/plugins/haml/test/haml/engine_test.rb +587 -0
- data/vendor/plugins/haml/test/haml/helper_test.rb +187 -0
- data/vendor/plugins/haml/test/haml/html2haml_test.rb +60 -0
- data/vendor/plugins/haml/test/haml/markaby/standard.mab +52 -0
- data/vendor/plugins/haml/test/haml/mocks/article.rb +6 -0
- data/vendor/plugins/haml/test/haml/results/content_for_layout.xhtml +16 -0
- data/vendor/plugins/haml/test/haml/results/eval_suppressed.xhtml +11 -0
- data/vendor/plugins/haml/test/haml/results/filters.xhtml +82 -0
- data/vendor/plugins/haml/test/haml/results/helpers.xhtml +94 -0
- data/vendor/plugins/haml/test/haml/results/helpful.xhtml +10 -0
- data/vendor/plugins/haml/test/haml/results/just_stuff.xhtml +64 -0
- data/vendor/plugins/haml/test/haml/results/list.xhtml +12 -0
- data/vendor/plugins/haml/test/haml/results/original_engine.xhtml +22 -0
- data/vendor/plugins/haml/test/haml/results/partials.xhtml +21 -0
- data/vendor/plugins/haml/test/haml/results/silent_script.xhtml +74 -0
- data/vendor/plugins/haml/test/haml/results/standard.xhtml +42 -0
- data/vendor/plugins/haml/test/haml/results/tag_parsing.xhtml +28 -0
- data/vendor/plugins/haml/test/haml/results/very_basic.xhtml +7 -0
- data/vendor/plugins/haml/test/haml/results/whitespace_handling.xhtml +94 -0
- data/vendor/plugins/haml/test/haml/rhtml/_av_partial_1.rhtml +12 -0
- data/vendor/plugins/haml/test/haml/rhtml/_av_partial_2.rhtml +8 -0
- data/vendor/plugins/haml/test/haml/rhtml/action_view.rhtml +62 -0
- data/vendor/plugins/haml/test/haml/rhtml/standard.rhtml +54 -0
- data/vendor/plugins/haml/test/haml/template_test.rb +168 -0
- data/vendor/plugins/haml/test/haml/templates/_av_partial_1.haml +9 -0
- data/vendor/plugins/haml/test/haml/templates/_av_partial_2.haml +5 -0
- data/vendor/plugins/haml/test/haml/templates/_partial.haml +8 -0
- data/vendor/plugins/haml/test/haml/templates/_text_area.haml +3 -0
- data/vendor/plugins/haml/test/haml/templates/action_view.haml +47 -0
- data/vendor/plugins/haml/test/haml/templates/breakage.haml +8 -0
- data/vendor/plugins/haml/test/haml/templates/content_for_layout.haml +10 -0
- data/vendor/plugins/haml/test/haml/templates/eval_suppressed.haml +11 -0
- data/vendor/plugins/haml/test/haml/templates/filters.haml +81 -0
- data/vendor/plugins/haml/test/haml/templates/helpers.haml +69 -0
- data/vendor/plugins/haml/test/haml/templates/helpful.haml +11 -0
- data/vendor/plugins/haml/test/haml/templates/just_stuff.haml +77 -0
- data/vendor/plugins/haml/test/haml/templates/list.haml +12 -0
- data/vendor/plugins/haml/test/haml/templates/original_engine.haml +17 -0
- data/vendor/plugins/haml/test/haml/templates/partialize.haml +1 -0
- data/vendor/plugins/haml/test/haml/templates/partials.haml +12 -0
- data/vendor/plugins/haml/test/haml/templates/silent_script.haml +40 -0
- data/vendor/plugins/haml/test/haml/templates/standard.haml +42 -0
- data/vendor/plugins/haml/test/haml/templates/tag_parsing.haml +24 -0
- data/vendor/plugins/haml/test/haml/templates/very_basic.haml +4 -0
- data/vendor/plugins/haml/test/haml/templates/whitespace_handling.haml +87 -0
- data/vendor/plugins/haml/test/haml/test_helper.rb +15 -0
- data/vendor/plugins/haml/test/profile.rb +65 -0
- data/vendor/plugins/haml/test/sass/engine_test.rb +276 -0
- data/vendor/plugins/haml/test/sass/plugin_test.rb +159 -0
- data/vendor/plugins/haml/test/sass/results/alt.css +4 -0
- data/vendor/plugins/haml/test/sass/results/basic.css +9 -0
- data/vendor/plugins/haml/test/sass/results/compact.css +5 -0
- data/vendor/plugins/haml/test/sass/results/complex.css +87 -0
- data/vendor/plugins/haml/test/sass/results/compressed.css +1 -0
- data/vendor/plugins/haml/test/sass/results/constants.css +14 -0
- data/vendor/plugins/haml/test/sass/results/expanded.css +19 -0
- data/vendor/plugins/haml/test/sass/results/import.css +29 -0
- data/vendor/plugins/haml/test/sass/results/mixins.css +95 -0
- data/vendor/plugins/haml/test/sass/results/multiline.css +24 -0
- data/vendor/plugins/haml/test/sass/results/nested.css +22 -0
- data/vendor/plugins/haml/test/sass/results/parent_ref.css +13 -0
- data/vendor/plugins/haml/test/sass/results/subdir/nested_subdir/nested_subdir.css +1 -0
- data/vendor/plugins/haml/test/sass/results/subdir/subdir.css +1 -0
- data/vendor/plugins/haml/test/sass/templates/_partial.sass +2 -0
- data/vendor/plugins/haml/test/sass/templates/alt.sass +16 -0
- data/vendor/plugins/haml/test/sass/templates/basic.sass +23 -0
- data/vendor/plugins/haml/test/sass/templates/bork.sass +2 -0
- data/vendor/plugins/haml/test/sass/templates/bork2.sass +2 -0
- data/vendor/plugins/haml/test/sass/templates/compact.sass +17 -0
- data/vendor/plugins/haml/test/sass/templates/complex.sass +310 -0
- data/vendor/plugins/haml/test/sass/templates/compressed.sass +15 -0
- data/vendor/plugins/haml/test/sass/templates/constants.sass +97 -0
- data/vendor/plugins/haml/test/sass/templates/expanded.sass +17 -0
- data/vendor/plugins/haml/test/sass/templates/import.sass +11 -0
- data/vendor/plugins/haml/test/sass/templates/importee.sass +14 -0
- data/vendor/plugins/haml/test/sass/templates/mixins.sass +76 -0
- data/vendor/plugins/haml/test/sass/templates/multiline.sass +20 -0
- data/vendor/plugins/haml/test/sass/templates/nested.sass +25 -0
- data/vendor/plugins/haml/test/sass/templates/parent_ref.sass +25 -0
- data/vendor/plugins/haml/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +3 -0
- data/vendor/plugins/haml/test/sass/templates/subdir/subdir.sass +6 -0
- metadata +185 -24
- data/app/views/admin/extension/index.html.erb +0 -40
- data/app/views/admin/layout/edit.html.erb +0 -39
- data/app/views/admin/layout/index.html.erb +0 -38
- data/app/views/admin/layout/remove.html.erb +0 -17
- data/app/views/admin/page/_meta_row.html.erb +0 -4
- data/app/views/admin/page/_node.html.erb +0 -28
- data/app/views/admin/page/_part.html.erb +0 -13
- data/app/views/admin/page/_tag_reference.html.erb +0 -4
- data/app/views/admin/page/children.html.erb +0 -4
- data/app/views/admin/page/edit.html.erb +0 -140
- data/app/views/admin/page/index.html.erb +0 -31
- data/app/views/admin/page/remove.html.erb +0 -14
- data/app/views/admin/snippet/edit.html.erb +0 -29
- data/app/views/admin/snippet/index.html.erb +0 -36
- data/app/views/admin/snippet/remove.html.erb +0 -16
- data/app/views/admin/user/edit.html.erb +0 -54
- data/app/views/admin/user/index.html.erb +0 -43
- data/app/views/admin/user/preferences.html.erb +0 -29
- data/app/views/admin/user/remove.html.erb +0 -16
- data/app/views/admin/welcome/login.html.erb +0 -51
- data/app/views/layouts/application.html.erb +0 -83
- data/app/views/site/not_found.html.erb +0 -3
@@ -2,19 +2,75 @@ require File.dirname(__FILE__) + "/../../spec_helper"
|
|
2
2
|
|
3
3
|
describe Radiant::AdminUI do
|
4
4
|
before :each do
|
5
|
-
@admin = Radiant::AdminUI.
|
5
|
+
@admin = Radiant::AdminUI.new
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
it "should be a Simpleton" do
|
9
9
|
Radiant::AdminUI.included_modules.should include(Simpleton)
|
10
10
|
Radiant::AdminUI.should respond_to(:instance)
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
it "should have a TabSet" do
|
14
14
|
@admin.should respond_to(:tabs)
|
15
15
|
@admin.tabs.should_not be_nil
|
16
16
|
@admin.tabs.should be_instance_of(Radiant::AdminUI::TabSet)
|
17
17
|
end
|
18
|
+
|
19
|
+
it "should have collections of Region Sets for every controller" do
|
20
|
+
%w{page snippet layout user}.each do |collection|
|
21
|
+
@admin.should respond_to(collection)
|
22
|
+
@admin.send(collection).should_not be_nil
|
23
|
+
@admin.send(collection).should be_kind_of(OpenStruct)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should load the default page regions" do
|
28
|
+
page = @admin.page
|
29
|
+
%w{edit remove children index}.each do |action|
|
30
|
+
page.send(action).should_not be_nil
|
31
|
+
page.send(action).should be_kind_of(Radiant::AdminUI::RegionSet)
|
32
|
+
end
|
33
|
+
page.edit.main.should == %w{edit_header edit_form edit_popups}
|
34
|
+
page.edit.form.should == %w{edit_title edit_extended_metadata
|
35
|
+
edit_page_parts}
|
36
|
+
page.edit.parts_bottom.should == %w{edit_layout_and_type edit_timestamp}
|
37
|
+
page.edit.form_bottom.should == %w{edit_buttons}
|
38
|
+
page.index.sitemap_head.should == %w{title_column_header
|
39
|
+
status_column_header
|
40
|
+
modify_column_header}
|
41
|
+
page.index.node.should == %w{title_column status_column add_child_column
|
42
|
+
remove_column}
|
43
|
+
page.remove.should === page.index
|
44
|
+
page.children.should === page.index
|
45
|
+
page._part.should === page.edit
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should load the default snippet regions" do
|
49
|
+
snippet = @admin.snippet
|
50
|
+
snippet.edit.should_not be_nil
|
51
|
+
snippet.edit.main.should == %w{edit_header edit_form}
|
52
|
+
snippet.edit.form.should == %w{edit_title edit_content edit_filter
|
53
|
+
edit_timestamp}
|
54
|
+
snippet.edit.form_bottom.should == %w{edit_buttons}
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should load the default layout regions" do
|
58
|
+
layout = @admin.layout
|
59
|
+
layout.edit.should_not be_nil
|
60
|
+
layout.edit.main.should == %w{edit_header edit_form}
|
61
|
+
layout.edit.form.should == %w{edit_title edit_extended_metadata
|
62
|
+
edit_content edit_timestamp}
|
63
|
+
layout.edit.form_bottom.should == %w{edit_buttons}
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should load the default user regions" do
|
67
|
+
user = @admin.user
|
68
|
+
user.edit.should_not be_nil
|
69
|
+
user.edit.main.should == %w{edit_header edit_form}
|
70
|
+
user.edit.form.should == %w{edit_name edit_email edit_username
|
71
|
+
edit_password edit_roles edit_notes}
|
72
|
+
user.edit.form_bottom.should == %w{edit_timestamp edit_buttons}
|
73
|
+
end
|
18
74
|
end
|
19
75
|
|
20
76
|
describe Radiant::AdminUI::TabSet do
|
@@ -30,7 +86,7 @@ describe Radiant::AdminUI::TabSet do
|
|
30
86
|
it "should be Enumerable" do
|
31
87
|
@tabs.class.included_modules.should include(Enumerable)
|
32
88
|
end
|
33
|
-
|
89
|
+
|
34
90
|
it "should have its tabs accessible by name using brackets" do
|
35
91
|
@tabs.should respond_to(:[])
|
36
92
|
@tab_names.each do |name|
|
@@ -38,27 +94,27 @@ describe Radiant::AdminUI::TabSet do
|
|
38
94
|
@tabs[name].name.should == name
|
39
95
|
end
|
40
96
|
end
|
41
|
-
|
97
|
+
|
42
98
|
it "should have its tabs accessible by index using brackets" do
|
43
99
|
@tab_names.each_with_index do |name, index|
|
44
100
|
@tabs[index].should be_instance_of(Radiant::AdminUI::Tab)
|
45
101
|
@tabs[index].name.should == name
|
46
|
-
end
|
102
|
+
end
|
47
103
|
end
|
48
|
-
|
104
|
+
|
49
105
|
it "should add new tabs to the end by default" do
|
50
106
|
@tabs.size.should == 3
|
51
107
|
@tabs.add "Test", "/test"
|
52
108
|
@tabs[3].name.should == "Test"
|
53
109
|
end
|
54
|
-
|
110
|
+
|
55
111
|
it "should add a new tab before the specified tab" do
|
56
112
|
@tabs[1].name.should == "Second"
|
57
113
|
@tabs.add "Before", "/before", :before => "Second"
|
58
114
|
@tabs[1].name.should == "Before"
|
59
115
|
@tabs[2].name.should == "Second"
|
60
116
|
end
|
61
|
-
|
117
|
+
|
62
118
|
it "should add a new tab after the specified tab" do
|
63
119
|
@tabs[1].name.should == "Second"
|
64
120
|
@tabs[2].name.should == "Third"
|
@@ -67,18 +123,18 @@ describe Radiant::AdminUI::TabSet do
|
|
67
123
|
@tabs[1].name.should == "Second"
|
68
124
|
@tabs[3].name.should == "Third"
|
69
125
|
end
|
70
|
-
|
126
|
+
|
71
127
|
it "should remove a tab by name" do
|
72
128
|
@tabs.size.should == 3
|
73
129
|
@tabs.remove "Second"
|
74
130
|
@tabs.size.should == 2
|
75
131
|
@tabs[1].name.should == "Third"
|
76
132
|
end
|
77
|
-
|
133
|
+
|
78
134
|
it "should not allow adding a tab with the same name as an existing tab" do
|
79
135
|
lambda { @tabs.add "First", "/first" }.should raise_error(Radiant::AdminUI::DuplicateTabNameError)
|
80
136
|
end
|
81
|
-
|
137
|
+
|
82
138
|
it "should remove all tabs when cleared" do
|
83
139
|
@tabs.size.should == 3
|
84
140
|
@tabs.clear
|
@@ -99,7 +155,7 @@ describe Radiant::AdminUI::Tab do
|
|
99
155
|
@tab.should be_shown_for(users(user))
|
100
156
|
end
|
101
157
|
end
|
102
|
-
|
158
|
+
|
103
159
|
it "should be shown only to admin users when visibility is admin" do
|
104
160
|
@tab.visibility = [:admin]
|
105
161
|
@tab.should be_shown_for(users(:admin))
|
@@ -107,25 +163,25 @@ describe Radiant::AdminUI::Tab do
|
|
107
163
|
@tab.should_not be_shown_for(users(user))
|
108
164
|
end
|
109
165
|
end
|
110
|
-
|
166
|
+
|
111
167
|
it "should be shown only to developer users when visibility is developer" do
|
112
168
|
@tab.visibility = [:developer]
|
113
169
|
@tab.should be_shown_for(users(:developer))
|
114
170
|
[:existing, :another, :admin, :non_admin].each do |user|
|
115
171
|
@tab.should_not be_shown_for(users(user))
|
116
|
-
end
|
172
|
+
end
|
117
173
|
end
|
118
|
-
|
174
|
+
|
119
175
|
it "should assign visibility from :for option when created" do
|
120
176
|
@tab = Radiant::AdminUI::Tab.new "Test", "/test", :for => :developer
|
121
177
|
@tab.visibility.should == [:developer]
|
122
178
|
end
|
123
|
-
|
179
|
+
|
124
180
|
it "should assign visibility from :visibility option when created" do
|
125
181
|
@tab = Radiant::AdminUI::Tab.new "Test", "/test", :visibility => :developer
|
126
182
|
@tab.visibility.should == [:developer]
|
127
183
|
end
|
128
|
-
|
184
|
+
|
129
185
|
it "should assign visibility from both :for and :visibility options when created" do
|
130
186
|
@tab = Radiant::AdminUI::Tab.new "Test", "/test", :for => :developer, :visibility => :admin
|
131
187
|
@tab.visibility.should == [:developer, :admin]
|
data/spec/models/user_spec.rb
CHANGED
@@ -93,26 +93,33 @@ describe User do
|
|
93
93
|
@user.confirm_password = true
|
94
94
|
@user.password_confirmation = @user.password = 'test_password'
|
95
95
|
@user.save!
|
96
|
-
@user.password.should ==
|
96
|
+
@user.password.should == @user.sha1('test_password')
|
97
97
|
end
|
98
98
|
|
99
99
|
it 'should save existing but empty password' do
|
100
100
|
@user.save!
|
101
101
|
@user.password_confirmation = @user.password = ''
|
102
102
|
@user.save!
|
103
|
-
@user.password.should ==
|
103
|
+
@user.password.should == @user.sha1('password')
|
104
104
|
end
|
105
105
|
|
106
106
|
it 'should save existing but different password' do
|
107
107
|
@user.save!
|
108
108
|
@user.password_confirmation = @user.password = 'cool beans'
|
109
109
|
@user.save!
|
110
|
-
@user.password.should ==
|
110
|
+
@user.password.should == @user.sha1('cool beans')
|
111
111
|
end
|
112
112
|
|
113
113
|
it 'should save existing but same password' do
|
114
114
|
@user.save! && @user.save!
|
115
|
-
@user.password.should ==
|
115
|
+
@user.password.should == @user.sha1('password')
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should create a salt when encrypting the password" do
|
119
|
+
@user.salt.should be_nil
|
120
|
+
@user.send(:encrypt_password)
|
121
|
+
@user.salt.should_not be_nil
|
122
|
+
@user.password.should == @user.sha1('password')
|
116
123
|
end
|
117
124
|
end
|
118
125
|
|
@@ -10,7 +10,7 @@ class UsersScenario < Scenario::Base
|
|
10
10
|
|
11
11
|
helpers do
|
12
12
|
def create_user(name, attributes={})
|
13
|
-
|
13
|
+
create_model :user, name.symbolize, user_attributes(attributes.update(:name => name))
|
14
14
|
end
|
15
15
|
def user_attributes(attributes={})
|
16
16
|
name = attributes[:name] || "John Doe"
|
@@ -21,7 +21,7 @@ class UsersScenario < Scenario::Base
|
|
21
21
|
:login => symbol.to_s,
|
22
22
|
:password => "password"
|
23
23
|
}.merge(attributes)
|
24
|
-
attributes[:
|
24
|
+
attributes[:password_confirmation] = attributes[:password]
|
25
25
|
attributes
|
26
26
|
end
|
27
27
|
def user_params(attributes={})
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2006-2008 Hampton Catlin
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,319 @@
|
|
1
|
+
= Haml and Sass
|
2
|
+
|
3
|
+
Haml and Sass are templating engines
|
4
|
+
for the two most common types of documents on the web:
|
5
|
+
HTML and CSS, respectively.
|
6
|
+
They are designed to make it both easier and more pleasant
|
7
|
+
to code HTML and CSS documents,
|
8
|
+
by eliminating redundancy,
|
9
|
+
reflecting the underlying structure that the document represents,
|
10
|
+
and providing elegant, easily understandable, and powerful syntax.
|
11
|
+
|
12
|
+
== Using
|
13
|
+
|
14
|
+
There are several ways to use Haml and Sass.
|
15
|
+
They can be used as a plugins for Rails or Merb,
|
16
|
+
or embedded on their own in other applications.
|
17
|
+
The first step of all of these is to install the Haml gem:
|
18
|
+
|
19
|
+
gem install haml
|
20
|
+
|
21
|
+
To install Haml and Sass as a Rails plugin,
|
22
|
+
just run <tt>haml --rails path/to/rails/app</tt>
|
23
|
+
and both Haml and Sass will be installed.
|
24
|
+
Views with the <tt>.haml</tt> (or <tt>.html.haml</tt> for edge)
|
25
|
+
extension will automatically use Haml.
|
26
|
+
Sass is a little more complicated;
|
27
|
+
<tt>.sass</tt> files should be placed in public/stylesheets/sass,
|
28
|
+
where they'll be automatically compiled
|
29
|
+
to corresponding CSS files in public/stylesheets when needed
|
30
|
+
(the Sass template directory is customizable...
|
31
|
+
see the Sass module docs for details).
|
32
|
+
|
33
|
+
For Merb, <tt>.html.haml</tt> views will work without any further modification.
|
34
|
+
To enable Sass, you also need to add it add a dependency.
|
35
|
+
To do so, just add
|
36
|
+
|
37
|
+
dependency "haml"
|
38
|
+
|
39
|
+
to config/dependencies.rb.
|
40
|
+
Then it'll work just like it does in Rails.
|
41
|
+
|
42
|
+
To use Haml and Sass programatically,
|
43
|
+
check out the RDocs for the Haml and Sass modules.
|
44
|
+
|
45
|
+
== Formatting
|
46
|
+
|
47
|
+
=== Haml
|
48
|
+
|
49
|
+
The most basic element of Haml
|
50
|
+
is a shorthand for creating HTML tags:
|
51
|
+
|
52
|
+
%tagname{ :attr1 => 'value1', :attr2 => 'value2' } Contents
|
53
|
+
|
54
|
+
No end-tag is needed; Haml handles that automatically.
|
55
|
+
Adding <tt>class</tt> and <tt>id</tt> attributes is even easier.
|
56
|
+
Haml uses the same syntax as the CSS that styles the document:
|
57
|
+
|
58
|
+
%tagname#id.class
|
59
|
+
|
60
|
+
In fact, when you're using the <tt><div></tt> tag,
|
61
|
+
it becomes <em>even easier</em>.
|
62
|
+
Because <tt><div></tt> is such a common element,
|
63
|
+
a tag without a name defaults to a div. So
|
64
|
+
|
65
|
+
#foo Hello!
|
66
|
+
|
67
|
+
becomes
|
68
|
+
|
69
|
+
<div id='foo'>Hello!</div>
|
70
|
+
|
71
|
+
Haml uses indentation
|
72
|
+
to bring the individual elements to represent the HTML structure.
|
73
|
+
A tag's children are indented two spaces more than the parent tag.
|
74
|
+
Again, a closing tag is automatically added.
|
75
|
+
For example:
|
76
|
+
|
77
|
+
%ul
|
78
|
+
%li Salt
|
79
|
+
%li Pepper
|
80
|
+
|
81
|
+
becomes:
|
82
|
+
|
83
|
+
<ul>
|
84
|
+
<li>Salt</li>
|
85
|
+
<li>Pepper</li>
|
86
|
+
</ul>
|
87
|
+
|
88
|
+
You can also put plain text as a child of an element:
|
89
|
+
|
90
|
+
%p
|
91
|
+
Hello,
|
92
|
+
World!
|
93
|
+
|
94
|
+
It's even possible to embed Ruby code into Haml documents.
|
95
|
+
An equals sign, <tt>=</tt>, will output the result of the code.
|
96
|
+
A hyphen, <tt>-</tt>, will run the code but not output the result.
|
97
|
+
You can even use control statements
|
98
|
+
like <tt>if</tt> and <tt>while</tt>:
|
99
|
+
|
100
|
+
%p
|
101
|
+
Date/Time:
|
102
|
+
- now = DateTime.now
|
103
|
+
%strong= now
|
104
|
+
- if now > DateTime.parse("December 31, 2006")
|
105
|
+
= "Happy new " + "year!"
|
106
|
+
|
107
|
+
Haml provides far more tools than those presented here.
|
108
|
+
Check out the reference documentation in the Haml module.
|
109
|
+
|
110
|
+
=== Sass
|
111
|
+
|
112
|
+
At its most basic,
|
113
|
+
Sass is just another way of writing CSS.
|
114
|
+
Although it's very much like normal CSS,
|
115
|
+
the basic syntax offers a few helpful features:
|
116
|
+
tabulation (using *two spaces*)
|
117
|
+
indicates the attributes in a rule,
|
118
|
+
rather than non-DRY brackets;
|
119
|
+
and newlines indicate the end of an attribute,
|
120
|
+
rather than a semicolon.
|
121
|
+
For example:
|
122
|
+
|
123
|
+
#main
|
124
|
+
:background-color #f00
|
125
|
+
:width 98%
|
126
|
+
|
127
|
+
becomes:
|
128
|
+
|
129
|
+
#main {
|
130
|
+
background-color: #f00;
|
131
|
+
width: 98% }
|
132
|
+
|
133
|
+
However, Sass provides much more than a way to make CSS look nice.
|
134
|
+
In CSS, it's important to have accurate selectors,
|
135
|
+
so your styles don't just apply to everything.
|
136
|
+
However, in order to do this,
|
137
|
+
you need to use nested element selectors.
|
138
|
+
These get very ugly very quickly.
|
139
|
+
I'm sure everyone's had to write something like
|
140
|
+
"#main .sidebar .top p h1 a",
|
141
|
+
followed by
|
142
|
+
"#main .sidebar .top p h1 a:visited" and
|
143
|
+
"#main .sidebar .top p h1 a:hover".
|
144
|
+
Well, Sass gets rid of that.
|
145
|
+
Like Haml, it uses indentation to indicate the structure of the document.
|
146
|
+
So, what was:
|
147
|
+
|
148
|
+
#main {
|
149
|
+
width: 90%;
|
150
|
+
}
|
151
|
+
#main p {
|
152
|
+
border-style: solid;
|
153
|
+
border-width: 1px;
|
154
|
+
border-color: #00f;
|
155
|
+
}
|
156
|
+
#main p a {
|
157
|
+
text-decoration: none;
|
158
|
+
font-weight: bold;
|
159
|
+
}
|
160
|
+
#main p a:hover {
|
161
|
+
text-decoration: underline;
|
162
|
+
}
|
163
|
+
|
164
|
+
becomes:
|
165
|
+
|
166
|
+
#main
|
167
|
+
:width 90%
|
168
|
+
p
|
169
|
+
:border-style solid
|
170
|
+
:border-width 1px
|
171
|
+
:border-color #00f
|
172
|
+
a
|
173
|
+
:text-decoration none
|
174
|
+
:font-weight bold
|
175
|
+
a:hover
|
176
|
+
:text-decoration underline
|
177
|
+
|
178
|
+
Pretty nice, no? Well, it gets better.
|
179
|
+
One of the main complaints against CSS is that it doesn't allow constants.
|
180
|
+
What if have a color or a width you re-use all the time?
|
181
|
+
In CSS, you just have to re-type it each time,
|
182
|
+
which is a nightmare when you decide to change it later.
|
183
|
+
Not so for Sass!
|
184
|
+
You can use the "!" character to set constants.
|
185
|
+
Then, if you put "=" after your attribute name,
|
186
|
+
you can set it to a constant.
|
187
|
+
For example:
|
188
|
+
|
189
|
+
!note_bg= #55aaff
|
190
|
+
|
191
|
+
#main
|
192
|
+
:width 70%
|
193
|
+
.note
|
194
|
+
:background-color= !note_bg
|
195
|
+
p
|
196
|
+
:width 5em
|
197
|
+
:background-color= !note_bg
|
198
|
+
|
199
|
+
becomes:
|
200
|
+
|
201
|
+
#main {
|
202
|
+
width: 70%; }
|
203
|
+
#main .note {
|
204
|
+
background-color: #55aaff; }
|
205
|
+
#main p {
|
206
|
+
width: 5em;
|
207
|
+
background-color: #55aaff; }
|
208
|
+
|
209
|
+
You can even do simple arithmetic operations with constants,
|
210
|
+
adding numbers and even colors together:
|
211
|
+
|
212
|
+
!main_bg= #46ar12
|
213
|
+
!main_width= 40em
|
214
|
+
|
215
|
+
#main
|
216
|
+
:background-color= !main_bg
|
217
|
+
:width= !main_width
|
218
|
+
.sidebar
|
219
|
+
:background-color= !main_bg + #333333
|
220
|
+
:width= !main_width - 25em
|
221
|
+
|
222
|
+
becomes:
|
223
|
+
|
224
|
+
#main {
|
225
|
+
background-color: #46a312;
|
226
|
+
width: 40em; }
|
227
|
+
#main .sidebar {
|
228
|
+
background-color: #79d645;
|
229
|
+
width: 15em; }
|
230
|
+
|
231
|
+
Taking the idea of constants a bit further are mixins.
|
232
|
+
These let you group whole swathes of CSS attributes into a single
|
233
|
+
directive and then include those anywhere you want:
|
234
|
+
|
235
|
+
=blue-border
|
236
|
+
:border
|
237
|
+
:color blue
|
238
|
+
:width 2px
|
239
|
+
:style dotted
|
240
|
+
|
241
|
+
.comment
|
242
|
+
+blue-border
|
243
|
+
:padding 2px
|
244
|
+
:margin 10px 0
|
245
|
+
|
246
|
+
.reply
|
247
|
+
+blue-border
|
248
|
+
|
249
|
+
becomes:
|
250
|
+
|
251
|
+
.comment {
|
252
|
+
border-color: blue;
|
253
|
+
border-width: 2px;
|
254
|
+
border-style: dotted;
|
255
|
+
padding: 2px;
|
256
|
+
margin: 10px 0;
|
257
|
+
}
|
258
|
+
|
259
|
+
.reply {
|
260
|
+
border-color: blue;
|
261
|
+
border-width: 2px;
|
262
|
+
border-style: dotted;
|
263
|
+
}
|
264
|
+
|
265
|
+
A comprehensive list of features is in
|
266
|
+
the documentation for the Sass module.
|
267
|
+
|
268
|
+
== Executables
|
269
|
+
|
270
|
+
The Haml gem includes several executables that are useful
|
271
|
+
for dealing with Haml and Sass from the command line.
|
272
|
+
|
273
|
+
=== +haml+
|
274
|
+
|
275
|
+
The +haml+ executable transforms a source Haml file into HTML.
|
276
|
+
See <tt>haml --help</tt> for further information and options.
|
277
|
+
|
278
|
+
=== +sass+
|
279
|
+
|
280
|
+
The +sass+ executable transforms a source Sass file into CSS.
|
281
|
+
See <tt>sass --help</tt> for further information and options.
|
282
|
+
|
283
|
+
=== <tt>html2haml</tt>
|
284
|
+
|
285
|
+
The <tt>html2haml</tt> executable attempts to transform HTML,
|
286
|
+
optionally with ERB markup, into Haml code.
|
287
|
+
Since HTML is so variable, this transformation is not always perfect;
|
288
|
+
it's a good idea to have a human check the output of this tool.
|
289
|
+
See <tt>html2haml --help</tt> for further information and options.
|
290
|
+
|
291
|
+
=== <tt>css2sass</tt>
|
292
|
+
|
293
|
+
The <tt>css2sass</tt> executable attempts to transform CSS into Sass code.
|
294
|
+
This transformation attempts to use Sass nesting where possible.
|
295
|
+
See <tt>css2sass --help</tt> for further information and options.
|
296
|
+
|
297
|
+
== Authors
|
298
|
+
|
299
|
+
Haml and Sass are designed by Hampton Catlin (hcatlin) and he is the author
|
300
|
+
of the original implementation. However, Hampton doesn't even know his way
|
301
|
+
around the code anymore and mostly just concentrates on the language issues.
|
302
|
+
Hampton lives in Toronto, Ontario (though he's an American by birth) and
|
303
|
+
is a partner at Unspace Interactive.
|
304
|
+
|
305
|
+
Nathan Weizenbaum is the primary maintainer and architect of the "modern" Ruby
|
306
|
+
implementation of Haml. His hard work has kept the project alive by endlessly
|
307
|
+
answering forum posts, fixing bugs, refactoring, finding speed improvements,
|
308
|
+
writing documentation, implementing new features, and getting Hampton
|
309
|
+
coffee (a fitting task for a boy-genius). Nathan lives in Seattle, Washington and
|
310
|
+
while not being a student at University of Washington he consults for
|
311
|
+
Unspace Interactive and Microsoft.
|
312
|
+
|
313
|
+
If you use this software, you must pay Hampton a compliment. And
|
314
|
+
buy Nathan some jelly beans. Maybe pet a kitten. Yeah. Pet that kitty.
|
315
|
+
|
316
|
+
Some of the work on Haml was supported by Unspace Interactive.
|
317
|
+
|
318
|
+
Beyond that, the implementation is licensed under the MIT License.
|
319
|
+
Ok, fine, I guess that means compliments aren't *required*.
|