controller

Rspec Controller tests, passing JSON params

試著忘記壹切 提交于 2019-12-06 00:39:33
问题 I'm trying to achieve the following: create a POST json request within RSpec Controller test, passing it params. Here's my code it 'returns access_token' do post :login, email: 'bla', password: 'bla1', format: :json end What I get in controllers request.body.read is a string with params, but passed like this email=bla&password=bla1 This is definitely not a JSON. But, if I make request using CURL curl -d '{"email": "bla@bla.com" }' http://127.0.0.1:3000/users/login --header "Accept:

@RestController without @ResponseBody on methods work incorrect

久未见 提交于 2019-12-06 00:30:22
问题 I have the following controller: @RestController @RequestMapping(value = "/base/url") public class MyController { @RequestMapping( value = "/child/url", method = RequestMethod.POST ) @ResponseBody public String mmm() { return "Ok"; } } Now its working(server response Ok ) but I thought that @ResponseBody redundant because we use @RestController and removed @ResponseBody annotation and I see following server response: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset

JMeter While Controller

 ̄綄美尐妖づ 提交于 2019-12-05 22:43:24
I have searched as crazy for the solution to my problem throughout the web, but none exist yet. My problem is that I have to check if I get specific text in HTTP request, which is in a while loop and if I do, then I should leave the loop and continue with the thread or stop the thread completely if text doesn't exist. I have set it up as follows: Thread Group .. While controller .. HTTP request .. Response Assertion Listener I used LAST in the while controller and set HTTP response to false text and it doesn't work. Hope the following one will work for you: Thread Group HTTP Request //set

Url Referrer is not available in WebApi 2 MVC project

烂漫一生 提交于 2019-12-05 22:05:38
I have an MVC WebAPI 2 project with a Controllers controller. The Method I'm trying to call is POST (Create). I need to access the referring URL that called that method yet, no matter what object I access, the referring URL either doesn't exist in the object or is null. For example, I've added the HTTPContext reference and the following returns null : var thingythingthing = HttpContext.Current.Request.UrlReferrer; The Request object does not have a UrlReferrer property. This returns null as well: HttpContext.Current.Request.ServerVariables["HTTP_REFERER"] I cannot modify the headers because I

How to test JavaFX (MVC) Controller Logic?

天大地大妈咪最大 提交于 2019-12-05 21:53:17
How do we properly write unit/integration tests for the JavaFX Controller logic? Assuming the Controller class I'm testing is named LoadController , and it's unit test class is LoadControllerTest , my confusion stems from: If the LoadControllerTest class instantiates a new LoadController object via LoadController loadController = new LoadController(); I can then inject values into the controller via (many) setters. This seems the only way short of using reflection (legacy code). If I don't inject the values into the FXML controls then the controls obviously aren't initialized yet, returning

How to assign roles on successful registration?

被刻印的时光 ゝ 提交于 2019-12-05 21:21:35
问题 I'm using fos user bundle and pugx multi user bundle. I've read all the documentation and I'm new to Symfony. In the pugx multi user bundle there's a sample on every point but one: sucessful registration. Samples of overriding controllers for generating forms => ok Samples of overriding templates for generating forms => ok Samples of overriding successful registration sample => nothing. Here's my code: class RegistrationController extends BaseController { public function registerAction

mvc controller test with session attribute

依然范特西╮ 提交于 2019-12-05 21:13:05
I'm trying to test a method with this signature: @Autowired HttpSession http_Session; @RequestMapping(method=RequestMethod.GET, value="/search/findByName") public @ResponseBody List<Map> search(@RequestParam(value="name", required=true) String name){ Integer user_id = http_Session.getAttribute("userinfo"); } userinfo is a class which contains informations about the user and set in session scope when the user logged in.but when I try the test : @RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration @ContextConfiguration(locations = { "classpath:/META-INF/applicationContext.xml"}) public

Unable to inject `$http` using AngularJS explicit `app.controller` syntax?

风流意气都作罢 提交于 2019-12-05 20:39:40
问题 I have been told that I should be using the app.controller syntax, in order to support minification. Rewriting the sample (tutorial) example, and I found that I couldn't get it to work: use 'strict'; /* Minifiable solution; which doesn't work */ var app = angular.module('myApp', ['ngGrid']); // phones.json: http://angular.github.io/angular-phonecat/step-5/app/phones/phones.json app.controller('PhoneListCtrl', ['$scope', '$http', function ($scope, $http) { $http.get('phones/phones.json')

Controller method #show getting called

余生长醉 提交于 2019-12-05 18:58:38
I have a link on my #index view: <%= link_to 'Export Calendar (ICS)', { controller: :tickets, action: :ics_export, format: :ics }, class: "class-needed right" %> routes.rb that pertains to this: resources :tickets get 'tickets/calendar' => 'tickets#ics_export' post 'tickets' => 'tickets#index' patch 'tickets/:id/close' => 'tickets#close', as: 'close_ticket' post 'tickets/:id' => 'ticket_comments#create' My TicketsController that pertains: before_action :set_ticket, only: [:show, :edit, :destroy, :update, :close] def show @ticket_comment = TicketComment.new end def ics_export tickets = Ticket

ASP.NET MVC - Job of Controllers

大憨熊 提交于 2019-12-05 18:54:25
I think I'm beginning to be confused with the job of a controller in MVC. I have a service that exposes five functions: list packages in queue get package delete package accept package deny package My ASP.NET MVC controller depends on this service, and can generally execute a service call on an Action. I'm happy so far. The second part is then building the ViewModel result. If I do this inside of the controller, the controller now has an exploding dependency list -- each action added increases the dependencies in order to build the view model, and these are all inherited by the controller. I