Fix invitations and tests

This commit is contained in:
Steffen van Bergerem 2015-03-01 19:10:33 +01:00
parent 56a79828bc
commit c838389b67
17 changed files with 71 additions and 93 deletions

View file

@ -7,7 +7,6 @@
//= require ./publisher/services_view //= require ./publisher/services_view
//= require ./publisher/aspect_selector_view //= require ./publisher/aspect_selector_view
//= require ./publisher/aspect_selector_blueprint_view
//= require ./publisher/getting_started_view //= require ./publisher/getting_started_view
//= require ./publisher/uploader_view //= require ./publisher/uploader_view
//= require jquery-textchange //= require jquery-textchange
@ -97,6 +96,7 @@ app.views.Publisher = Backbone.View.extend({
}); });
this.initSubviews(); this.initSubviews();
this.checkSubmitAvailability();
return this; return this;
}, },
@ -114,14 +114,9 @@ app.views.Publisher = Backbone.View.extend({
form: form form: form
}); });
this.view_aspect_selector_blueprint = new app.views.PublisherAspectSelectorBlueprint({
el: this.$('.public_toggle > .dropdown'),
form: form
});
this.view_getting_started = new app.views.PublisherGettingStarted({ this.view_getting_started = new app.views.PublisherGettingStarted({
el_first_msg: this.el_input, el_first_msg: this.el_input,
el_visibility: this.$('.public_toggle > .dropdown'), el_visibility: this.$('.public_toggle .aspect_dropdown > .dropdown-toggle'),
el_stream: $('#gs-shim') el_stream: $('#gs-shim')
}); });
@ -136,13 +131,11 @@ app.views.Publisher = Backbone.View.extend({
}); });
this.view_poll_creator.on('change', this.checkSubmitAvailability, this); this.view_poll_creator.on('change', this.checkSubmitAvailability, this);
this.view_poll_creator.render(); this.view_poll_creator.render();
}, },
// set the selected aspects in the dropdown by their ids // set the selected aspects in the dropdown by their ids
setSelectedAspects: function(ids) { setSelectedAspects: function(ids) {
this.view_aspect_selector.updateAspectsSelector(ids); this.view_aspect_selector.updateAspectsSelector(ids);
this.view_aspect_selector_blueprint.updateAspectsSelector(ids);
}, },
// inject content into the publisher textarea // inject content into the publisher textarea
@ -461,15 +454,23 @@ app.views.Publisher = Backbone.View.extend({
}, },
setButtonsEnabled: function(bool) { setButtonsEnabled: function(bool) {
bool = !bool; if (bool) {
this.el_submit.prop({disabled: bool}); this.el_submit.removeProp('disabled');
this.el_preview.prop({disabled: bool}); this.el_preview.removeProp('disabled');
} else {
this.el_submit.prop('disabled', true);
this.el_preview.prop('disabled', true);
}
}, },
setInputEnabled: function(bool) { setInputEnabled: function(bool) {
bool = !bool; if (bool) {
this.el_input.prop({disabled: bool}); this.el_input.removeProp('disabled');
this.el_hiddenInput.prop({disabled: bool}); this.el_hiddenInput.removeProp('disabled');
} else {
this.el_input.prop('disabled', true);
this.el_hiddenInput.prop('disabled', true);
}
}, },
// determine submit availability // determine submit availability

View file

@ -15,6 +15,7 @@ $link-disabled-grey: #999999;
$text-grey: #999999; $text-grey: #999999;
$text-dark-grey: #666666; $text-dark-grey: #666666;
$text: #333333;
$white: white; $white: white;
$black: black; $black: black;

View file

@ -5,19 +5,16 @@
} }
#invitationsModal { #invitationsModal {
#paste_link_wrapper { .modal-header, .modal-body {
font-size: 12px; color: $text;
padding: 10px; font-size: 14px;
text-align: initial;
} }
#paste_link { font-weight: 700; } #paste_link { font-weight: 700; }
#invite_code { #invite_code { margin-top: 10px; }
padding: 5px;
display: block;
height: auto;
}
#codes_left { color: $text-grey; } #codes_left { color: $text-grey; }
.control-label { width: 200px; } .control-label { width: 120px; }
.controls { margin-left: 220px; } .controls { margin-left: 140px; }
#email_invitation { #email_invitation {
padding-top: 10px; padding-top: 10px;
margin-top: 20px; margin-top: 20px;

View file

