Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Matt Powell
committed
Oct 5, 2015
1 parent
a563664
commit 4f853a7
Showing
13 changed files
with
145 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class UpdateEvent | ||
attr_reader :event | ||
|
||
delegate :errors, to: :event | ||
|
||
def initialize(event, params) | ||
@event = event | ||
@params = params | ||
end | ||
|
||
def call | ||
@event.update!(@params) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
= form_for @event do |form| | ||
= @event.errors.inspect | ||
|
||
= form.label(:name) | ||
= form.text_field(:name) | ||
= inline_errors_for(@event, :name) | ||
|
||
= form.label(:slug) | ||
= form.text_field(:slug) | ||
= inline_errors_for(@event, :slug) | ||
|
||
= form.label(:starts_on) | ||
= form.date_field(:starts_on) | ||
= inline_errors_for(@event, :starts_on) | ||
|
||
= form.label(:ends_on) | ||
= form.date_field(:ends_on) | ||
= inline_errors_for(@event, :ends_on) | ||
|
||
= save_button(form) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
= render "form" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1 @@ | ||
= form_for @event do |form| | ||
= @event.errors.inspect | ||
|
||
= form.label(:name) | ||
= form.text_field(:name) | ||
= inline_errors_for(@event, :name) | ||
|
||
= form.label(:slug) | ||
= form.text_field(:slug) | ||
= inline_errors_for(@event, :slug) | ||
|
||
= form.label(:starts_on) | ||
= form.date_field(:starts_on) | ||
= inline_errors_for(@event, :starts_on) | ||
|
||
= form.label(:ends_on) | ||
= form.date_field(:ends_on) | ||
= inline_errors_for(@event, :ends_on) | ||
|
||
= button_tag t(".create"), type: :submit | ||
= render "form" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,5 +10,6 @@ en: | |
updated: "Your profile was updated" | ||
|
||
events: | ||
new: | ||
form: | ||
create: "Create event" | ||
save: "Save settings" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Feature: Edit event settings | ||
In order to manage my event | ||
As an event administrator | ||
I want to edit my event's settings | ||
|
||
Scenario: Change event name | ||
Given I am logged in as an event administrator | ||
When I visit the event settings page | ||
And I enter a new event name | ||
And I click the "Save settings" button | ||
Then I should be on the event settings page | ||
And I should see "updated" | ||
And I should see the new event name | ||
And the event should have been updated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require "rails_helper" | ||
|
||
describe UpdateEvent do | ||
subject { service.call } | ||
let(:service) { UpdateEvent.new(event, params) } | ||
let(:event) { FactoryGirl.create(:event) } | ||
let(:params) { { name: new_name } } | ||
let(:new_name) { "Updated name" } | ||
|
||
it { is_expected.to be true } | ||
|
||
it "does not raise an error" do | ||
expect { subject }.not_to raise_error | ||
end | ||
|
||
it "updates the name" do | ||
service.call | ||
event.reload | ||
expect(event.name).to eq(new_name) | ||
end | ||
|
||
context "without an event name" do | ||
let(:new_name) { "" } | ||
|
||
it "raises an error" do | ||
expect { subject }.to raise_error(ActiveRecord::RecordInvalid) | ||
end | ||
end | ||
end |