From 09d282fffa5dbb214ef315b1388fac4f28486adf Mon Sep 17 00:00:00 2001 From: Fellipe Souto Sampaio Date: Thu, 16 Jan 2014 17:03:01 -0200 Subject: [PATCH] Reading group creation page --- app/views/reading_groups/_form.html.erb | 15 +++++++++++++++ app/views/reading_groups/new.html.erb | 5 +++++ features/reading_group/create.features | 43 +++++++++++++++++++++++++++++++++++++++++++ features/step_definitions/reading_group_steps.rb | 12 ++++++++++++ 4 files changed, 75 insertions(+), 0 deletions(-) create mode 100644 app/views/reading_groups/_form.html.erb create mode 100644 features/reading_group/create.features diff --git a/app/views/reading_groups/_form.html.erb b/app/views/reading_groups/_form.html.erb new file mode 100644 index 0000000..d295b57 --- /dev/null +++ b/app/views/reading_groups/_form.html.erb @@ -0,0 +1,15 @@ +<%= form_for(@reading_group, :html => { role: 'form' }) do |f| %> + <%= render :partial => 'shared/form_errors', :locals => {:object => @reading_group} %> + +
+ <%= f.label :name, class: 'control-label' %>
+ <%= f.text_field :name, class: 'form-control' %> +
+ +
+ <%= f.label :description, class: 'control-label' %>
+ <%= f.text_area :description, class: 'form-control' %> +
+ + <%= f.submit 'Save', class: 'btn btn-primary' %> +<% end %> diff --git a/app/views/reading_groups/new.html.erb b/app/views/reading_groups/new.html.erb index e69de29..c619475 100644 --- a/app/views/reading_groups/new.html.erb +++ b/app/views/reading_groups/new.html.erb @@ -0,0 +1,5 @@ + + +<%= render 'form' %> diff --git a/features/reading_group/create.features b/features/reading_group/create.features new file mode 100644 index 0000000..a829d71 --- /dev/null +++ b/features/reading_group/create.features @@ -0,0 +1,43 @@ +Feature: Reading Group Creation + In order to create new reading groups to make my own readings + As a regular user + I should be able to create reading groups + +@kalibro_restart +Scenario: Should not create reading groups without login + Given I am at the All Reading Groups page + Then I should not see New Reading Group + +@kalibro_restart +Scenario: Reading Group creation + Given I am a regular user + And I am signed in + And I am at the New Reading Group page + And I fill the Name field with "My reading group" + And I fill the Description field with "New reading group" + When I press the Save button + Then I should see "My reading group" + And I should see "New reading group" + And I should see "New Reading" + And I should see "Destroy Reading Group" + +@kalibro_restart +Scenario: reading group creation with already taken name + Given I am a regular user + And I am signed in + And I have a reading group named "Group" + And I am at the New Reading Group page + And I fill the Name field with "Group" + And I fill the Description field with "Same Group" + When I press the Save button + Then I should see "There's already" + +@kalibro_restart +Scenario: reading group creation with blank name + Given I am a regular user + And I am signed in + And I am at the New Reading Group page + And I fill the Name field with " " + And I fill the Description field with "Anything" + When I press the Save button + Then I should see "Name can't be blank" \ No newline at end of file diff --git a/features/step_definitions/reading_group_steps.rb b/features/step_definitions/reading_group_steps.rb index 0daf284..880ee84 100644 --- a/features/step_definitions/reading_group_steps.rb +++ b/features/step_definitions/reading_group_steps.rb @@ -1,5 +1,17 @@ require 'kalibro_gem/errors' +Given(/^I am at the All Reading Groups page$/) do + visit reading_groups_path +end + +Given(/^I am at the New Reading Group page$/) do + visit new_reading_group_path +end + +Given(/^I have a reading group named "(.*?)"$/) do |name| + @reading_group = FactoryGirl.create(:reading_group, {id: nil, name: name}) +end + Given(/^I own a sample reading group$/) do @reading_group = FactoryGirl.create(:reading_group, {id: nil}) FactoryGirl.create(:reading_group_ownership, {user_id: @user.id, reading_group_id: @reading_group.id}) -- libgit2 0.21.2