@ -2,27 +2,25 @@
.controls { .controls {
z-index: 6; z-index: 6;
float: right; float: right;
.post_report, .comment_report {
.block_user,
.comment_report,
.create_participation,
.delete,
.destroy_participation,
.post_report {
display: inline-block; display: inline-block;
.icons-create_participation,
.icons-deletelabel,
.icons-destroy_participation,
.icons-ignoreuser,
.icons-report { .icons-report {
height: 14px; height: 14px;
width: 14px; width: 14px;
} }
} }
.block_user {
display: inline-block;
.icons-ignoreuser {
height: 14px;
width: 14px;
}
}
.delete {
display: inline-block;
.icons-deletelabel {
height: 14px;
width: 14px;
}
}
& > a:hover { & > a:hover {
text-decoration: none; text-decoration: none;
} }

View file

@ -1,6 +1,5 @@
#profile_container { #profile_container {
.profile_header { .profile_header {
border-bottom: 1px solid $border-grey;
margin-bottom: 20px; margin-bottom: 20px;
border-left: 1px solid #dddddd; border-left: 1px solid #dddddd;
padding-left: 10px; padding-left: 10px;
@ -54,6 +53,7 @@
#profile_horizontal_bar { #profile_horizontal_bar {
border-top: 1px dashed $border-grey; border-top: 1px dashed $border-grey;
border-bottom: 1px solid $border-grey;
min-height: 50px; min-height: 50px;
margin-top: 10px; margin-top: 10px;
#profile_buttons { #profile_buttons {

View file

@ -140,7 +140,7 @@
} }
} }
#invite_code { & > #invite_code {
width: 100%; width: 100%;
box-sizing: border-box; box-sizing: border-box;
font-size: 11px; font-size: 11px;

View file

@ -1,9 +1,11 @@
#paste_link_wrapper #paste_link
#paste_link = t('.paste_link')
= t('.paste_link') %span#codes_left
%span#codes_left = '(' + t('.codes_left', :count => @invite_code.count) + ')'
= '(' + t('.codes_left', :count => @invite_code.count) + ')' .form-horizontal
= invite_link(@invite_code) .control-group
.controls
= invite_link(@invite_code)
#email_invitation #email_invitation
= form_tag new_user_invitation_path, :class => 'form-horizontal' do = form_tag new_user_invitation_path, :class => 'form-horizontal' do

View file

@ -31,13 +31,13 @@ Feature: invitation acceptance
And I close the publisher And I close the publisher
And I log out And I log out
And I sign in as "bob@bob.bob" And I sign in as "bob@bob.bob"
And I follow "By email" And I click on selector ".btn-link[data-target='#invitationsModal']"
Then I should see one less invite Then I should see one less invite
Scenario: sends an invitation Scenario: sends an invitation
Given a user with email "bob@bob.bob" Given a user with email "bob@bob.bob"
When I sign in as "bob@bob.bob" When I sign in as "bob@bob.bob"
And I follow "By email" And I click on selector ".btn-link[data-target='#invitationsModal']"
And I fill in the following: And I fill in the following:
| email_inviter_emails | alex@example.com | | email_inviter_emails | alex@example.com |
And I press "Send an invitation" And I press "Send an invitation"

View file

@ -10,16 +10,10 @@ Feature: following and being followed
When I sign in as "bob@bob.bob" When I sign in as "bob@bob.bob"
And I am on "alice@alice.alice"'s page And I am on "alice@alice.alice"'s page
And I add the person to my "Besties" aspect And I add the person to my "Besties" aspect
When I am on the home page
And I expand the publisher
And I fill in the following:
| status_message_fake_text | I am following you |
And I press "Share"
Then I should see "I am following you" within "#main_stream"
And I sign out And I sign out
Scenario: seeing a follower's posts on their profile page, but not in your stream Scenario: seeing a follower's posts on their profile page, but not in your stream
Given "bob@bob.bob" has a non public post with text "I am following you"
When I sign in as "alice@alice.alice" When I sign in as "alice@alice.alice"
And I am on "bob@bob.bob"'s page And I am on "bob@bob.bob"'s page
Then I should see "I am following you" Then I should see "I am following you"
@ -28,16 +22,7 @@ Feature: following and being followed
Then I should not see "I am following you" Then I should not see "I am following you"
Scenario: seeing public posts of someone you follow Scenario: seeing public posts of someone you follow
Given I sign in as "alice@alice.alice" Given "alice@alice.alice" has a public post with text "I am ALICE"
And I am on the home page
And I expand the publisher
And I fill in the following:
| status_message_fake_text | I am ALICE |
And I press the first ".toggle" within "#publisher"
And I press the first ".public" within "#publisher"
And I press "Share"
Then I should see "I am ALICE" within "#main_stream"
And I sign out
When I sign in as "bob@bob.bob" When I sign in as "bob@bob.bob"
And I am on "alice@alice.alice"'s page And I am on "alice@alice.alice"'s page

