From d03d7fa06ca5987ef274ac9e2cc3c498e1524103 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20B=C3=A4ume?= Date: Wed, 18 Jul 2012 03:59:33 +0200 Subject: [PATCH 1/4] implement first scenario of posix settings feature users want to be able to change their shell. This adds the view part of the feature, basically. --- app/views/users/_posix_fields.html.haml | 5 ++++ app/views/users/edit.html.haml | 2 ++ features/step_definitions/web_steps.rb | 5 ++++ features/user_change_shell.feature | 13 +++++++++++ .../users/posix_fields.html.haml_spec.rb | 23 +++++++++++++++++++ 5 files changed, 48 insertions(+) create mode 100644 app/views/users/_posix_fields.html.haml create mode 100644 features/user_change_shell.feature create mode 100644 spec/views/users/posix_fields.html.haml_spec.rb diff --git a/app/views/users/_posix_fields.html.haml b/app/views/users/_posix_fields.html.haml new file mode 100644 index 0000000..cdc1e71 --- /dev/null +++ b/app/views/users/_posix_fields.html.haml @@ -0,0 +1,5 @@ +%h1#nav_posix_settings.section=t :posix_settings, :scope => :user_form +#shell + = f.fields_for :posix_settings do |p| + = p.label :login_shell + = p.select :login_shell, {"/bin/bash" => :bash} diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index 4c91184..ae42351 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -12,5 +12,7 @@ #git_config_fields = f.fields_for :git_config do |git_config| =render :partial => '/git_configs/fields', :locals => { :f => git_config } + #posix_settings_fields + =render :partial => 'posix_fields', :locals => { :f => f } #buttons = f.submit diff --git a/features/step_definitions/web_steps.rb b/features/step_definitions/web_steps.rb index f53a899..28fc448 100644 --- a/features/step_definitions/web_steps.rb +++ b/features/step_definitions/web_steps.rb @@ -46,6 +46,11 @@ page.should_not have_content(text) end +When /^I visit my account settings page$/ do + @user = User.find_by_nick("Robert") + visit edit_user_path(@user) +end + When /^I go the home page$/ do visit '/' end diff --git a/features/user_change_shell.feature b/features/user_change_shell.feature new file mode 100644 index 0000000..908ac75 --- /dev/null +++ b/features/user_change_shell.feature @@ -0,0 +1,13 @@ +Feature: Change shell for a user + + In order to let everybody decide about their own shell + as a user with a posix account + I want be able to change my shell. + + Scenario: show default shell + Given a user "Robert" + And I am logged in as "Robert" + When I visit my account settings page + Then I should see "Login shell" + And I should see "/bin/bash" + diff --git a/spec/views/users/posix_fields.html.haml_spec.rb b/spec/views/users/posix_fields.html.haml_spec.rb new file mode 100644 index 0000000..56f4255 --- /dev/null +++ b/spec/views/users/posix_fields.html.haml_spec.rb @@ -0,0 +1,23 @@ +require 'spec_helper' + +describe "users/edit.html.haml" do + describe "users/_posix_fields.html.haml" do + before(:each) do + gc = mock_model(GitConfig, :name => "", :email => "") + u = mock_model(User, :email => "", :git_config => gc) + assign :user, u + end + + it "should provide a section for posix settings" do + render + rendered.should have_css("h1.section", :text => "Posix Settings") + end + + it "should have a field for the shell" do + render + rendered.should have_css("form label", :text => "Login shell") + rendered.should have_css("form select#user_posix_settings_login_shell") + end + end +end + From 7c197e4753dcd370bab6f3a585bdb2724869fcdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20B=C3=A4ume?= Date: Wed, 18 Jul 2012 04:15:04 +0200 Subject: [PATCH 2/4] change order of html elements this integrates better with the allready existing css --- app/views/users/_posix_fields.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/users/_posix_fields.html.haml b/app/views/users/_posix_fields.html.haml index cdc1e71..7026cef 100644 --- a/app/views/users/_posix_fields.html.haml +++ b/app/views/users/_posix_fields.html.haml @@ -1,5 +1,5 @@ %h1#nav_posix_settings.section=t :posix_settings, :scope => :user_form -#shell - = f.fields_for :posix_settings do |p| += f.fields_for :posix_settings do |p| + #shell.text_input = p.label :login_shell = p.select :login_shell, {"/bin/bash" => :bash} From b3dc3d6d55961624f0181c095e67a101d4c25fad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20B=C3=A4ume?= Date: Wed, 18 Jul 2012 04:21:22 +0200 Subject: [PATCH 3/4] add menu item for posix settings section users can now navigate using this anchor --- app/views/users/edit.html.haml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index ae42351..3b0a6c1 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -3,6 +3,7 @@ %ul#nav_profile.menu.nav.nav-pills.nav-stacked = menu_item t(:password, :scope => :user_form), '#password_fields' = menu_item t(:git_config, :scope => :user_form), '#git_config_fields' + = menu_item t(:posix_settings, :scope => :user_form), '#posix_settings_fields' #page_content - unless @user.nil? From be1288cc207e1e3a6cb07babe6e0bc5ba3487f92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20B=C3=A4ume?= Date: Wed, 18 Jul 2012 04:23:35 +0200 Subject: [PATCH 4/4] add javascript for navigation menu makes the menu useable --- app/assets/javascripts/users.js.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/javascripts/users.js.coffee b/app/assets/javascripts/users.js.coffee index 38bfe1d..2e1bcab 100644 --- a/app/assets/javascripts/users.js.coffee +++ b/app/assets/javascripts/users.js.coffee @@ -1,3 +1,4 @@ jQuery -> $('nav_profile').scrollspy({offset: 50}) + $('nav_posix_settings').scrollspy({offset: 50})