diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index ba9d3ffd9..9b0b5faa3 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -14,8 +14,12 @@ class AspectsController < ApplicationController end def create - @aspect = current_user.aspect params[:aspect] - flash[:notice] = I18n.t('aspects.create.success') + @aspect = current_user.aspect(params[:aspect]) + if @aspect.valid? + flash[:notice] = I18n.t('aspects.create.success') + else + flash[:notice] = I18n.t('aspects.create.failure') + end respond_with :location => aspects_manage_path end diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 8e6542639..a6a98c7cd 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -86,6 +86,7 @@ en: create: "Create" create: success: "Click on the plus on the left side to tell Diaspora who can see your new aspect." + failure: "Aspect creation failed." destroy: success: "%{name} was successfully removed." update: diff --git a/features/step_definitions/custom_web_steps.rb b/features/step_definitions/custom_web_steps.rb new file mode 100644 index 000000000..e3f8bc373 --- /dev/null +++ b/features/step_definitions/custom_web_steps.rb @@ -0,0 +1,17 @@ +When /^(.*) in the header$/ do |action| + within('header') do + When action + end +end + +When /^(.*) in the modal window$/ do |action| + within('#fancybox-wrap') do + When action + end +end + +When /^(.*) in the aspect list$/ do |action| + within('#aspect_list') do + When action + end +end diff --git a/features/step_definitions/scope_steps.rb b/features/step_definitions/scope_steps.rb index cb39d33ad..43fe2f48a 100644 --- a/features/step_definitions/scope_steps.rb +++ b/features/step_definitions/scope_steps.rb @@ -9,7 +9,7 @@ end World(SectionLocator) -sections = %w(h1 h2 h3 h4 h5 h6 legend caption dt strong) +sections = %w(h1 h2 h3 h4 h5 h6 legend caption dt strong header) When /^(.*) in the "([^\"]*)" section$/ do |action, title| within_parent(title, sections) do diff --git a/features/user_creates_an_aspect.feature b/features/user_creates_an_aspect.feature new file mode 100644 index 000000000..27cb6f2f3 --- /dev/null +++ b/features/user_creates_an_aspect.feature @@ -0,0 +1,23 @@ +@aspects @javascript +Feature: User creates an aspect + In order to share with a limited group + As a User + I want to create a new aspect + + Scenario: success + Given I am signed in + And I follow "Manage" in the header + And I follow "Add a new aspect" + When I fill in "Name" with "Dorm Mates" in the modal window + And I press "Create" in the modal window + Then I should see "Manage Aspects" + And I should see "Dorm Mates" in the header + And I should see "Dorm Mates" in the aspect list + + Scenario: I omit the name + Given I am signed in + And I follow "Manage" in the header + And I follow "Add a new aspect" + When I press "Create" in the modal window + Then I should see "Manage Aspects" + And I should see "Aspect creation failed."