Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added design controller and icon model. Fixed BDD infrastucture
- Loading branch information
Showing
13 changed files
with
422 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
BUNDLE_WITHOUT: "" |
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 |
---|---|---|
@@ -1,7 +1,25 @@ | ||
# Helper methods defined here can be accessed in any controller or view in the application | ||
|
||
PadMeTee.helpers do | ||
# def simple_helper_method | ||
# ... | ||
# end | ||
end | ||
# prints size option with selected if in session | ||
def option_for(size) | ||
res = '<option' | ||
res += session['size'] == size ? ' selected="selected">' : '>' | ||
res += (size + '</option>') | ||
end | ||
|
||
# returns chosen icon image | ||
def chosen_icon_image(type, size = '') | ||
if icon = session[type] || (@order && @order.document[type]) | ||
'<img src="/icons/%s/%s.gif" alt="%s" width="%s" height="%s" />' % [type, icon, icon, size, size] | ||
else | ||
"<span></span>" | ||
end | ||
end | ||
|
||
# renders img tag for icon thumb for carousel | ||
def icon_image_thumb(icon) | ||
"<a href='/icons/%s' title='%s'><img src='%s' width='72' height='72' class='hidden' /></a>" % [icon.id, icon.full_name, icon.path] | ||
end | ||
j | ||
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,24 @@ | ||
class Icon | ||
include Mongoid::Document | ||
include Mongoid::Timestamps # adds created_at and updated_at fields | ||
|
||
field :name | ||
field :filename | ||
field :type | ||
|
||
key :type, :name | ||
|
||
scope :hobbies, where(:type => 'hobby') | ||
scope :faces, where(:type => 'face') | ||
scope :jobs, where(:type => 'job') | ||
|
||
# returns path for web printing | ||
def path | ||
@path ||= "/icons/#{filename}" | ||
end | ||
|
||
# returns full name with type | ||
def full_name | ||
@full_name ||= "%s %s" % [type, name] | ||
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 @@ | ||
Autotest.add_discovery { "rspec2" } |
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,17 @@ | ||
Feature: Genre changing | ||
In order to change t-shirt gender for male or female | ||
As a customer | ||
I need link to do it and see result | ||
|
||
Scenario: Changing to male t-shirt | ||
Given I visit '/' | ||
When I follow 'male' | ||
Then I should see 'me-tee t-shirt about you' | ||
Then I should see 'You chose male tee' | ||
|
||
Scenario: Changing to female t-shirt | ||
Given I visit '/' | ||
When I follow 'female' | ||
Then I should see 'me-tee t-shirt about you' | ||
Then I should see 'You chose female tee' | ||
|
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,41 @@ | ||
Feature: Home page | ||
In order to have start somewhere and configure t-shirt | ||
As a customer | ||
I need home page | ||
|
||
Scenario: Visiting home page | ||
Given I visit '/' | ||
Then I should see 'me-tee t-shirt about you' | ||
|
||
Scenario: Checking t-shirt configuration | ||
Given I visit '/' | ||
Then I should see 'male' | ||
Then I should see 'female' | ||
Then I should see 'save' | ||
Then I should see 'random' | ||
|
||
Scenario: Choosing size | ||
Given I visit '/' | ||
Then I could select 'S' from 'size' | ||
Then I could select 'M' from 'size' | ||
Then I could select 'L' from 'size' | ||
Then I could select 'XL' from 'size' | ||
Then I could select 'XXL' from 'size' | ||
|
||
Scenario: Changing gender | ||
Given I visit '/' | ||
Then I could follow 'male' | ||
Given I visit '/' | ||
Then I could follow 'female' | ||
|
||
Scenario: Saving design | ||
Given I visit '/' | ||
Then I could follow 'save' | ||
|
||
Scenario: Randomizing design | ||
Given I visit '/' | ||
Then I could follow 'random' | ||
|
||
Scenario: Order | ||
Given I visit '/' | ||
Then I could press 'order' |
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,15 @@ | ||
Feature: Saving of design | ||
In order to have design saved for tomorrows | ||
As a customer | ||
I want to save current design | ||
|
||
Background: | ||
Given there are icons in system | ||
|
||
Scenario: Saving t-shirt design | ||
Given I visit '/' | ||
And I follow 'face angry' | ||
And I follow 'hobby swim' | ||
And I follow 'job cook' | ||
When I follow 'save' | ||
Then I should see 'Tee how you design it' |
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,138 @@ | ||
Given /^I visit '(.+)'$/ do |url| | ||
visit(url) | ||
end | ||
|
||
Then /^I should see '(.+)'$/ do |text| | ||
page.should have_content(text) | ||
end | ||
|
||
Then /^I should not see '(.+)'$/ do |text| | ||
response_body.should_not contain(Regexp.new(text, Regexp::MULTILINE)) | ||
end | ||
|
||
Then /^I should see big '(.+)'$/ do |text| | ||
text = '<h1>[\s]*%s[\s]*<\/h1>' % text | ||
response_body.should =~ Regexp.new(text) | ||
end | ||
|
||
Then /^I fill in '(.*)' for '(.*)'$/ do |value, field| | ||
fill_in(field, :with => value) | ||
end | ||
|
||
When /^I press '(.*)'$/ do |name| | ||
click_button(name) | ||
end | ||
|
||
Then /^I could press '(.*)'$/ do |name| | ||
Then "I press '#{name}'" | ||
end | ||
|
||
Then /^I choose '(.*)'$/ do |value| | ||
choose(value.gsub(/ /, '')) | ||
end | ||
|
||
Given /^I will get mail$/ do | ||
Pony.should_receive(:mail) | ||
end | ||
|
||
Then /^I follow '(.+)'$/ do |link| | ||
click_link link | ||
end | ||
|
||
Then /^I could follow '(.+)'$/ do |link| | ||
Then "I follow '#{link}'" | ||
end | ||
|
||
When /^I select '(.+)' from '(.+)'$/ do |value, field| | ||
select(value, :from => field) | ||
end | ||
|
||
Then /^I could select '(.+)' from '(.+)'$/ do |value, field| | ||
When "I select '#{value}' from '#{field}'" | ||
end | ||
|
||
Then /^I should see '([^']+)' icon '([^']+)'$/ do |type, name| | ||
response_body.should have_selector('img', :src => "/icons/#{type}/#{name}.gif") | ||
end | ||
|
||
Then /^I should see not '([^']+)' icon '([^']+)'$/ do |type, name| | ||
response_body.should_not have_selector('img', :src => "/icons/#{type}/#{name}.gif") | ||
end | ||
|
||
Then /^I should see choosed icon '([^']+)' in '([^']+)'$/ do |name, type| | ||
response_body.should have_selector('div', :class => 'placeholder', :id => "#{type}-placeholder") do |node| | ||
node.first.inner_html.should =~ /#{name}/ | ||
end | ||
end | ||
|
||
Then /^I should see '([^']+)' placeholder$/ do |type| | ||
response_body.should have_selector('div', :class => 'placeholder', :id => "#{type}-placeholder") | ||
end | ||
|
||
Given /^I choose size '([^']+)'$/ do |size| | ||
visit '/' + size | ||
end | ||
|
||
Then /^I should see choosed '([^']+)'$/ do |size| | ||
response_body.should have_selector('option', :selected => 'selected', :content => size) | ||
end | ||
|
||
Given /^I know customer '([^']+)' ordered tee as usual$/ do |customer| | ||
Given "I ordered tee as usual as customer '#{customer}'" | ||
end | ||
|
||
Given /^I ordered tee as usual as customer '([^']+)'$/ do |customer| | ||
Given "I designed a tee" | ||
And "I press 'objednat'" | ||
Given "I fill in '#{customer}' for 'name'" | ||
And "I fill in 'Pool 1' for 'street'" | ||
And "I fill in 'Prague' for 'city'" | ||
And "I fill in '11150' for 'zip'" | ||
And "I fill in 'joe@doe.cz' for 'email'" | ||
And "I fill in '420777888999' for 'phone'" | ||
And "I fill in 'will come again' for 'note'" | ||
And "I fill in 'METEE2010' for 'coupon'" | ||
Then "I press 'Pokračovat v objednávce'" | ||
When "I follow 'DOKONČIT OBJEDNÁVKU'" | ||
end | ||
|
||
Then /^I should see '([^']+)' prefilled in '([^']+)'$/ do |content, id| | ||
response_body.should have_selector('input', :id => id, :value => content) | ||
end | ||
|
||
Given /^I left session$/ do | ||
last_request.session[:order] = nil | ||
end | ||
|
||
Then /^mail should be sent to my address '(.+)'$/ do |email| | ||
Mail.deliveries.size.should == 1 | ||
Mail.deliveries.first.to.value == /#{email}/ | ||
end | ||
|
||
Given /^I am using ajax$/ do | ||
header 'X-Requested-With', 'XMLHttpRequest' | ||
end | ||
|
||
Given /^I designed a tee$/ do | ||
Given "I visit '/'" | ||
And "I visit '/faces/angry'" | ||
And "I visit '/hobbies/swim'" | ||
And "I visit '/jobs/cook'" | ||
And "I visit '/male'" | ||
end | ||
|
||
Then /^I should see startup link$/ do | ||
response_body.should have_selector('a', :id => "startup") | ||
end | ||
|
||
Then /^I should not see startup link$/ do | ||
response_body.should_not have_selector('a', :id => "startup") | ||
end | ||
|
||
Given /^there are icons in system$/ do | ||
Icon.destroy_all | ||
Icon.create(:type => 'hobby', :name => 'swim', :filename => 'swim.gif') | ||
Icon.create(:type => 'face', :name => 'angry', :filename => 'angry.gif') | ||
Icon.create(:type => 'job', :name => 'cook', :filename => 'cook.gif') | ||
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
Oops, something went wrong.