Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search above block items and block lists for calls to check use scope #434

Merged
merged 2 commits into from
Sep 15, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Failing regression test for 429
  • Loading branch information
KronicDeth committed Sep 15, 2016
commit fc261d599a33cb803775fdd2802c1bffd19dc09f
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
defmodule Zzyzzzyzy.MessageController do
use Zzyzzzyzy.Web, :controller

alias Zzyzzzyzy.Endpoint

def create(conn, params) do
case params do
%{"auth" => auth} ->
if auth == Endpoint.config(:auth_key) do
case params do
%{"channel" => channel, "event" => event, "data" => data} ->
Endpoint.broadcast!(channel, event, data)
conn |> put_status(:created) |> json(%{success: true})
_no_required_data ->
conn |> put_status(:precondition_failed) |> json(%{error: "Incorrect input"})
end
else
conn |> hu<caret>
end
_no_auth_token ->
conn |> handle_unauthorized
end
end

defp handle_unauthorized(conn) do
conn |> put_status(:unauthorized)
end
end
57 changes: 57 additions & 0 deletions tests/org/elixir_lang/reference/callable/Issue429Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package org.elixir_lang.reference.callable;

import com.intellij.codeInsight.completion.CompletionType;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiPolyVariantReference;
import com.intellij.psi.ResolveResult;
import com.intellij.psi.search.LocalSearchScope;
import com.intellij.psi.search.SearchScope;
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
import org.elixir_lang.psi.ElixirAlias;
import org.elixir_lang.psi.call.Call;

import java.util.Arrays;
import java.util.List;

public class Issue429Test extends LightCodeInsightFixtureTestCase {
/*
* Tests
*/

public void testUseScope() {
myFixture.configureByFiles("get_use_scope.ex");
PsiElement callable = myFixture
.getFile()
.findElementAt(myFixture.getCaretOffset())
.getParent()
.getPrevSibling()
.getLastChild()
.getLastChild()
.getLastChild();

assertInstanceOf(callable, Call.class);
SearchScope useScope = callable.getUseScope();

assertInstanceOf(useScope, LocalSearchScope.class);

LocalSearchScope localSearchScope = (LocalSearchScope) useScope;
PsiElement[] scope = localSearchScope.getScope();

assertEquals(1, scope.length);
PsiElement singleScope = scope[0];

assertTrue(
"Use Scope is not the surrounding if",
singleScope.getText().startsWith("if auth == ")
);
}

/*
* Protected Instance Methods
*/

@Override
protected String getTestDataPath() {
return "testData/org/elixir_lang/reference/callable/issue_429";
}
}