View file

@ -75,7 +75,7 @@ Feature: preview posts in the stream
Given I expand the publisher Given I expand the publisher
When I fill in the following: When I fill in the following:
| status_message_fake_text | I am eating yogurt | | status_message_fake_text | I am eating yogurt |
And I press the element "#poll_creator" And I click on selector "#poll_creator"
When I fill in the following: When I fill in the following:
| status_message_fake_text | I am eating yogurt | | status_message_fake_text | I am eating yogurt |
| poll_question | What kind of yogurt do you like? | | poll_question | What kind of yogurt do you like? |

View file

@ -16,13 +16,13 @@ Feature: posting with a poll
Scenario: expanding the poll creator Scenario: expanding the poll creator
Given "#poll_creator_container" is hidden Given "#poll_creator_container" is hidden
When I expand the publisher When I expand the publisher
And I press the element "#poll_creator" And I click on selector "#poll_creator"
Then I should see an element "#poll_creator_container" Then I should see an element "#poll_creator_container"
Scenario: adding option to poll Scenario: adding option to poll
Given "#poll_creator_container" is hidden Given "#poll_creator_container" is hidden
When I expand the publisher When I expand the publisher
And I press the element "#poll_creator" And I click on selector "#poll_creator"
And I fill in values for the first two options And I fill in values for the first two options
And I lose focus And I lose focus
Then I should see 3 options Then I should see 3 options
@ -30,7 +30,7 @@ Feature: posting with a poll
Scenario: delete an option Scenario: delete an option
Given "#poll_creator_container" is hidden Given "#poll_creator_container" is hidden
When I expand the publisher When I expand the publisher
And I press the element "#poll_creator" And I click on selector "#poll_creator"
And I fill in values for the first two options And I fill in values for the first two options
And I lose focus And I lose focus
And I delete the last option And I delete the last option
@ -39,7 +39,7 @@ Feature: posting with a poll
Scenario: post with an attached poll Scenario: post with an attached poll
Given I expand the publisher Given I expand the publisher
And I press the element "#poll_creator" And I click on selector "#poll_creator"
When I fill in the following: When I fill in the following:
| status_message_fake_text | I am eating yogurt | | status_message_fake_text | I am eating yogurt |
| poll_question | What kind of yogurt do you like? | | poll_question | What kind of yogurt do you like? |
@ -52,7 +52,7 @@ Feature: posting with a poll
Scenario: vote for an option Scenario: vote for an option
Given I expand the publisher Given I expand the publisher
And I press the element "#poll_creator" And I click on selector "#poll_creator"
When I fill in the following: When I fill in the following:
| status_message_fake_text | I am eating yogurt | | status_message_fake_text | I am eating yogurt |
| poll_question | What kind of yogurt do you like? | | poll_question | What kind of yogurt do you like? |
@ -69,7 +69,7 @@ Feature: posting with a poll
Scenario: click to show result Scenario: click to show result
Given I expand the publisher Given I expand the publisher
And I press the element "#poll_creator" And I click on selector "#poll_creator"
When I fill in the following: When I fill in the following:
| status_message_fake_text | I am eating yogurt | | status_message_fake_text | I am eating yogurt |
| poll_question | What kind of yogurt do you like? | | poll_question | What kind of yogurt do you like? |
@ -77,18 +77,18 @@ Feature: posting with a poll
| normal | | normal |
| not normal | | not normal |
And I press "Share" And I press "Share"
And I press the element ".toggle_result" And I click on selector ".toggle_result"
Then I should see an element ".percentage" Then I should see an element ".percentage"
Scenario: validate answer input Scenario: validate answer input
Given I expand the publisher Given I expand the publisher
And I press the element "#poll_creator" And I click on selector "#poll_creator"
When I fill in the following: When I fill in the following:
| status_message_fake_text | I am eating yogurt | | status_message_fake_text | I am eating yogurt |
| poll_question | What kind of yogurt do you like? | | poll_question | What kind of yogurt do you like? |
And I fill in the following for the options: And I fill in the following for the options:
| normal | | normal |
| | | |
And I press the element "#poll_creator_container" And I click on selector "#poll_creator_container"
And I press the element "input[type=submit]" And I click on selector "#publisher button#submit"
Then I should see an element ".poll-answer input.error" Then I should see an element ".poll-answer input.error"

View file

@ -22,7 +22,7 @@ Feature: posting from the main page
Given ".markdownIndications" is hidden Given ".markdownIndications" is hidden
And ".options_and_submit" is hidden And ".options_and_submit" is hidden
When I expand the publisher When I expand the publisher
Then I should see "You can use Markdown to format your post" within "#publisher-images" Then I should see "You can use Markdown to format your post" within ".markdownIndications"
Then I should see "All aspects" within ".options_and_submit" Then I should see "All aspects" within ".options_and_submit"
Then I should see "Preview" within ".options_and_submit" Then I should see "Preview" within ".options_and_submit"

View file

@ -1,13 +1,11 @@
module AspectCukeHelpers module AspectCukeHelpers
def click_aspect_dropdown def click_aspect_dropdown
# blueprint: .dropdown .button, bootstrap: .aspect_dropdown .dropdown-toggle find('.aspect_dropdown .dropdown-toggle').click
find('.dropdown .button, .aspect_dropdown .dropdown-toggle').click
end end
def toggle_aspect(a_name) def toggle_aspect(a_name)
# blueprint: .dropdown li, bootstrap: .aspect_dropdown li
a_id = @me.aspects.where(name: a_name).pluck(:id).first a_id = @me.aspects.where(name: a_name).pluck(:id).first
aspect_css = ".dropdown li[data-aspect_id='#{a_id}'], .aspect_dropdown li[data-aspect_id='#{a_id}']" aspect_css = ".aspect_dropdown li[data-aspect_id='#{a_id}']"
expect(page).to have_selector(aspect_css) expect(page).to have_selector(aspect_css)
find(aspect_css).click find(aspect_css).click
end end
@ -30,7 +28,7 @@ module AspectCukeHelpers
end end
def aspect_dropdown_visible? def aspect_dropdown_visible?
expect(find('.aspect_membership.dropdown.active')).to be_visible expect(find('.aspect_membership_dropdown.open')).to be_visible
end end
end end
World(AspectCukeHelpers) World(AspectCukeHelpers)

View file

@ -23,12 +23,6 @@ When /^I check the first option$/ do
first(".poll_form input").click first(".poll_form input").click
end end
When(/^I press the element "(.*?)"$/) do |selector|
page.should have_css(selector)
find(selector).click
end
When(/^I fill in values for the first two options$/) do When(/^I fill in values for the first two options$/) do
all(".poll-answer input").each_with_index do |answer, i| all(".poll-answer input").each_with_index do |answer, i|
answer.set "answer option #{i}" answer.set "answer option #{i}"

View file

@ -126,6 +126,10 @@ When /^I post a status with the text "([^\"]*)"$/ do |text|
@me.post(:status_message, :text => text, :public => true, :to => 'all') @me.post(:status_message, :text => text, :public => true, :to => 'all')
end end
When /^I post a limited status with the text "([^\"]*)"$/ do |text|
@me.post(:status_message, :text => text, :public => false, :to => @me.aspect_ids)
end
And /^I follow the "([^\"]*)" link from the last sent email$/ do |link_text| And /^I follow the "([^\"]*)" link from the last sent email$/ do |link_text|
email_text = Devise.mailer.deliveries.first.body.to_s email_text = Devise.mailer.deliveries.first.body.to_s
email_text = Devise.mailer.deliveries.first.html_part.body.raw_source if email_text.blank? email_text = Devise.mailer.deliveries.first.html_part.body.raw_source if email_text.blank?

View file

@ -45,7 +45,7 @@ module PublishingCukeHelpers
end end
def publisher_submittable? def publisher_submittable?
submit_btn = find("#publisher input[type=submit]") submit_btn = find("#publisher button#submit")
!submit_btn[:disabled] !submit_btn[:disabled]
end end

View file

@ -150,8 +150,6 @@ describe("app.views.Publisher", function() {
}); });
it("disables submitting", function() { it("disables submitting", function() {
this.view.togglePollCreator();
this.view.setText('TESTING'); this.view.setText('TESTING');
expect(this.view.el_submit.prop('disabled')).toBeFalsy(); expect(this.view.el_submit.prop('disabled')).toBeFalsy();
expect(this.view.el_preview.prop('disabled')).toBeFalsy(); expect(this.view.el_preview.prop('disabled')).toBeFalsy();