Fixes flagging specs by making them id-based instead of text-based

This commit is contained in:
kikito
2015-08-26 13:14:42 +02:00
parent 5eeb89584b
commit 015fe704e4
4 changed files with 29 additions and 25 deletions

View File

@@ -1,23 +1,23 @@
<% if can? :flag_as_inappropiate, comment %> <% if can? :flag_as_inappropiate, comment %>
<span class="divider">&nbsp;|&nbsp;</span> <span class="divider">&nbsp;|&nbsp;</span>
<a data-dropdown="drop-comment-flag-<%= comment.id %>" aria-controls="drop-comment-flag-<%= comment.id %>" aria-expanded="false" title="<%= t('shared.flag_as_inappropiate') %>"> <a id="flag-expand-comment-<%= comment.id %>" data-dropdown="flag-drop-comment-<%= comment.id %>" aria-controls="flag-drop-comment-<%= comment.id %>" aria-expanded="false" title="<%= t('shared.flag_as_inappropiate') %>">
&nbsp;<i class="icon-flag flag-disable"></i>&nbsp;&nbsp; &nbsp;<i class="icon-flag flag-disable"></i>&nbsp;&nbsp;
</a> </a>
<ul id="drop-comment-flag-<%= comment.id %>" class="f-dropdown" data-dropdown-content aria-hidden="true" tabindex="-1"> <ul id="flag-drop-comment-<%= comment.id %>" class="f-dropdown" data-dropdown-content aria-hidden="true" tabindex="-1">
<li> <li>
<%= link_to t("shared.flag_as_inappropiate"), flag_as_inappropiate_comment_path(comment), method: :put, remote: true, title: t("shared.flag_as_inappropiate") %> <%= link_to t("shared.flag_as_inappropiate"), flag_as_inappropiate_comment_path(comment), method: :put, remote: true, id: "flag-comment-#{comment.id}" %>
</li> </li>
</ul> </ul>
<% end %> <% end %>
<% if can? :undo_flag_as_inappropiate, comment %> <% if can? :undo_flag_as_inappropiate, comment %>
<span class="divider">&nbsp;|&nbsp;</span> <span class="divider">&nbsp;|&nbsp;</span>
<a data-dropdown="drop-comment-unflag-<%= comment.id %>" aria-controls="drop-comment-unflag-<%= comment.id %>" aria-expanded="false" title="<%= t('shared.undo_flag_as_inappropiate') %>"> <a id="unflag-expand-comment-<%= comment.id %>" data-dropdown="unflag-drop-comment-<%= comment.id %>" aria-controls="unflag-drop-comment-<%= comment.id %>" aria-expanded="false" title="<%= t('shared.undo_flag_as_inappropiate') %>">
&nbsp;<i class="icon-flag flag-active"></i>&nbsp;&nbsp; &nbsp;<i class="icon-flag flag-active"></i>&nbsp;&nbsp;
</a> </a>
<ul id="drop-comment-unflag-<%= comment.id %>" class="f-dropdown" data-dropdown-content aria-hidden="true" tabindex="-1"> <ul id="unflag-drop-comment-<%= comment.id %>" class="f-dropdown" data-dropdown-content aria-hidden="true" tabindex="-1">
<li> <li>
<%= link_to t("shared.undo_flag_as_inappropiate"), undo_flag_as_inappropiate_comment_path(comment), method: :put, remote: true, title: t("shared.undo_flag_as_inappropiate") %> <%= link_to t("shared.undo_flag_as_inappropiate"), undo_flag_as_inappropiate_comment_path(comment), method: :put, remote: true, id: "unflag-comment-#{comment.id}" %>
</li> </li>
</ul> </ul>
<% end %> <% end %>

View File

@@ -1,21 +1,21 @@
<% if can? :flag_as_inappropiate, debate %> <% if can? :flag_as_inappropiate, debate %>
<a data-dropdown="drop-debate-flag-<%= debate.id %>" aria-controls="drop-debate-flag-<%= debate.id %>" aria-expanded="false" title="<%= t('shared.flag_as_inappropiate') %>"> <a id="flag-expand-debate-<%= debate.id %>" data-dropdown="flag-drop-debate-<%= debate.id %>" aria-controls="flag-drop-debate-<%= debate.id %>" aria-expanded="false" title="<%= t('shared.flag_as_inappropiate') %>">
&nbsp;<i class="icon-flag flag-disable"></i>&nbsp;&nbsp; &nbsp;<i class="icon-flag flag-disable"></i>&nbsp;&nbsp;
</a> </a>
<ul id="drop-debate-flag-<%= debate.id %>" class="f-dropdown" data-dropdown-content aria-hidden="true" tabindex="-1"> <ul id="flag-drop-debate-<%= debate.id %>" class="f-dropdown" data-dropdown-content aria-hidden="true" tabindex="-1">
<li> <li>
<%= link_to t('shared.flag_as_inappropiate'), flag_as_inappropiate_debate_path(debate), method: :put, remote: true %> <%= link_to t('shared.flag_as_inappropiate'), flag_as_inappropiate_debate_path(debate), method: :put, remote: true, id: "flag-debate-#{ debate.id }" %>
</li> </li>
</ul> </ul>
<% end %> <% end %>
<% if can? :undo_flag_as_inappropiate, debate %> <% if can? :undo_flag_as_inappropiate, debate %>
<a data-dropdown="drop-debate-unflag-<%= debate.id %>" aria-controls="drop-debate-unflag-<%= debate.id %>" aria-expanded="false" title="<%= t('shared.undo_flag_as_inappropiate') %>"> <a id="unflag-expand-debate-<%= debate.id %>" data-dropdown="unflag-drop-debate-<%= debate.id %>" aria-controls="unflag-drop-debate-<%= debate.id %>" aria-expanded="false" title="<%= t('shared.undo_flag_as_inappropiate') %>">
&nbsp;<i class="icon-flag flag-active"></i>&nbsp;&nbsp; &nbsp;<i class="icon-flag flag-active"></i>&nbsp;&nbsp;
</a> </a>
<ul id="drop-debate-unflag-<%= debate.id %>" class="f-dropdown" data-dropdown-content aria-hidden="true" tabindex="-1"> <ul id="unflag-drop-debate-<%= debate.id %>" class="f-dropdown" data-dropdown-content aria-hidden="true" tabindex="-1">
<li> <li>
<%= link_to t('shared.undo_flag_as_inappropiate'), undo_flag_as_inappropiate_debate_path(debate), method: :put, remote: true %> <%= link_to t('shared.undo_flag_as_inappropiate'), undo_flag_as_inappropiate_debate_path(debate), method: :put, remote: true, id: "unflag-debate-#{ debate.id }" %>
</li> </li>
</ul> </ul>
<% end %> <% end %>

View File

@@ -142,9 +142,10 @@ feature 'Comments' do
visit debate_path(debate) visit debate_path(debate)
within "#comment_#{comment.id}" do within "#comment_#{comment.id}" do
expect(page).to_not have_link "Undo flag as inappropriate" page.find("#flag-expand-comment-#{comment.id}").click
click_on 'Flag as inappropriate' page.find("#flag-comment-#{comment.id}").click
expect(page).to have_link "Undo flag as inappropriate"
expect(page).to have_css("#unflag-expand-comment-#{comment.id}")
end end
expect(InappropiateFlag.flagged?(user, comment)).to be expect(InappropiateFlag.flagged?(user, comment)).to be
@@ -160,9 +161,10 @@ feature 'Comments' do
visit debate_path(debate) visit debate_path(debate)
within "#comment_#{comment.id}" do within "#comment_#{comment.id}" do
expect(page).to_not have_link("Flag as inappropriate", exact: true) page.find("#unflag-expand-comment-#{comment.id}").click
click_on 'Undo flag as inappropiate' page.find("#unflag-comment-#{comment.id}").click
expect(page).to have_link("Flag as inappropriate", exact: true)
expect(page).to have_css("#flag-expand-comment-#{comment.id}")
end end
expect(InappropiateFlag.flagged?(user, comment)).to_not be expect(InappropiateFlag.flagged?(user, comment)).to_not be

View File

@@ -323,9 +323,10 @@ feature 'Debates' do
visit debate_path(debate) visit debate_path(debate)
within "#debate_#{debate.id}" do within "#debate_#{debate.id}" do
expect(page).to_not have_link "Undo flag as inappropiate" page.find("#flag-expand-debate-#{debate.id}").click
click_on 'Flag as inappropiate' page.find("#flag-debate-#{debate.id}").click
expect(page).to have_link "Undo flag as inappropiate"
expect(page).to have_css("#unflag-expand-debate-#{debate.id}")
end end
expect(InappropiateFlag.flagged?(user, debate)).to be expect(InappropiateFlag.flagged?(user, debate)).to be
@@ -340,9 +341,10 @@ feature 'Debates' do
visit debate_path(debate) visit debate_path(debate)
within "#debate_#{debate.id}" do within "#debate_#{debate.id}" do
expect(page).to_not have_link("Flag as inappropiate", exact: true) page.find("#unflag-expand-debate-#{debate.id}").click
click_on 'Undo flag as inappropiate' page.find("#unflag-debate-#{debate.id}").click
expect(page).to have_link("Flag as inappropiate", exact: true)
expect(page).to have_css("#flag-expand-debate-#{debate.id}")
end end
expect(InappropiateFlag.flagged?(user, debate)).to_not be expect(InappropiateFlag.flagged?(user, debate)).to_not be