added cucumber tests, updated spec with xml class test
This commit is contained in:
parent
8f9736a741
commit
a9843ae996
5 changed files with 105 additions and 1 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -65,3 +65,6 @@ dump.rdb
|
|||
|
||||
#Rubinius's JIT
|
||||
*.rbc
|
||||
|
||||
#IDE
|
||||
diaspora.iml
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class PollAnswer < ActiveRecord::Base
|
|||
self.include_root_in_json = false
|
||||
|
||||
def update_vote_counter
|
||||
self.vote_count = self.vote_count + 1
|
||||
self.vote_count += 1
|
||||
self.save!
|
||||
end
|
||||
|
||||
|
|
|
|||
65
features/desktop/post_with_a_poll.feature
Normal file
65
features/desktop/post_with_a_poll.feature
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
@javascript
|
||||
Feature: posting with a poll
|
||||
|
||||
Background:
|
||||
Given following users exist:
|
||||
| username |
|
||||
| bob |
|
||||
And I sign in as "bob@bob.bob"
|
||||
And I am on the home page
|
||||
|
||||
Scenario: expanding the publisher
|
||||
Given "#poll_creator_wrapper" is hidden
|
||||
When I expand the publisher
|
||||
Then I should see an element "#poll_creator"
|
||||
|
||||
Scenario: expanding the poll creator
|
||||
Given "#poll_creator_wrapper" is hidden
|
||||
When I expand the publisher
|
||||
And I press the element "#poll_creator"
|
||||
Then I should see an element "#poll_creator_wrapper"
|
||||
|
||||
Scenario: adding option to poll
|
||||
Given "#poll_creator_wrapper" is hidden
|
||||
When I expand the publisher
|
||||
And I press the element "#poll_creator"
|
||||
And I press the element "#add_poll_answer"
|
||||
Then I should see 3 options
|
||||
|
||||
Scenario: delete an option
|
||||
Given "#poll_creator_wrapper" is hidden
|
||||
When I expand the publisher
|
||||
And I press the element "#poll_creator"
|
||||
And I delete the first option
|
||||
Then I should see 1 option
|
||||
And I should not see a remove icon
|
||||
|
||||
Scenario: post with an attached poll
|
||||
Given I expand the publisher
|
||||
And I press the element "#poll_creator"
|
||||
When I fill in the following:
|
||||
| status_message_fake_text | I am eating yogurt |
|
||||
| poll_question | What kind of yogurt do you like? |
|
||||
And I fill in the following for the options:
|
||||
| normal |
|
||||
| not normal |
|
||||
And I press "Share"
|
||||
Then I should see a ".poll_form" within ".stream_element"
|
||||
And I should see a "form" within ".stream_element"
|
||||
|
||||
Scenario: vote for an option
|
||||
Given I expand the publisher
|
||||
And I press the element "#poll_creator"
|
||||
When I fill in the following:
|
||||
| status_message_fake_text | I am eating yogurt |
|
||||
| poll_question | What kind of yogurt do you like? |
|
||||
And I fill in the following for the options:
|
||||
| normal |
|
||||
| not normal |
|
||||
And I press "Share"
|
||||
|
||||
And I check the first option
|
||||
And I press "Vote" within ".stream_element"
|
||||
Then I should see an element ".poll_progress_bar"
|
||||
And I should see an element ".percentage"
|
||||
And I should see "1 vote so far" within ".poll_statistic"
|
||||
32
features/step_definitions/post_with_poll_steps.rb
Normal file
32
features/step_definitions/post_with_poll_steps.rb
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
Then /^I should see ([1-9]+) options?$/ do |number|
|
||||
find("#poll_creator_wrapper").all(".poll_answer").count.should eql(number.to_i)
|
||||
end
|
||||
|
||||
And /^I delete the first option$/ do
|
||||
find("#poll_creator_wrapper").all(".poll_answer .remove_poll_answer").first.click
|
||||
end
|
||||
|
||||
And /^I should not see a remove icon$/ do
|
||||
page.should_not have_css(".remove_poll_answer")
|
||||
end
|
||||
|
||||
When /^I fill in the following for the options:$/ do |table|
|
||||
i = 0
|
||||
table.raw.flatten.each do |value|
|
||||
all(".poll_answer_input")[i].set(value)
|
||||
i+=1
|
||||
end
|
||||
end
|
||||
|
||||
When /^I check the first option$/ do
|
||||
sleep 1
|
||||
first(".poll_form input").click
|
||||
end
|
||||
|
||||
And /^I press the element "([^"]*)"$/ do |selector|
|
||||
find(selector).click
|
||||
end
|
||||
|
||||
Then /^I should see an element "([^"]*)"$/ do |selector|
|
||||
page.should have_css(selector)
|
||||
end
|
||||
|
|
@ -43,6 +43,10 @@ describe PollParticipation do
|
|||
@xml = @poll_participation.to_xml.to_s
|
||||
end
|
||||
|
||||
it 'serializes the class name' do
|
||||
@xml.include?(PollParticipation.name.underscore.to_s).should be_true
|
||||
end
|
||||
|
||||
it 'serializes the sender handle' do
|
||||
@xml.include?(@poll_participation.diaspora_handle).should be_true
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue